+ if (input_format == DUMP_FORMAT_AUTO)
+ input_format = DUMP_FORMAT_BATCH_TAG;
+
+ if (input_format == DUMP_FORMAT_SUP)
+ if ( xregcomp (®ex,
+ "^([^ ]+) \\(([^)]*)\\)$",
+ REG_EXTENDED) )
+ INTERNAL_ERROR ("compile time constant regex failed.");
+
+ do {
+ char *query_string, *prefix, *term;
+
+ if (line_ctx != NULL)
+ talloc_free (line_ctx);
+
+ line_ctx = talloc_new (config);
+ if (input_format == DUMP_FORMAT_SUP) {
+ ret = parse_sup_line (line_ctx, line, &query_string, tag_ops);
+ } else {
+ ret = parse_tag_line (line_ctx, line, TAG_FLAG_BE_GENEROUS,
+ &query_string, tag_ops);
+
+ if (ret == 0) {
+ ret = parse_boolean_term (line_ctx, query_string,
+ &prefix, &term);
+ if (ret && errno == EINVAL) {
+ fprintf (stderr, "Warning: cannot parse query: %s (skipping)\n", query_string);
+ continue;
+ } else if (ret) {
+ /* This is more fatal (e.g., out of memory) */
+ fprintf (stderr, "Error parsing query: %s\n",
+ strerror (errno));
+ ret = 1;
+ break;
+ } else if (strcmp ("id", prefix) != 0) {
+ fprintf (stderr, "Warning: not an id query: %s (skipping)\n", query_string);
+ continue;
+ }
+ query_string = term;
+ }
+ }
+
+ if (ret > 0)
+ continue;
+
+ if (ret < 0)
+ break;
+
+ ret = tag_message (line_ctx, notmuch, query_string,
+ tag_ops, flags);
+ if (ret)
+ break;
+
+ } while ((line_len = getline (&line, &line_size, input)) != -1);
+
+ if (line_ctx != NULL)
+ talloc_free (line_ctx);
+
+ if (input_format == DUMP_FORMAT_SUP)
+ regfree (®ex);