bug-gnulib
[Top][All Lists]
Advanced

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

[Bug-gnulib] modechange.c sync from coreutils


From: Paul Eggert
Subject: [Bug-gnulib] modechange.c sync from coreutils
Date: Sun, 03 Oct 2004 21:25:41 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

I installed this fix, imported from coreutils:

2004-10-03  Paul Eggert  <address@hidden>

        * modechange.c (mode_compile): Don't decrement a pointer that
        points to the start of a string, as the C Standard says the
        resulting behavior is undefined.

Index: modechange.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/modechange.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -p -u -r1.27 -r1.28
--- modechange.c        7 Aug 2004 00:09:39 -0000       1.27
+++ modechange.c        4 Oct 2004 04:24:47 -0000       1.28
@@ -211,10 +211,9 @@ mode_compile (const char *mode_string, u
 
   umask_value = umask (0);
   umask (umask_value);         /* Restore the old value. */
-  --mode_string;
 
   /* One loop iteration for each "ugoa...=+-rwxXstugo...[=+-rwxXstugo...]". */
-  do
+  for (;; mode_string++)
     {
       /* Which bits in the mode are operated on. */
       mode_t affected_bits = 0;
@@ -226,7 +225,7 @@ mode_compile (const char *mode_string, u
       bool who_specified_p;
 
       /* Turn on all the bits in `affected_bits' for each group given. */
-      for (++mode_string;; ++mode_string)
+      for (;; mode_string++)
        switch (*mode_string)
          {
          case 'u':
@@ -349,7 +348,11 @@ mode_compile (const char *mode_string, u
              }
        no_more_values:;
        }
-  } while (*mode_string == ',');
+
+      if (*mode_string != ',')
+       break;
+    }
+
   if (*mode_string == 0)
     return head;
 invalid:




reply via email to

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