Patch for g77/fortran "format not a string literal" warnings

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Sat Nov 27 17:08:00 GMT 1999


	This patch zaps the "format not a string literal" warnings in
the fortran directory.  It does so by making various functions which
took a format and fixed args and passed it to sprintf into real
variadic functions which call vasprintf (from libiberty.)

Bootstrapped on Irix6, no fortran regressions.  Okay to install?

		--Kaveh


1999-11-27  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* com.c (ffecom_end_transition): Rewrite to take an ellipses.
	
	(ffecom_char_enhance_arg_, ffecom_do_entry_,
	ffecom_f2c_make_type_, ffecom_gen_sfuncdef_,
	ffecom_start_progunit_, ffecom_start_progunit_,
	ffecom_start_progunit_, ffecom_sym_transform_assign_,
	ffecom_transform_equiv_, ffecom_transform_namelist_,
	ffecom_vardesc_, ffecom_vardesc_array_, ffecom_vardesc_dims_,
	ffecom_end_transition, ffecom_lookup_label, ffecom_temp_label):
	Adjust accordingly.

	* com.h (ffecom_get_invented_identifier): Likewise.

	* sts.c (ffests_printf): New function taking ellipses.
	(ffests_printf_1D, ffests_printf_1U, ffests_printf_1s,
	ffests_printf_2Us): Delete.

	* sts.h: Likewise.

	* std.c (ffestd_R1001dump_, ffestd_R1001dump_1005_1_,
	ffestd_R1001dump_1005_2_, ffestd_R1001dump_1005_3_,
	ffestd_R1001dump_1005_4_, ffestd_R1001dump_1005_5_,
	ffestd_R1001dump_1010_2_, ffestd_R1001dump_1010_3_,
	ffestd_R1001dump_1010_4_, ffestd_R1001dump_1010_5_,
	ffestd_R1001rtexpr_): Call `ffests_printf', not `ffests_printf_*'.

	* ste.c (ffeste_io_ialist_, ffeste_io_cilist_, ffeste_io_cllist_,
	ffeste_io_icilist_, ffeste_io_inlist_, ffeste_io_olist_): Likewise.

	
