File release-current-tip.diff of Package octave-forge-struct
# HG changeset patch
# User Olaf Till <i7tiol@t-online.de>
# Date 1530563206 -7200
# Mon Jul 02 22:26:46 2018 +0200
# Node ID d5c3cdc052b679a29bd61e5a138634562c469869
# Parent 60b27d46269a7442098239e4b533736027457553
Use autoheader and check for alternative Octave symbols.
diff --git a/src/Makefile.in b/src/Makefile.in
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,6 +1,6 @@
# Makefile for struct package for Octave
#
-# Copyright (C) 2016 Olaf Till <i7tiol@t-online.de>
+# Copyright (C) 2016-2018 Olaf Till <i7tiol@t-online.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,13 +17,10 @@
# Uncomment this for a release.
-RELEASE := yes
+# RELEASE := yes
ifdef RELEASE
-# Currently this avoids warnings due to introduction of Octave
-# namespaces in Octave-4.1.0+. If the deprecated versions will be
-# available long enough, we could get away with just suppressing the
-# warnings.
-RELEASE_CXXFLAGS = -Wno-deprecated-declarations
+# Currently this does nothing.
+RELEASE_CXXFLAGS =
endif
MKOCTFILE ?= @MKOCTFILE@
diff --git a/src/bootstrap b/src/bootstrap
--- a/src/bootstrap
+++ b/src/bootstrap
@@ -1,3 +1,7 @@
#! /bin/sh
+aclocal
+
autoconf
+
+autoheader -f
diff --git a/src/config.h.in b/src/config.h.in
deleted file mode 100644
--- a/src/config.h.in
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Define as 1 if liboctinterp is old enough to provide error_state. */
-#undef HAVE_OCTAVE_ERROR_STATE
-
-/* Define as 1 if liboctinterp has
-'verror (octave_execution_exception&, const char *, va_list)'. */
-#undef HAVE_OCTAVE_VERROR_ARG_EXC
diff --git a/src/configure.ac b/src/configure.ac
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -22,6 +22,12 @@
AC_CONFIG_SRCDIR([cell2fields.cc])
AC_CONFIG_HEADERS([config.h])
+# Avoid warnings for redefining AH-generated preprocessor symbols of
+# Octave.
+AH_TOP([#include "undef-ah-octave.h"])
+
+AC_CONFIG_MACRO_DIRS([m4])
+
# Checks for programs.
AC_CHECK_PROG(MKOCTFILE, mkoctfile, mkoctfile)
if test -z "$MKOCTFILE"; then
@@ -72,16 +78,48 @@
[AC_LANG_PROGRAM([[#include <octave/oct.h>]
[#include <stdio.h>]],
[[printf ("%i", error_state);]])],
- [AC_DEFINE([HAVE_OCTAVE_ERROR_STATE], 1)])
+ [AC_DEFINE([HAVE_OCTAVE_ERROR_STATE], 1,
+ [Define as 1 if liboctinterp is old enough to provide error_state.])])
-## Presence of 'verror (octave_execution_exception&, const char *,
+## Presence of 'verror (octave(_|::)execution_exception&, const char *,
## va_list)'
-AC_LINK_IFELSE(
+AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <octave/oct.h>]],
[[octave_execution_exception e;]
[va_list args;]
[verror (e, "test", args);]])],
- [AC_DEFINE([HAVE_OCTAVE_VERROR_ARG_EXC], 1)])
+ [AC_DEFINE([HAVE_OCTAVE_VERROR_ARG_EXC], 1,
+ [Define as 1 if liboctinterp has 'verror (octave(_|::)execution_exception&, const char *, va_list)'.])],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[#include <octave/oct.h>]],
+ [[octave::execution_exception e;]
+ [va_list args;]
+ [verror (e, "test", args);]])],
+ [AC_DEFINE([HAVE_OCTAVE_VERROR_ARG_EXC], 1,
+ [Define as 1 if liboctinterp has 'verror (octave(_|::)execution_exception&, const char *, va_list)'.])])])
+
+## Simple symbol alternatives of different Octave versions.
+OF_OCTAVE_LIST_ALT_SYMS([
+[dnl
+ [is_map],
+ [isstruct],
+ [[octave_value ().isstruct ();]],
+ [OV_ISSTRUCT],
+ [],
+ []
+],
+
+[dnl
+ [octave_execution_exception],
+ [octave::execution_exception],
+ [[octave::execution_exception ();]],
+ [OCTAVE__EXECUTION_EXCEPTION],
+ [],
+ []
+]
+
+],
+ [oct-alt-includes.h])
LIBS=$TLIBS
LDFLAGS=$TLDFLAGS
diff --git a/src/error-helpers.cc b/src/error-helpers.cc
--- a/src/error-helpers.cc
+++ b/src/error-helpers.cc
@@ -1,6 +1,6 @@
/*
-Copyright (C) 2016, 2017 Olaf Till <i7tiol@t-online.de>
+Copyright (C) 2016-2018 Olaf Till <i7tiol@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
// call verror
#ifdef HAVE_OCTAVE_VERROR_ARG_EXC
void
-c_verror (octave_execution_exception& e, const char *fmt, ...)
+c_verror (OCTAVE__EXECUTION_EXCEPTION& e, const char *fmt, ...)
{
va_list args;
va_start (args, fmt);
@@ -33,7 +33,7 @@
}
#else
void
-c_verror (const octave_execution_exception&, const char *fmt, ...)
+c_verror (const OCTAVE__EXECUTION_EXCEPTION&, const char *fmt, ...)
{
va_list args;
va_start (args, fmt);
diff --git a/src/error-helpers.h b/src/error-helpers.h
--- a/src/error-helpers.h
+++ b/src/error-helpers.h
@@ -1,6 +1,6 @@
/*
-Copyright (C) 2016, 2017 Olaf Till <i7tiol@t-online.de>
+Copyright (C) 2016-2018 Olaf Till <i7tiol@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,9 +26,9 @@
// call verror, for _linking_ also against Octave versions who have no
// verror() with these arguments
#ifdef HAVE_OCTAVE_VERROR_ARG_EXC
-void c_verror (octave_execution_exception&, const char *, ...);
+void c_verror (OCTAVE__EXECUTION_EXCEPTION&, const char *, ...);
#else
-void c_verror (const octave_execution_exception&, const char *, ...);
+void c_verror (const OCTAVE__EXECUTION_EXCEPTION&, const char *, ...);
#endif
void _p_error (const char *fmt, ...);
@@ -37,7 +37,7 @@
// both if Octave uses exceptions for errors and if it still uses
// error_state. In the latter case return 'retval'.
#ifdef HAVE_OCTAVE_ERROR_STATE
- // can throw octave_execution_exception despite of this
+ // can throw OCTAVE__EXECUTION_EXCEPTION despite of this
#define CHECK_ERROR(code, retval, ...) \
try \
{ \
@@ -50,7 +50,7 @@
return retval; \
} \
} \
- catch (octave_execution_exception& e) \
+ catch (OCTAVE__EXECUTION_EXCEPTION& e) \
{ \
c_verror (e, __VA_ARGS__); \
}
@@ -60,7 +60,7 @@
{ \
code ; \
} \
- catch (octave_execution_exception& e) \
+ catch (OCTAVE__EXECUTION_EXCEPTION& e) \
{ \
verror (e, __VA_ARGS__); \
}
@@ -70,7 +70,7 @@
// Octave doesn't throw exceptions for errors but still uses
// error_state.
#ifdef HAVE_OCTAVE_ERROR_STATE
- // can throw octave_execution_exception despite of this
+ // can throw OCTAVE__EXECUTION_EXCEPTION despite of this
#define CHECK_ERROR_EXIT1(code, ...) \
try \
{ \
@@ -83,7 +83,7 @@
exit (1); \
} \
} \
- catch (octave_execution_exception&) \
+ catch (OCTAVE__EXECUTION_EXCEPTION&) \
{ \
_p_error (__VA_ARGS__); \
\
@@ -95,7 +95,7 @@
{ \
code ; \
} \
- catch (octave_execution_exception&) \
+ catch (OCTAVE__EXECUTION_EXCEPTION&) \
{ \
_p_error (__VA_ARGS__); \
\
@@ -107,7 +107,7 @@
// Octave uses exceptions for errors and if it still uses
// error_state. In the latter case reset error_state to 0.
#ifdef HAVE_OCTAVE_ERROR_STATE
- // can throw octave_execution_exception despite of this
+ // can throw OCTAVE__EXECUTION_EXCEPTION despite of this
#define SET_ERR(code, err) \
err = false; \
\
@@ -120,7 +120,7 @@
err = true; \
} \
} \
- catch (octave_execution_exception&) \
+ catch (OCTAVE__EXECUTION_EXCEPTION&) \
{ \
err = true; \
}
@@ -132,7 +132,7 @@
{ \
code ; \
} \
- catch (octave_execution_exception&) \
+ catch (OCTAVE__EXECUTION_EXCEPTION&) \
{ \
err = true; \
}
diff --git a/src/m4/octave-forge.m4 b/src/m4/octave-forge.m4
new file mode 100644
--- /dev/null
+++ b/src/m4/octave-forge.m4
@@ -0,0 +1,93 @@
+# Copyright (C) 2017 Olaf Till <i7tiol@t-online.de>
+# Modifications to print what is searching for by JohnD
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+# arguments of OF_OCTAVE_ALT_SYMS (see also description of
+# OF_OCTAVE_LIST_ALT_SYMS below):
+#
+# $1: symbol version 1
+# $2: symbol version 2
+# $3: test for symbol version 2
+# $4: macro name to access alternative symbols
+# $5: include directives for symbol version 1
+# $6: include directives for symbol version 2
+# (a list of lists of args 1--6 is $1 of OF_OCTAVE_LIST_ALT_SYMS)
+# $7: name of generated include file with alternatives of Octave headers
+# (arg7 is $2 of OF_OCTAVE_LIST_ALT_SYMS)
+AC_DEFUN([OF_OCTAVE_ALT_SYMS], [
+AC_MSG_CHECKING([$1 or $2])
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[#include <octave/oct.h>]
+ $6],
+ [$3])],
+ [AC_DEFINE($4,
+ [[$2]],
+ [macro for alternative Octave symbols])
+ AC_MSG_RESULT([$2])
+ echo '$6' >> $7],
+ [AC_DEFINE($4,
+ [[$1]],
+ [macro for alternative Octave symbols])
+ AC_MSG_RESULT([$1])
+ echo '$5' >> $7]
+)
+])
+
+
+# OF_OCTAVE_LIST_ALT_SYMS is called in the following way:
+#
+# OF_OCTAVE_LIST_ALT_SYMS([
+# [dnl
+# [old_octave_symbol],
+# [new_octave_symbol],
+# [[compilation test]
+# [for new_octave_symbol]],
+# [NAME_OF_GENERATED_MACRO____WILL_EXPAND_TO_OLD_OR_NEW_SYMBOL],
+# [[include directives]
+# [except #include <octave/oct.h>]
+# [necessary to compile with old_octave_symbol]],
+# [[include directives]
+# [except #include <octave/oct.h>]
+# [nessary to compile with new_octave_symbol]
+# [and to compile the test]]
+# ],
+#
+# ... further such lists as the above
+#
+# ],
+#
+# [name-of-header-file-for-alternative-octave-iclude-directives.h])
+#
+#
+# This file should be put into src/m4/, and the line
+#
+# AC_CONFIG_MACRO_DIRS([m4])
+#
+# should be put into src/configure.ac. The package should use
+# autoheader to generate config.h.in (src/bootstrap should contain the
+# lines 'aclocal', 'autoconf', and 'autoheader -f'). Package code
+# should include config.h and use the generated macros to access the
+# alternative symbols of Octave. An example of a call to
+# OF_OCTAVE_LIST_ALT_SYMS in src/configure.ac is available together
+# with this file.
+AC_DEFUN([OF_OCTAVE_LIST_ALT_SYMS], [
+
+echo '/* generated by configure */' > $2
+
+m4_foreach([it], [$1], [m4_apply([OF_OCTAVE_ALT_SYMS], [it, $2])])
+
+AH_BOTTOM([#include "$2"])
+
+])
diff --git a/src/structcat.cc b/src/structcat.cc
--- a/src/structcat.cc
+++ b/src/structcat.cc
@@ -132,7 +132,7 @@
for (octave_idx_type i = m1_id; i < n_args; i++)
{
- if (! args(i).is_map ())
+ if (! args(i).OV_ISSTRUCT ())
{
error ("%s: some argument not a structure", fname.c_str ());
diff --git a/src/undef-ah-octave.h b/src/undef-ah-octave.h
new file mode 100644
--- /dev/null
+++ b/src/undef-ah-octave.h
@@ -0,0 +1,27 @@
+/* To be included at the top of config.h (by autoheader). Avoid
+ warnings for redefining AH-generated preprocessor symbols of
+ Octave. */
+
+#ifdef PACKAGE_BUGREPORT
+#undef PACKAGE_BUGREPORT
+#endif
+
+#ifdef PACKAGE_NAME
+#undef PACKAGE_NAME
+#endif
+
+#ifdef PACKAGE_STRING
+#undef PACKAGE_STRING
+#endif
+
+#ifdef PACKAGE_TARNAME
+#undef PACKAGE_TARNAME
+#endif
+
+#ifdef PACKAGE_URL
+#undef PACKAGE_URL
+#endif
+
+#ifdef PACKAGE_VERSION
+#undef PACKAGE_VERSION
+#endif
# HG changeset patch
# User Olaf Till <i7tiol@t-online.de>
# Date 1534092890 -7200
# Sun Aug 12 18:54:50 2018 +0200
# Node ID 320e8484cd10b73cef40c9b51d99ebbb0c7b8360
# Parent d5c3cdc052b679a29bd61e5a138634562c469869
error-helpers.h: include <iostream>
diff --git a/src/error-helpers.h b/src/error-helpers.h
--- a/src/error-helpers.h
+++ b/src/error-helpers.h
@@ -19,6 +19,8 @@
#include "config.h"
+#include <iostream>
+
// Octaves non-static verror functions: The elder all set error_state,
// the newer, present from the time on at which error started to throw
// an exception, all throw, too.
# HG changeset patch
# User Olaf Till <i7tiol@t-online.de>
# Date 1547200761 -3600
# Fri Jan 11 10:59:21 2019 +0100
# Node ID 217a5b7b066a5e51572f29be8a5b1ac22a883a9f
# Parent 320e8484cd10b73cef40c9b51d99ebbb0c7b8360
check for octave::vformat
diff --git a/src/configure.ac b/src/configure.ac
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -110,6 +110,17 @@
],
[dnl
+ [octave_vformat],
+ [octave::vformat],
+ [[std::ostringstream obuf;]
+ [va_list args;]
+ [octave::vformat (obuf, "dummy", args);]],
+ [OCTAVE__VFORMAT],
+ [],
+ []
+],
+
+[dnl
[octave_execution_exception],
[octave::execution_exception],
[[octave::execution_exception ();]],
diff --git a/src/error-helpers.cc b/src/error-helpers.cc
--- a/src/error-helpers.cc
+++ b/src/error-helpers.cc
@@ -50,7 +50,7 @@
std::ostringstream output_buf;
- octave_vformat (output_buf, fmt, args);
+ OCTAVE__VFORMAT (output_buf, fmt, args);
std::string msg = output_buf.str ();