aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"
"\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
"\tdutmp /var/run/utmp\n";
-static int dutmp_main (int argc, char **argv)
+extern int dutmp_main (int argc, char **argv)
{
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[] =
"This version of grep matches strings (not full regexps).\n";
#endif
+int tellName=TRUE;
+int ignoreCase=FALSE;
+int tellLine=FALSE;
+
+static do_grep(char* needle, char* haystack )
+{
+ line = 0;
+
+ while (fgets (haystack, sizeof (haystack), fp)) {
+ line++;
+ cp = &haystack[strlen (haystack) - 1];
+
+ if (*cp != '\n')
+ fprintf (stderr, "%s: Line too long\n", name);
+
+ if (find_match(haystack, needle, ignoreCase) == TRUE) {
+ if (tellName==TRUE)
+ printf ("%s: ", name);
+
+ if (tellLine==TRUE)
+ printf ("%ld: ", line);
+
+ fputs (haystack, stdout);
+ }
+ }
+}
+
extern int grep_main (int argc, char **argv)
{
@@ -50,9 +77,6 @@ extern int grep_main (int argc, char **argv)
char *needle;
char *name;
char *cp;
- int tellName=TRUE;
- int ignoreCase=FALSE;
- int tellLine=FALSE;
long line;
char haystack[BUF_SIZE];
@@ -91,7 +115,16 @@ extern int grep_main (int argc, char **argv)
needle = *argv++;
argc--;
+
while (argc-- > 0) {
+
+ if (argc==0) {
+ file = stdin;
+ }
+ else
+ file = fopen(*argv, "r");
+
+
name = *argv++;
fp = fopen (name, "r");
@@ -100,26 +133,6 @@ extern int grep_main (int argc, char **argv)
continue;
}
- line = 0;
-
- while (fgets (haystack, sizeof (haystack), fp)) {
- line++;
- cp = &haystack[strlen (haystack) - 1];
-
- if (*cp != '\n')
- fprintf (stderr, "%s: Line too long\n", name);
-
- if (find_match(haystack, needle, ignoreCase) == TRUE) {
- if (tellName==TRUE)
- printf ("%s: ", name);
-
- if (tellLine==TRUE)
- printf ("%ld: ", line);
-
- fputs (haystack, stdout);
- }
- }
-
if (ferror (fp))
perror (name);
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[] =
"This version of grep matches strings (not full regexps).\n";
#endif
+int tellName=TRUE;
+int ignoreCase=FALSE;
+int tellLine=FALSE;
+
+static do_grep(char* needle, char* haystack )
+{
+ line = 0;
+
+ while (fgets (haystack, sizeof (haystack), fp)) {
+ line++;
+ cp = &haystack[strlen (haystack) - 1];
+
+ if (*cp != '\n')
+ fprintf (stderr, "%s: Line too long\n", name);
+
+ if (find_match(haystack, needle, ignoreCase) == TRUE) {
+ if (tellName==TRUE)
+ printf ("%s: ", name);
+
+ if (tellLine==TRUE)
+ printf ("%ld: ", line);
+
+ fputs (haystack, stdout);
+ }
+ }
+}
+
extern int grep_main (int argc, char **argv)
{
@@ -50,9 +77,6 @@ extern int grep_main (int argc, char **argv)
char *needle;
char *name;
char *cp;
- int tellName=TRUE;
- int ignoreCase=FALSE;
- int tellLine=FALSE;
long line;
char haystack[BUF_SIZE];
@@ -91,7 +115,16 @@ extern int grep_main (int argc, char **argv)
needle = *argv++;
argc--;
+
while (argc-- > 0) {
+
+ if (argc==0) {
+ file = stdin;
+ }
+ else
+ file = fopen(*argv, "r");
+
+
name = *argv++;
fp = fopen (name, "r");
@@ -100,26 +133,6 @@ extern int grep_main (int argc, char **argv)
continue;
}
- line = 0;
-
- while (fgets (haystack, sizeof (haystack), fp)) {
- line++;
- cp = &haystack[strlen (haystack) - 1];
-
- if (*cp != '\n')
- fprintf (stderr, "%s: Line too long\n", name);
-
- if (find_match(haystack, needle, ignoreCase) == TRUE) {
- if (tellName==TRUE)
- printf ("%s: ", name);
-
- if (tellLine==TRUE)
- printf ("%ld: ", line);
-
- fputs (haystack, stdout);
- }
- }
-
if (ferror (fp))
perror (name);
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()
if ((s = getenv("CONSOLE")) != NULL) {
console = s;
}
-#if defined (__sparc__)
+#if #cpu(sparc)
/* sparc kernel supports console=tty[ab] parameter which is also
* passed to init, so catch it here */
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()
if ((s = getenv("CONSOLE")) != NULL) {
console = s;
}
-#if defined (__sparc__)
+#if #cpu(sparc)
/* sparc kernel supports console=tty[ab] parameter which is also
* passed to init, so catch it here */
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"
"\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
"\tdutmp /var/run/utmp\n";
-static int dutmp_main (int argc, char **argv)
+extern int dutmp_main (int argc, char **argv)
{
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 ...]";
/* ED: sparc termios is broken: revert back to old termio handling. */
#ifdef BB_MORE_TERM
-
-#if defined (__sparc__)
+#if #cpu(sparc)
# define USE_OLD_TERMIO
# include <termio.h>
# include <sys/ioctl.h>
@@ -69,13 +68,13 @@ extern int more_main(int argc, char **argv)
struct stat st;
FILE *file;
- if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) {
- usage (more_usage);
- }
argc--;
argv++;
- while (argc >= 0) {
+ if ( argc > 0 && (strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0) ) {
+ usage (more_usage);
+ }
+ do {
if (argc==0) {
file = stdin;
}
@@ -103,6 +102,9 @@ extern int more_main(int argc, char **argv)
stty(fileno(cin), &new_settings);
(void) signal(SIGINT, gotsig);
+ (void) signal(SIGQUIT, gotsig);
+ (void) signal(SIGTERM, gotsig);
+
#endif
while ((c = getc(file)) != EOF) {
@@ -141,18 +143,17 @@ extern int more_main(int argc, char **argv)
}
if (input=='q')
goto end;
- if (input==' ' && c == '\n' )
+ if (input=='\n' && c == '\n' )
next_page = 1;
- if ( c == '\n' && ++lines == 24 )
+ if ( c == ' ' && ++lines == 24 )
next_page = 1;
putc(c, stdout);
}
fclose(file);
fflush(stdout);
- argc--;
argv++;
- }
+ } while (--argc > 0);
end:
#ifdef BB_MORE_TERM
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 ...]";
/* ED: sparc termios is broken: revert back to old termio handling. */
#ifdef BB_MORE_TERM
-
-#if defined (__sparc__)
+#if #cpu(sparc)
# define USE_OLD_TERMIO
# include <termio.h>
# include <sys/ioctl.h>
@@ -69,13 +68,13 @@ extern int more_main(int argc, char **argv)
struct stat st;
FILE *file;
- if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) {
- usage (more_usage);
- }
argc--;
argv++;
- while (argc >= 0) {
+ if ( argc > 0 && (strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0) ) {
+ usage (more_usage);
+ }
+ do {
if (argc==0) {
file = stdin;
}
@@ -103,6 +102,9 @@ extern int more_main(int argc, char **argv)
stty(fileno(cin), &new_settings);
(void) signal(SIGINT, gotsig);
+ (void) signal(SIGQUIT, gotsig);
+ (void) signal(SIGTERM, gotsig);
+
#endif
while ((c = getc(file)) != EOF) {
@@ -141,18 +143,17 @@ extern int more_main(int argc, char **argv)
}
if (input=='q')
goto end;
- if (input==' ' && c == '\n' )
+ if (input=='\n' && c == '\n' )
next_page = 1;
- if ( c == '\n' && ++lines == 24 )
+ if ( c == ' ' && ++lines == 24 )
next_page = 1;
putc(c, stdout);
}
fclose(file);
fflush(stdout);
- argc--;
argv++;
- }
+ } while (--argc > 0);
end:
#ifdef BB_MORE_TERM
gotsig(0);