Re: HEAD: inclusion order wrong for input.c

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.bugs,gmane.comp.gnu.m4.patches
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Ralf Wildenhues on 4/2/2007 11:45 AM:
> * Gary V. Vaughan wrote on Mon, Apr 02, 2007 at 02:32:45PM CEST:
>>  Thanks for the report.  Although I don't get this warning, I have cleaned
>>  up the remaining warnings that I did see on OS X.
> 
> Thanks, looking better now.  I do get these warnings now, with -Wall:
> 
> ../m4/m4/macro.c: In function 'expand_macro':
> ../m4/m4/macro.c:279: warning: format '%d' expects type 'int', but argument 5 has type 'size_t'
> ../m4/m4/macro.c: In function 'process_macro':
> ../m4/m4/macro.c:425: warning: array subscript has type 'char'
> ../m4/m4/macro.c:478: warning: array subscript has type 'char'
> 
> ../m4/src/freeze.c: In function ‘produce_resyntax_dump’:
> ../m4/src/freeze.c:97: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’

This fixes these warnings; gnulib makes it possible to assume %z nowadays.

2007-04-02  Eric Blake  <[email protected]>

	Fix warnings from last commit.
	* ltdl/m4/gnulib-cache.m4: Augment with 'gnulib-tool --import
	fprintf-posix sprintf-posix'.
	* m4/macro.c (expand_macro, trace_format): Use correct specifier
	for size_t.
	(process_macro): Avoid negative array index.
	* src/freeze.c (produce_resyntax_dump, produce_module_dump)
	(dump_symbol_CB, produce_frozen_state): Use correct specifier for
	size_t.

> 
> and also, I still get two test failures on GNU/Linux x86_64.

