diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-15 15:40:16 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-15 15:40:16 +0200 |
commit | 4f731ce30ec2a9f5e9b231b47aa68f32b75feb35 (patch) | |
tree | f63b07e88c4f31b4b3d1b5a1deeac971785158e6 /findutils/grep.c | |
parent | c37fecb86c52da9e2781ee9eeb90d5d8894f59e0 (diff) | |
download | busybox-w32-4f731ce30ec2a9f5e9b231b47aa68f32b75feb35.tar.gz busybox-w32-4f731ce30ec2a9f5e9b231b47aa68f32b75feb35.tar.bz2 busybox-w32-4f731ce30ec2a9f5e9b231b47aa68f32b75feb35.zip |
findutils/*: move usage and applet bits to *.c files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'findutils/grep.c')
-rw-r--r-- | findutils/grep.c | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/findutils/grep.c b/findutils/grep.c index dd1a4efc4..ac290a911 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -14,13 +14,16 @@ | |||
14 | * 2004,2006 (C) Vladimir Oleynik <dzo@simtreas.ru> - | 14 | * 2004,2006 (C) Vladimir Oleynik <dzo@simtreas.ru> - |
15 | * correction "-e pattern1 -e pattern2" logic and more optimizations. | 15 | * correction "-e pattern1 -e pattern2" logic and more optimizations. |
16 | * precompiled regex | 16 | * precompiled regex |
17 | */ | 17 | * |
18 | /* | ||
19 | * (C) 2006 Jac Goudsmit added -o option | 18 | * (C) 2006 Jac Goudsmit added -o option |
20 | */ | 19 | */ |
21 | 20 | ||
21 | //applet:IF_GREP(APPLET(grep, _BB_DIR_BIN, _BB_SUID_DROP)) | ||
22 | //applet:IF_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, egrep)) | ||
23 | //applet:IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, fgrep)) | ||
24 | |||
22 | //kbuild:lib-$(CONFIG_GREP) += grep.o | 25 | //kbuild:lib-$(CONFIG_GREP) += grep.o |
23 | //config: | 26 | |
24 | //config:config GREP | 27 | //config:config GREP |
25 | //config: bool "grep" | 28 | //config: bool "grep" |
26 | //config: default y | 29 | //config: default y |
@@ -57,17 +60,67 @@ | |||
57 | #include "libbb.h" | 60 | #include "libbb.h" |
58 | #include "xregex.h" | 61 | #include "xregex.h" |
59 | 62 | ||
63 | |||
60 | /* options */ | 64 | /* options */ |
65 | //usage:#define grep_trivial_usage | ||
66 | //usage: "[-HhnlLoqvsriw" | ||
67 | //usage: "F" | ||
68 | //usage: IF_FEATURE_GREP_EGREP_ALIAS("E") | ||
69 | //usage: IF_EXTRA_COMPAT("z") | ||
70 | //usage: "] [-m N] " | ||
71 | //usage: IF_FEATURE_GREP_CONTEXT("[-A/B/C N] ") | ||
72 | //usage: "PATTERN/-e PATTERN.../-f FILE [FILE]..." | ||
73 | //usage:#define grep_full_usage "\n\n" | ||
74 | //usage: "Search for PATTERN in FILEs (or stdin)\n" | ||
75 | //usage: "\nOptions:" | ||
76 | //usage: "\n -H Add 'filename:' prefix" | ||
77 | //usage: "\n -h Do not add 'filename:' prefix" | ||
78 | //usage: "\n -n Add 'line_no:' prefix" | ||
79 | //usage: "\n -l Show only names of files that match" | ||
80 | //usage: "\n -L Show only names of files that don't match" | ||
81 | //usage: "\n -c Show only count of matching lines" | ||
82 | //usage: "\n -o Show only the matching part of line" | ||
83 | //usage: "\n -q Quiet. Return 0 if PATTERN is found, 1 otherwise" | ||
84 | //usage: "\n -v Select non-matching lines" | ||
85 | //usage: "\n -s Suppress open and read errors" | ||
86 | //usage: "\n -r Recurse" | ||
87 | //usage: "\n -i Ignore case" | ||
88 | //usage: "\n -w Match whole words only" | ||
89 | //usage: "\n -F PATTERN is a literal (not regexp)" | ||
90 | //usage: IF_FEATURE_GREP_EGREP_ALIAS( | ||
91 | //usage: "\n -E PATTERN is an extended regexp" | ||
92 | //usage: ) | ||
93 | //usage: IF_EXTRA_COMPAT( | ||
94 | //usage: "\n -z Input is NUL terminated" | ||
95 | //usage: ) | ||
96 | //usage: "\n -m N Match up to N times per file" | ||
97 | //usage: IF_FEATURE_GREP_CONTEXT( | ||
98 | //usage: "\n -A N Print N lines of trailing context" | ||
99 | //usage: "\n -B N Print N lines of leading context" | ||
100 | //usage: "\n -C N Same as '-A N -B N'" | ||
101 | //usage: ) | ||
102 | //usage: "\n -e PTRN Pattern to match" | ||
103 | //usage: "\n -f FILE Read pattern from file" | ||
104 | //usage: | ||
105 | //usage:#define grep_example_usage | ||
106 | //usage: "$ grep root /etc/passwd\n" | ||
107 | //usage: "root:x:0:0:root:/root:/bin/bash\n" | ||
108 | //usage: "$ grep ^[rR]oo. /etc/passwd\n" | ||
109 | //usage: "root:x:0:0:root:/root:/bin/bash\n" | ||
110 | //usage: | ||
111 | //usage:#define egrep_trivial_usage NOUSAGE_STR | ||
112 | //usage:#define egrep_full_usage "" | ||
113 | //usage:#define fgrep_trivial_usage NOUSAGE_STR | ||
114 | //usage:#define fgrep_full_usage "" | ||
115 | |||
61 | #define OPTSTR_GREP \ | 116 | #define OPTSTR_GREP \ |
62 | "lnqvscFiHhe:f:Lorm:w" \ | 117 | "lnqvscFiHhe:f:Lorm:w" \ |
63 | IF_FEATURE_GREP_CONTEXT("A:B:C:") \ | 118 | IF_FEATURE_GREP_CONTEXT("A:B:C:") \ |
64 | IF_FEATURE_GREP_EGREP_ALIAS("E") \ | 119 | IF_FEATURE_GREP_EGREP_ALIAS("E") \ |
65 | IF_EXTRA_COMPAT("z") \ | 120 | IF_EXTRA_COMPAT("z") \ |
66 | "aI" | 121 | "aI" |
67 | |||
68 | /* ignored: -a "assume all files to be text" */ | 122 | /* ignored: -a "assume all files to be text" */ |
69 | /* ignored: -I "assume binary files have no matches" */ | 123 | /* ignored: -I "assume binary files have no matches" */ |
70 | |||
71 | enum { | 124 | enum { |
72 | OPTBIT_l, /* list matched file names only */ | 125 | OPTBIT_l, /* list matched file names only */ |
73 | OPTBIT_n, /* print line# */ | 126 | OPTBIT_n, /* print line# */ |