]> mj.ucw.cz Git - libucw.git/blobdiff - lib/conf-input.c
Allow empty test cases.
[libucw.git] / lib / conf-input.c
index e44cba1b3dcf9c025fd92b0b0230800812c35db6..0272de21eb27722c68a1704cdb862d80640136c3 100644 (file)
@@ -159,7 +159,7 @@ get_token(uns is_command_name, byte **msg)
        return NULL;
       }
       if (!*line || *line == '#')
-       log(L_WARN, "The line %s:%d following a backslash is empty", name_parse_fb, line_num);
+       log(L_WARN, "The line %s:%d following a backslash is empty", name_parse_fb ? : (byte*) "", line_num);
     } else {
       split_grow(&word_buf, words+1);
       uns start = copied;
@@ -247,7 +247,11 @@ parse_fastbuf(byte *name_fb, struct fastbuf *fb, uns depth)
       switch (Clocase(*c)) {
        case 's': op = OP_SET; break;
        case 'c': op = Clocase(c[1]) == 'l' ? OP_CLEAR: OP_COPY; break;
-       case 'a': op = Clocase(c[1]) == 'p' ? OP_APPEND : OP_AFTER; break;
+       case 'a': switch (Clocase(c[1])) {
+                   case 'p': op = OP_APPEND; break;
+                   case 'f': op = OP_AFTER; break;
+                   default: op = OP_ALL;
+                 }; break;
        case 'p': op = OP_PREPEND; break;
        case 'r': op = OP_REMOVE; break;
        case 'e': op = OP_EDIT; break;
@@ -266,7 +270,12 @@ parse_fastbuf(byte *name_fb, struct fastbuf *fb, uns depth)
       goto error;
   }
 error:
-  log(L_ERROR, "File %s, line %d: %s", name_fb, line_num, msg);
+  if (name_fb)
+    log(L_ERROR, "File %s, line %d: %s", name_fb, line_num, msg);
+  else if (line_num == 1)
+    log(L_ERROR, "Manual setting of configuration: %s", msg);
+  else
+    log(L_ERROR, "Manual setting of configuration, line %d: %s", line_num, msg);
   return "included from here";
 }
 
@@ -313,7 +322,7 @@ load_string(byte *string)
   cf_init_stack();
   struct fastbuf fb;
   fbbuf_init_read(&fb, string, strlen(string), 0);
-  byte *msg = parse_fastbuf("memory string", &fb, 0);
+  byte *msg = parse_fastbuf(NULL, &fb, 0);
   return !!msg || done_stack();
 }