chiark / gitweb /
udevtest: add --subsystem option
[elogind.git] / udev_rules.c
index 526993e21ca64043ac483f26488a2c8698b3484c..1139c99a7d0e84ff3b8e289a3c6af251d5aabf76 100644 (file)
@@ -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;
 }