X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev_rules.c;h=1139c99a7d0e84ff3b8e289a3c6af251d5aabf76;hb=a7e2961c0f6dfb50bed2c66f30c4be16cadfa088;hp=526993e21ca64043ac483f26488a2c8698b3484c;hpb=2f2c4fa442f33d7eaee02eda016d6149b9aa0be6;p=elogind.git diff --git a/udev_rules.c b/udev_rules.c index 526993e21..1139c99a7 100644 --- a/udev_rules.c +++ b/udev_rules.c @@ -87,54 +87,29 @@ static int get_key(char **line, char **key, char **value) linepos++; /* get the key */ + temp = strchr(linepos, '='); + if (temp == NULL || temp == linepos) + return -1; + temp[0] = '\0'; *key = linepos; - while (1) { - linepos++; - if (linepos[0] == '\0') - return -1; - if (isspace(linepos[0])) - break; - if (linepos[0] == '=') - break; + linepos = &temp[1]; + + /* get a quoted value */ + if (linepos[0] == '"' || linepos[0] == '\'') { + temp = strchr(&linepos[1], linepos[0]); + if (temp != NULL) { + temp[0] = '\0'; + *value = &linepos[1]; + goto out; + } } - /* terminate key */ - linepos[0] = '\0'; - linepos++; - - /* skip whitespace */ - while (isspace(linepos[0])) - linepos++; - /* get the value*/ - if (linepos[0] == '"') { - linepos++; - temp = strchr(linepos, '"'); - if (!temp) { - dbg("missing closing quote"); - return -1; - } - dbg("value is quoted"); + temp = strchr(linepos, '\n'); + if (temp != NULL) temp[0] = '\0'; - } else if (linepos[0] == '\'') { - linepos++; - temp = strchr(linepos, '\''); - if (!temp) { - dbg("missing closing quote"); - return -1; - } - dbg("value is quoted"); - temp[0] = '\0'; - } else if (linepos[0] == '\0') { - dbg("value is empty"); - } else { - temp = linepos; - while (temp[0] && !isspace(temp[0])) - temp++; - temp[0] = '\0'; - } *value = linepos; - +out: return 0; }