m4-commit
[Top][All Lists]
Advanced

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

Changes to m4/modules/m4.c,v


From: Eric Blake
Subject: Changes to m4/modules/m4.c,v
Date: Sat, 14 Oct 2006 14:16:25 +0000

CVSROOT:        /sources/m4
Module name:    m4
Changes by:     Eric Blake <ericb>      06/10/14 14:16:23

Index: modules/m4.c
===================================================================
RCS file: /sources/m4/m4/modules/m4.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -b -r1.82 -r1.83
--- modules/m4.c        12 Oct 2006 21:14:50 -0000      1.82
+++ modules/m4.c        14 Oct 2006 14:16:23 -0000      1.83
@@ -560,26 +560,33 @@
 M4BUILTIN_HANDLER (undivert)
 {
   int i = 0;
+  const char *me = M4ARG (0);
 
   if (argc == 1)
     m4_undivert_all (context);
   else
+    for (i = 1; i < argc; i++)
     {
-      if (sscanf (M4ARG (1), "%d", &i) == 1)
-       m4_insert_diversion (context, i);
+       const char *str = M4ARG (i);
+       char *endp;
+       int diversion = strtol (str, &endp, 10);
+       if (*endp == '\0' && !isspace ((unsigned char) *str))
+         m4_insert_diversion (context, diversion);
       else if (m4_get_posixly_correct_opt (context))
-       m4_numeric_arg (context, argc, argv, 1, &i);
+         m4_numeric_arg (context, argc, argv, i, &diversion);
       else
        {
-         FILE *fp = m4_path_search (context, M4ARG (1), (char **) NULL);
+           FILE *fp = m4_path_search (context, str, NULL);
          if (fp != NULL)
            {
              m4_insert_file (context, fp);
-             fclose (fp);
+               if (fclose (fp) == EOF)
+                 m4_error (context, 0, errno, _("%s: error undiverting `%s'"),
+                           me, str);
            }
          else
            m4_error (context, 0, errno, _("%s: cannot undivert `%s'"),
-                     M4ARG (0), M4ARG (1));
+                       me, str);
        }
     }
 }




reply via email to

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