aboutsummaryrefslogtreecommitdiff
path: root/editors/patch.c
diff options
context:
space:
mode:
authorlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-05-07 21:10:06 +0000
committerlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-05-07 21:10:06 +0000
commit797e25a392c9bf4dd78600ad4a9d9a5973bbc27e (patch)
tree483dee1eb5ee32e13196d0d12ca828c4f8017d8c /editors/patch.c
parent60cd232fba6d12f135d94eee69bc8ece8192e0d4 (diff)
downloadbusybox-w32-797e25a392c9bf4dd78600ad4a9d9a5973bbc27e.tar.gz
busybox-w32-797e25a392c9bf4dd78600ad4a9d9a5973bbc27e.tar.bz2
busybox-w32-797e25a392c9bf4dd78600ad4a9d9a5973bbc27e.zip
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. git-svn-id: svn://busybox.net/trunk/busybox@15025 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'editors/patch.c')
-rw-r--r--editors/patch.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/editors/patch.c b/editors/patch.c
index 9a3740882..337d1bbad 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -54,29 +54,17 @@ static unsigned int copy_lines(FILE *src_stream, FILE *dest_stream, const unsign
54 54
55static char *extract_filename(char *line, int patch_level) 55static char *extract_filename(char *line, int patch_level)
56{ 56{
57 char *filename_start_ptr = line + 4; 57 char *temp, *filename_start_ptr = line + 4;
58 int i; 58 int i;
59 59
60 /* Terminate string at end of source filename */ 60 /* Terminate string at end of source filename */
61 { 61 temp = strchr(filename_start_ptr, '\t');
62 char *line_ptr; 62 if (temp) *temp = 0;
63 line_ptr = strchr(filename_start_ptr, '\t');
64 if (!line_ptr) {
65 bb_perror_msg("Malformed line %s", line);
66 return(NULL);
67 }
68 *line_ptr = '\0';
69 }
70 63
71 /* Skip over (patch_level) number of leading directories */ 64 /* skip over (patch_level) number of leading directories */
72 for (i = 0; i < patch_level; i++) { 65 for (i = 0; i < patch_level; i++) {
73 char *dirname_ptr; 66 if(!(temp = strchr(filename_start_ptr, '/'))) break;
74 67 filename_start_ptr = temp + 1;
75 dirname_ptr = strchr(filename_start_ptr, '/');
76 if (!dirname_ptr) {
77 break;
78 }
79 filename_start_ptr = dirname_ptr + 1;
80 } 68 }
81 69
82 return(bb_xstrdup(filename_start_ptr)); 70 return(bb_xstrdup(filename_start_ptr));