From bea1942a5068cd1a2e83545d71c832ec58d6738d Mon Sep 17 00:00:00 2001 From: bug1 Date: Mon, 15 Sep 2003 14:22:37 +0000 Subject: Patch from Tito, Reduces the size of busybox's strings applet from 1900 to 1788 bytes (for strings.o). git-svn-id: svn://busybox.net/trunk/busybox@7530 69ca8d6d-28ef-0310-b511-8ec308f3f277 --- miscutils/strings.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'miscutils') diff --git a/miscutils/strings.c b/miscutils/strings.c index 1231a93bd..4778cfb5f 100644 --- a/miscutils/strings.c +++ b/miscutils/strings.c @@ -37,10 +37,11 @@ int strings_main(int argc, char **argv) { - int n=4, c, i, opt=0, a=0, status=EXIT_SUCCESS; + int n=4, c, i, opt=0, status=EXIT_SUCCESS; long t=0, count; - FILE *file; + FILE *file = stdin; char *string=NULL; + const char *fmt="%s: "; while ((i = getopt(argc, argv, "afon:")) > 0) switch(i) @@ -66,18 +67,19 @@ int strings_main(int argc, char **argv) i=0; string=xmalloc(n+1); - string[n]='\0'; + /*string[n]='\0';*/ n-=1; - if(!argc ) + if(argc==0) { - file = stdin; + fmt="{%s}: "; + *argv=(char *)bb_msg_standard_input; goto pipe; } - for(a=0;a= 2 ) printf("%7lo ", t); printf("%s", string); @@ -114,12 +116,9 @@ pipe: bb_fclose_nonstdin(file); } else - { - bb_perror_msg("%s",argv[a]); status=EXIT_FAILURE; - } } - free(string); + /*free(string);*/ exit(status); } -- cgit v1.2.3-55-g6feb