libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] [cygwin|mingw] Fix compile warnings when -std=c89.


From: Charles Wilson
Subject: Re: [PATCH] [cygwin|mingw] Fix compile warnings when -std=c89.
Date: Wed, 21 Jan 2009 16:10:08 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.5.666

Ralf Wildenhues wrote:
> Part (1) is easy to review: it is obvious that regressions are very
> unlikely to be system-dependent.  One does get the impression that it
> might just be more efficient to let libtool save the cwrapper text
> somewhere and the program just cat that.  But still, this part is ok,
> please apply.

This part pushed...

> Why is this patch not accompanied by a testsuite addition using
> -std=c89 -Werror on a program that creates a C wrapper?

...but without an additional test. Ralf, how should such a test be
structured? Do we need (like Darwin) a separate category of windows-ish
tests, that are skipped elsewhere, or what?


The bits removed from this commit are attached as
"cygwin-cwrapper-cleanups.patch". I did not run a full test suite with
just the pushed bits; however, those bits plus the
cygwin-cwrapper-cleanups did pass, and the pushed bits alone passed a
bootstrap/configure/make cycle and some (old) testsuite spot checks.
Also, the generated cwrapper code compiled when -std=c89 without error
(cygwin).

As pushed
(0010--cygwin-mingw-Fix-compile-warnings-when-std-c89.patch-pushed):

    [cygwin|mingw] Fix compile warnings when -std=c89.

    * libltdl/config/ltmain.m4sh (func_emit_wrapper_part1):
    move contents to...
    (func_emit_wrapper_part2): move contents to...
    (func_emit_wrapper): here.
    (func_emit_cwrapperexe_src) [file scope]: 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.

--
Chuck

diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 760f647..8728a7c 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -2746,18 +2716,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>
@@ -2771,6 +2734,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)
@@ -2788,7 +2778,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
@@ -2841,7 +2830,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, ...)
diff --git a/ChangeLog b/ChangeLog
index b702907..8d83a7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2009-01-21  Charles Wilson  <address@hidden>
 
+       [cygwin|mingw] Fix compile warnings when -std=c89.
+       * libltdl/config/ltmain.m4sh (func_emit_wrapper_part1):
+       move contents to...
+       (func_emit_wrapper_part2): move contents to...
+       (func_emit_wrapper): here.
+       (func_emit_cwrapperexe_src) [file scope]: 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.
+
+2009-01-21  Charles Wilson  <address@hidden>
+
        Minor cygwin cleanup
        * libltdl/config/ltmain.m4sh (func_generate_dlsyms): Correct
        case pattern for cygwin.
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 760f647..3f1a30c 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -2308,15 +2308,23 @@ func_extract_archives ()
 }
 
 
-
-# func_emit_wrapper_part1 [arg=no]
+# func_emit_wrapper [arg=no]
 #
-# 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 ()
+# 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 ()
 {
-       func_emit_wrapper_part1_arg1=${1-no}
+       func_emit_wrapper_arg1=${1-no}
 
        $ECHO "\
 #! $SHELL
@@ -2397,24 +2405,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
@@ -2531,30 +2525,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
@@ -2875,22 +2845,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";
@@ -2986,8 +2942,7 @@ EOF
              esac
 
            cat <<"EOF"
-         printf ("%s", script_text_part1);
-         printf ("%s", script_text_part2);
+         lt_dump_script (stdout);
          return 0;
        }
     }
@@ -3747,6 +3702,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
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]