diff options
-rw-r--r-- | .x-sc_makefile_check | 2 | ||||
-rw-r--r-- | .x-sc_program_name | 1 | ||||
-rw-r--r-- | .x-sc_prohibit_HAVE_MBRTOWC | 3 | ||||
-rw-r--r-- | .x-sc_prohibit_atoi_atof | 1 | ||||
-rw-r--r-- | .x-sc_space_tab | 1 | ||||
-rw-r--r-- | .x-sc_useless_cpp_parens | 1 | ||||
-rw-r--r-- | build-aux/warn-on-use.h | 75 | ||||
-rw-r--r-- | cfg.mk | 13 | ||||
-rw-r--r-- | doc/fdl-1.3.texi | 3 | ||||
-rw-r--r-- | doc/gendocs_template | 2 | ||||
-rw-r--r-- | gl/Makefile.am | 22 | ||||
-rw-r--r-- | gl/m4/gnulib-common.m4 | 10 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 2 | ||||
-rw-r--r-- | gl/m4/unistd_h.m4 | 12 | ||||
-rw-r--r-- | gl/m4/warn-on-use.m4 | 45 | ||||
-rw-r--r-- | gl/m4/warnings.m4 | 10 | ||||
-rw-r--r-- | gl/unistd.in.h | 18 | ||||
-rw-r--r-- | lib/glm4/gnulib-common.m4 | 10 | ||||
-rw-r--r-- | maint.mk | 7 | ||||
-rw-r--r-- | src/asn1Coding.c | 2 | ||||
-rw-r--r-- | src/asn1Parser.c | 4 |
21 files changed, 199 insertions, 45 deletions
diff --git a/.x-sc_makefile_check b/.x-sc_makefile_check deleted file mode 100644 index 705a87f..0000000 --- a/.x-sc_makefile_check +++ /dev/null @@ -1,2 +0,0 @@ -^gl/ -^lib/gllib/ diff --git a/.x-sc_program_name b/.x-sc_program_name index fcea3ad..1aa4fff 100644 --- a/.x-sc_program_name +++ b/.x-sc_program_name @@ -1,3 +1,2 @@ ^examples/ -^gl/ ^tests/ diff --git a/.x-sc_prohibit_HAVE_MBRTOWC b/.x-sc_prohibit_HAVE_MBRTOWC deleted file mode 100644 index 31ea67c..0000000 --- a/.x-sc_prohibit_HAVE_MBRTOWC +++ /dev/null @@ -1,3 +0,0 @@ -^gl/ -^lib/gllib/ -^lib/glm4/ diff --git a/.x-sc_prohibit_atoi_atof b/.x-sc_prohibit_atoi_atof index da95a48..71c17b3 100644 --- a/.x-sc_prohibit_atoi_atof +++ b/.x-sc_prohibit_atoi_atof @@ -1,3 +1,2 @@ -^gl/ ^src/asn1Coding.c ^src/asn1Decoding.c diff --git a/.x-sc_space_tab b/.x-sc_space_tab index 79ed1c1..07693ee 100644 --- a/.x-sc_space_tab +++ b/.x-sc_space_tab @@ -1,3 +1,2 @@ ^doc/cyclo/ -^gl/ ^lib/ASN1.c diff --git a/.x-sc_useless_cpp_parens b/.x-sc_useless_cpp_parens index 4c03a93..a25f758 100644 --- a/.x-sc_useless_cpp_parens +++ b/.x-sc_useless_cpp_parens @@ -1,2 +1 @@ -^gl/gettext.h ^lib/ASN1.c diff --git a/build-aux/warn-on-use.h b/build-aux/warn-on-use.h new file mode 100644 index 0000000..b314d36 --- /dev/null +++ b/build-aux/warn-on-use.h @@ -0,0 +1,75 @@ +/* A C macro for emitting warnings if a function is used. + Copyright (C) 2010 Free Software Foundation, Inc. + + 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 + Lesser 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/>. */ + +/* _GL_WARN_ON_USE(function, "literal string") issues a declaration + for FUNCTION which will then trigger a compiler warning containing + the text of "literal string" anywhere that function is called, if + supported by the compiler. If the compiler does not support this + feature, the macro expands to an unused extern declaration. + + This macro is useful for marking a function as a potential + portability trap, with the intent that "literal string" include + instructions on the replacement function that should be used + instead. However, one of the reasons that a function is a + portability trap is if it has the wrong signature. Declaring + FUNCTION with a different signature in C is a compilation error, so + this macro must use the same type as any existing declaration so + that programs that avoid the problematic FUNCTION do not fail to + compile merely because they included a header that poisoned the + function. But this implies that _GL_WARN_ON_USE is only safe to + use if FUNCTION is known to already have a declaration. Use of + this macro implies that there must not be any other macro hiding + the declaration of FUNCTION; but undefining FUNCTION first is part + of the poisoning process anyway (although for symbols that are + provided only via a macro, the result is a compilation error rather + than a warning containing "literal string"). Also note that in + C++, it is only safe to use if FUNCTION has no overloads. + + For an example, it is possible to poison 'getline' by: + - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], + [getline]) in configure.ac, which potentially defines + HAVE_RAW_DECL_GETLINE + - adding this code to a header that wraps the system <stdio.h>: + #undef getline + #if HAVE_RAW_DECL_GETLINE + _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" + "not universally present; use the gnulib module getline"); + #endif + + It is not possible to directly poison global variables. But it is + possible to write a wrapper accessor function, and poison that + (less common usage, like &environ, will cause a compilation error + rather than issue the nice warning, but the end result of informing + the developer about their portability problem is still achieved): + #if HAVE_RAW_DECL_ENVIRON + static inline char ***rpl_environ (void) { return &environ; } + _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); + # undef environ + # define environ (*rpl_environ ()) + #endif + */ +#ifndef _GL_WARN_ON_USE + +# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) +/* A compiler attribute is available in gcc versions 4.3.0 and later. */ +# define _GL_WARN_ON_USE(function, message) \ +extern __typeof__ (function) function __attribute__ ((__warning__ (message))) + +# else /* Unsupported. */ +# define _GL_WARN_ON_USE(function, message) \ +extern int _gl_warn_on_use +# endif +#endif @@ -17,16 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# Use alpha.gnu.org for alpha and beta releases. -# Use ftp.gnu.org for major releases. -gnu_ftp_host-alpha = alpha.gnu.org -gnu_ftp_host-beta = alpha.gnu.org -gnu_ftp_host-major = ftp.gnu.org -gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE)) - -url_dir_list = \ - ftp://$(gnu_rel_host)/gnu/libtasn1 - WFLAGS ?= --enable-gcc-warnings ADDFLAGS ?= CFGFLAGS ?= --enable-gtk-doc $(ADDFLAGS) $(WFLAGS) @@ -40,7 +30,8 @@ endif local-checks-to-skip = sc_prohibit_strcmp sc_prohibit_have_config_h \ sc_require_config_h sc_require_config_h_first \ sc_trailing_blank sc_GPL_version sc_immutable_NEWS \ - sc_copyright_check + sc_copyright_check sc_prohibit_magic_number_exit +VC_LIST_ALWAYS_EXCLUDE_REGEX = ^(gl|lib/gllib|lib/glm4)/.*$ bootstrap-tools := autoconf,automake,libtool,bison gpg_key_ID = b565716f diff --git a/doc/fdl-1.3.texi b/doc/fdl-1.3.texi index 10a302b..8805f1a 100644 --- a/doc/fdl-1.3.texi +++ b/doc/fdl-1.3.texi @@ -5,8 +5,7 @@ @c hence no sectioning command or @node. @display -Copyright @copyright{} 2000, 2001, 2002, 2007, 2008, 2010 Free Software -Foundation, Inc. +Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. @uref{http://fsf.org/} Everyone is permitted to copy and distribute verbatim copies diff --git a/doc/gendocs_template b/doc/gendocs_template index 5730f35..9259875 100644 --- a/doc/gendocs_template +++ b/doc/gendocs_template @@ -93,7 +93,7 @@ Please send broken links and other corrections or suggestions to <a href="mailto:%%EMAIL%%"><%%EMAIL%%></a>. </p> -<p>Copyright © 2009, 2010 Free Software Foundation, Inc.</p> +<p>Copyright © 2009 Free Software Foundation, Inc.</p> <p>Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.</p> diff --git a/gl/Makefile.am b/gl/Makefile.am index 13c55ee..ebfa36a 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -336,7 +336,7 @@ BUILT_SOURCES += unistd.h # We need the following in order to create an empty placeholder for # <unistd.h> when the system doesn't have one. -unistd.h: unistd.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) +unistd.h: unistd.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ @@ -438,6 +438,7 @@ unistd.h: unistd.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/unistd.in.h; \ } > $@-t && \ mv $@-t $@ @@ -480,6 +481,25 @@ libgnu_la_SOURCES += version-etc-fsf.c ## end gnulib module version-etc-fsf +## begin gnulib module warn-on-use + +BUILT_SOURCES += warn-on-use.h +# The warn-on-use.h that gets inserted into generated .h files is the same as +# build-aux/warn-on-use.h, except that it has the copyright header cut off. +warn-on-use.h: $(top_srcdir)/build-aux/warn-on-use.h + $(AM_V_GEN)rm -f $@-t $@ && \ + sed -n -e '/^.ifndef/,$$p' \ + < $(top_srcdir)/build-aux/warn-on-use.h \ + > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t + +WARN_ON_USE_H=warn-on-use.h + +EXTRA_DIST += $(top_srcdir)/build-aux/warn-on-use.h + +## end gnulib module warn-on-use + ## begin gnulib module wchar BUILT_SOURCES += wchar.h diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4 index d53b9cb..b7812a8 100644 --- a/gl/m4/gnulib-common.m4 +++ b/gl/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 11 +# gnulib-common.m4 serial 12 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -52,6 +52,14 @@ m4_ifndef([m4_foreach_w], [m4_define([m4_foreach_w], [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])]) +# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH]) +# ---------------------------------------------------- +# Backport of autoconf-2.63b's macro. +# Remove this macro when we can assume autoconf >= 2.64. +m4_ifndef([AS_VAR_IF], +[m4_define([AS_VAR_IF], +[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])]) + # AC_PROG_MKDIR_P # is a backport of autoconf-2.60's AC_PROG_MKDIR_P. # Remove this macro when we can assume autoconf >= 2.60. diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index e65fb75..a84bfee 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -213,6 +213,7 @@ AC_DEFUN([gl_FILE_LIST], [ build-aux/update-copyright build-aux/useless-if-before-free build-aux/vc-list-files + build-aux/warn-on-use.h doc/fdl-1.3.texi doc/gendocs_template lib/getopt.c @@ -252,6 +253,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/stdlib_h.m4 m4/unistd_h.m4 m4/version-etc.m4 + m4/warn-on-use.m4 m4/warnings.m4 m4/wchar.m4 m4/wchar_t.m4 diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4 index f3074ea..aacec2b 100644 --- a/gl/m4/unistd_h.m4 +++ b/gl/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 37 +# unistd_h.m4 serial 38 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,6 +11,7 @@ AC_DEFUN([gl_UNISTD_H], dnl Use AC_REQUIRE here, so that the default behavior below is expanded dnl once only, before all statements that occur in other macros. AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_C_INLINE]) gl_CHECK_NEXT_HEADERS([unistd.h]) @@ -21,6 +22,15 @@ AC_DEFUN([gl_UNISTD_H], HAVE_UNISTD_H=0 fi AC_SUBST([HAVE_UNISTD_H]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include <unistd.h> +/* Some systems declare environ in the wrong header. */ +#ifndef __GLIBC__ +# include <stdlib.h> +#endif + ]], [environ]) ]) AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], diff --git a/gl/m4/warn-on-use.m4 b/gl/m4/warn-on-use.m4 new file mode 100644 index 0000000..ab46422 --- /dev/null +++ b/gl/m4/warn-on-use.m4 @@ -0,0 +1,45 @@ +# warn-on-use.m4 serial 1 +dnl Copyright (C) 2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES) +# --------------------------------------- +# For each whitespace-separated element in the list of NAMES, define +# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES +# even after being undefined as a macro. +# +# See warn-on-use.h for some hints on how to poison function names, as +# well as ideas on poisoning global variables and macros. NAMES may +# include global variables, but remember that only functions work with +# _GL_WARN_ON_USE. Typically, INCLUDES only needs to list a single +# header, but if the replacement header pulls in other headers because +# some systems declare functions in the wrong header, then INCLUDES +# should do likewise. +# +# If you assume C89, then it is generally safe to assume declarations +# for functions declared in that standard (such as gets) without +# needing gl_WARN_ON_USE_PREPARE. +AC_DEFUN([gl_WARN_ON_USE_PREPARE], +[ + m4_foreach_w([gl_decl], [$2], + [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])), + [Define to 1 if ]m4_defn([gl_decl])[ is declared even after + undefining macros.])])dnl + for gl_func in m4_flatten([$2]); do + AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl + AC_CACHE_CHECK([whether $gl_func is declared without a macro], + [gl_Symbol], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1], +[@%:@undef $gl_func + (void) $gl_func;])], + [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])]) + AS_VAR_IF([gl_Symbol], [yes], + [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) + dnl shortcut - if the raw declaration exists, then set a cache + dnl variable to allow skipping any later AC_CHECK_DECL efforts + eval ac_cv_have_decl_$gl_func=yes]) + AS_VAR_POPDEF([gl_Symbol])dnl + done +]) diff --git a/gl/m4/warnings.m4 b/gl/m4/warnings.m4 index 2745d73..dad5c1f 100644 --- a/gl/m4/warnings.m4 +++ b/gl/m4/warnings.m4 @@ -6,14 +6,6 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Simon Josefsson -# gl_AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH]) -# ---------------------------------------------------- -# Provide the functionality of AS_VAR_IF if Autoconf does not have it. -m4_ifdef([AS_VAR_IF], -[m4_copy([AS_VAR_IF], [gl_AS_VAR_IF])], -[m4_define([gl_AS_VAR_IF], -[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])]) - # gl_AS_VAR_APPEND(VAR, VALUE) # ---------------------------- # Provide the functionality of AS_VAR_APPEND if Autoconf does not have it. @@ -37,7 +29,7 @@ AC_CACHE_CHECK([whether compiler handles $1], [gl_Warn], [ CPPFLAGS="$save_CPPFLAGS" ]) AS_VAR_PUSHDEF([gl_Flags], m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]))dnl -gl_AS_VAR_IF([gl_Warn], [yes], [gl_AS_VAR_APPEND([gl_Flags], [" $1"])]) +AS_VAR_IF([gl_Warn], [yes], [gl_AS_VAR_APPEND([gl_Flags], [" $1"])]) AS_VAR_POPDEF([gl_Flags])dnl AS_VAR_POPDEF([gl_Warn])dnl m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl diff --git a/gl/unistd.in.h b/gl/unistd.in.h index 350109b..0b2d591 100644 --- a/gl/unistd.in.h +++ b/gl/unistd.in.h @@ -118,6 +118,8 @@ /* The definition of _GL_ARG_NONNULL is copied here. */ +/* The definition of _GL_WARN_ON_USE is copied here. */ + /* OS/2 EMX lacks these macros. */ #ifndef STDIN_FILENO @@ -250,11 +252,17 @@ extern char **environ; # endif # endif #elif defined GNULIB_POSIXCHECK -# undef environ -# define environ \ - (GL_LINK_WARNING ("environ is unportable - " \ - "use gnulib module environ for portability"), \ - environ) +# if HAVE_RAW_DECL_ENVIRON +static inline char *** +rpl_environ (void) +{ + return &environ; +} +_GL_WARN_ON_USE (rpl_environ, "environ is unportable - " + "use gnulib module environ for portability"); +# undef environ +# define environ (*rpl_environ ()) +# endif #endif diff --git a/lib/glm4/gnulib-common.m4 b/lib/glm4/gnulib-common.m4 index d53b9cb..b7812a8 100644 --- a/lib/glm4/gnulib-common.m4 +++ b/lib/glm4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 11 +# gnulib-common.m4 serial 12 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -52,6 +52,14 @@ m4_ifndef([m4_foreach_w], [m4_define([m4_foreach_w], [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])]) +# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH]) +# ---------------------------------------------------- +# Backport of autoconf-2.63b's macro. +# Remove this macro when we can assume autoconf >= 2.64. +m4_ifndef([AS_VAR_IF], +[m4_define([AS_VAR_IF], +[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])]) + # AC_PROG_MKDIR_P # is a backport of autoconf-2.60's AC_PROG_MKDIR_P. # Remove this macro when we can assume autoconf >= 2.60. @@ -36,9 +36,14 @@ VC-tag = git tag -s -m '$(VERSION)' -u '$(gpg_key_ID)' VC_LIST = $(build_aux)/vc-list-files -C $(srcdir) +# You can override this variable in cfg.mk to set your own regexp +# matching files to ignore. +VC_LIST_ALWAYS_EXCLUDE_REGEX ?= ^$$ + VC_LIST_EXCEPT = \ $(VC_LIST) | if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \ - else grep -Ev "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi + else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \ + | grep -Ev -e '$(VC_LIST_ALWAYS_EXCLUDE_REGEX)' ifeq ($(origin prev_version_file), undefined) prev_version_file = $(srcdir)/.prev-version diff --git a/src/asn1Coding.c b/src/asn1Coding.c index a3aeed9..28c2f7d 100644 --- a/src/asn1Coding.c +++ b/src/asn1Coding.c @@ -57,7 +57,7 @@ and ASSIGNMENTS file with value assignments.\n\ printf ("\ Mandatory arguments to long options are mandatory for short options too.\n\ -c, --check checks the syntax only\n\ - -o, --output FILE output file\n\ + -o, --output=FILE output file\n\ -h, --help display this help and exit\n\ -v, --version output version information and exit\n"); emit_bug_reporting_address (); diff --git a/src/asn1Parser.c b/src/asn1Parser.c index b7b53c7..9232dad 100644 --- a/src/asn1Parser.c +++ b/src/asn1Parser.c @@ -57,8 +57,8 @@ a C array that is used with libtasn1 functions.\n\ printf ("\ Mandatory arguments to long options are mandatory for short options too.\n\ -c, --check checks the syntax only\n\ - -o, --output FILE output file\n\ - -n, --name NAME array name\n\ + -o, --output=FILE output file\n\ + -n, --name=NAME array name\n\ -h, --help display this help and exit\n\ -v, --version output version information and exit\n"); emit_bug_reporting_address (); |