Care to share the testsuite.log?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             [email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGEdOf84KuGfSFAYARApXZAJwK7E41+AIwL8sLgD0mV+J7PzlwxgCeND+H
N9tnhqCj2DMz5YalWmCq8Lg=
=Rra2
-----END PGP SIGNATURE-----

_______________________________________________
Bug-m4 mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-m4
m4.patch253 (text/plain, 7.9 KB)
Index: ltdl/m4/gnulib-cache.m4
===================================================================
RCS file: /sources/m4/m4/ltdl/m4/gnulib-cache.m4,v
retrieving revision 1.23
diff -u -p -r1.23 gnulib-cache.m4
--- ltdl/m4/gnulib-cache.m4	7 Mar 2007 15:31:14 -0000	1.23
+++ ltdl/m4/gnulib-cache.m4	3 Apr 2007 04:07:51 -0000
@@ -15,11 +15,11 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --lib=libgnu --source-base=gnu --m4-base=ltdl/m4 --doc-base=doc --aux-dir=ltdl/config --libtool --macro-prefix=M4 assert avltree-oset binary-io clean-temp cloexec close-stream closeout config-h configmake dirname error exit fdl filenamecat fopen-safer free gendocs gettext gnupload mkstemp obstack progname regex regexprops-generic stdbool stdlib-safer strnlen strtol tempname unlocked-io vasprintf-posix verror xalloc xalloc-die xstrndup xstrtol xvasprintf
+#   gnulib-tool --import --dir=. --lib=libgnu --source-base=gnu --m4-base=ltdl/m4 --doc-base=doc --aux-dir=ltdl/config --libtool --macro-prefix=M4 assert avltree-oset binary-io clean-temp cloexec close-stream closeout config-h configmake dirname error exit fdl filenamecat fopen-safer fprintf-posix free gendocs gettext gnupload mkstemp obstack progname regex regexprops-generic sprintf-posix stdbool stdlib-safer strnlen strtol tempname unlocked-io vasprintf-posix verror xalloc xalloc-die xstrndup xstrtol xvasprintf
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([])
-gl_MODULES([assert avltree-oset binary-io clean-temp cloexec close-stream closeout config-h configmake dirname error exit fdl filenamecat fopen-safer free gendocs gettext gnupload mkstemp obstack progname regex regexprops-generic stdbool stdlib-safer strnlen strtol tempname unlocked-io vasprintf-posix verror xalloc xalloc-die xstrndup xstrtol xvasprintf])
+gl_MODULES([assert avltree-oset binary-io clean-temp cloexec close-stream closeout config-h configmake dirname error exit fdl filenamecat fopen-safer fprintf-posix free gendocs gettext gnupload mkstemp obstack progname regex regexprops-generic sprintf-posix stdbool stdlib-safer strnlen strtol tempname unlocked-io vasprintf-posix verror xalloc xalloc-die xstrndup xstrtol xvasprintf])
 gl_AVOID([])
 gl_SOURCE_BASE([gnu])
 gl_M4_BASE([ltdl/m4])
Index: m4/macro.c
===================================================================
RCS file: /sources/m4/m4/m4/macro.c,v
retrieving revision 1.65
diff -u -p -r1.65 macro.c
--- m4/macro.c	2 Apr 2007 12:28:08 -0000	1.65
+++ m4/macro.c	3 Apr 2007 04:07:51 -0000
@@ -1,5 +1,5 @@
 /* GNU m4 -- A simple macro processor
-   Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2001, 2006
+   Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2001, 2006, 2007
    Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -275,7 +275,7 @@ expand_macro (m4 *context, const char *n
   if (m4_get_nesting_limit_opt (context) > 0
       && expansion_level > m4_get_nesting_limit_opt (context))
     m4_error (context, EXIT_FAILURE, 0, _("\
-recursion limit of %d exceeded, use -L<N> to change it"),
+recursion limit of %zu exceeded, use -L<N> to change it"),
 	      m4_get_nesting_limit_opt (context));
 
   macro_call_id++;
@@ -422,7 +422,7 @@ process_macro (m4 *context, m4_symbol_va
     {
       char ch;
 
-      if (!m4_has_syntax (M4SYNTAX, *text, M4_SYNTAX_DOLLAR))
+      if (!m4_has_syntax (M4SYNTAX, to_uchar (*text), M4_SYNTAX_DOLLAR))
 	{
 	  obstack_1grow (obs, *text);
 	  text++;
@@ -475,7 +475,7 @@ process_macro (m4 *context, m4_symbol_va
 	      const char *key;
 
 	      for (endp = ++text;
-		   *endp && m4_has_syntax (M4SYNTAX, *endp,
+		   *endp && m4_has_syntax (M4SYNTAX, to_uchar (*endp),
 					   (M4_SYNTAX_OTHER | M4_SYNTAX_ALPHA
 					    | M4_SYNTAX_NUM));
 		   ++endp)
@@ -565,21 +565,13 @@ trace_format (m4 *context, const char *f
 	  break;
 
 	case 'z':
-	  /* GNU assumption: Although POSIX allows size_t to be just
-	     16 bits, independently of int, GNU assumes is at least as
-	     big as int.  Likewise, although POSIX allows size_t to be
-	     bigger than unsigned long in some compilation
-	     environments, GNU assumes that size_t always fits in
-	     unsigned long.  Unfortunately, GNU does not assume that
-	     %zu is portable, yet.  */
 	  ch = *fmt++;
 	  assert (ch == 'u');
-	  assert (sizeof (size_t) >= sizeof (int));
 	  {
 	    size_t z = va_arg (args, size_t);
 	    char nbuf[INT_BUFSIZE_BOUND (size_t)];
 
-	    sprintf (nbuf, "%lu", (unsigned long int) z);
+	    sprintf (nbuf, "%zu", z);
 	    s = nbuf;
 	  }
 	  break;
Index: src/freeze.c
===================================================================
RCS file: /sources/m4/m4/src/freeze.c,v
retrieving revision 1.63
diff -u -p -r1.63 freeze.c
--- src/freeze.c	2 Apr 2007 12:06:23 -0000	1.63
+++ src/freeze.c	3 Apr 2007 04:07:51 -0000
@@ -94,7 +94,7 @@ produce_resyntax_dump (m4 *context, FILE
 
       /* No need to use produce_mem_dump, since we know all resyntax
 	 names are already ASCII-encoded.  */
-      fprintf (file, "R%d\n%s\n", strlen (resyntax), resyntax);
+      fprintf (file, "R%zu\n%s\n", strlen (resyntax), resyntax);
     }
 }
 
