break;
case PRE_VALUE:
- if (strchr(newline, c) || strchr(COMMENTS, c)) {
+ if (strchr(newline, c)) {
state = PRE_KEY;
key[n_key] = 0;
value[n_value] = 0;
/* strip trailing whitespace from key */
- while(strchr(WHITESPACE, key[--n_key]))
+ while(n_key && strchr(WHITESPACE, key[--n_key]))
key[n_key]=0;
r = push(key, value, userdata);
case VALUE:
if (strchr(newline, c)) {
state = PRE_KEY;
+
key[n_key] = 0;
if (value)
value[last_whitespace] = 0;
/* strip trailing whitespace from key */
- while(strchr(WHITESPACE, key[--n_key]))
+ while(n_key && strchr(WHITESPACE, key[--n_key]))
key[n_key]=0;
r = push(key, value, userdata);
value[n_value] = 0;
/* strip trailing whitespace from key */
- while(strchr(WHITESPACE, key[--n_key]))
+ while(n_key && strchr(WHITESPACE, key[--n_key]))
key[n_key]=0;
r = push(key, value, userdata);
int write_env_file(const char *fname, char **l) {
char **i;
- char _cleanup_free_ *p = NULL;
- FILE _cleanup_fclose_ *f = NULL;
+ _cleanup_free_ char *p = NULL;
+ _cleanup_fclose_ FILE *f = NULL;
int r;
r = fopen_temporary(fname, &f, &p);