]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-restore.c
xregcomp: don't consider every regex compilation failure an internal error.
[notmuch] / notmuch-restore.c
index 75bc09a68629da667fb8e3a62257ba028c6fc431..13b4325a882667b9178e432d87de14f94f1fb85c 100644 (file)
@@ -77,13 +77,21 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
        optind++;
     }
 
+    if (optind < argc) {
+       fprintf (stderr,
+        "Cannot read dump from more than one file: %s\n",
+                argv[optind]);
+       return 1;
+    }
+
     /* Dump output is one line per message. We match a sequence of
      * non-space characters for the message-id, then one or more
      * spaces, then a list of space-separated tags as a sequence of
      * characters within literal '(' and ')'. */
-    xregcomp (&regex,
-             "^([^ ]+) \\(([^)]*)\\)$",
-             REG_EXTENDED);
+    if ( xregcomp (&regex,
+                  "^([^ ]+) \\(([^)]*)\\)$",
+                  REG_EXTENDED) )
+       INTERNAL_ERROR("compile time constant regex failed.");
 
     while ((line_len = getline (&line, &line_size, input)) != -1) {
        regmatch_t match[3];