@@ -138,13 +138,7 @@ produce_module_dump (FILE *file, lt_dlha
   if (handle)
     produce_module_dump (file, handle);
 
-  /* GNU assumption: Although POSIX allows size_t to be just 16 bits,
-     independently of int, GNU assumes is at least as big as int.
-     Likewise, although POSIX allows size_t to be bigger than unsigned
-     long in some compilation environments, GNU assumes that size_t
-     always fits in unsigned long.  Unfortunately, GNU does not assume
-     that %zu is portable, yet.  */
-  fprintf (file, "M%lu\n", (unsigned long int) len);
+  fprintf (file, "M%zu\n", len);
   produce_mem_dump (file, name, len);
   fputc ('\n', file);
 }
@@ -173,10 +167,9 @@ dump_symbol_CB (m4_symbol_table *symtab,
     {
       const char *text = m4_get_symbol_text (symbol);
       size_t text_len = strlen (text);
-      fprintf (file, "T%lu,%lu", (unsigned long int) symbol_len,
-	       (unsigned long int) text_len);
+      fprintf (file, "T%zu,%zu", symbol_len, text_len);
       if (handle)
-	fprintf (file, ",%lu", (unsigned long int) module_len);
+	fprintf (file, ",%zu", module_len);
       fputc ('\n', file);
 
       produce_mem_dump (file, symbol_name, symbol_len);
@@ -193,10 +186,9 @@ dump_symbol_CB (m4_symbol_table *symtab,
 	assert (!"INTERNAL ERROR: builtin not found in builtin table!");
       bp_len = strlen (bp->name);
 
-      fprintf (file, "F%lu,%lu", (unsigned long int) symbol_len,
-	       (unsigned long int) bp_len);
+      fprintf (file, "F%zu,%zu", symbol_len, bp_len);
       if (handle)
-	fprintf (file, ",%lu", (unsigned long int) module_len);
+	fprintf (file, ",%zu", module_len);
       fputc ('\n', file);
 
       produce_mem_dump (file, symbol_name, symbol_len);
@@ -237,9 +229,8 @@ produce_frozen_state (m4 *context, const
   if (strcmp (m4_get_syntax_lquote (M4SYNTAX), DEF_LQUOTE)
       || strcmp (m4_get_syntax_rquote (M4SYNTAX), DEF_RQUOTE))
     {
-      fprintf (file, "Q%lu,%lu\n",
-	       (unsigned long int) M4SYNTAX->lquote.length,
-	       (unsigned long int) M4SYNTAX->rquote.length);
+      fprintf (file, "Q%zu,%zu\n", M4SYNTAX->lquote.length,
+	       M4SYNTAX->rquote.length);
       produce_mem_dump (file, M4SYNTAX->lquote.string,
 			M4SYNTAX->lquote.length);
       produce_mem_dump (file, M4SYNTAX->rquote.string,
@@ -252,9 +243,8 @@ produce_frozen_state (m4 *context, const
   if (strcmp (m4_get_syntax_bcomm (M4SYNTAX), DEF_BCOMM)
       || strcmp (m4_get_syntax_ecomm (M4SYNTAX), DEF_ECOMM))
     {
-      fprintf (file, "C%lu,%lu\n",
-	       (unsigned long int) M4SYNTAX->bcomm.length,
-	       (unsigned long int) M4SYNTAX->ecomm.length);
+      fprintf (file, "C%zu,%zu\n", M4SYNTAX->bcomm.length,
+	       M4SYNTAX->ecomm.length);
       produce_mem_dump (file, M4SYNTAX->bcomm.string, M4SYNTAX->bcomm.length);
       produce_mem_dump (file, M4SYNTAX->ecomm.string, M4SYNTAX->ecomm.length);
       fputc ('\n', file);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.