seq: use of ^ should not produce a "parse" error when parent isn't found

This commit is contained in:
Oliver Kiddle 2017-07-03 00:39:37 +02:00
parent 12b1722868
commit 3fe44ac055

34
seq.c
View File

@ -257,10 +257,10 @@ parse_thread(char *map, long a, long *starto, long *stopo)
if (state == 2) { if (state == 2) {
*starto = start; *starto = start;
*stopo = stop; *stopo = stop;
return 1;
}
return 0; return 0;
} }
return 1;
}
static int static int
parse_subthread(char *map, long a, long *stopo) parse_subthread(char *map, long a, long *stopo)
@ -292,14 +292,14 @@ parse_subthread(char *map, long a, long *stopo)
} }
if (line < a) if (line < a)
return 0; return 1;
if (minindent == -1) if (minindent == -1)
stop = line; stop = line;
*stopo = stop; *stopo = stop;
return 1; return 0;
} }
static int static int
@ -326,14 +326,14 @@ parse_parent(char *map, long *starto, long *stopo)
if (line == *starto) { if (line == *starto) {
if (previndent[indent-1]) { if (previndent[indent-1]) {
*starto = *stopo = previndent[indent-1]; *starto = *stopo = previndent[indent-1];
return 1;
} else {
return 0; return 0;
} else {
return 1;
} }
} }
} }
return 0; return 1;
} }
static int static int
@ -345,7 +345,7 @@ parse_range(char *map, char *a, long *start, long *stop, long cur, long lines)
while (*a && *a != ':' && *a != '=' && *a != '_' && *a != '^') { while (*a && *a != ':' && *a != '=' && *a != '_' && *a != '^') {
char *b = parse_relnum(a, cur, 0, lines, start); char *b = parse_relnum(a, cur, 0, lines, start);
if (a == b) if (a == b)
return 0; return 1;
a = b; a = b;
} }
if (*start == 0) if (*start == 0)
@ -353,8 +353,8 @@ parse_range(char *map, char *a, long *start, long *stop, long cur, long lines)
while (*a == '^') { while (*a == '^') {
a++; a++;
if (!parse_parent(map, start, stop)) if (parse_parent(map, start, stop))
return 0; return 2;
} }
if (*a == ':') { if (*a == ':') {
@ -364,7 +364,7 @@ parse_range(char *map, char *a, long *start, long *stop, long cur, long lines)
} else { } else {
char *b = parse_relnum(a, cur, *start, lines, stop); char *b = parse_relnum(a, cur, *start, lines, stop);
if (a == b) if (a == b)
return 0; return 1;
} }
} else if (*a == '=') { } else if (*a == '=') {
return parse_thread(map, *start, start, stop); return parse_thread(map, *start, start, stop);
@ -373,10 +373,10 @@ parse_range(char *map, char *a, long *start, long *stop, long cur, long lines)
} else if (!*a) { } else if (!*a) {
*stop = *start; *stop = *start;
} else { } else {
return 0; return 1;
} }
return 1; return 0;
} }
void void
@ -427,10 +427,14 @@ blaze822_seq_next(char *map, char *range, struct blaze822_seq_iter *iter)
find_cur(map, iter); find_cur(map, iter);
if (!iter->start) { if (!iter->start) {
if (!parse_range(map, range, &iter->start, &iter->stop, int ret = parse_range(map, range, &iter->start, &iter->stop,
iter->cur, iter->lines)) { iter->cur, iter->lines);
if (ret == 1) {
fprintf(stderr, "can't parse range: %s\n", range); fprintf(stderr, "can't parse range: %s\n", range);
return 0; return 0;
} else if (ret == 2) {
fprintf(stderr, "message not found for specified range: %s\n", range);
return 0;
} }
iter->s = map; iter->s = map;