Re: Fixed the WriteEnvironmentStrings action [try2]
"James Hawkins" <truiken(a)gmail.com> wrote:
+ while (*cptr && (*cptr == '=' || *cptr == '+' || + *cptr == '-' || *cptr == '!' || *cptr == '*')) + { + switch (*cptr) + { + case '=': + *flags |= ENV_ACT_SETALWAYS; + break; + case '+': + *flags |= ENV_ACT_SETABSENT; + break; + case '-': + *flags |= ENV_ACT_REMOVE; + break; + case '!': + *flags |= ENV_ACT_REMOVEMATCH; + break; + case '*': + *flags |= ENV_MOD_MACHINE; + break; + default: + ERR("Unknown Environment flag: %c\n", *cptr); + return ERROR_FUNCTION_FAILED; + } + + cptr++; + (*name)++; + }
A simple 'goto' in the 'default:' case, or using while (*cptr) { if (*cptr == '=') else if (*cptr == '+') { } else if (...) { } else break; } would help to avoid double comparisons and simplify the code. -- Dmitry.
participants (1)
-
Dmitry Timoshkov