diff -rup orig/egcs-CVS19991126/gcc/f/com.c egcs-CVS19991126/gcc/f/com.c
--- orig/egcs-CVS19991126/gcc/f/com.c	Tue Oct 26 07:38:03 1999
+++ egcs-CVS19991126/gcc/f/com.c	Sat Nov 27 14:11:00 1999
@@ -2402,10 +2402,9 @@ ffecom_char_enhance_arg_ (tree *xtype, f
     {
       if (ffesymbol_where (s) == FFEINFO_whereDUMMY)
 	tlen = ffecom_get_invented_identifier ("__g77_length_%s",
-					       ffesymbol_text (s), -1);
+					       ffesymbol_text (s));
       else
-	tlen = ffecom_get_invented_identifier ("__g77_%s",
-					       "length", -1);
+	tlen = ffecom_get_invented_identifier ("__g77_%s", "length");
       tlen = build_decl (PARM_DECL, tlen, ffecom_f2c_ftnlen_type_node);
 #if BUILT_FOR_270
       DECL_ARTIFICIAL (tlen) = 1;
@@ -2841,8 +2840,7 @@ ffecom_do_entry_ (ffesymbol fn, int entr
       else
 	type = ffecom_tree_type[FFEINFO_basictypeCOMPLEX][kt];
 
-      result = ffecom_get_invented_identifier ("__g77_%s",
-					       "result", -1);
+      result = ffecom_get_invented_identifier ("__g77_%s", "result");
 
       /* Make length arg _and_ enhance type info for CHAR arg itself.  */
 
@@ -2883,7 +2881,7 @@ ffecom_do_entry_ (ffesymbol fn, int entr
       yes = suspend_momentary ();
 
       multi_retval = ffecom_get_invented_identifier ("__g77_%s",
-						     "multi_retval", -1);
+						     "multi_retval");
       multi_retval = build_decl (VAR_DECL, multi_retval,
 				 ffecom_multi_type_node_);
       multi_retval = start_decl (multi_retval, FALSE);
@@ -6042,8 +6040,7 @@ ffecom_f2c_make_type_ (tree *type, int t
     }
 
   pushdecl (build_decl (TYPE_DECL,
-			ffecom_get_invented_identifier ("__g77_f2c_%s",
-							name, -1),
+			ffecom_get_invented_identifier ("__g77_f2c_%s", name),
 			*type));
 }
 
@@ -6340,8 +6337,7 @@ ffecom_gen_sfuncdef_ (ffesymbol s, ffein
 
       type = ffecom_tree_type[FFEINFO_basictypeCHARACTER][kt];
 
-      result = ffecom_get_invented_identifier ("__g77_%s",
-					       "result", -1);
+      result = ffecom_get_invented_identifier ("__g77_%s", "result");
 
       ffecom_char_enhance_arg_ (&type, s);	/* Ignore returned length. */
 
@@ -7384,8 +7380,7 @@ ffecom_start_progunit_ ()
   if (altentries)
     {
       id = ffecom_get_invented_identifier ("__g77_masterfun_%s",
-					   ffesymbol_text (fn),
-					   -1);
+					   ffesymbol_text (fn));
     }
 #if FFETARGET_isENFORCED_MAIN
   else if (main_program)
@@ -7420,8 +7415,7 @@ ffecom_start_progunit_ ()
       ffecom_which_entrypoint_decl_
 	= build_decl (PARM_DECL,
 		      ffecom_get_invented_identifier ("__g77_%s",
-						      "which_entrypoint",
-						      -1),
+						      "which_entrypoint"),
 		      integer_type_node);
       push_parm_decl (ffecom_which_entrypoint_decl_);
     }
@@ -7440,8 +7434,7 @@ ffecom_start_progunit_ ()
       else
 	type = ffecom_multi_type_node_;
 
-      result = ffecom_get_invented_identifier ("__g77_%s",
-					       "result", -1);
+      result = ffecom_get_invented_identifier ("__g77_%s", "result");
 
       /* Make length arg _and_ enhance type info for CHAR arg itself.  */
 
@@ -8605,8 +8598,7 @@ ffecom_sym_transform_assign_ (ffesymbol 
 
   t = build_decl (VAR_DECL,
 		  ffecom_get_invented_identifier ("__g77_ASSIGN_%s",
-						   ffesymbol_text (s),
-						   -1),
+						   ffesymbol_text (s)),
 		  TREE_TYPE (null_pointer_node));
 
   switch (ffesymbol_where (s))
@@ -8924,9 +8916,7 @@ ffecom_transform_equiv_ (ffestorag eqst)
   eqt = build_decl (VAR_DECL,
 		    ffecom_get_invented_identifier ("__g77_equiv_%s",
 						    ffesymbol_text
-						    (ffestorag_symbol
-						     (eqst)),
-						    -1),
+						    (ffestorag_symbol (eqst))),
 		    eqtype);
   DECL_EXTERNAL (eqt) = 0;
   if (is_init
@@ -9010,7 +9000,7 @@ ffecom_transform_namelist_ (ffesymbol s)
 
   nmlt = build_decl (VAR_DECL,
 		     ffecom_get_invented_identifier ("__g77_namelist_%d",
-						     NULL, mynumber++),
+						     mynumber++),
 		     nmltype);
   TREE_STATIC (nmlt) = 1;
   DECL_INITIAL (nmlt) = error_mark_node;
@@ -9616,7 +9606,7 @@ ffecom_vardesc_ (ffebld expr)
 
       var = build_decl (VAR_DECL,
 			ffecom_get_invented_identifier ("__g77_vardesc_%d",
-							NULL, mynumber++),
+							mynumber++),
 			vardesctype);
       TREE_STATIC (var) = 1;
       DECL_INITIAL (var) = error_mark_node;
