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 <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
2a48afe1c2
commit
6263c06d49
@ -134,21 +134,29 @@ static void handle_property(uint32_t key, const char *val, uint32_t len)
|
|||||||
|
|
||||||
static void read_props(void)
|
static void read_props(void)
|
||||||
{
|
{
|
||||||
uint32_t len;
|
|
||||||
uint32_t key = ~0;
|
uint32_t key = ~0;
|
||||||
char *val = NULL;
|
const char *t;
|
||||||
char *t;
|
|
||||||
while ((t = buffer_read_line()) && strcmp(t, "PROPS-END")) {
|
while ((t = buffer_read_line()) && strcmp(t, "PROPS-END")) {
|
||||||
if (!strncmp(t, "K ", 2)) {
|
uint32_t len;
|
||||||
len = atoi(&t[2]);
|
const char *val;
|
||||||
key = pool_intern(buffer_read_string(len));
|
const char type = t[0];
|
||||||
buffer_read_line();
|
|
||||||
} else if (!strncmp(t, "V ", 2)) {
|
if (!type || t[1] != ' ')
|
||||||
len = atoi(&t[2]);
|
die("invalid property line: %s\n", t);
|
||||||
val = buffer_read_string(len);
|
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);
|
handle_property(key, val, len);
|
||||||
key = ~0;
|
key = ~0;
|
||||||
buffer_read_line();
|
continue;
|
||||||
|
default:
|
||||||
|
die("invalid property line: %s\n", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user