aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>1999-11-08 17:00:52 +0000
committerEric Andersen <andersen@codepoet.org>1999-11-08 17:00:52 +0000
commitfbb39c83b69d6c4de943c0b7374000339635d13d (patch)
tree874ba86bb5753f4afd5a770308df9e555c78cf90
parent07e5297ca7707d2fd56ab2fa8e1ea0c9805035e3 (diff)
downloadbusybox-w32-fbb39c83b69d6c4de943c0b7374000339635d13d.tar.gz
busybox-w32-fbb39c83b69d6c4de943c0b7374000339635d13d.tar.bz2
busybox-w32-fbb39c83b69d6c4de943c0b7374000339635d13d.zip
Stuff
-Erik
-rw-r--r--dutmp.c2
-rw-r--r--findutils/grep.c59
-rw-r--r--grep.c59
-rw-r--r--init.c2
-rw-r--r--init/init.c2
-rw-r--r--miscutils/dutmp.c2
-rw-r--r--more.c21
-rw-r--r--util-linux/more.c21
8 files changed, 98 insertions, 70 deletions
diff --git a/dutmp.c b/dutmp.c
index c5307b638..a9e879daf 100644
--- a/dutmp.c
+++ b/dutmp.c
@@ -19,7 +19,7 @@ static const char dutmp_usage[] = "dutmp\n"
19 "\tDump file or stdin utmp file format to stdout, pipe delimited.\n" 19 "\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
20 "\tdutmp /var/run/utmp\n"; 20 "\tdutmp /var/run/utmp\n";
21 21
22static int dutmp_main (int argc, char **argv) 22extern int dutmp_main (int argc, char **argv)
23{ 23{
24 24
25 FILE *f = stdin; 25 FILE *f = stdin;
diff --git a/findutils/grep.c b/findutils/grep.c
index 9495bf858..50a296178 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -43,6 +43,33 @@ static const char grep_usage[] =
43"This version of grep matches strings (not full regexps).\n"; 43"This version of grep matches strings (not full regexps).\n";
44#endif 44#endif
45 45
46int tellName=TRUE;
47int ignoreCase=FALSE;
48int tellLine=FALSE;
49
50static do_grep(char* needle, char* haystack )
51{
52 line = 0;
53
54 while (fgets (haystack, sizeof (haystack), fp)) {
55 line++;
56 cp = &haystack[strlen (haystack) - 1];
57
58 if (*cp != '\n')
59 fprintf (stderr, "%s: Line too long\n", name);
60
61 if (find_match(haystack, needle, ignoreCase) == TRUE) {
62 if (tellName==TRUE)
63 printf ("%s: ", name);
64
65 if (tellLine==TRUE)
66 printf ("%ld: ", line);
67
68 fputs (haystack, stdout);
69 }
70 }
71}
72
46 73
47extern int grep_main (int argc, char **argv) 74extern int grep_main (int argc, char **argv)
48{ 75{
@@ -50,9 +77,6 @@ extern int grep_main (int argc, char **argv)
50 char *needle; 77 char *needle;
51 char *name; 78 char *name;
52 char *cp; 79 char *cp;
53 int tellName=TRUE;
54 int ignoreCase=FALSE;
55 int tellLine=FALSE;
56 long line; 80 long line;
57 char haystack[BUF_SIZE]; 81 char haystack[BUF_SIZE];
58 82
@@ -91,7 +115,16 @@ extern int grep_main (int argc, char **argv)
91 needle = *argv++; 115 needle = *argv++;
92 argc--; 116 argc--;
93 117
118
94 while (argc-- > 0) { 119 while (argc-- > 0) {
120
121 if (argc==0) {
122 file = stdin;
123 }
124 else
125 file = fopen(*argv, "r");
126
127
95 name = *argv++; 128 name = *argv++;
96 129
97 fp = fopen (name, "r"); 130 fp = fopen (name, "r");
@@ -100,26 +133,6 @@ extern int grep_main (int argc, char **argv)
100 continue; 133 continue;
101 } 134 }
102 135
103 line = 0;
104
105 while (fgets (haystack, sizeof (haystack), fp)) {
106 line++;
107 cp = &haystack[strlen (haystack) - 1];
108
109 if (*cp != '\n')
110 fprintf (stderr, "%s: Line too long\n", name);
111
112 if (find_match(haystack, needle, ignoreCase) == TRUE) {
113 if (tellName==TRUE)
114 printf ("%s: ", name);
115
116 if (tellLine==TRUE)
117 printf ("%ld: ", line);
118
119 fputs (haystack, stdout);
120 }
121 }
122
123 if (ferror (fp)) 136 if (ferror (fp))
124 perror (name); 137 perror (name);
125 138
diff --git a/grep.c b/grep.c
index 9495bf858..50a296178 100644
--- a/grep.c
+++ b/grep.c
@@ -43,6 +43,33 @@ static const char grep_usage[] =
43"This version of grep matches strings (not full regexps).\n"; 43"This version of grep matches strings (not full regexps).\n";
44#endif 44#endif
45 45
46int tellName=TRUE;
47int ignoreCase=FALSE;
48int tellLine=FALSE;
49
50static do_grep(char* needle, char* haystack )
51{
52 line = 0;
53
54 while (fgets (haystack, sizeof (haystack), fp)) {
55 line++;
56 cp = &haystack[strlen (haystack) - 1];
57
58 if (*cp != '\n')
59 fprintf (stderr, "%s: Line too long\n", name);
60
61 if (find_match(haystack, needle, ignoreCase) == TRUE) {
62 if (tellName==TRUE)
63 printf ("%s: ", name);
64
65 if (tellLine==TRUE)
66 printf ("%ld: ", line);
67
68 fputs (haystack, stdout);
69 }
70 }
71}
72
46 73
47extern int grep_main (int argc, char **argv) 74extern int grep_main (int argc, char **argv)
48{ 75{
@@ -50,9 +77,6 @@ extern int grep_main (int argc, char **argv)
50 char *needle; 77 char *needle;
51 char *name; 78 char *name;
52 char *cp; 79 char *cp;
53 int tellName=TRUE;
54 int ignoreCase=FALSE;
55 int tellLine=FALSE;
56 long line; 80 long line;
57 char haystack[BUF_SIZE]; 81 char haystack[BUF_SIZE];
58 82
@@ -91,7 +115,16 @@ extern int grep_main (int argc, char **argv)
91 needle = *argv++; 115 needle = *argv++;
92 argc--; 116 argc--;
93 117
118
94 while (argc-- > 0) { 119 while (argc-- > 0) {
120
121 if (argc==0) {
122 file = stdin;
123 }
124 else
125 file = fopen(*argv, "r");
126
127
95 name = *argv++; 128 name = *argv++;
96 129
97 fp = fopen (name, "r"); 130 fp = fopen (name, "r");
@@ -100,26 +133,6 @@ extern int grep_main (int argc, char **argv)
100 continue; 133 continue;
101 } 134 }
102 135
103 line = 0;
104
105 while (fgets (haystack, sizeof (haystack), fp)) {
106 line++;
107 cp = &haystack[strlen (haystack) - 1];
108
109 if (*cp != '\n')
110 fprintf (stderr, "%s: Line too long\n", name);
111
112 if (find_match(haystack, needle, ignoreCase) == TRUE) {
113 if (tellName==TRUE)
114 printf ("%s: ", name);
115
116 if (tellLine==TRUE)
117 printf ("%ld: ", line);
118
119 fputs (haystack, stdout);
120 }
121 }
122
123 if (ferror (fp)) 136 if (ferror (fp))
124 perror (name); 137 perror (name);
125 138
diff --git a/init.c b/init.c
index 707b1916f..a354f8a75 100644
--- a/init.c
+++ b/init.c
@@ -192,7 +192,7 @@ static void console_init()
192 if ((s = getenv("CONSOLE")) != NULL) { 192 if ((s = getenv("CONSOLE")) != NULL) {
193 console = s; 193 console = s;
194 } 194 }
195#if defined (__sparc__) 195#if #cpu(sparc)
196 /* sparc kernel supports console=tty[ab] parameter which is also 196 /* sparc kernel supports console=tty[ab] parameter which is also
197 * passed to init, so catch it here */ 197 * passed to init, so catch it here */
198 else if ((s = getenv("console")) != NULL) { 198 else if ((s = getenv("console")) != NULL) {
diff --git a/init/init.c b/init/init.c
index 707b1916f..a354f8a75 100644
--- a/init/init.c
+++ b/init/init.c
@@ -192,7 +192,7 @@ static void console_init()
192 if ((s = getenv("CONSOLE")) != NULL) { 192 if ((s = getenv("CONSOLE")) != NULL) {
193 console = s; 193 console = s;
194 } 194 }
195#if defined (__sparc__) 195#if #cpu(sparc)
196 /* sparc kernel supports console=tty[ab] parameter which is also 196 /* sparc kernel supports console=tty[ab] parameter which is also
197 * passed to init, so catch it here */ 197 * passed to init, so catch it here */
198 else if ((s = getenv("console")) != NULL) { 198 else if ((s = getenv("console")) != NULL) {
diff --git a/miscutils/dutmp.c b/miscutils/dutmp.c
index c5307b638..a9e879daf 100644
--- a/miscutils/dutmp.c
+++ b/miscutils/dutmp.c
@@ -19,7 +19,7 @@ static const char dutmp_usage[] = "dutmp\n"
19 "\tDump file or stdin utmp file format to stdout, pipe delimited.\n" 19 "\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
20 "\tdutmp /var/run/utmp\n"; 20 "\tdutmp /var/run/utmp\n";
21 21
22static int dutmp_main (int argc, char **argv) 22extern int dutmp_main (int argc, char **argv)
23{ 23{
24 24
25 FILE *f = stdin; 25 FILE *f = stdin;
diff --git a/more.c b/more.c
index bc3850510..ea5e22562 100644
--- a/more.c
+++ b/more.c
@@ -41,8 +41,7 @@ static const char more_usage[] = "[file ...]";
41/* ED: sparc termios is broken: revert back to old termio handling. */ 41/* ED: sparc termios is broken: revert back to old termio handling. */
42#ifdef BB_MORE_TERM 42#ifdef BB_MORE_TERM
43 43
44 44#if #cpu(sparc)
45#if defined (__sparc__)
46# define USE_OLD_TERMIO 45# define USE_OLD_TERMIO
47# include <termio.h> 46# include <termio.h>
48# include <sys/ioctl.h> 47# include <sys/ioctl.h>
@@ -69,13 +68,13 @@ extern int more_main(int argc, char **argv)
69 struct stat st; 68 struct stat st;
70 FILE *file; 69 FILE *file;
71 70
72 if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) {
73 usage (more_usage);
74 }
75 argc--; 71 argc--;
76 argv++; 72 argv++;
77 73
78 while (argc >= 0) { 74 if ( argc > 0 && (strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0) ) {
75 usage (more_usage);
76 }
77 do {
79 if (argc==0) { 78 if (argc==0) {
80 file = stdin; 79 file = stdin;
81 } 80 }
@@ -103,6 +102,9 @@ extern int more_main(int argc, char **argv)
103 stty(fileno(cin), &new_settings); 102 stty(fileno(cin), &new_settings);
104 103
105 (void) signal(SIGINT, gotsig); 104 (void) signal(SIGINT, gotsig);
105 (void) signal(SIGQUIT, gotsig);
106 (void) signal(SIGTERM, gotsig);
107
106 108
107#endif 109#endif
108 while ((c = getc(file)) != EOF) { 110 while ((c = getc(file)) != EOF) {
@@ -141,18 +143,17 @@ extern int more_main(int argc, char **argv)
141 } 143 }
142 if (input=='q') 144 if (input=='q')
143 goto end; 145 goto end;
144 if (input==' ' && c == '\n' ) 146 if (input=='\n' && c == '\n' )
145 next_page = 1; 147 next_page = 1;
146 if ( c == '\n' && ++lines == 24 ) 148 if ( c == ' ' && ++lines == 24 )
147 next_page = 1; 149 next_page = 1;
148 putc(c, stdout); 150 putc(c, stdout);
149 } 151 }
150 fclose(file); 152 fclose(file);
151 fflush(stdout); 153 fflush(stdout);
152 154
153 argc--;
154 argv++; 155 argv++;
155 } 156 } while (--argc > 0);
156end: 157end:
157#ifdef BB_MORE_TERM 158#ifdef BB_MORE_TERM
158 gotsig(0); 159 gotsig(0);
diff --git a/util-linux/more.c b/util-linux/more.c
index bc3850510..ea5e22562 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -41,8 +41,7 @@ static const char more_usage[] = "[file ...]";
41/* ED: sparc termios is broken: revert back to old termio handling. */ 41/* ED: sparc termios is broken: revert back to old termio handling. */
42#ifdef BB_MORE_TERM 42#ifdef BB_MORE_TERM
43 43
44 44#if #cpu(sparc)
45#if defined (__sparc__)
46# define USE_OLD_TERMIO 45# define USE_OLD_TERMIO
47# include <termio.h> 46# include <termio.h>
48# include <sys/ioctl.h> 47# include <sys/ioctl.h>
@@ -69,13 +68,13 @@ extern int more_main(int argc, char **argv)
69 struct stat st; 68 struct stat st;
70 FILE *file; 69 FILE *file;
71 70
72 if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) {
73 usage (more_usage);
74 }
75 argc--; 71 argc--;
76 argv++; 72 argv++;
77 73
78 while (argc >= 0) { 74 if ( argc > 0 && (strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0) ) {
75 usage (more_usage);
76 }
77 do {
79 if (argc==0) { 78 if (argc==0) {
80 file = stdin; 79 file = stdin;
81 } 80 }
@@ -103,6 +102,9 @@ extern int more_main(int argc, char **argv)
103 stty(fileno(cin), &new_settings); 102 stty(fileno(cin), &new_settings);
104 103
105 (void) signal(SIGINT, gotsig); 104 (void) signal(SIGINT, gotsig);
105 (void) signal(SIGQUIT, gotsig);
106 (void) signal(SIGTERM, gotsig);
107
106 108
107#endif 109#endif
108 while ((c = getc(file)) != EOF) { 110 while ((c = getc(file)) != EOF) {
@@ -141,18 +143,17 @@ extern int more_main(int argc, char **argv)
141 } 143 }
142 if (input=='q') 144 if (input=='q')
143 goto end; 145 goto end;
144 if (input==' ' && c == '\n' ) 146 if (input=='\n' && c == '\n' )
145 next_page = 1; 147 next_page = 1;
146 if ( c == '\n' && ++lines == 24 ) 148 if ( c == ' ' && ++lines == 24 )
147 next_page = 1; 149 next_page = 1;
148 putc(c, stdout); 150 putc(c, stdout);
149 } 151 }
150 fclose(file); 152 fclose(file);
151 fflush(stdout); 153 fflush(stdout);
152 154
153 argc--;
154 argv++; 155 argv++;
155 } 156 } while (--argc > 0);
156end: 157end:
157#ifdef BB_MORE_TERM 158#ifdef BB_MORE_TERM
158 gotsig(0); 159 gotsig(0);