diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-22 14:11:12 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-22 14:11:12 +0000 |
commit | 67758035a4fe040c6ac69b39d61bcd6bddd7b827 (patch) | |
tree | a4a1db7f54c16d12fabe2626b8f1e235cd694e9e /editors | |
parent | 811c449748d5bd0505f8510e5582892f94ac0cda (diff) | |
parent | b83c9704128dd106071184e4b00335a3b8486857 (diff) | |
download | busybox-w32-67758035a4fe040c6ac69b39d61bcd6bddd7b827.tar.gz busybox-w32-67758035a4fe040c6ac69b39d61bcd6bddd7b827.tar.bz2 busybox-w32-67758035a4fe040c6ac69b39d61bcd6bddd7b827.zip |
Merge commit 'b83c9704128dd106071184e4b00335a3b8486857' into merge
Diffstat (limited to 'editors')
-rw-r--r-- | editors/awk.c | 8 | ||||
-rw-r--r-- | editors/cmp.c | 9 | ||||
-rw-r--r-- | editors/diff.c | 47 | ||||
-rw-r--r-- | editors/ed.c | 5 | ||||
-rw-r--r-- | editors/sed.c | 17 | ||||
-rw-r--r-- | editors/vi.c | 13 |
6 files changed, 98 insertions, 1 deletions
diff --git a/editors/awk.c b/editors/awk.c index 2eeb9d77a..9d38b1f88 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -7,6 +7,14 @@ | |||
7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //usage:#define awk_trivial_usage | ||
11 | //usage: "[OPTIONS] [AWK_PROGRAM] [FILE]..." | ||
12 | //usage:#define awk_full_usage "\n\n" | ||
13 | //usage: "Options:" | ||
14 | //usage: "\n -v VAR=VAL Set variable" | ||
15 | //usage: "\n -F SEP Use SEP as field separator" | ||
16 | //usage: "\n -f FILE Read program from FILE" | ||
17 | |||
10 | #include "libbb.h" | 18 | #include "libbb.h" |
11 | #include "xregex.h" | 19 | #include "xregex.h" |
12 | #include <math.h> | 20 | #include <math.h> |
diff --git a/editors/cmp.c b/editors/cmp.c index f84a56e3e..3a0f5aa4f 100644 --- a/editors/cmp.c +++ b/editors/cmp.c | |||
@@ -10,6 +10,15 @@ | |||
10 | /* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */ | 10 | /* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */ |
11 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/cmp.html */ | 11 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/cmp.html */ |
12 | 12 | ||
13 | //usage:#define cmp_trivial_usage | ||
14 | //usage: "[-l] [-s] FILE1 [FILE2" IF_DESKTOP(" [SKIP1 [SKIP2]]") "]" | ||
15 | //usage:#define cmp_full_usage "\n\n" | ||
16 | //usage: "Compare FILE1 with FILE2 (or stdin)\n" | ||
17 | //usage: "\nOptions:" | ||
18 | //usage: "\n -l Write the byte numbers (decimal) and values (octal)" | ||
19 | //usage: "\n for all differing bytes" | ||
20 | //usage: "\n -s Quiet" | ||
21 | |||
13 | #include "libbb.h" | 22 | #include "libbb.h" |
14 | 23 | ||
15 | static const char fmt_eof[] ALIGN1 = "cmp: EOF on %s\n"; | 24 | static const char fmt_eof[] ALIGN1 = "cmp: EOF on %s\n"; |
diff --git a/editors/diff.c b/editors/diff.c index ca4a4eae7..daa58af9b 100644 --- a/editors/diff.c +++ b/editors/diff.c | |||
@@ -76,6 +76,28 @@ | |||
76 | * 6n words for files of length n. | 76 | * 6n words for files of length n. |
77 | */ | 77 | */ |
78 | 78 | ||
79 | //usage:#define diff_trivial_usage | ||
80 | //usage: "[-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2" | ||
81 | //usage:#define diff_full_usage "\n\n" | ||
82 | //usage: "Compare files line by line and output the differences between them.\n" | ||
83 | //usage: "This implementation supports unified diffs only.\n" | ||
84 | //usage: "\nOptions:" | ||
85 | //usage: "\n -a Treat all files as text" | ||
86 | //usage: "\n -b Ignore changes in the amount of whitespace" | ||
87 | //usage: "\n -B Ignore changes whose lines are all blank" | ||
88 | //usage: "\n -d Try hard to find a smaller set of changes" | ||
89 | //usage: "\n -i Ignore case differences" | ||
90 | //usage: "\n -L Use LABEL instead of the filename in the unified header" | ||
91 | //usage: "\n -N Treat absent files as empty" | ||
92 | //usage: "\n -q Output only whether files differ" | ||
93 | //usage: "\n -r Recurse" | ||
94 | //usage: "\n -S Start with FILE when comparing directories" | ||
95 | //usage: "\n -T Make tabs line up by prefixing a tab when necessary" | ||
96 | //usage: "\n -s Report when two files are the same" | ||
97 | //usage: "\n -t Expand tabs to spaces in output" | ||
98 | //usage: "\n -U Output LINES lines of context" | ||
99 | //usage: "\n -w Ignore all whitespace" | ||
100 | |||
79 | #include "libbb.h" | 101 | #include "libbb.h" |
80 | 102 | ||
81 | #if 0 | 103 | #if 0 |
@@ -952,6 +974,31 @@ int diff_main(int argc UNUSED_PARAM, char **argv) | |||
952 | if (gotstdin && (S_ISDIR(stb[0].st_mode) || S_ISDIR(stb[1].st_mode))) | 974 | if (gotstdin && (S_ISDIR(stb[0].st_mode) || S_ISDIR(stb[1].st_mode))) |
953 | bb_error_msg_and_die("can't compare stdin to a directory"); | 975 | bb_error_msg_and_die("can't compare stdin to a directory"); |
954 | 976 | ||
977 | /* Compare metadata to check if the files are the same physical file. | ||
978 | * | ||
979 | * Comment from diffutils source says: | ||
980 | * POSIX says that two files are identical if st_ino and st_dev are | ||
981 | * the same, but many file systems incorrectly assign the same (device, | ||
982 | * inode) pair to two distinct files, including: | ||
983 | * GNU/Linux NFS servers that export all local file systems as a | ||
984 | * single NFS file system, if a local device number (st_dev) exceeds | ||
985 | * 255, or if a local inode number (st_ino) exceeds 16777215. | ||
986 | */ | ||
987 | if (ENABLE_DESKTOP | ||
988 | && stb[0].st_ino == stb[1].st_ino | ||
989 | && stb[0].st_dev == stb[1].st_dev | ||
990 | && stb[0].st_size == stb[1].st_size | ||
991 | && stb[0].st_mtime == stb[1].st_mtime | ||
992 | && stb[0].st_ctime == stb[1].st_ctime | ||
993 | && stb[0].st_mode == stb[1].st_mode | ||
994 | && stb[0].st_nlink == stb[1].st_nlink | ||
995 | && stb[0].st_uid == stb[1].st_uid | ||
996 | && stb[0].st_gid == stb[1].st_gid | ||
997 | ) { | ||
998 | /* files are physically the same; no need to compare them */ | ||
999 | return STATUS_SAME; | ||
1000 | } | ||
1001 | |||
955 | if (S_ISDIR(stb[0].st_mode) && S_ISDIR(stb[1].st_mode)) { | 1002 | if (S_ISDIR(stb[0].st_mode) && S_ISDIR(stb[1].st_mode)) { |
956 | #if ENABLE_FEATURE_DIFF_DIR | 1003 | #if ENABLE_FEATURE_DIFF_DIR |
957 | diffdir(file, s_start); | 1004 | diffdir(file, s_start); |
diff --git a/editors/ed.c b/editors/ed.c index b1b6a8d27..dbb51306c 100644 --- a/editors/ed.c +++ b/editors/ed.c | |||
@@ -7,6 +7,9 @@ | |||
7 | * The "ed" built-in command (much simplified) | 7 | * The "ed" built-in command (much simplified) |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //usage:#define ed_trivial_usage "" | ||
11 | //usage:#define ed_full_usage "" | ||
12 | |||
10 | #include "libbb.h" | 13 | #include "libbb.h" |
11 | 14 | ||
12 | typedef struct LINE { | 15 | typedef struct LINE { |
@@ -451,7 +454,7 @@ static void subCommand(const char *cmd, int num1, int num2) | |||
451 | 454 | ||
452 | /* | 455 | /* |
453 | * The new string is larger, so allocate a new line | 456 | * The new string is larger, so allocate a new line |
454 | * structure and use that. Link it in in place of | 457 | * structure and use that. Link it in place of |
455 | * the old line structure. | 458 | * the old line structure. |
456 | */ | 459 | */ |
457 | nlp = xmalloc(sizeof(LINE) + lp->len + deltaLen); | 460 | nlp = xmalloc(sizeof(LINE) + lp->len + deltaLen); |
diff --git a/editors/sed.c b/editors/sed.c index d3555243f..9ab758bd7 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -58,6 +58,23 @@ | |||
58 | Reference http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html | 58 | Reference http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html |
59 | */ | 59 | */ |
60 | 60 | ||
61 | //usage:#define sed_trivial_usage | ||
62 | //usage: "[-efinr] SED_CMD [FILE]..." | ||
63 | //usage:#define sed_full_usage "\n\n" | ||
64 | //usage: "Options:" | ||
65 | //usage: "\n -e CMD Add CMD to sed commands to be executed" | ||
66 | //usage: "\n -f FILE Add FILE contents to sed commands to be executed" | ||
67 | //usage: "\n -i Edit files in-place (else sends result to stdout)" | ||
68 | //usage: "\n -n Suppress automatic printing of pattern space" | ||
69 | //usage: "\n -r Use extended regex syntax" | ||
70 | //usage: "\n" | ||
71 | //usage: "\nIf no -e or -f, the first non-option argument is the sed command string." | ||
72 | //usage: "\nRemaining arguments are input files (stdin if none)." | ||
73 | //usage: | ||
74 | //usage:#define sed_example_usage | ||
75 | //usage: "$ echo \"foo\" | sed -e 's/f[a-zA-Z]o/bar/g'\n" | ||
76 | //usage: "bar\n" | ||
77 | |||
61 | #include "libbb.h" | 78 | #include "libbb.h" |
62 | #include "xregex.h" | 79 | #include "xregex.h" |
63 | 80 | ||
diff --git a/editors/vi.c b/editors/vi.c index f59d5a706..712af0326 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -21,6 +21,19 @@ | |||
21 | * An "ex" line oriented mode- maybe using "cmdedit" | 21 | * An "ex" line oriented mode- maybe using "cmdedit" |
22 | */ | 22 | */ |
23 | 23 | ||
24 | //usage:#define vi_trivial_usage | ||
25 | //usage: "[OPTIONS] [FILE]..." | ||
26 | //usage:#define vi_full_usage "\n\n" | ||
27 | //usage: "Edit FILE\n" | ||
28 | //usage: "\nOptions:" | ||
29 | //usage: IF_FEATURE_VI_COLON( | ||
30 | //usage: "\n -c Initial command to run ($EXINIT also available)" | ||
31 | //usage: ) | ||
32 | //usage: IF_FEATURE_VI_READONLY( | ||
33 | //usage: "\n -R Read-only" | ||
34 | //usage: ) | ||
35 | //usage: "\n -H Short help regarding available features" | ||
36 | |||
24 | #include "libbb.h" | 37 | #include "libbb.h" |
25 | 38 | ||
26 | /* the CRASHME code is unmaintained, and doesn't currently build */ | 39 | /* the CRASHME code is unmaintained, and doesn't currently build */ |