summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2020-02-18 22:16:49 +0100
committerHans Ulrich Niedermann <hun@n-dimensional.de>2020-02-18 22:52:33 +0100
commit22ed5d30ce48d9741c36a299b9908b850463ff5a (patch)
tree75719d9ee8f61baf054467e94ab7c4d1121c653d
parent4947053f7ac62c4a6006438195be352ccf27a047 (diff)
downloadlibgphoto2-22ed5d30ce48d9741c36a299b9908b850463ff5a.tar.gz
m4_pattern: Forbid everything related to GP, then allow specific uses
Forbid the patterns [GP_] and [_GP] (while allowing [_GPHOTO], then explicitly allow uses of GP_ and _GP in variables and messages where needed.
-rw-r--r--gphoto-m4/gp-check-pendantic-compiler-flags.m45
-rw-r--r--gphoto-m4/gp-gettext-hack.m43
-rw-r--r--gphoto-m4/gp-init.m42
-rw-r--r--gphoto-m4/gp-set.m426
-rw-r--r--libgphoto2_port/configure.ac2
-rw-r--r--libgphoto2_port/gphoto-m4/gp-gettext-hack.m418
-rw-r--r--libgphoto2_port/gphoto-m4/gp-init.m415
7 files changed, 44 insertions, 27 deletions
diff --git a/gphoto-m4/gp-check-pendantic-compiler-flags.m4 b/gphoto-m4/gp-check-pendantic-compiler-flags.m4
index e274bf0b7..46721d1bc 100644
--- a/gphoto-m4/gp-check-pendantic-compiler-flags.m4
+++ b/gphoto-m4/gp-check-pendantic-compiler-flags.m4
@@ -2,8 +2,6 @@ dnl ####################################################################
dnl GP_CHECK_PEDANTIC_COMPILER_FLAGS & Co.
dnl ####################################################################
dnl
-m4_pattern_forbid([_GP_])dnl
-dnl
dnl
dnl ####################################################################
dnl _GP_CONDITIONAL_COMPILE_FLAGS(FLAG_VAR, FLAGS)
@@ -86,6 +84,9 @@ dnl $1 Depending on the language, CFLAGS or CXXFLAGS
dnl $2 The variable/conditional component the caller wants us to use
dnl $3 The -std= argument (such as -std=c++98 or -std=c99)
dnl ####################################################################
+m4_pattern_allow([GP_PEDANTIC_CFLAGS_])dnl
+m4_pattern_allow([GP_PEDANTIC_CXXFLAGS_])dnl
+m4_pattern_allow([GP_HAVE_PEDANTIC_FLAGS_])dnl
AC_DEFUN([_GP_CHECK_PEDANTIC_COMPILER_FLAGS], [dnl
# BEGIN $0($@)
gp_compiler_flags_saved_$1="[$]$1"
diff --git a/gphoto-m4/gp-gettext-hack.m4 b/gphoto-m4/gp-gettext-hack.m4
index f7427745e..4b8cee34d 100644
--- a/gphoto-m4/gp-gettext-hack.m4
+++ b/gphoto-m4/gp-gettext-hack.m4
@@ -30,13 +30,14 @@ AC_SUBST([GETTEXT_PACKAGE])
sed_cmds="s|^DOMAIN.*|DOMAIN = ${GETTEXT_PACKAGE}|"
m4_if([$2],[],[],[sed_cmds="${sed_cmds};s|^COPYRIGHT_HOLDER.*|COPYRIGHT_HOLDER = $2|"])
m4_ifval([$3],[
+m4_pattern_allow([GP_GETTEXT_HACK])dnl
if test -n "$PACKAGE_BUGREPORT"; then
sed_mb="${PACKAGE_BUGREPORT}"
else
AC_MSG_ERROR([
*** Your configure.{ac,in} is wrong.
*** Either define PACKAGE_BUGREPORT (by using the 4-parameter AC INIT syntax)
-*** or give [GP_GETTEXT_HACK] the third parameter.
+*** or give GP_GETTEXT_HACK the third parameter.
***
])
fi
diff --git a/gphoto-m4/gp-init.m4 b/gphoto-m4/gp-init.m4
index f5f92a6d7..d9672879f 100644
--- a/gphoto-m4/gp-init.m4
+++ b/gphoto-m4/gp-init.m4
@@ -5,6 +5,8 @@ dnl thus the m4_pattern_forbid() call.
dnl ####################################################################
dnl
m4_pattern_forbid([GP_])dnl
+m4_pattern_forbid([_GP])dnl
+m4_pattern_allow([_GPHOTO])dnl
dnl
dnl
AC_DEFUN_ONCE([GP_INIT], [dnl
diff --git a/gphoto-m4/gp-set.m4 b/gphoto-m4/gp-set.m4
index 7ca9c7b17..ffc514194 100644
--- a/gphoto-m4/gp-set.m4
+++ b/gphoto-m4/gp-set.m4
@@ -101,14 +101,6 @@ dnl FIXME: Do we need to stop using shell functions?
dnl
dnl
dnl ######################################################################
-dnl Try catching unexpanded macros in the output.
-dnl ######################################################################
-m4_pattern_forbid([GP_SET_])dnl
-m4_pattern_forbid([_GP_SET_])dnl
-m4_pattern_allow([GP_SET_EOF])dnl
-dnl
-dnl
-dnl ######################################################################
dnl _GP_SET_INIT
dnl Called internally before any set operation.
dnl ######################################################################
@@ -245,12 +237,11 @@ dnl ######################################################################
AC_DEFUN([GP_SET_ADD_ALL], [dnl
AC_REQUIRE([_GP_SET_INIT])dnl
_GP_SET_CHECK([$1])dnl
-m4_pattern_allow([_GPEOF])dnl
-cat>>"_GP_SET_FILENAME([$1])"<<_GP_EOF
+cat>>"_GP_SET_FILENAME([$1])"<<_GPEOF
m4_foreach([myvar], [m4_shift($@)], [dnl
myvar
])dnl
-_GP_EOF
+_GPEOF
])dnl
dnl
dnl
@@ -328,17 +319,18 @@ AC_REQUIRE([_GP_SET_INIT])dnl
AC_REQUIRE([_GP_SET_CHECK_INIT])dnl
AC_REQUIRE([_GP_SET_CANONICALIZE_INIT])dnl
AC_REQUIRE([GP_PROG_COMM])dnl
-cat>confset_a.txt<<GP_EOF
+cat>confset_a.txt<<_GPEOF
x
y
-GP_EOF
-cat>confset_b.txt<<GP_EOF
+_GPEOF
+cat>confset_b.txt<<_GPEOF
y
z
-GP_EOF
-cat>confset_res_23.txt<<GP_EOF
+_GPEOF
+cat>confset_res_23.txt<<_GPEOF
x
-GP_EOF
+_GPEOF
+m4_pattern_allow([GP_SET_*])dnl
AC_MSG_CHECKING([whether comm -23 works])
AS_IF([${COMM} -23 confset_a.txt confset_b.txt > confset_diff_23.txt], [dnl
], [dnl
diff --git a/libgphoto2_port/configure.ac b/libgphoto2_port/configure.ac
index 6af8bd914..f8ba57f1e 100644
--- a/libgphoto2_port/configure.ac
+++ b/libgphoto2_port/configure.ac
@@ -20,6 +20,8 @@ AC_LANG(C)
m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
AM_SILENT_RULES([no])
+GP_INIT
+
dnl ---------------------------------------------------------------------------
dnl Advanced information about versioning:
dnl * "Writing shared libraries" by Mike Hearn
diff --git a/libgphoto2_port/gphoto-m4/gp-gettext-hack.m4 b/libgphoto2_port/gphoto-m4/gp-gettext-hack.m4
index 3f5dbb72a..4b8cee34d 100644
--- a/libgphoto2_port/gphoto-m4/gp-gettext-hack.m4
+++ b/libgphoto2_port/gphoto-m4/gp-gettext-hack.m4
@@ -19,9 +19,8 @@ dnl
dnl You can leave out the GP_GETTEXT_HACK parameters if you want to,
dnl GP_GETTEXT_HACK will try fall back to sensible values in that case:
dnl
-
-AC_DEFUN([GP_GETTEXT_HACK],
-[
+dnl
+AC_DEFUN([GP_GETTEXT_HACK], [dnl
AC_BEFORE([$0], [AM_GNU_GETTEXT])dnl
AC_BEFORE([$0], [AM_GNU_GETTEXT_VERSION])dnl
m4_if([$1],[],[GETTEXT_PACKAGE="${PACKAGE_TARNAME}"],[GETTEXT_PACKAGE="$1"])
@@ -31,13 +30,14 @@ AC_SUBST([GETTEXT_PACKAGE])
sed_cmds="s|^DOMAIN.*|DOMAIN = ${GETTEXT_PACKAGE}|"
m4_if([$2],[],[],[sed_cmds="${sed_cmds};s|^COPYRIGHT_HOLDER.*|COPYRIGHT_HOLDER = $2|"])
m4_ifval([$3],[
+m4_pattern_allow([GP_GETTEXT_HACK])dnl
if test -n "$PACKAGE_BUGREPORT"; then
sed_mb="${PACKAGE_BUGREPORT}"
else
AC_MSG_ERROR([
*** Your configure.{ac,in} is wrong.
*** Either define PACKAGE_BUGREPORT (by using the 4-parameter AC INIT syntax)
-*** or give [GP_GETTEXT_HACK] the third parameter.
+*** or give GP_GETTEXT_HACK the third parameter.
***
])
fi
@@ -53,8 +53,10 @@ if test -f "${srcdir}/po/Makevars.template"; then
else
AC_MSG_RESULT([no])
fi
-])
-
+])dnl
+dnl
+dnl
+dnl
AC_DEFUN([GP_GETTEXT_FLAGS],
[
AC_REQUIRE([AM_GNU_GETTEXT])
@@ -66,7 +68,9 @@ GP_CONFIG_MSG([Use translations],[${USE_NLS}])
if test "x$USE_NLS" = "xyes" && test "${BUILD_INCLUDED_LIBINTL}"; then
GP_CONFIG_MSG([Use included libintl],[${BUILD_INCLUDED_LIBINTL}])
fi
-])
+])dnl
+dnl
+dnl
dnl Please do not remove this:
dnl filetype: 71ff3941-a5ae-4677-a369-d7cb01f92c81
diff --git a/libgphoto2_port/gphoto-m4/gp-init.m4 b/libgphoto2_port/gphoto-m4/gp-init.m4
new file mode 100644
index 000000000..d9672879f
--- /dev/null
+++ b/libgphoto2_port/gphoto-m4/gp-init.m4
@@ -0,0 +1,15 @@
+dnl ####################################################################
+dnl GP_INIT
+dnl So far, a dummy function to force inclusion of this file and
+dnl thus the m4_pattern_forbid() call.
+dnl ####################################################################
+dnl
+m4_pattern_forbid([GP_])dnl
+m4_pattern_forbid([_GP])dnl
+m4_pattern_allow([_GPHOTO])dnl
+dnl
+dnl
+AC_DEFUN_ONCE([GP_INIT], [dnl
+])dnl
+dnl
+dnl