summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer2006-05-19 10:49:38 +0000
committerBernhard Reutner-Fischer2006-05-19 10:49:38 +0000
commit4ab339129edcea77e0a08228636114dd8ebd6093 (patch)
treeae6cc1d2c17270fb59ee8f919eec0681bb3fc483
parent1de534114f26a385487f98707abd609f5ab84bac (diff)
downloadbusybox-4ab339129edcea77e0a08228636114dd8ebd6093.zip
busybox-4ab339129edcea77e0a08228636114dd8ebd6093.tar.gz
Patch to fix bug 868, and some related cleanup while I was in the area.
A tab is now taken as the end of filename if it's there, but if it isn't (because the timestamp isn't there) we continue with the existing untruncated line as the filename. (r15025 from trunk plus coding-style fixes for the patch)
-rw-r--r--editors/patch.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/editors/patch.c b/editors/patch.c
index 9a37408..666aa73 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -54,29 +54,19 @@ static unsigned int copy_lines(FILE *src_stream, FILE *dest_stream, const unsign
static char *extract_filename(char *line, int patch_level)
{
- char *filename_start_ptr = line + 4;
+ char *temp, *filename_start_ptr = line + 4;
int i;
/* Terminate string at end of source filename */
- {
- char *line_ptr;
- line_ptr = strchr(filename_start_ptr, '\t');
- if (!line_ptr) {
- bb_perror_msg("Malformed line %s", line);
- return(NULL);
- }
- *line_ptr = '\0';
- }
+ temp = strchr(filename_start_ptr, '\t');
+ if (temp)
+ *temp = 0;
/* Skip over (patch_level) number of leading directories */
for (i = 0; i < patch_level; i++) {
- char *dirname_ptr;
-
- dirname_ptr = strchr(filename_start_ptr, '/');
- if (!dirname_ptr) {
+ if (!(temp = strchr(filename_start_ptr, '/')))
break;
- }
- filename_start_ptr = dirname_ptr + 1;
+ filename_start_ptr = temp + 1;
}
return(bb_xstrdup(filename_start_ptr));