@@ -9723,8 +9713,7 @@ ffecom_vardesc_array_ (ffesymbol s)
   TREE_CONSTANT (list) = 1;
   TREE_STATIC (list) = 1;
 
-  var = ffecom_get_invented_identifier ("__g77_vardesc_array_%d", NULL,
-					mynumber++);
+  var = ffecom_get_invented_identifier ("__g77_vardesc_array_%d", mynumber++);
   var = build_decl (VAR_DECL, var, item);
   TREE_STATIC (var) = 1;
   DECL_INITIAL (var) = error_mark_node;
@@ -9837,8 +9826,7 @@ ffecom_vardesc_dims_ (ffesymbol s)
     TREE_CONSTANT (list) = 1;
     TREE_STATIC (list) = 1;
 
-    var = ffecom_get_invented_identifier ("__g77_dims_%d", NULL,
-					  mynumber++);
+    var = ffecom_get_invented_identifier ("__g77_dims_%d", mynumber++);
     var = build_decl (VAR_DECL, var, item);
     TREE_STATIC (var) = 1;
     DECL_INITIAL (var) = error_mark_node;
@@ -11164,7 +11152,7 @@ ffecom_end_transition ()
 
       var = build_decl (VAR_DECL,
 			ffecom_get_invented_identifier ("__g77_forceload_%d",
-							NULL, number++),
+							number++),
 			dt);
       DECL_EXTERNAL (var) = 0;
       TREE_STATIC (var) = 1;
@@ -11453,59 +11441,26 @@ ffecom_finish_progunit ()
 }
 
 #endif
-/* Wrapper for get_identifier.  pattern is sprintf-like, assumed to contain
-   one %s if text is not NULL, assumed to contain one %d if number is
-   not -1.  If both are assumed, the %s is assumed to precede the %d.  */
+
+extern int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0);
+
+/* Wrapper for get_identifier.  pattern is sprintf-like.  */
 
 #if FFECOM_targetCURRENT == FFECOM_targetGCC
 tree
-ffecom_get_invented_identifier (const char *pattern, const char *text,
-				int number)
+ffecom_get_invented_identifier (const char *pattern, ...)
 {
   tree decl;
   char *nam;
-  mallocSize lenlen;
-  char space[66];
-
-  lenlen = 0;
-  if (text)
-    lenlen += strlen (text);
-  if (number != -1)
-    lenlen += 20;
-  if (text || number != -1)
-    {
-      lenlen += strlen (pattern);
-      if (lenlen > ARRAY_SIZE (space))
-	nam = malloc_new_ks (malloc_pool_image (), pattern, lenlen);
-      else
-	nam = &space[0];
-    }
-  else
-    {
-      lenlen = 0;
-      nam = (char *) pattern;
-    }
-
-  if (text == NULL)
-    {
-      if (number != -1)
-	sprintf (&nam[0], pattern, number);
-    }
-  else
-    {
-      if (number == -1)
-	sprintf (&nam[0], pattern, text);
-      else
-	sprintf (&nam[0], pattern, text, number);
-    }
+  va_list ap;
 
+  va_start (ap, pattern);
+  if (vasprintf (&nam, pattern, ap) == 0)
+    abort();
+  va_end(ap);
   decl = get_identifier (nam);
-
-  if (lenlen > ARRAY_SIZE (space))
-    malloc_kill_ks (malloc_pool_image (), nam, lenlen);
-
+  free (nam);
   IDENTIFIER_INVENTED (decl) = 1;
-
   return decl;
 }
 
