This commit is contained in:
Your Name 2023-11-02 12:32:35 +03:00
parent ae4f4e73ed
commit 973057bef1

View File

@ -20,10 +20,11 @@ mode_t mu_parse_mode(const char *s) {
if (!*p && mode < 07777U) if (!*p && mode < 07777U)
return mode; return mode;
mode = 0; else if (mode > 07777U)
return 0;
/* 0 - + */ mode = 0;
int type = 0; int append = 1;
mode_t mask = 0; mode_t mask = 0;
for (size_t i = 0; i < strlen(s); i++) { for (size_t i = 0; i < strlen(s); i++) {
@ -41,11 +42,11 @@ mode_t mu_parse_mode(const char *s) {
break; break;
case '+': case '+':
type = 0; append = 1;
break; break;
case '-': case '-':
type = 1; append = 0;
break; break;
case 'g': case 'g':
@ -65,14 +66,19 @@ mode_t mu_parse_mode(const char *s) {
break; break;
default: default:
return -1; return 0;
} }
} }
if (type) if (mask == 0)
return ~mask & mode; mask = U(FULL_PERM);
return mask & mode; if (append)
return mask & mode;
mode_t test = mask & mode;
printf("test: %d\n", test);
return test;
} }
#endif #endif