diff options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/Kbuild.src | 2 | ||||
-rw-r--r-- | editors/awk.c | 2 | ||||
-rw-r--r-- | editors/cmp.c | 2 | ||||
-rw-r--r-- | editors/diff.c | 4 | ||||
-rw-r--r-- | editors/patch.c | 51 | ||||
-rw-r--r-- | editors/patch_bbox.c | 26 | ||||
-rw-r--r-- | editors/sed.c | 16 | ||||
-rw-r--r-- | editors/vi.c | 2 |
8 files changed, 66 insertions, 39 deletions
diff --git a/editors/Kbuild.src b/editors/Kbuild.src index 9d4b9d053..98128064d 100644 --- a/editors/Kbuild.src +++ b/editors/Kbuild.src | |||
@@ -2,7 +2,7 @@ | |||
2 | # | 2 | # |
3 | # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> | 3 | # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> |
4 | # | 4 | # |
5 | # Licensed under the GPL v2, see the file LICENSE in this tarball. | 5 | # Licensed under GPLv2, see file LICENSE in this source tree. |
6 | 6 | ||
7 | lib-y:= | 7 | lib-y:= |
8 | 8 | ||
diff --git a/editors/awk.c b/editors/awk.c index 83c5b47ce..f47d1ab02 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2002 by Dmitry Zakharov <dmit@crp.bank.gov.ua> | 5 | * Copyright (C) 2002 by Dmitry Zakharov <dmit@crp.bank.gov.ua> |
6 | * | 6 | * |
7 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "libbb.h" | 10 | #include "libbb.h" |
diff --git a/editors/cmp.c b/editors/cmp.c index dbfa4be35..f495da7d2 100644 --- a/editors/cmp.c +++ b/editors/cmp.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2000,2001 by Matt Kraai <kraai@alumni.carnegiemellon.edu> | 5 | * Copyright (C) 2000,2001 by Matt Kraai <kraai@alumni.carnegiemellon.edu> |
6 | * | 6 | * |
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */ | 10 | /* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */ |
diff --git a/editors/diff.c b/editors/diff.c index a3ca2b660..83de52753 100644 --- a/editors/diff.c +++ b/editors/diff.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * Agency (DARPA) and Air Force Research Laboratory, Air Force | 10 | * Agency (DARPA) and Air Force Research Laboratory, Air Force |
11 | * Materiel Command, USAF, under agreement number F39502-99-1-0512. | 11 | * Materiel Command, USAF, under agreement number F39502-99-1-0512. |
12 | * | 12 | * |
13 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 13 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | /* | 16 | /* |
@@ -479,7 +479,7 @@ start: | |||
479 | for (; suff < nlen[0] - pref && suff < nlen[1] - pref && | 479 | for (; suff < nlen[0] - pref && suff < nlen[1] - pref && |
480 | nfile[0][nlen[0] - suff].value == nfile[1][nlen[1] - suff].value; | 480 | nfile[0][nlen[0] - suff].value == nfile[1][nlen[1] - suff].value; |
481 | suff++); | 481 | suff++); |
482 | /* Arrays are pruned by the suffix and prefix lenght, | 482 | /* Arrays are pruned by the suffix and prefix length, |
483 | * the result being sorted and stored in sfile[fileno], | 483 | * the result being sorted and stored in sfile[fileno], |
484 | * and their sizes are stored in slen[fileno] | 484 | * and their sizes are stored in slen[fileno] |
485 | */ | 485 | */ |
diff --git a/editors/patch.c b/editors/patch.c index eb16bca12..c40f54155 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -12,7 +12,6 @@ | |||
12 | * TODO: | 12 | * TODO: |
13 | * -b backup | 13 | * -b backup |
14 | * -l treat all whitespace as a single space | 14 | * -l treat all whitespace as a single space |
15 | * -N ignore already applied | ||
16 | * -d chdir first | 15 | * -d chdir first |
17 | * -D define wrap #ifdef and #ifndef around changes | 16 | * -D define wrap #ifdef and #ifndef around changes |
18 | * -o outfile output here instead of in place | 17 | * -o outfile output here instead of in place |
@@ -244,14 +243,12 @@ struct globals { | |||
244 | } while (0) | 243 | } while (0) |
245 | 244 | ||
246 | 245 | ||
247 | //bbox had: "p:i:RN" | ||
248 | #define FLAG_STR "Rup:i:Nx" | 246 | #define FLAG_STR "Rup:i:Nx" |
249 | /* FLAG_REVERSE must be == 1! Code uses this fact. */ | 247 | /* FLAG_REVERSE must be == 1! Code uses this fact. */ |
250 | #define FLAG_REVERSE (1 << 0) | 248 | #define FLAG_REVERSE (1 << 0) |
251 | #define FLAG_u (1 << 1) | 249 | #define FLAG_u (1 << 1) |
252 | #define FLAG_PATHLEN (1 << 2) | 250 | #define FLAG_PATHLEN (1 << 2) |
253 | #define FLAG_INPUT (1 << 3) | 251 | #define FLAG_INPUT (1 << 3) |
254 | // -N: not supported yet | ||
255 | #define FLAG_IGNORE (1 << 4) | 252 | #define FLAG_IGNORE (1 << 4) |
256 | //non-standard: | 253 | //non-standard: |
257 | #define FLAG_DEBUG (1 << 5) | 254 | #define FLAG_DEBUG (1 << 5) |
@@ -314,6 +311,10 @@ static int apply_one_hunk(void) | |||
314 | { | 311 | { |
315 | struct double_list *plist, *buf = NULL, *check; | 312 | struct double_list *plist, *buf = NULL, *check; |
316 | int matcheof = 0, reverse = option_mask32 & FLAG_REVERSE, backwarn = 0; | 313 | int matcheof = 0, reverse = option_mask32 & FLAG_REVERSE, backwarn = 0; |
314 | /* Do we try "dummy" revert to check whether | ||
315 | * to silently skip this hunk? Used to implement -N. | ||
316 | */ | ||
317 | int dummy_revert = 0; | ||
317 | 318 | ||
318 | // Break doubly linked list so we can use singly linked traversal function. | 319 | // Break doubly linked list so we can use singly linked traversal function. |
319 | TT.current_hunk->prev->next = NULL; | 320 | TT.current_hunk->prev->next = NULL; |
@@ -343,9 +344,14 @@ static int apply_one_hunk(void) | |||
343 | while (plist && *plist->data == "+-"[reverse]) { | 344 | while (plist && *plist->data == "+-"[reverse]) { |
344 | if (data && !strcmp(data, plist->data+1)) { | 345 | if (data && !strcmp(data, plist->data+1)) { |
345 | if (!backwarn) { | 346 | if (!backwarn) { |
347 | backwarn++; | ||
348 | if (option_mask32 & FLAG_IGNORE) { | ||
349 | dummy_revert = 1; | ||
350 | reverse ^= 1; | ||
351 | continue; | ||
352 | } | ||
346 | fdprintf(2,"Possibly reversed hunk %d at %ld\n", | 353 | fdprintf(2,"Possibly reversed hunk %d at %ld\n", |
347 | TT.hunknum, TT.linenum); | 354 | TT.hunknum, TT.linenum); |
348 | backwarn++; | ||
349 | } | 355 | } |
350 | } | 356 | } |
351 | plist = plist->next; | 357 | plist = plist->next; |
@@ -409,7 +415,7 @@ static int apply_one_hunk(void) | |||
409 | } | 415 | } |
410 | out: | 416 | out: |
411 | // We have a match. Emit changed data. | 417 | // We have a match. Emit changed data. |
412 | TT.state = "-+"[reverse]; | 418 | TT.state = "-+"[reverse ^ dummy_revert]; |
413 | llist_free(TT.current_hunk, do_line); | 419 | llist_free(TT.current_hunk, do_line); |
414 | TT.current_hunk = NULL; | 420 | TT.current_hunk = NULL; |
415 | TT.state = 1; | 421 | TT.state = 1; |
@@ -441,10 +447,21 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
441 | INIT_TT(); | 447 | INIT_TT(); |
442 | 448 | ||
443 | opts = getopt32(argv, FLAG_STR, &opt_p, &opt_i); | 449 | opts = getopt32(argv, FLAG_STR, &opt_p, &opt_i); |
450 | argv += optind; | ||
444 | reverse = opts & FLAG_REVERSE; | 451 | reverse = opts & FLAG_REVERSE; |
445 | TT.prefix = (opts & FLAG_PATHLEN) ? xatoi(opt_p) : 0; // can be negative! | 452 | TT.prefix = (opts & FLAG_PATHLEN) ? xatoi(opt_p) : 0; // can be negative! |
446 | if (opts & FLAG_INPUT) TT.filepatch = xopen(opt_i, O_RDONLY); | ||
447 | TT.filein = TT.fileout = -1; | 453 | TT.filein = TT.fileout = -1; |
454 | if (opts & FLAG_INPUT) { | ||
455 | TT.filepatch = xopen_stdin(opt_i); | ||
456 | } else { | ||
457 | if (argv[0] && argv[1]) { | ||
458 | TT.filepatch = xopen_stdin(argv[1]); | ||
459 | } | ||
460 | } | ||
461 | if (argv[0]) { | ||
462 | oldname = xstrdup(argv[0]); | ||
463 | newname = xstrdup(argv[0]); | ||
464 | } | ||
448 | 465 | ||
449 | // Loop through the lines in the patch | 466 | // Loop through the lines in the patch |
450 | for(;;) { | 467 | for(;;) { |
@@ -492,18 +509,20 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
492 | state = 1; | 509 | state = 1; |
493 | } | 510 | } |
494 | 511 | ||
495 | free(*name); | ||
496 | finish_oldfile(); | 512 | finish_oldfile(); |
497 | 513 | ||
498 | // Trim date from end of filename (if any). We don't care. | 514 | if (!argv[0]) { |
499 | for (s = patchline+4; *s && *s!='\t'; s++) | 515 | free(*name); |
500 | if (*s=='\\' && s[1]) s++; | 516 | // Trim date from end of filename (if any). We don't care. |
501 | i = atoi(s); | 517 | for (s = patchline+4; *s && *s!='\t'; s++) |
502 | if (i>1900 && i<=1970) | 518 | if (*s=='\\' && s[1]) s++; |
503 | *name = xstrdup("/dev/null"); | 519 | i = atoi(s); |
504 | else { | 520 | if (i>1900 && i<=1970) |
505 | *s = 0; | 521 | *name = xstrdup("/dev/null"); |
506 | *name = xstrdup(patchline+4); | 522 | else { |
523 | *s = 0; | ||
524 | *name = xstrdup(patchline+4); | ||
525 | } | ||
507 | } | 526 | } |
508 | 527 | ||
509 | // We defer actually opening the file because svn produces broken | 528 | // We defer actually opening the file because svn produces broken |
diff --git a/editors/patch_bbox.c b/editors/patch_bbox.c index 62477af16..78aa5fde8 100644 --- a/editors/patch_bbox.c +++ b/editors/patch_bbox.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * busybox patch applet to handle the unified diff format. | 3 | * busybox patch applet to handle the unified diff format. |
4 | * Copyright (C) 2003 Glenn McGrath | 4 | * Copyright (C) 2003 Glenn McGrath |
5 | * | 5 | * |
6 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. | 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
7 | * | 7 | * |
8 | * This applet is written to work with patches generated by GNU diff, | 8 | * This applet is written to work with patches generated by GNU diff, |
9 | * where there is equivalent functionality busybox patch shall behave | 9 | * where there is equivalent functionality busybox patch shall behave |
10 | * as per GNU patch. | 10 | * as per GNU patch. |
11 | * | 11 | * |
12 | * There is a SUSv3 specification for patch, however it looks to be | 12 | * There is a SUSv3 specification for patch, however it looks to be |
13 | * incomplete, it doesnt even mention unified diff format. | 13 | * incomplete, it doesnt even mention unified diff format. |
14 | * http://www.opengroup.org/onlinepubs/007904975/utilities/patch.html | 14 | * http://www.opengroup.org/onlinepubs/007904975/utilities/patch.html |
15 | * | 15 | * |
16 | * Issues | 16 | * Issues |
17 | * - Non-interactive | 17 | * - Non-interactive |
18 | * - Patches must apply cleanly or patch (not just one hunk) will fail. | 18 | * - Patches must apply cleanly or patch (not just one hunk) will fail. |
19 | * - Reject file isnt saved | 19 | * - Reject file isnt saved |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include "libbb.h" | 22 | #include "libbb.h" |
diff --git a/editors/sed.c b/editors/sed.c index 7d6e7e79f..8d9f7b25b 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * | 10 | * |
11 | * MAINTAINER: Rob Landley <rob@landley.net> | 11 | * MAINTAINER: Rob Landley <rob@landley.net> |
12 | * | 12 | * |
13 | * Licensed under GPL version 2, see file LICENSE in this tarball for details. | 13 | * Licensed under GPLv2, see file LICENSE in this source tree. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | /* Code overview. | 16 | /* Code overview. |
@@ -992,6 +992,8 @@ static void process_files(void) | |||
992 | } | 992 | } |
993 | 993 | ||
994 | /* actual sedding */ | 994 | /* actual sedding */ |
995 | //bb_error_msg("pattern_space:'%s' next_line:'%s' cmd:%c", | ||
996 | //pattern_space, next_line, sed_cmd->cmd); | ||
995 | switch (sed_cmd->cmd) { | 997 | switch (sed_cmd->cmd) { |
996 | 998 | ||
997 | /* Print line number */ | 999 | /* Print line number */ |
@@ -1118,10 +1120,16 @@ static void process_files(void) | |||
1118 | { | 1120 | { |
1119 | int len; | 1121 | int len; |
1120 | /* If no next line, jump to end of script and exit. */ | 1122 | /* If no next line, jump to end of script and exit. */ |
1123 | /* http://www.gnu.org/software/sed/manual/sed.html: | ||
1124 | * "Most versions of sed exit without printing anything | ||
1125 | * when the N command is issued on the last line of | ||
1126 | * a file. GNU sed prints pattern space before exiting | ||
1127 | * unless of course the -n command switch has been | ||
1128 | * specified. This choice is by design." | ||
1129 | */ | ||
1121 | if (next_line == NULL) { | 1130 | if (next_line == NULL) { |
1122 | free(next_line); | 1131 | //goto discard_line; |
1123 | next_line = NULL; | 1132 | goto discard_commands; /* GNU behavior */ |
1124 | goto discard_line; | ||
1125 | } | 1133 | } |
1126 | /* Append next_line, read new next_line. */ | 1134 | /* Append next_line, read new next_line. */ |
1127 | len = strlen(pattern_space); | 1135 | len = strlen(pattern_space); |
diff --git a/editors/vi.c b/editors/vi.c index 73e095cf8..602fc61d9 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * tiny vi.c: A small 'vi' clone | 3 | * tiny vi.c: A small 'vi' clone |
4 | * Copyright (C) 2000, 2001 Sterling Huxley <sterling@europa.com> | 4 | * Copyright (C) 2000, 2001 Sterling Huxley <sterling@europa.com> |
5 | * | 5 | * |
6 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. | 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | /* | 9 | /* |