From: Jonathan Nieder Date: Sat, 20 Nov 2010 00:54:45 +0000 (-0600) Subject: vcs-svn: Sharpen parsing of property lines X-Git-Tag: v1.7.5-rc0~3^2~20^2~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6263c06d49abdf5e5defdf528c3ff67bf948ac9b;p=git.git vcs-svn: Sharpen parsing of property lines Prepare to add a new type of property line (the 'D' line) to handle property deltas. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c index 5de8dadcd..576d148e5 100644 --- a/vcs-svn/svndump.c +++ b/vcs-svn/svndump.c @@ -134,21 +134,29 @@ static void handle_property(uint32_t key, const char *val, uint32_t len) static void read_props(void) { - uint32_t len; uint32_t key = ~0; - char *val = NULL; - char *t; + const char *t; while ((t = buffer_read_line()) && strcmp(t, "PROPS-END")) { - if (!strncmp(t, "K ", 2)) { - len = atoi(&t[2]); - key = pool_intern(buffer_read_string(len)); - buffer_read_line(); - } else if (!strncmp(t, "V ", 2)) { - len = atoi(&t[2]); - val = buffer_read_string(len); + uint32_t len; + const char *val; + const char type = t[0]; + + if (!type || t[1] != ' ') + die("invalid property line: %s\n", t); + len = atoi(&t[2]); + val = buffer_read_string(len); + buffer_skip_bytes(1); /* Discard trailing newline. */ + + switch (type) { + case 'K': + key = pool_intern(val); + continue; + case 'V': handle_property(key, val, len); key = ~0; - buffer_read_line(); + continue; + default: + die("invalid property line: %s\n", t); } } }