diff options
Diffstat (limited to 'editors/patch_toybox.c')
-rw-r--r-- | editors/patch_toybox.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/editors/patch_toybox.c b/editors/patch_toybox.c index 69a508b2e..5478ece7d 100644 --- a/editors/patch_toybox.c +++ b/editors/patch_toybox.c | |||
@@ -79,7 +79,7 @@ void TOY_llist_free(void *list, void (*freeit)(void *data)) | |||
79 | else free(pop); | 79 | else free(pop); |
80 | 80 | ||
81 | // End doubly linked list too. | 81 | // End doubly linked list too. |
82 | if (list==pop) break; | 82 | if (list == pop) break; |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
@@ -137,11 +137,11 @@ char *get_rawline(int fd, long *plen, char end) | |||
137 | long len = 0; | 137 | long len = 0; |
138 | 138 | ||
139 | for (;;) { | 139 | for (;;) { |
140 | if (1>read(fd, &c, 1)) break; | 140 | if (1 > read(fd, &c, 1)) break; |
141 | if (!(len & 63)) buf=xrealloc(buf, len+65); | 141 | if (!(len & 63)) buf=xrealloc(buf, len+65); |
142 | if ((buf[len++]=c) == end) break; | 142 | if ((buf[len++] = c) == end) break; |
143 | } | 143 | } |
144 | if (buf) buf[len]=0; | 144 | if (buf) buf[len] = 0; |
145 | if (plen) *plen = len; | 145 | if (plen) *plen = len; |
146 | 146 | ||
147 | return buf; | 147 | return buf; |
@@ -153,7 +153,7 @@ char *get_line(int fd) | |||
153 | long len; | 153 | long len; |
154 | char *buf = get_rawline(fd, &len, '\n'); | 154 | char *buf = get_rawline(fd, &len, '\n'); |
155 | 155 | ||
156 | if (buf && buf[--len]=='\n') buf[len]=0; | 156 | if (buf && buf[--len] == '\n') buf[len] = 0; |
157 | 157 | ||
158 | return buf; | 158 | return buf; |
159 | } | 159 | } |
@@ -165,10 +165,10 @@ void xsendfile(int in, int out) | |||
165 | long len; | 165 | long len; |
166 | char buf[4096]; | 166 | char buf[4096]; |
167 | 167 | ||
168 | if (in<0) return; | 168 | if (in < 0) return; |
169 | for (;;) { | 169 | for (;;) { |
170 | len = safe_read(in, buf, 4096); | 170 | len = safe_read(in, buf, 4096); |
171 | if (len<1) break; | 171 | if (len < 1) break; |
172 | xwrite(out, buf, len); | 172 | xwrite(out, buf, len); |
173 | } | 173 | } |
174 | } | 174 | } |
@@ -179,7 +179,7 @@ void replace_tempfile(int fdin, int fdout, char **tempname) | |||
179 | { | 179 | { |
180 | char *temp = xstrdup(*tempname); | 180 | char *temp = xstrdup(*tempname); |
181 | 181 | ||
182 | temp[strlen(temp)-6]=0; | 182 | temp[strlen(temp)-6] = 0; |
183 | if (fdin != -1) { | 183 | if (fdin != -1) { |
184 | xsendfile(fdin, fdout); | 184 | xsendfile(fdin, fdout); |
185 | xclose(fdin); | 185 | xclose(fdin); |
@@ -263,9 +263,9 @@ static void do_line(void *data) | |||
263 | { | 263 | { |
264 | struct double_list *dlist = (struct double_list *)data; | 264 | struct double_list *dlist = (struct double_list *)data; |
265 | 265 | ||
266 | if (TT.state>1 && *dlist->data != TT.state) | 266 | if (TT.state > 1 && *dlist->data != TT.state) |
267 | fdprintf(TT.state == 2 ? 2 : TT.fileout, | 267 | fdprintf(TT.state == 2 ? 2 : TT.fileout, |
268 | "%s\n", dlist->data+(TT.state>3 ? 1 : 0)); | 268 | "%s\n", dlist->data + (TT.state > 3 ? 1 : 0)); |
269 | 269 | ||
270 | if (PATCH_DEBUG) fdprintf(2, "DO %d: %s\n", TT.state, dlist->data); | 270 | if (PATCH_DEBUG) fdprintf(2, "DO %d: %s\n", TT.state, dlist->data); |
271 | 271 | ||
@@ -314,7 +314,7 @@ static int apply_one_hunk(void) | |||
314 | 314 | ||
315 | // Match EOF if there aren't as many ending context lines as beginning | 315 | // Match EOF if there aren't as many ending context lines as beginning |
316 | for (plist = TT.current_hunk; plist; plist = plist->next) { | 316 | for (plist = TT.current_hunk; plist; plist = plist->next) { |
317 | if (plist->data[0]==' ') matcheof++; | 317 | if (plist->data[0] == ' ') matcheof++; |
318 | else matcheof = 0; | 318 | else matcheof = 0; |
319 | if (PATCH_DEBUG) fdprintf(2, "HUNK:%s\n", plist->data); | 319 | if (PATCH_DEBUG) fdprintf(2, "HUNK:%s\n", plist->data); |
320 | } | 320 | } |
@@ -385,7 +385,7 @@ static int apply_one_hunk(void) | |||
385 | 385 | ||
386 | // If we've reached the end of the buffer without confirming a | 386 | // If we've reached the end of the buffer without confirming a |
387 | // match, read more lines. | 387 | // match, read more lines. |
388 | if (check==buf) { | 388 | if (check == buf) { |
389 | buf = 0; | 389 | buf = 0; |
390 | break; | 390 | break; |
391 | } | 391 | } |
@@ -456,15 +456,15 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
456 | 456 | ||
457 | // Are we assembling a hunk? | 457 | // Are we assembling a hunk? |
458 | if (state >= 2) { | 458 | if (state >= 2) { |
459 | if (*patchline==' ' || *patchline=='+' || *patchline=='-') { | 459 | if (*patchline == ' ' || *patchline == '+' || *patchline == '-') { |
460 | dlist_add(&TT.current_hunk, patchline); | 460 | dlist_add(&TT.current_hunk, patchline); |
461 | 461 | ||
462 | if (*patchline != '+') TT.oldlen--; | 462 | if (*patchline != '+') TT.oldlen--; |
463 | if (*patchline != '-') TT.newlen--; | 463 | if (*patchline != '-') TT.newlen--; |
464 | 464 | ||
465 | // Context line? | 465 | // Context line? |
466 | if (*patchline==' ' && state==2) TT.context++; | 466 | if (*patchline == ' ' && state == 2) TT.context++; |
467 | else state=3; | 467 | else state = 3; |
468 | 468 | ||
469 | // If we've consumed all expected hunk lines, apply the hunk. | 469 | // If we've consumed all expected hunk lines, apply the hunk. |
470 | 470 | ||
@@ -491,9 +491,9 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
491 | 491 | ||
492 | // Trim date from end of filename (if any). We don't care. | 492 | // Trim date from end of filename (if any). We don't care. |
493 | for (s = patchline+4; *s && *s!='\t'; s++) | 493 | for (s = patchline+4; *s && *s!='\t'; s++) |
494 | if (*s=='\\' && s[1]) s++; | 494 | if (*s == '\\' && s[1]) s++; |
495 | i = atoi(s); | 495 | i = atoi(s); |
496 | if (i>1900 && i<=1970) | 496 | if (i > 1900 && i <= 1970) |
497 | *name = xstrdup("/dev/null"); | 497 | *name = xstrdup("/dev/null"); |
498 | else { | 498 | else { |
499 | *s = 0; | 499 | *s = 0; |
@@ -537,7 +537,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
537 | // handle -p path truncation. | 537 | // handle -p path truncation. |
538 | for (i=0, s = name; *s;) { | 538 | for (i=0, s = name; *s;) { |
539 | if ((option_mask32 & FLAG_PATHLEN) && TT.prefix == i) break; | 539 | if ((option_mask32 & FLAG_PATHLEN) && TT.prefix == i) break; |
540 | if (*(s++)=='/') { | 540 | if (*(s++) == '/') { |
541 | name = s; | 541 | name = s; |
542 | i++; | 542 | i++; |
543 | } | 543 | } |