changeset 5304:707482f5c106

(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.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 04 Oct 2004 04:24:47 +0000
parents 1e92d75c6d3a
children 077fc6e8f1ce
files lib/modechange.c
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lib/modechange.c
+++ b/lib/modechange.c
@@ -211,10 +211,9 @@
 
   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 @@
       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 @@
 	      }
 	no_more_values:;
 	}
-  } while (*mode_string == ',');
+
+      if (*mode_string != ',')
+	break;
+    }
+
   if (*mode_string == 0)
     return head;
 invalid: