diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-03-24 14:06:51 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-03-24 14:06:51 +0000 |
commit | 65dffc48de553ce08c0083482d3ec7e71b25c151 (patch) | |
tree | c6a7e85b1d6d1c8e18089c3f7d83e392cf04448f | |
parent | 4ff05ea28bef62c4fafce789f07a02735af40f9e (diff) | |
download | busybox-w32-65dffc48de553ce08c0083482d3ec7e71b25c151.tar.gz busybox-w32-65dffc48de553ce08c0083482d3ec7e71b25c151.tar.bz2 busybox-w32-65dffc48de553ce08c0083482d3ec7e71b25c151.zip |
dc: use common_bufsiz1 for evaluation stack
msh: fix "underscore bug" (a_b=1111 didn't work)
dnsd: openlog(), so that applet's name is logged
git-svn-id: svn://busybox.net/trunk/busybox@18225 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | miscutils/dc.c | 35 | ||||
-rw-r--r-- | networking/dnsd.c | 3 | ||||
-rw-r--r-- | shell/msh.c | 17 |
3 files changed, 27 insertions, 28 deletions
diff --git a/miscutils/dc.c b/miscutils/dc.c index 2121f7669..8c9d77fc3 100644 --- a/miscutils/dc.c +++ b/miscutils/dc.c | |||
@@ -4,22 +4,19 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "busybox.h" | 6 | #include "busybox.h" |
7 | #include <ctype.h> | ||
8 | #include <stdio.h> | ||
9 | #include <stdlib.h> | ||
10 | #include <string.h> | ||
11 | #include <unistd.h> | ||
12 | #include <math.h> | 7 | #include <math.h> |
13 | 8 | ||
14 | /* Tiny RPN calculator, because "expr" didn't give me bitwise operations. */ | 9 | /* Tiny RPN calculator, because "expr" didn't give me bitwise operations. */ |
15 | 10 | ||
16 | static double stack[100]; | 11 | enum { STACK_SIZE = sizeof(bb_common_bufsiz1) / sizeof(double) }; |
12 | |||
13 | #define stack ((double*)&bb_common_bufsiz1) | ||
17 | static unsigned int pointer; | 14 | static unsigned int pointer; |
18 | static unsigned char base; | 15 | static unsigned char base; |
19 | 16 | ||
20 | static void push(double a) | 17 | static void push(double a) |
21 | { | 18 | { |
22 | if (pointer >= (sizeof(stack) / sizeof(*stack))) | 19 | if (pointer >= STACK_SIZE) |
23 | bb_error_msg_and_die("stack overflow"); | 20 | bb_error_msg_and_die("stack overflow"); |
24 | stack[pointer++] = a; | 21 | stack[pointer++] = a; |
25 | } | 22 | } |
@@ -91,10 +88,10 @@ static void not(void) | |||
91 | 88 | ||
92 | static void set_output_base(void) | 89 | static void set_output_base(void) |
93 | { | 90 | { |
94 | base=(unsigned char)pop(); | 91 | base = (unsigned char)pop(); |
95 | if ((base != 10) && (base != 16)) { | 92 | if ((base != 10) && (base != 16)) { |
96 | fprintf(stderr, "Error: base = %d is not supported.\n", base); | 93 | bb_error_msg("error, base %d is not supported", base); |
97 | base=10; | 94 | base = 10; |
98 | } | 95 | } |
99 | } | 96 | } |
100 | 97 | ||
@@ -103,12 +100,12 @@ static void print_base(double print) | |||
103 | if (base == 16) | 100 | if (base == 16) |
104 | printf("%x\n", (unsigned int)print); | 101 | printf("%x\n", (unsigned int)print); |
105 | else | 102 | else |
106 | printf("%g\n", print); | 103 | printf("%g\n", print); |
107 | } | 104 | } |
108 | 105 | ||
109 | static void print_stack_no_pop(void) | 106 | static void print_stack_no_pop(void) |
110 | { | 107 | { |
111 | unsigned int i=pointer; | 108 | unsigned int i = pointer; |
112 | while (i) | 109 | while (i) |
113 | print_base(stack[--i]); | 110 | print_base(stack[--i]); |
114 | } | 111 | } |
@@ -119,7 +116,7 @@ static void print_no_pop(void) | |||
119 | } | 116 | } |
120 | 117 | ||
121 | struct op { | 118 | struct op { |
122 | const char *name; | 119 | const char name[4]; |
123 | void (*function) (void); | 120 | void (*function) (void); |
124 | }; | 121 | }; |
125 | 122 | ||
@@ -145,7 +142,7 @@ static const struct op operators[] = { | |||
145 | {"p", print_no_pop}, | 142 | {"p", print_no_pop}, |
146 | {"f", print_stack_no_pop}, | 143 | {"f", print_stack_no_pop}, |
147 | {"o", set_output_base}, | 144 | {"o", set_output_base}, |
148 | {0, 0} | 145 | {"", 0} |
149 | }; | 146 | }; |
150 | 147 | ||
151 | static void stack_machine(const char *argument) | 148 | static void stack_machine(const char *argument) |
@@ -164,9 +161,9 @@ static void stack_machine(const char *argument) | |||
164 | return; | 161 | return; |
165 | } | 162 | } |
166 | 163 | ||
167 | while (o->name != 0) { | 164 | while (o->name[0]) { |
168 | if (strcmp(o->name, argument) == 0) { | 165 | if (strcmp(o->name, argument) == 0) { |
169 | (*(o->function)) (); | 166 | o->function(); |
170 | return; | 167 | return; |
171 | } | 168 | } |
172 | o++; | 169 | o++; |
@@ -185,7 +182,9 @@ static char *get_token(char **buffer) | |||
185 | current = skip_whitespace(*buffer); | 182 | current = skip_whitespace(*buffer); |
186 | if (*current != 0) { | 183 | if (*current != 0) { |
187 | start = current; | 184 | start = current; |
188 | while (!isspace(*current) && *current != 0) { current++; } | 185 | while (!isspace(*current) && *current != 0) { |
186 | current++; | ||
187 | } | ||
189 | *buffer = current; | 188 | *buffer = current; |
190 | } | 189 | } |
191 | return start; | 190 | return start; |
@@ -220,7 +219,7 @@ int dc_main(int argc, char **argv) | |||
220 | free(line); | 219 | free(line); |
221 | } | 220 | } |
222 | } else { | 221 | } else { |
223 | if (*argv[1]=='-') | 222 | if (*argv[1] == '-') |
224 | bb_show_usage(); | 223 | bb_show_usage(); |
225 | while (argc >= 2) { | 224 | while (argc >= 2) { |
226 | stack_machine(argv[1]); | 225 | stack_machine(argv[1]); |
diff --git a/networking/dnsd.c b/networking/dnsd.c index 2cecf6491..c9c7b3a7c 100644 --- a/networking/dnsd.c +++ b/networking/dnsd.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * the first porting of oao' scdns to busybox also. | 17 | * the first porting of oao' scdns to busybox also. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <syslog.h> | ||
20 | #include "busybox.h" | 21 | #include "busybox.h" |
21 | 22 | ||
22 | //#define DEBUG 1 | 23 | //#define DEBUG 1 |
@@ -114,7 +115,6 @@ static void undot(uint8_t * rip) | |||
114 | * Presently the dot is copied into name without | 115 | * Presently the dot is copied into name without |
115 | * converting to a length/string substring for that label. | 116 | * converting to a length/string substring for that label. |
116 | */ | 117 | */ |
117 | |||
118 | static int getfileentry(FILE * fp, struct dns_entry *s) | 118 | static int getfileentry(FILE * fp, struct dns_entry *s) |
119 | { | 119 | { |
120 | unsigned int a,b,c,d; | 120 | unsigned int a,b,c,d; |
@@ -359,6 +359,7 @@ int dnsd_main(int argc, char **argv) | |||
359 | #else | 359 | #else |
360 | xdaemon(1, 0); | 360 | xdaemon(1, 0); |
361 | #endif | 361 | #endif |
362 | openlog(applet_name, LOG_PID, LOG_DAEMON); | ||
362 | logmode = LOGMODE_SYSLOG; | 363 | logmode = LOGMODE_SYSLOG; |
363 | } | 364 | } |
364 | 365 | ||
diff --git a/shell/msh.c b/shell/msh.c index 41f4cc60d..d9dd3efb2 100644 --- a/shell/msh.c +++ b/shell/msh.c | |||
@@ -1191,23 +1191,22 @@ static int isassign(const char *s) | |||
1191 | unsigned char c; | 1191 | unsigned char c; |
1192 | DBGPRINTF7(("ISASSIGN: enter, s=%s\n", s)); | 1192 | DBGPRINTF7(("ISASSIGN: enter, s=%s\n", s)); |
1193 | 1193 | ||
1194 | /* no isalpha() - we shouldn't use locale */ | ||
1195 | c = *s; | 1194 | c = *s; |
1196 | if (c != '_' | 1195 | /* no isalpha() - we shouldn't use locale */ |
1197 | && (unsigned)((c|0x20) - 'a') > 25 /* not letter */ | 1196 | /* c | 0x20 - lowercase (Latin) letters */ |
1198 | ) { | 1197 | if (c != '_' && (unsigned)((c|0x20) - 'a') > 25) |
1198 | /* not letter */ | ||
1199 | return 0; | 1199 | return 0; |
1200 | } | 1200 | |
1201 | while (1) { | 1201 | while (1) { |
1202 | c = *++s; | 1202 | c = *++s; |
1203 | if (c == '\0') | ||
1204 | return 0; | ||
1205 | if (c == '=') | 1203 | if (c == '=') |
1206 | return 1; | 1204 | return 1; |
1207 | c |= 0x20; /* lowercase letters, doesn't affect numbers */ | 1205 | if (c == '\0') |
1206 | return 0; | ||
1208 | if (c != '_' | 1207 | if (c != '_' |
1209 | && (unsigned)(c - '0') > 9 /* not number */ | 1208 | && (unsigned)(c - '0') > 9 /* not number */ |
1210 | && (unsigned)(c - 'a') > 25 /* not letter */ | 1209 | && (unsigned)((c|0x20) - 'a') > 25 /* not letter */ |
1211 | ) { | 1210 | ) { |
1212 | return 0; | 1211 | return 0; |
1213 | } | 1212 | } |