Hallo Shawn,
Shawn O. Pearce schrieb am Mon 14. Apr, 19:29 (-0400):
of fast-import in that point
=3D :0 and =E2=80=9C:-12=E2=80=9D
What about this:
diff --git a/fast-import.c b/fast-import.c
index 73e5439..f60e4ab 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1690,10 +1690,31 @@ static void skip_optional_lf(void)
ungetc(term_char, stdin);
}
=20
+static inline int parse_mark(const const char *str, uintmax_t* mark,
+ char **after_mark)
+{
+ if (!str || str[0] !=3D ':' || !isdigit(str[1]))
+ return 1;
+
+ char *am;
+ const uintmax_t m =3D strtoumax(&str[1], &am, 10);
+ if (errno =3D=3D 0) {
+ *mark =3D m;
+ *after_mark =3D am;
+ return 0;
+ }
+ return 1;
+}
+
static void cmd_mark(void)
{
- if (!prefixcmp(command_buf.buf, "mark :")) {
- next_mark =3D strtoumax(command_buf.buf + 6, NULL, 10);
+ uintmax_t mark =3D 0;
+ char *after_mark =3D NULL;
+
+ if (!prefixcmp(command_buf.buf, "mark ") &&
+ parse_mark(&command_buf.buf[5], &mark, &after_mark) &&
+ *after_mark =3D=3D '\0') {
+ next_mark =3D mark;
read_next_command();
}
else
@@ -1878,7 +1899,10 @@ static void file_change_m(struct branch *b)
=20
if (*p =3D=3D ':') {
char *x;
- oe =3D find_mark(strtoumax(p + 1, &x, 10));
+ uintmax_t m;
+ if (parse_mark(p, &m, &x))
+ die("Invalid mark: %s", p);
+ oe =3D find_mark(m);
hashcpy(sha1, oe->sha1);
p =3D x;
} else if (!prefixcmp(p, "inline")) {
@@ -2045,7 +2069,11 @@ static int cmd_from(struct branch *b)
hashcpy(b->branch_tree.versions[0].sha1, t);
hashcpy(b->branch_tree.versions[1].sha1, t);
} else if (*from =3D=3D ':') {
- uintmax_t idnum =3D strtoumax(from + 1, NULL, 10);
+ char *after_mark;
+ uintmax_t idnum;
+ if (parse_mark(from, &idnum, &after_mark) ||
+ *after_mark !=3D '\0')
+ die("Not a valid mark: %s", from);
struct object_entry *oe =3D find_mark(idnum);
if (oe->type !=3D OBJ_COMMIT)
die("Mark :%" PRIuMAX " not a commit", idnum);
@@ -2080,7 +2108,11 @@ static struct hash_list *cmd_merge(unsigned int *cou=
nt)
if (s)
hashcpy(n->sha1, s->sha1);
else if (*from =3D=3D ':') {
- uintmax_t idnum =3D strtoumax(from + 1, NULL, 10);
+ char *after_mark;
+ uintmax_t idnum;
+ if (parse_mark(from, &idnum, &after_mark) ||
+ *after_mark !=3D '\0')
+ die("Not a valid mark: %s", from);
struct object_entry *oe =3D find_mark(idnum);
if (oe->type !=3D OBJ_COMMIT)
die("Mark :%" PRIuMAX " not a commit", idnum);
@@ -2228,7 +2260,10 @@ static void cmd_new_tag(void)
hashcpy(sha1, s->sha1);
} else if (*from =3D=3D ':') {
struct object_entry *oe;
- from_mark =3D strtoumax(from + 1, NULL, 10);
+ char *after_mark;
+ if (parse_mark(from, &from_mark, &after_mark) ||
+ *after_mark !=3D '\0')
+ die("Not a valid mark: %s", from);
oe =3D find_mark(from_mark);
if (oe->type !=3D OBJ_COMMIT)
die("Mark :%" PRIuMAX " not a commit", from_mark);
@@ -2333,9 +2368,8 @@ static void import_marks(const char *input_file)
if (line[0] !=3D ':' || !end)
die("corrupt mark line: %s", line);
*end =3D 0;
- mark =3D strtoumax(line + 1, &end, 10);
- if (!mark || end =3D=3D line + 1
- || *end !=3D ' ' || get_sha1(end + 1, sha1))
+ if (parse_mark(line, &mark, &end) || !mark ||
+ *end !=3D ' ' || get_sha1(end + 1, sha1))
die("corrupt mark line: %s", line);
e =3D find_object(sha1);
if (!e) {
Bye, J=C3=B6rg.
--=20
Wer eher stirbt ist l=C3=A4nger tot.
(Un B. Kant)