aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/dd.c23
-rw-r--r--coreutils/env.c2
-rw-r--r--coreutils/expr.c7
-rw-r--r--coreutils/install.c2
-rw-r--r--coreutils/ls.c2
-rw-r--r--coreutils/mkdir.c2
-rw-r--r--coreutils/mv.c2
-rw-r--r--coreutils/od_bloaty.c2
-rw-r--r--coreutils/stty.c22
-rw-r--r--coreutils/tr.c11
10 files changed, 35 insertions, 40 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index dd311d86a..22ad19287 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -51,7 +51,7 @@ static ssize_t full_write_or_warn(int fd, const void *buf, size_t len,
51} 51}
52 52
53static bool write_and_stats(int fd, const void *buf, size_t len, size_t obs, 53static bool write_and_stats(int fd, const void *buf, size_t len, size_t obs,
54 const char * const filename) 54 const char *filename)
55{ 55{
56 ssize_t n = full_write_or_warn(fd, buf, len, filename); 56 ssize_t n = full_write_or_warn(fd, buf, len, filename);
57 if (n < 0) 57 if (n < 0)
@@ -78,13 +78,12 @@ int dd_main(int argc, char **argv)
78 TRUNC_FLAG = 1 << 2, 78 TRUNC_FLAG = 1 << 2,
79 TWOBUFS_FLAG = 1 << 3, 79 TWOBUFS_FLAG = 1 << 3,
80 }; 80 };
81 static const char * const keywords[] = { 81 static const char keywords[] =
82 "bs=", "count=", "seek=", "skip=", "if=", "of=", 82 "bs=\0""count=\0""seek=\0""skip=\0""if=\0""of=\0"
83#if ENABLE_FEATURE_DD_IBS_OBS 83#if ENABLE_FEATURE_DD_IBS_OBS
84 "ibs=", "obs=", "conv=", "notrunc", "sync", "noerror", 84 "ibs=\0""obs=\0""conv=\0""notrunc\0""sync\0""noerror\0"
85#endif 85#endif
86 NULL 86 ;
87 };
88 enum { 87 enum {
89 OP_bs = 1, 88 OP_bs = 1,
90 OP_count, 89 OP_count,
@@ -134,7 +133,7 @@ int dd_main(int argc, char **argv)
134 bb_show_usage(); 133 bb_show_usage();
135 key_len = key - arg + 1; 134 key_len = key - arg + 1;
136 key = xstrndup(arg, key_len); 135 key = xstrndup(arg, key_len);
137 what = index_in_str_array(keywords, key) + 1; 136 what = index_in_strings(keywords, key) + 1;
138 if (ENABLE_FEATURE_CLEAN_UP) 137 if (ENABLE_FEATURE_CLEAN_UP)
139 free(key); 138 free(key);
140 if (what == 0) 139 if (what == 0)
@@ -153,13 +152,13 @@ int dd_main(int argc, char **argv)
153 if (what == OP_conv) { 152 if (what == OP_conv) {
154 while (1) { 153 while (1) {
155 /* find ',', replace them with nil so we can use arg for 154 /* find ',', replace them with nil so we can use arg for
156 * index_in_str_array without copying. 155 * index_in_strings() without copying.
157 * We rely on arg being non-null, else strchr would fault. 156 * We rely on arg being non-null, else strchr would fault.
158 */ 157 */
159 key = strchr(arg, ','); 158 key = strchr(arg, ',');
160 if (key) 159 if (key)
161 *key = '\0'; 160 *key = '\0';
162 what = index_in_str_array(keywords, arg) + 1; 161 what = index_in_strings(keywords, arg) + 1;
163 if (what < OP_conv_notrunc) 162 if (what < OP_conv_notrunc)
164 bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv"); 163 bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv");
165 if (what == OP_conv_notrunc) 164 if (what == OP_conv_notrunc)
@@ -298,15 +297,15 @@ int dd_main(int argc, char **argv)
298 G.out_part++; 297 G.out_part++;
299 } 298 }
300 if (close(ifd) < 0) { 299 if (close(ifd) < 0) {
301die_infile: 300 die_infile:
302 bb_perror_msg_and_die("%s", infile); 301 bb_perror_msg_and_die("%s", infile);
303 } 302 }
304 303
305 if (close(ofd) < 0) { 304 if (close(ofd) < 0) {
306die_outfile: 305 die_outfile:
307 bb_perror_msg_and_die("%s", outfile); 306 bb_perror_msg_and_die("%s", outfile);
308 } 307 }
309out_status: 308 out_status:
310 dd_output_status(0); 309 dd_output_status(0);
311 310
312 return EXIT_SUCCESS; 311 return EXIT_SUCCESS;
diff --git a/coreutils/env.c b/coreutils/env.c
index 8d20eac9c..31167d029 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -38,7 +38,7 @@ extern char **environ;
38static const char env_longopts[] = 38static const char env_longopts[] =
39 "ignore-environment\0" No_argument "i" 39 "ignore-environment\0" No_argument "i"
40 "unset\0" Required_argument "u" 40 "unset\0" Required_argument "u"
41 "\0"; 41 ;
42#endif 42#endif
43 43
44int env_main(int argc, char** argv); 44int env_main(int argc, char** argv);
diff --git a/coreutils/expr.c b/coreutils/expr.c
index ab182a804..6a4683d90 100644
--- a/coreutils/expr.c
+++ b/coreutils/expr.c
@@ -277,14 +277,13 @@ static VALUE *eval7(void)
277 277
278static VALUE *eval6(void) 278static VALUE *eval6(void)
279{ 279{
280 static const char * const keywords[] = { 280 static const char keywords[] =
281 "quote", "length", "match", "index", "substr", NULL 281 "quote\0""length\0""match\0""index\0""substr\0";
282 };
283 282
284 VALUE *r, *i1, *i2; 283 VALUE *r, *i1, *i2;
285 VALUE *l = l; /* silence gcc */ 284 VALUE *l = l; /* silence gcc */
286 VALUE *v = v; /* silence gcc */ 285 VALUE *v = v; /* silence gcc */
287 int key = *G.args ? index_in_str_array(keywords, *G.args) + 1 : 0; 286 int key = *G.args ? index_in_strings(keywords, *G.args) + 1 : 0;
288 287
289 if (key == 0) /* not a keyword */ 288 if (key == 0) /* not a keyword */
290 return eval7(); 289 return eval7();
diff --git a/coreutils/install.c b/coreutils/install.c
index 8d5494958..c2638f492 100644
--- a/coreutils/install.c
+++ b/coreutils/install.c
@@ -28,7 +28,7 @@ static const char install_longopts[] =
28 "preserve_context\0" No_argument "\xff" 28 "preserve_context\0" No_argument "\xff"
29 "preserve-context\0" No_argument "\xff" 29 "preserve-context\0" No_argument "\xff"
30#endif 30#endif
31 "\0"; 31 ;
32#endif 32#endif
33 33
34 34
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 8545edda9..f47ec204c 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -122,7 +122,7 @@ static smallint show_color;
122 * equivalent */ 122 * equivalent */
123static const char ls_color_opt[] = 123static const char ls_color_opt[] =
124 "color\0" Optional_argument "\xff" /* no short equivalent */ 124 "color\0" Optional_argument "\xff" /* no short equivalent */
125 "\0"; 125 ;
126#else 126#else
127enum { show_color = 0 }; 127enum { show_color = 0 };
128#endif 128#endif
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index b0595b43f..a6eaa9612 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -31,7 +31,7 @@ static const char mkdir_longopts[] =
31#if ENABLE_SELINUX 31#if ENABLE_SELINUX
32 "context\0" Required_argument "Z" 32 "context\0" Required_argument "Z"
33#endif 33#endif
34 "\0"; 34 ;
35#endif 35#endif
36 36
37int mkdir_main(int argc, char **argv); 37int mkdir_main(int argc, char **argv);
diff --git a/coreutils/mv.c b/coreutils/mv.c
index bb96af8f6..064407838 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -24,7 +24,7 @@
24static const char mv_longopts[] = 24static const char mv_longopts[] =
25 "interactive\0" No_argument "i" 25 "interactive\0" No_argument "i"
26 "force\0" No_argument "f" 26 "force\0" No_argument "f"
27 "\0"; 27 ;
28#endif 28#endif
29 29
30#define OPT_FILEUTILS_FORCE 1 30#define OPT_FILEUTILS_FORCE 1
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index 0b77f8b94..803407224 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -1242,7 +1242,7 @@ int od_main(int argc, char **argv)
1242 "strings\0" Optional_argument "S" 1242 "strings\0" Optional_argument "S"
1243 "width\0" Optional_argument "w" 1243 "width\0" Optional_argument "w"
1244 "traditional\0" No_argument "\xff" 1244 "traditional\0" No_argument "\xff"
1245 "\0"; 1245 ;
1246#endif 1246#endif
1247 char *str_A, *str_N, *str_j, *str_S; 1247 char *str_A, *str_N, *str_j, *str_S;
1248 char *str_w = NULL; 1248 char *str_w = NULL;
diff --git a/coreutils/stty.c b/coreutils/stty.c
index 0983532cf..b73e2eace 100644
--- a/coreutils/stty.c
+++ b/coreutils/stty.c
@@ -562,18 +562,16 @@ enum {
562 562
563static int find_param(const char * const name) 563static int find_param(const char * const name)
564{ 564{
565 static const char * const params[] = { 565 static const char params[] =
566 "line", /* 1 */ 566 "line\0" /* 1 */
567 "rows", /* 2 */ 567 "rows\0" /* 2 */
568 "cols", /* 3 */ 568 "cols\0" /* 3 */
569 "columns", /* 4 */ 569 "columns\0" /* 4 */
570 "size", /* 5 */ 570 "size\0" /* 5 */
571 "ispeed"+1, /* 6 */ 571 "speed\0" /* 6 */
572 "ispeed", 572 "ispeed\0"
573 "ospeed", 573 "ospeed\0";
574 NULL 574 int i = index_in_strings(params, name) + 1;
575 };
576 int i = index_in_str_array(params, name) + 1;
577 if (i == 0) 575 if (i == 0)
578 return 0; 576 return 0;
579 if (i != 5 && i != 6) 577 if (i != 5 && i != 6)
diff --git a/coreutils/tr.c b/coreutils/tr.c
index c0d0dfacb..594571833 100644
--- a/coreutils/tr.c
+++ b/coreutils/tr.c
@@ -51,11 +51,10 @@ static unsigned int expand(const char *arg, char *buffer)
51 char *buffer_start = buffer; 51 char *buffer_start = buffer;
52 unsigned i; /* XXX: FIXME: use unsigned char? */ 52 unsigned i; /* XXX: FIXME: use unsigned char? */
53 unsigned char ac; 53 unsigned char ac;
54#define CLO ":]" 54#define CLO ":]\0"
55 static const char * const classes[] = { 55 static const char classes[] =
56 "alpha"CLO, "alnum"CLO, "digit"CLO, "lower"CLO, "upper"CLO, "space"CLO, 56 "alpha"CLO "alnum"CLO "digit"CLO "lower"CLO "upper"CLO "space"CLO
57 "blank"CLO, "punct"CLO, "cntrl"CLO, NULL 57 "blank"CLO "punct"CLO "cntrl"CLO;
58 };
59#define CLASS_invalid 0 /* we increment the retval */ 58#define CLASS_invalid 0 /* we increment the retval */
60#define CLASS_alpha 1 59#define CLASS_alpha 1
61#define CLASS_alnum 2 60#define CLASS_alnum 2
@@ -90,7 +89,7 @@ static unsigned int expand(const char *arg, char *buffer)
90 smalluint j; 89 smalluint j;
91 { /* not really pretty.. */ 90 { /* not really pretty.. */
92 char *tmp = xstrndup(arg, 7); // warning: xdigit needs 8, not 7 91 char *tmp = xstrndup(arg, 7); // warning: xdigit needs 8, not 7
93 j = index_in_str_array(classes, tmp) + 1; 92 j = index_in_strings(classes, tmp) + 1;
94 free(tmp); 93 free(tmp);
95 } 94 }
96 if (j == CLASS_alnum || j == CLASS_digit) { 95 if (j == CLASS_alnum || j == CLASS_digit) {