Skip to content

Commit 6263c06

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2a48afe commit 6263c06

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

vcs-svn/svndump.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,29 @@ static void handle_property(uint32_t key, const char *val, uint32_t len)
134134

135135
static void read_props(void)
136136
{
137-
uint32_t len;
138137
uint32_t key = ~0;
139-
char *val = NULL;
140-
char *t;
138+
const char *t;
141139
while ((t = buffer_read_line()) && strcmp(t, "PROPS-END")) {
142-
if (!strncmp(t, "K ", 2)) {
143-
len = atoi(&t[2]);
144-
key = pool_intern(buffer_read_string(len));
145-
buffer_read_line();
146-
} else if (!strncmp(t, "V ", 2)) {
147-
len = atoi(&t[2]);
148-
val = buffer_read_string(len);
140+
uint32_t len;
141+
const char *val;
142+
const char type = t[0];
143+
144+
if (!type || t[1] != ' ')
145+
die("invalid property line: %s\n", t);
146+
len = atoi(&t[2]);
147+
val = buffer_read_string(len);
148+
buffer_skip_bytes(1); /* Discard trailing newline. */
149+
150+
switch (type) {
151+
case 'K':
152+
key = pool_intern(val);
153+
continue;
154+
case 'V':
149155
handle_property(key, val, len);
150156
key = ~0;
151-
buffer_read_line();
157+
continue;
158+
default:
159+
die("invalid property line: %s\n", t);
152160
}
153161
}
154162
}

0 commit comments

Comments
 (0)