@@ -12444,8 +12399,7 @@ ffecom_lookup_label (ffelab label)
 
 	  glabel = build_decl (VAR_DECL,
 			       ffecom_get_invented_identifier
-			       ("__g77_format_%d", NULL,
-				(int) ffelab_value (label)),
+			       ("__g77_format_%d", (int) ffelab_value (label)),
 			       build_type_variant (build_array_type
 						   (char_type_node,
 						    NULL_TREE),
@@ -13578,7 +13532,6 @@ ffecom_temp_label ()
 
   glabel = build_decl (LABEL_DECL,
 		       ffecom_get_invented_identifier ("__g77_label_%d",
-						       NULL,
 						       mynumber++),
 		       void_type_node);
   DECL_CONTEXT (glabel) = current_function_decl;
diff -rup orig/egcs-CVS19991126/gcc/f/com.h egcs-CVS19991126/gcc/f/com.h
--- orig/egcs-CVS19991126/gcc/f/com.h	Fri Sep 10 06:35:56 1999
+++ egcs-CVS19991126/gcc/f/com.h	Sat Nov 27 13:57:45 1999
@@ -306,8 +306,8 @@ tree ffecom_expr_w (tree type, ffebld ex
 void ffecom_finish_compile (void);
 void ffecom_finish_decl (tree decl, tree init, bool is_top_level);
 void ffecom_finish_progunit (void);
-tree ffecom_get_invented_identifier (const char *pattern, const char *text,
-				     int number);
+tree ffecom_get_invented_identifier (const char *pattern, ...)
+  ATTRIBUTE_PRINTF_1;
 ffeinfoKindtype ffecom_gfrt_basictype (ffecomGfrt ix);
 ffeinfoKindtype ffecom_gfrt_kindtype (ffecomGfrt ix);
 void ffecom_init_0 (void);
diff -rup orig/egcs-CVS19991126/gcc/f/std.c egcs-CVS19991126/gcc/f/std.c
--- orig/egcs-CVS19991126/gcc/f/std.c	Sat Apr 17 06:58:28 1999
+++ egcs-CVS19991126/gcc/f/std.c	Sat Nov 27 13:49:25 1999
@@ -4465,9 +4465,7 @@ ffestd_R1001dump_ (ffests s, ffesttForma
 		char *p = ffelex_token_text (next->t);
 		ffeTokenLength i = ffelex_token_length (next->t);
 
-		ffests_printf_1U (s,
-				  "%" ffeTokenLength_f "uH",
-				  i);
+		ffests_printf (s, "%" ffeTokenLength_f "uH", i);
 		while (i-- != 0)
 		  {
 		    ffests_putc (s, *p);
@@ -4487,8 +4485,7 @@ ffestd_R1001dump_ (ffests s, ffesttForma
 	      if (next->u.R1003D.R1004.rtexpr)
 		ffestd_R1001rtexpr_ (s, next, next->u.R1003D.R1004.u.expr);
 	      else
-		ffests_printf_1U (s, "%lu",
-				  next->u.R1003D.R1004.u.unsigned_val);
+		ffests_printf (s, "%lu", next->u.R1003D.R1004.u.unsigned_val);
 	    }
 
 	  ffests_putc (s, '(');
@@ -4520,7 +4517,7 @@ ffestd_R1001dump_1005_1_ (ffests s, ffes
       if (f->u.R1005.R1004.rtexpr)
 	ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1004.u.expr);
       else
-	ffests_printf_1U (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
+	ffests_printf (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
     }
 
   ffests_puts (s, string);
@@ -4530,7 +4527,7 @@ ffestd_R1001dump_1005_1_ (ffests s, ffes
       if (f->u.R1005.R1006.rtexpr)
 	ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1006.u.expr);
       else
-	ffests_printf_1U (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
+	ffests_printf (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
     }
 }
 
@@ -4553,7 +4550,7 @@ ffestd_R1001dump_1005_2_ (ffests s, ffes
       if (f->u.R1005.R1004.rtexpr)
 	ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1004.u.expr);
       else
-	ffests_printf_1U (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
+	ffests_printf (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
     }
 
   ffests_puts (s, string);
@@ -4561,7 +4558,7 @@ ffestd_R1001dump_1005_2_ (ffests s, ffes
   if (f->u.R1005.R1006.rtexpr)
     ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1006.u.expr);
   else
-    ffests_printf_1U (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
+    ffests_printf (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
 }
 
 /* ffestd_R1001dump_1005_3_ -- Dump a particular format
@@ -4582,7 +4579,7 @@ ffestd_R1001dump_1005_3_ (ffests s, ffes
       if (f->u.R1005.R1004.rtexpr)
 	ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1004.u.expr);
       else
-	ffests_printf_1U (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
+	ffests_printf (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
     }
 
   ffests_puts (s, string);
@@ -4590,7 +4587,7 @@ ffestd_R1001dump_1005_3_ (ffests s, ffes
   if (f->u.R1005.R1006.rtexpr)
     ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1006.u.expr);
   else
-    ffests_printf_1U (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
+    ffests_printf (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
 
   if (f->u.R1005.R1007_or_R1008.present)
     {
@@ -4598,8 +4595,7 @@ ffestd_R1001dump_1005_3_ (ffests s, ffes
       if (f->u.R1005.R1007_or_R1008.rtexpr)
 	ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1007_or_R1008.u.expr);
       else
-	ffests_printf_1U (s, "%lu",
-			  f->u.R1005.R1007_or_R1008.u.unsigned_val);
+	ffests_printf (s, "%lu", f->u.R1005.R1007_or_R1008.u.unsigned_val);
     }
 }
 
@@ -4622,7 +4618,7 @@ ffestd_R1001dump_1005_4_ (ffests s, ffes
       if (f->u.R1005.R1004.rtexpr)
 	ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1004.u.expr);
       else
-	ffests_printf_1U (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
+	ffests_printf (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
     }
 
   ffests_puts (s, string);
@@ -4630,13 +4626,13 @@ ffestd_R1001dump_1005_4_ (ffests s, ffes
   if (f->u.R1005.R1006.rtexpr)
     ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1006.u.expr);
   else
-    ffests_printf_1U (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
+    ffests_printf (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
 
   ffests_putc (s, '.');
   if (f->u.R1005.R1007_or_R1008.rtexpr)
     ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1007_or_R1008.u.expr);
   else
-    ffests_printf_1U (s, "%lu", f->u.R1005.R1007_or_R1008.u.unsigned_val);
+    ffests_printf (s, "%lu", f->u.R1005.R1007_or_R1008.u.unsigned_val);
 }
 
 /* ffestd_R1001dump_1005_5_ -- Dump a particular format
@@ -4657,7 +4653,7 @@ ffestd_R1001dump_1005_5_ (ffests s, ffes
       if (f->u.R1005.R1004.rtexpr)
 	ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1004.u.expr);
       else
-	ffests_printf_1U (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
+	ffests_printf (s, "%lu", f->u.R1005.R1004.u.unsigned_val);
     }
 
   ffests_puts (s, string);
@@ -4665,13 +4661,13 @@ ffestd_R1001dump_1005_5_ (ffests s, ffes
   if (f->u.R1005.R1006.rtexpr)
     ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1006.u.expr);
   else
-    ffests_printf_1U (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
+    ffests_printf (s, "%lu", f->u.R1005.R1006.u.unsigned_val);
 
   ffests_putc (s, '.');
   if (f->u.R1005.R1007_or_R1008.rtexpr)
     ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1007_or_R1008.u.expr);
   else
-    ffests_printf_1U (s, "%lu", f->u.R1005.R1007_or_R1008.u.unsigned_val);
+    ffests_printf (s, "%lu", f->u.R1005.R1007_or_R1008.u.unsigned_val);
 
   if (f->u.R1005.R1009.present)
     {
@@ -4679,7 +4675,7 @@ ffestd_R1001dump_1005_5_ (ffests s, ffes
       if (f->u.R1005.R1009.rtexpr)
 	ffestd_R1001rtexpr_ (s, f, f->u.R1005.R1009.u.expr);
       else
-	ffests_printf_1U (s, "%lu", f->u.R1005.R1009.u.unsigned_val);
+	ffests_printf (s, "%lu", f->u.R1005.R1009.u.unsigned_val);
     }
 }
 
@@ -4713,7 +4709,7 @@ ffestd_R1001dump_1010_2_ (ffests s, ffes
       if (f->u.R1010.val.rtexpr)
 	ffestd_R1001rtexpr_ (s, f, f->u.R1010.val.u.expr);
       else
-	ffests_printf_1U (s, "%lu", f->u.R1010.val.u.unsigned_val);
+	ffests_printf (s, "%lu", f->u.R1010.val.u.unsigned_val);
     }
 
   ffests_puts (s, string);
@@ -4734,7 +4730,7 @@ ffestd_R1001dump_1010_3_ (ffests s, ffes
   if (f->u.R1010.val.rtexpr)
     ffestd_R1001rtexpr_ (s, f, f->u.R1010.val.u.expr);
   else
-    ffests_printf_1U (s, "%lu", f->u.R1010.val.u.unsigned_val);
+    ffests_printf (s, "%lu", f->u.R1010.val.u.unsigned_val);
 
   ffests_puts (s, string);
 }
@@ -4754,7 +4750,7 @@ ffestd_R1001dump_1010_4_ (ffests s, ffes
   if (f->u.R1010.val.rtexpr)
     ffestd_R1001rtexpr_ (s, f, f->u.R1010.val.u.expr);
   else
-    ffests_printf_1D (s, "%ld", f->u.R1010.val.u.signed_val);
+    ffests_printf (s, "%ld", f->u.R1010.val.u.signed_val);
 
   ffests_puts (s, string);
 }
@@ -4776,7 +4772,7 @@ ffestd_R1001dump_1010_5_ (ffests s, ffes
   if (f->u.R1010.val.rtexpr)
     ffestd_R1001rtexpr_ (s, f, f->u.R1010.val.u.expr);
   else
-    ffests_printf_1U (s, "%lu", f->u.R1010.val.u.unsigned_val);
+    ffests_printf (s, "%lu", f->u.R1010.val.u.unsigned_val);
 }
 
 /* ffestd_R1001error_ -- Complain about FORMAT specification not supported
@@ -4836,7 +4832,7 @@ ffestd_R1001rtexpr_ (ffests s, ffesttFor
 	case FFEINFO_kindtypeANY:
 	  return;
 	}
-      ffests_printf_1D (s, "%ld", val);
+      ffests_printf (s, "%ld", (long) val);
     }
 }
 
diff -rup orig/egcs-CVS19991126/gcc/f/ste.c egcs-CVS19991126/gcc/f/ste.c
--- orig/egcs-CVS19991126/gcc/f/ste.c	Sun May  2 10:04:25 1999
+++ egcs-CVS19991126/gcc/f/ste.c	Sat Nov 27 14:14:47 1999
@@ -1279,7 +1279,7 @@ ffeste_io_ialist_ (bool have_err,
   yes = suspend_momentary ();
 
   t = build_decl (VAR_DECL,
-		  ffecom_get_invented_identifier ("__g77_alist_%d", NULL,
+		  ffecom_get_invented_identifier ("__g77_alist_%d",
 						  mynumber++),
 		  f2c_alist_struct);
   TREE_STATIC (t) = 1;
@@ -1495,7 +1495,7 @@ ffeste_io_cilist_ (bool have_err,
   yes = suspend_momentary ();
 
   t = build_decl (VAR_DECL,
-		  ffecom_get_invented_identifier ("__g77_cilist_%d", NULL,
+		  ffecom_get_invented_identifier ("__g77_cilist_%d",
 						  mynumber++),
 		  f2c_cilist_struct);
   TREE_STATIC (t) = 1;
@@ -1635,7 +1635,7 @@ ffeste_io_cllist_ (bool have_err,
   yes = suspend_momentary ();
 
   t = build_decl (VAR_DECL,
-		  ffecom_get_invented_identifier ("__g77_cllist_%d", NULL,
+		  ffecom_get_invented_identifier ("__g77_cllist_%d",
 						  mynumber++),
 		  f2c_close_struct);
   TREE_STATIC (t) = 1;
@@ -1853,7 +1853,7 @@ ffeste_io_icilist_ (bool have_err,
   yes = suspend_momentary ();
 
   t = build_decl (VAR_DECL,
-		  ffecom_get_invented_identifier ("__g77_icilist_%d", NULL,
+		  ffecom_get_invented_identifier ("__g77_icilist_%d",
 						  mynumber++),
 		  f2c_icilist_struct);
   TREE_STATIC (t) = 1;
@@ -2113,7 +2113,7 @@ ffeste_io_inlist_ (bool have_err,
   yes = suspend_momentary ();
 
   t = build_decl (VAR_DECL,
-		  ffecom_get_invented_identifier ("__g77_inlist_%d", NULL,
+		  ffecom_get_invented_identifier ("__g77_inlist_%d",
 						  mynumber++),
 		  f2c_inquire_struct);
   TREE_STATIC (t) = 1;
@@ -2302,7 +2302,7 @@ ffeste_io_olist_ (bool have_err,
   yes = suspend_momentary ();
 
   t = build_decl (VAR_DECL,
-		  ffecom_get_invented_identifier ("__g77_olist_%d", NULL,
+		  ffecom_get_invented_identifier ("__g77_olist_%d",
 						  mynumber++),
 		  f2c_open_struct);
   TREE_STATIC (t) = 1;
diff -rup orig/egcs-CVS19991126/gcc/f/sts.c egcs-CVS19991126/gcc/f/sts.c
--- orig/egcs-CVS19991126/gcc/f/sts.c	Tue Mar 30 04:23:44 1999
+++ egcs-CVS19991126/gcc/f/sts.c	Sat Nov 27 13:59:01 1999
@@ -96,119 +96,27 @@ ffests_new (ffests s, mallocPool pool, f
     s->text_ = malloc_new_ksr (pool, "ffests", size);
 }
 
-/* ffests_printf_1D -- printf("...%ld...",(long)) to a string
+extern int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0);
 
-   ffests s;
-   ffests_printf_1D(s,"...%ld...",1);
-
-   Like printf, but into a string.  */
-
-void
-ffests_printf_1D (ffests s, const char *ctl, long arg1)
-{
-  char quickbuf[40];
-  char *buff;
-  ffestsLength len;
-
-  if ((len = strlen (ctl) + 21) < ARRAY_SIZE (quickbuf))
-    /* No # bigger than 20 digits. */
-    {
-      sprintf (&quickbuf[0], ctl, arg1);
-      ffests_puttext (s, &quickbuf[0], strlen (quickbuf));
-    }
-  else
-    {
-      buff = malloc_new_ks (malloc_pool_image (), "ffests_printf_1D", len);
-      sprintf (buff, ctl, arg1);
-      ffests_puttext (s, buff, strlen (buff));
-      malloc_kill_ks (malloc_pool_image (), buff, len);
-    }
-}
-
-/* ffests_printf_1U -- printf("...%lu...",(unsigned long)) to a string
+/* ffests_printf -- printf ("...%ld...",(long)) to a string
 
    ffests s;
-   ffests_printf_1U(s,"...%lu...",1);
+   ffests_printf (s,"...%ld...",1);
 
    Like printf, but into a string.  */
 
 void
-ffests_printf_1U (ffests s, const char *ctl, unsigned long arg1)
+ffests_printf (ffests s, const char *ctl, ...)
 {
-  char quickbuf[40];
-  char *buff;
-  ffestsLength len;
-
-  if ((len = strlen (ctl) + 21) < ARRAY_SIZE (quickbuf))
-    /* No # bigger than 20 digits. */
-    {
-      sprintf (&quickbuf[0], ctl, arg1);
-      ffests_puttext (s, &quickbuf[0], strlen (quickbuf));
-    }
-  else
-    {
-      buff = malloc_new_ks (malloc_pool_image (), "ffests_printf_1U", len);
-      sprintf (buff, ctl, arg1);
-      ffests_puttext (s, buff, strlen (buff));
-      malloc_kill_ks (malloc_pool_image (), buff, len);
-    }
-}
-
-/* ffests_printf_1s -- printf("...%s...",(char *)) to a string
-
-   ffests s;
-   ffests_printf_1s(s,"...%s...","hi there!");
-
-   Like printf, but into a string.  */
-
-void
-ffests_printf_1s (ffests s, const char *ctl, const char *arg1)
-{
-  char quickbuf[40];
-  char *buff;
-  ffestsLength len;
-
-  if ((len = strlen (ctl) + strlen (arg1) - 1) < ARRAY_SIZE (quickbuf))
-    {
-      sprintf (&quickbuf[0], ctl, arg1);
-      ffests_puttext (s, &quickbuf[0], strlen (quickbuf));
-    }
-  else
-    {
-      buff = malloc_new_ks (malloc_pool_image (), "ffests_printf_1s", len);
-      sprintf (buff, ctl, arg1);
-      ffests_puttext (s, buff, strlen (buff));
-      malloc_kill_ks (malloc_pool_image (), buff, len);
-    }
-}
-
-/* ffests_printf_2Us -- printf("...%lu...%s...",...) to a string
-
-   ffests s;
-   ffests_printf_2Us(s,"...%lu...%s...",1,"hi there!");
-
-   Like printf, but into a string.  */
-
-void
-ffests_printf_2Us (ffests s, const char *ctl, unsigned long arg1, const char *arg2)
-{
-  char quickbuf[60];
-  char *buff;
-  ffestsLength len;
-
-  if ((len = strlen (ctl) + 21 + strlen (arg2) - 1) < ARRAY_SIZE (quickbuf))
-    /* No # bigger than 20 digits. */
-    {
-      sprintf (&quickbuf[0], ctl, arg1, arg2);
-      ffests_puttext (s, &quickbuf[0], strlen (quickbuf));
-    }
-  else
-    {
-      buff = malloc_new_ks (malloc_pool_image (), "ffests_printf_2Us", len);
-      sprintf (buff, ctl, arg1, arg2);
-      ffests_puttext (s, buff, strlen (buff));
-      malloc_kill_ks (malloc_pool_image (), buff, len);
-    }
+  char *string;
+  va_list ap;
+  
+  va_start (ap, ctl);
+  if (vasprintf(&string, ctl, ap) == 0)
+    abort();
+  va_end (ap);
+  ffests_puts (s, string);
+  free (string);
 }
 
 /* ffests_putc -- Put a single character into string
diff -rup orig/egcs-CVS19991126/gcc/f/sts.h egcs-CVS19991126/gcc/f/sts.h
--- orig/egcs-CVS19991126/gcc/f/sts.h	Tue Mar 30 04:23:45 1999
+++ egcs-CVS19991126/gcc/f/sts.h	Sat Nov 27 13:58:14 1999
@@ -60,11 +60,7 @@ struct _ffests_
 
 void ffests_kill (ffests s);
 void ffests_new (ffests s, mallocPool pool, ffestsLength size);
-void ffests_printf_1D (ffests s, const char *ctl, long arg1);
-void ffests_printf_1U (ffests s, const char *ctl, unsigned long arg1);
-void ffests_printf_1s (ffests s, const char *ctl, const char *arg1);
-void ffests_printf_2Us (ffests s, const char *ctl, unsigned long arg1,
-			const char *arg2);
+void ffests_printf (ffests s, const char *ctl, ...) ATTRIBUTE_PRINTF_2;
 void ffests_putc (ffests s, char c);
 void ffests_puts (ffests s, const char *string);
 void ffests_puttext (ffests s, const char *text, ffestsLength length);


More information about the Gcc-patches mailing list