diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-05-21 08:00:09 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2007-05-21 08:00:09 +0200 |
commit | 90a1e83a3b9fe74245892e5538538671a85db112 (patch) | |
tree | e99b67425a1c7844ce7fd2d1c9a9ccefc9bc5936 /udev_rules.c | |
parent | c19870519d0a23bbf7f5cf206cefab6418a9f4be (diff) |
IMPORT: do not mangle whitespace
Diffstat (limited to 'udev_rules.c')
-rw-r--r-- | udev_rules.c | 59 |
1 files changed, 17 insertions, 42 deletions
diff --git a/udev_rules.c b/udev_rules.c index 526993e21c..1139c99a7d 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; } |