svn commit: trunk/busybox: coreutils editors include libbb loginuti etc...
vodz at busybox.net
vodz at busybox.net
Sat Oct 15 10:24:00 UTC 2005
Author: vodz
Date: 2005-10-15 03:23:55 -0700 (Sat, 15 Oct 2005)
New Revision: 11867
Log:
common BUFSIZ BSS buffer, small reduce code, data and bss
Modified:
trunk/busybox/coreutils/dos2unix.c
trunk/busybox/coreutils/tee.c
trunk/busybox/coreutils/tr.c
trunk/busybox/editors/vi.c
trunk/busybox/include/libbb.h
trunk/busybox/libbb/Makefile.in
trunk/busybox/libbb/messages.c
trunk/busybox/loginutils/getty.c
trunk/busybox/loginutils/sulogin.c
trunk/busybox/networking/nc.c
trunk/busybox/shell/ash.c
Changeset:
Modified: trunk/busybox/coreutils/dos2unix.c
===================================================================
--- trunk/busybox/coreutils/dos2unix.c 2005-10-15 06:32:38 UTC (rev 11866)
+++ trunk/busybox/coreutils/dos2unix.c 2005-10-15 10:23:55 UTC (rev 11867)
@@ -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;
Modified: trunk/busybox/coreutils/tee.c
===================================================================
--- trunk/busybox/coreutils/tee.c 2005-10-15 06:32:38 UTC (rev 11866)
+++ trunk/busybox/coreutils/tee.c 2005-10-15 10:23:55 UTC (rev 11867)
@@ -39,7 +39,7 @@
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 @@
retval = EXIT_FAILURE;
}
-#ifdef CONFIG_FEATURE_CLEAN_UP
- RELEASE_CONFIG_BUFFER(buf);
-#endif
-
#else
setvbuf(stdout, NULL, _IONBF, 0);
while ((c = getchar()) != EOF) {
Modified: trunk/busybox/coreutils/tr.c
===================================================================
--- trunk/busybox/coreutils/tr.c 2005-10-15 06:32:38 UTC (rev 11866)
+++ trunk/busybox/coreutils/tr.c 2005-10-15 10:23:55 UTC (rev 11867)
@@ -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 @@
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 @@
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;
Modified: trunk/busybox/editors/vi.c
===================================================================
--- trunk/busybox/editors/vi.c 2005-10-15 06:32:38 UTC (rev 11866)
+++ trunk/busybox/editors/vi.c 2005-10-15 10:23:55 UTC (rev 11867)
@@ -2226,7 +2226,8 @@
return (FD_ISSET(0, &rfds));
}
-static Byte readbuffer[BUFSIZ];
+#define readbuffer bb_common_bufsiz1
+
static int readed_for_parse;
//----- IO Routines --------------------------------------------
Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h 2005-10-15 06:32:38 UTC (rev 11866)
+++ trunk/busybox/include/libbb.h 2005-10-15 10:23:55 UTC (rev 11867)
@@ -333,6 +333,12 @@
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,
Modified: trunk/busybox/libbb/Makefile.in
===================================================================
--- trunk/busybox/libbb/Makefile.in 2005-10-15 06:32:38 UTC (rev 11866)
+++ trunk/busybox/libbb/Makefile.in 2005-10-15 10:23:55 UTC (rev 11867)
@@ -47,7 +47,8 @@
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 \
Modified: trunk/busybox/libbb/messages.c
===================================================================
--- trunk/busybox/libbb/messages.c 2005-10-15 06:32:38 UTC (rev 11866)
+++ trunk/busybox/libbb/messages.c 2005-10-15 10:23:55 UTC (rev 11867)
@@ -101,3 +101,6 @@
const char * const bb_dev_null = "/dev/null";
#endif
+#ifdef L_bb_common_bufsiz1
+char bb_common_bufsiz1[BUFSIZ+1];
+#endif
Modified: trunk/busybox/loginutils/getty.c
===================================================================
--- trunk/busybox/loginutils/getty.c 2005-10-15 06:32:38 UTC (rev 11866)
+++ trunk/busybox/loginutils/getty.c 2005-10-15 10:23:55 UTC (rev 11867)
@@ -113,15 +113,6 @@
#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
-
- /*
* When multiple baud rates are specified on the command line, the first one
* we will try is the first one specified.
*/
@@ -744,12 +735,12 @@
/* 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 */
Modified: trunk/busybox/loginutils/sulogin.c
===================================================================
--- trunk/busybox/loginutils/sulogin.c 2005-10-15 06:32:38 UTC (rev 11866)
+++ trunk/busybox/loginutils/sulogin.c 2005-10-15 10:23:55 UTC (rev 11867)
@@ -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 @@
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 */
Modified: trunk/busybox/networking/nc.c
===================================================================
--- trunk/busybox/networking/nc.c 2005-10-15 06:32:38 UTC (rev 11866)
+++ trunk/busybox/networking/nc.c 2005-10-15 10:23:55 UTC (rev 11867)
@@ -48,7 +48,9 @@
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
Modified: trunk/busybox/shell/ash.c
===================================================================
--- trunk/busybox/shell/ash.c 2005-10-15 06:32:38 UTC (rev 11866)
+++ trunk/busybox/shell/ash.c 2005-10-15 10:23:55 UTC (rev 11867)
@@ -568,7 +568,7 @@
};
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 @@
*/
#define EOF_NLEFT -99 /* value of parsenleft when EOF pushed back */
-#define IBUFSIZ (BUFSIZ + 1)
static void pushfile(void);
More information about the busybox-cvs
mailing list