common BUFSIZ BSS buffer, small reduce code, data and bss
This commit was genuinely broken at the time (not related to our build system): scripts/config/mkconfigs.c (2005-08-01 - 2006-10-05 arasi) uretilen bbconfigopts.h icine .config satirlarini kacissiz, ham newline'larla gömüyordu - gecerli C degildi, busybox'un kendi bb_mkdep araci bile parse edemiyordu (7d219aab7 ile duzeltildi, mkconfigs shell scripte cevrildi)
No binary (build failed)
—
(log yok)
| @@ -44,12 +44,13 @@ | |
| * to pick a random letter to add to out temporary file. */ | |
| typedef unsigned long int bb_uint64_t; | |
| + | #define tempFn bb_common_bufsiz1 |
| + | |
| /* if fn is NULL then input is stdin and output is stdout */ | |
| static int convert(char *fn, int ConvType) | |
| { | |
| int c, fd; | |
| struct timeval tv; | |
| - | RESERVE_CONFIG_BUFFER(tempFn, BUFSIZ); |
| static bb_uint64_t value=0; | |
| FILE *in, *out; | |
| @@ -39,7 +39,7 @@ int tee_main(int argc, char **argv) | |
| int retval = EXIT_SUCCESS; | |
| #ifdef CONFIG_FEATURE_TEE_USE_BLOCK_IO | |
| ssize_t c; | |
| - | RESERVE_CONFIG_BUFFER(buf, BUFSIZ); |
| + | # define buf bb_common_bufsiz1 |
| #else | |
| int c; | |
| #endif | |
| @@ -88,10 +88,6 @@ int tee_main(int argc, char **argv) | |
| retval = EXIT_FAILURE; | |
| } | |
| - | #ifdef CONFIG_FEATURE_CLEAN_UP |
| - | RELEASE_CONFIG_BUFFER(buf); |
| - | #endif |
| - | |
| #else | |
| setvbuf(stdout, NULL, _IONBF, 0); | |
| while ((c = getchar()) != EOF) { | |
| @@ -38,10 +38,11 @@ | |
| static char com_fl, del_fl, sq_fl; | |
| static short in_index, out_index; | |
| /* these last are pointers to static buffers declared in tr_main */ | |
| - | static unsigned char *poutput, *pinput; |
| + | static unsigned char *poutput; |
| static unsigned char *pvector; | |
| static char *pinvec, *poutvec; | |
| + | #define input bb_common_bufsiz1 |
| static void convert(void) | |
| { | |
| @@ -51,14 +52,14 @@ static void convert(void) | |
| for (;;) { | |
| if (in_index == read_chars) { | |
| - | if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) { |
| + | if ((read_chars = read(0, input, BUFSIZ)) <= 0) { |
| if (write(1, (char *) poutput, out_index) != out_index) | |
| bb_error_msg(bb_msg_write_error); | |
| exit(0); | |
| } | |
| in_index = 0; | |
| } | |
| - | c = pinput[in_index++]; |
| + | c = input[in_index++]; |
| coded = pvector[c]; | |
| if (del_fl && pinvec[c]) | |
| continue; | |
| @@ -208,14 +209,12 @@ extern int tr_main(int argc, char **argv) | |
| int idx = 1; | |
| int i; | |
| RESERVE_CONFIG_BUFFER(output, BUFSIZ); | |
| - | RESERVE_CONFIG_BUFFER(input, BUFSIZ); |
| RESERVE_CONFIG_UBUFFER(vector, ASCII+1); | |
| RESERVE_CONFIG_BUFFER(invec, ASCII+1); | |
| RESERVE_CONFIG_BUFFER(outvec, ASCII+1); | |
| /* ... but make them available globally */ | |
| poutput = output; | |
| - | pinput = input; |
| pvector = vector; | |
| pinvec = invec; | |
| poutvec = outvec; | |
| @@ -2226,7 +2226,8 @@ static int mysleep(int hund) // sleep for 'h' 1/100 seconds | |
| return (FD_ISSET(0, &rfds)); | |
| } | |
| - | static Byte readbuffer[BUFSIZ]; |
| + | #define readbuffer bb_common_bufsiz1 |
| + | |
| static int readed_for_parse; | |
| //----- IO Routines -------------------------------------------- | |
| @@ -333,6 +333,12 @@ extern const char * const bb_path_group_file; | |
| extern const char * const bb_path_securetty_file; | |
| extern const char * const bb_path_motd_file; | |
| extern const char * const bb_dev_null; | |
| + | |
| + | #ifndef BUFSIZ |
| + | #define BUFSIZ 4096 |
| + | #endif |
| + | extern char bb_common_bufsiz1[BUFSIZ+1]; |
| + | |
| /* | |
| * You can change LIBBB_DEFAULT_LOGIN_SHELL, but don`t use, | |
| * use bb_default_login_shell and next defines, | |
| @@ -47,7 +47,8 @@ LIBBB_MOBJ0:=full_version.o \ | |
| can_not_create_raw_socket.o perm_denied_are_you_root.o \ | |
| shadow_file.o passwd_file.o group_file.o gshadow_file.o nologin_file.o \ | |
| securetty_file.o motd_file.o \ | |
| - | msg_standard_input.o msg_standard_output.o shell_file.o bb_dev_null.o |
| + | msg_standard_input.o msg_standard_output.o shell_file.o \ |
| + | bb_dev_null.o bb_common_bufsiz1.o |
| LIBBB_MSRC1:=$(srcdir)/xfuncs.c | |
| LIBBB_MOBJ1:=xmalloc.o xrealloc.o xcalloc.o xstrdup.o xstrndup.o \ | |
| @@ -101,3 +101,6 @@ const char * const bb_default_login_shell = LIBBB_DEFAULT_LOGIN_SHELL; | |
| const char * const bb_dev_null = "/dev/null"; | |
| #endif | |
| + | #ifdef L_bb_common_bufsiz1 |
| + | char bb_common_bufsiz1[BUFSIZ+1]; |
| + | #endif |
| @@ -110,15 +110,6 @@ extern void updwtmp(const char *filename, const struct utmp *ut); | |
| #define TCGETA TCGETS | |
| #define TCSETA TCSETS | |
| #define TCSETAW TCSETSW | |
| - | #endif |
| - | |
| - | /* |
| - | * This program tries to not use the standard-i/o library. This keeps the |
| - | * executable small on systems that do not have shared libraries (System V |
| - | * Release <3). |
| - | */ |
| - | #ifndef BUFSIZ |
| - | #define BUFSIZ 1024 |
| #endif | |
| /* | |
| @@ -744,12 +735,12 @@ static void next_speed(struct termio *tp, struct options *op) | |
| /* return NULL on failure, logname on success */ | |
| static char *get_logname(struct options *op, struct chardata *cp, struct termio *tp) | |
| { | |
| - | static char logname[BUFSIZ]; |
| + | #define logname bb_common_bufsiz1 |
| char *bp; | |
| - | char c; /* input character, full eight bits */ |
| - | char ascval; /* low 7 bits of input character */ |
| - | int bits; /* # of "1" bits per character */ |
| - | int mask; /* mask with 1 bit up */ |
| + | char c; /* input character, full eight bits */ |
| + | char ascval; /* low 7 bits of input character */ |
| + | int bits; /* # of "1" bits per character */ |
| + | int mask; /* mask with 1 bit up */ |
| static char *erase[] = { /* backspace-space-backspace */ | |
| "\010\040\010", /* space parity */ | |
| "\010\040\010", /* odd parity */ | |
| @@ -21,7 +21,7 @@ | |
| #define SULOGIN_PROMPT "\nGive root password for system maintenance\n" \ | |
| "(or type Control-D for normal startup):" | |
| - | static const char *forbid[] = { |
| + | static const char * const forbid[] = { |
| "ENV", | |
| "BASH_ENV", | |
| "HOME", | |
| @@ -53,11 +53,13 @@ extern int sulogin_main(int argc, char **argv) | |
| char *device = (char *) 0; | |
| const char *name = "root"; | |
| int timeout = 0; | |
| - | static char pass[BUFSIZ]; |
| + | |
| + | #define pass bb_common_bufsiz1 |
| + | |
| struct passwd pwent; | |
| struct passwd *pwd; | |
| time_t start, now; | |
| - | const char **p; |
| + | const char * const *p; |
| #ifdef CONFIG_FEATURE_SHADOWPASSWDS | |
| struct spwd *spwd = NULL; | |
| #endif /* CONFIG_FEATURE_SHADOWPASSWDS */ | |
| @@ -48,7 +48,9 @@ static void timeout(int signum) | |
| int nc_main(int argc, char **argv) | |
| { | |
| int do_listen = 0, lport = 0, delay = 0, wsecs = 0, tmpfd, opt, sfd, x; | |
| - | char buf[BUFSIZ]; |
| + | |
| + | #define buf bb_common_bufsiz1 |
| + | |
| #ifdef CONFIG_NC_GAPING_SECURITY_HOLE | |
| char *pr00gie = NULL; | |
| #endif | |
| @@ -568,7 +568,7 @@ struct parsefile { | |
| }; | |
| static struct parsefile basepf; /* top level input file */ | |
| - | static char basebuf[IBUFSIZ]; /* buffer for top level input file */ |
| + | #define basebuf bb_common_bufsiz1 /* buffer for top level input file */ |
| static struct parsefile *parsefile = &basepf; /* current input file */ | |
| @@ -5939,7 +5939,6 @@ varunset(const char *end, const char *var, const char *umsg, int varflags) | |
| */ | |
| #define EOF_NLEFT -99 /* value of parsenleft when EOF pushed back */ | |
| - | #define IBUFSIZ (BUFSIZ + 1) |
| static void pushfile(void); | |