chiark / gitweb /
fileio:parse_env_file_internal() fix environment file parsing
[elogind.git] / src / shared / fileio.c
index 617afeace2bf0eb14930e4e60814b4326bc95ff3..3f242edc600a1b0a864820639b3073dbfb309bb4 100644 (file)
@@ -209,7 +209,9 @@ static int parse_env_file_internal(
                 switch (state) {
 
                 case PRE_KEY:
                 switch (state) {
 
                 case PRE_KEY:
-                        if (strchr(COMMENTS, c))
+                        if (startswith(p, "export "))
+                                p+=6;
+                        else if (strchr(COMMENTS, c))
                                 state = COMMENT;
                         else if (!strchr(WHITESPACE, c)) {
                                 state = KEY;
                                 state = COMMENT;
                         else if (!strchr(WHITESPACE, c)) {
                                 state = KEY;
@@ -255,7 +257,7 @@ static int parse_env_file_internal(
                         break;
 
                 case PRE_VALUE:
                         break;
 
                 case PRE_VALUE:
-                        if (strchr(newline, c)) {
+                        if (strchr(newline, c) || strchr(COMMENTS, c)) {
                                 state = PRE_KEY;
                                 key[n_key] = 0;
 
                                 state = PRE_KEY;
                                 key[n_key] = 0;