diff options
author | Rob Landley <rob@landley.net> | 2020-12-05 03:51:20 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-12-05 03:51:20 -0600 |
commit | 5657214ac24a62e96b366097ffbfba39ebcd3380 (patch) | |
tree | 98f12554927dd5c7826fa272e45320576d3afc94 /lib | |
parent | 60e8974e215801f6c29de9f4b786f45323e9af89 (diff) | |
download | toybox-5657214ac24a62e96b366097ffbfba39ebcd3380.tar.gz |
Small cleanup.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 19 |
1 files changed, 6 insertions, 13 deletions
@@ -971,18 +971,12 @@ mode_t string_to_mode(char *modestr, mode_t mode) } // Repeated "hows" are allowed; something like "a=r+w+s" is valid. - if (!*str) goto barf; - while (*str) { - if (!strchr(hows, *str)) goto barf; - if (!(dohow = *(str++))) goto barf; - - while (*str && (s = strchr(whats, *str))) { - dowhat |= 1<<(s-whats); - str++; - } + do { + if (!(dohow = *str) || !strchr(hows, *str)) goto barf; + while (*++str && (s = strchr(whats, *str))) dowhat |= 1<<(s-whats); // Convert X to x for directory or if already executable somewhere - if ((dowhat&32) && (S_ISDIR(mode) || (mode&0111))) dowhat |= 1; + if ((dowhat&32) && (S_ISDIR(mode) || (mode&0111))) dowhat |= 1; // Copy mode from another category? if (!dowhat && *str && (s = strchr(whys, *str))) { @@ -1004,7 +998,7 @@ mode_t string_to_mode(char *modestr, mode_t mode) // Figure out new value at this location if (i == 3) { // suid and sticky - if (!j) bit = dowhat&16; // o+s = t + if (!j) bit = dowhat&16; // o+s = t but a+s doesn't set t, hence t else if ((dowhat&8) && (dowho&(8|(1<<j)))) bit++; } else { if (!(dowho&(8|(1<<i)))) continue; @@ -1012,12 +1006,11 @@ mode_t string_to_mode(char *modestr, mode_t mode) } // When selection active, modify bit - if (dohow == '=' || (bit && dohow == '-')) mode &= ~where; if (bit && dohow != '-') mode |= where; } } - } + } while (*str); if (!*str) break; } |