* libltdl/config/ltmain.m4sh: Update copyright date. (func_emit_wrapper_part1): move contents to... (func_emit_wrapper_part2): move contents to... (func_emit_wrapper): here. (func_emit_cwrapperexe_src) [file scope]: re-organized includes and portability macros. Avoid oldnames on MINGW32 and MSVC for setmode/stat/chmod/getcwd/putenv. Declare _putenv on MINGW32 when -ansi. Use namespaced macro LT_DEBUGWRAPPER. Remove variables script_text_part1 and script_text_part2. (func_emit_cwrapperexe_src) [lt_dump_script]: New function. (func_emit_cwrapperexe_src) [main]: Call it. ---
This patch attempts to correct the issues raised in this thread: "msys/mingw warnings about string length and putenv absence with gcc -Wall -ansi" http://lists.gnu.org/archive/html/bug-libtool/2008-12/msg00038.html There was an earlier, similar patch related to errors that occurred when -std=c99. One of those errors, related to a limitation on const char* arrays to less than 4096 bytes, led to splitting the existing function 'func_emit_wrapper' into two different pieces, each less than 4096 characters. However, the string limitation in c89 is 509 characters, which would lead to too many such subfunctions. Futher, it would be very difficult to chose breakpoints to ensure this char length limit, when some chunks would include long variable values such as LD_LIBRARY_PATH or PATH. To achieve this more stringent limitation, the best we can (easily) do is to emit each line of the script as a single const char*. Thus, we require -- but do not check -- that each line in the wrapper script has less than 509 characters. However, we do not want 127 'func_emit_wrapper_partN' functions. So, in this patch I reverted the "split" and moved all of the script contents back into func_emit_wrapper. However, when building the cwrapper source code, each line of the script is turned into a separate C string: fputs ("one line\n", stdout); I probably should have done it this way to start with, but was trying to avoid 127 different function calls. Oh well. Also took the opportunity here to move the DEBUGWRAPPER macro into the LT_* namespace, and to reorganize the #includes and the portability #defines into separate sections. Spot checked some regression tests on cygwin (all passed). Running full regression suite on mingw. OK to push, pending testsuite results? ===== libltdl/config/ltmain.m4sh | 132 ++++++++++++++++++++------------------------ 1 files changed, 59 insertions(+), 73 deletions(-) diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 20ca07b..ebedf69 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -5,7 +5,7 @@ m4_divert_push([SCRIPT])# @configure_input@ # Written by Gordon Matzigkeit <g...@gnu.ai.mit.edu>, 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. +# 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -2309,15 +2309,23 @@ func_extract_archives () } - -# func_emit_wrapper_part1 [arg=no] +# func_emit_wrapper [arg=no] +# +# Emit a libtool wrapper script on stdout. +# Don't directly open a file because we may want to +# incorporate the script contents within a cygwin/mingw +# wrapper executable. Must ONLY be called from within +# func_mode_link because it depends on a number of variables +# set therein. # -# Emit the first part of a libtool wrapper script on stdout. -# For more information, see the description associated with -# func_emit_wrapper(), below. -func_emit_wrapper_part1 () +# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR +# variable will take. If 'yes', then the emitted script +# will assume that the directory in which it is stored is +# the $objdir directory. This is a cygwin/mingw-specific +# behavior. +func_emit_wrapper () { - func_emit_wrapper_part1_arg1=${1-no} + func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL @@ -2398,24 +2406,10 @@ _LTECHO_EOF' file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done -" -} -# end: func_emit_wrapper_part1 - -# func_emit_wrapper_part2 [arg=no] -# -# Emit the second part of a libtool wrapper script on stdout. -# For more information, see the description associated with -# func_emit_wrapper(), below. -func_emit_wrapper_part2 () -{ - func_emit_wrapper_part2_arg1=${1-no} - - $ECHO "\ # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. - WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1 + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then @@ -2532,30 +2526,6 @@ func_emit_wrapper_part2 () fi\ " } -# end: func_emit_wrapper_part2 - - -# func_emit_wrapper [arg=no] -# -# Emit a libtool wrapper script on stdout. -# Don't directly open a file because we may want to -# incorporate the script contents within a cygwin/mingw -# wrapper executable. Must ONLY be called from within -# func_mode_link because it depends on a number of variables -# set therein. -# -# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR -# variable will take. If 'yes', then the emitted script -# will assume that the directory in which it is stored is -# the $objdir directory. This is a cygwin/mingw-specific -# behavior. -func_emit_wrapper () -{ - # split this up so that func_emit_cwrapperexe_src - # can call each part independently. - func_emit_wrapper_part1 ${1-no} - func_emit_wrapper_part2 ${1-no} -} # func_to_host_path arg @@ -2747,18 +2717,11 @@ EOF # include <direct.h> # include <process.h> # include <io.h> -# define setmode _setmode #else # include <unistd.h> # include <stdint.h> # ifdef __CYGWIN__ # include <io.h> -# define HAVE_SETENV -# ifdef __STRICT_ANSI__ -char *realpath (const char *, char *); -int putenv (char *); -int setenv (const char *, const char *, int); -# endif # endif #endif #include <malloc.h> @@ -2772,6 +2735,33 @@ int setenv (const char *, const char *, int); #include <fcntl.h> #include <sys/stat.h> +/* declarations of non-ANSI functions */ +#if defined(__MINGW32__) +# ifdef __STRICT_ANSI__ +int _putenv (const char *); +# endif +#elif defined(__CYGWIN__) +# ifdef __STRICT_ANSI__ +char *realpath (const char *, char *); +int putenv (char *); +int setenv (const char *, const char *, int); +# endif +#endif + +/* portability #defines */ +#if defined(_MSC_VER) || defined(__MINGW32__) +# ifndef __MINGW32CE__ +# define setmode _setmode +# define stat _stat +# define chmod _chmod +# define getcwd _getcwd +# define putenv _putenv +# endif +#endif +#ifdef __CYGWIN__ +# define HAVE_SETENV +#endif + #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) @@ -2789,7 +2779,6 @@ int setenv (const char *, const char *, int); #ifdef _MSC_VER # define S_IXUSR _S_IEXEC -# define stat _stat # ifndef _INTPTR_T_DEFINED # define intptr_t int # endif @@ -2842,7 +2831,7 @@ int setenv (const char *, const char *, int); } while (0) #undef LTWRAPPER_DEBUGPRINTF -#if defined DEBUGWRAPPER +#if defined LT_DEBUGWRAPPER # define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args static void ltwrapper_debugprintf (const char *fmt, ...) @@ -2876,22 +2865,8 @@ int lt_split_name_value (const char *arg, char** name, char** value); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); - -static const char *script_text_part1 = -EOF - - func_emit_wrapper_part1 yes | - $SED -e 's/\([\\"]\)/\\\1/g' \ - -e 's/^/ "/' -e 's/$/\\n"/' - echo ";" - cat <<EOF - -static const char *script_text_part2 = +void lt_dump_script (FILE *f); EOF - func_emit_wrapper_part2 yes | - $SED -e 's/\([\\"]\)/\\\1/g' \ - -e 's/^/ "/' -e 's/$/\\n"/' - echo ";" cat <<EOF const char * MAGIC_EXE = "$magic_exe"; @@ -2987,8 +2962,7 @@ EOF esac cat <<"EOF" - printf ("%s", script_text_part1); - printf ("%s", script_text_part2); + lt_dump_script (stdout); return 0; } } @@ -3748,6 +3722,18 @@ prepare_spawn (char **argv) EOF ;; esac + + cat <<"EOF" +void lt_dump_script (FILE* f) +{ +EOF + func_emit_wrapper yes | + $SED -e 's/\([\\"]\)/\\\1/g' \ + -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' + + cat <<"EOF" +} +EOF } # end: func_emit_cwrapperexe_src -- 1.6.0.4