diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-29 23:09:13 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-29 23:09:13 +0000 |
commit | 7f1acfdb8928de69bf02db6cf217f0f3b4af45ea (patch) | |
tree | 752654d9a3ef967d5409600962e31bea5cae14fc /editors | |
parent | 24d8e7d787aa1940030a1beaabdd4388588ca512 (diff) | |
download | busybox-7f1acfdb8928de69bf02db6cf217f0f3b4af45ea.tar.gz |
More stuf. sed works.
Diffstat (limited to 'editors')
-rw-r--r-- | editors/sed.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/editors/sed.c b/editors/sed.c index 0df53a7f8..f0a6a3b48 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -57,7 +57,8 @@ extern int sed_main (int argc, char **argv) char *cp; int ignoreCase=FALSE; int foundOne=FALSE; - int noprintFlag=FALSE; + int printFlag=FALSE; + int quietFlag=FALSE; int stopNow; char *haystack; @@ -75,7 +76,7 @@ extern int sed_main (int argc, char **argv) while (*++cp && stopNow==FALSE) switch (*cp) { case 'n': - noprintFlag = TRUE; + quietFlag = TRUE; break; case 'e': if (*(cp+1)==0 && --argc < 0) { @@ -113,6 +114,23 @@ extern int sed_main (int argc, char **argv) break; } *pos=0; + if (pos+2 != 0) { + while (*++pos) { + fprintf(stderr, "pos='%s'\n", pos); + switch (*pos) { + case 'i': + ignoreCase=TRUE; + break; + case 'p': + printFlag=TRUE; + break; + case 'g': + break; + default: + usage( sed_usage); + } + } + } } cp++; } @@ -135,13 +153,13 @@ extern int sed_main (int argc, char **argv) continue; } - haystack = (char*)malloc( BUF_SIZE); - while (fgets (haystack, BUF_SIZE-1, fp)) { + haystack = (char*)malloc( 1024); + while (fgets (haystack, 1023, fp)) { foundOne = replace_match(haystack, needle, newNeedle, ignoreCase); - if (noprintFlag==TRUE && foundOne==TRUE) - fputs (haystack, stdout); - else + if (foundOne==TRUE && printFlag==TRUE) + fputs (haystack, stdout); + if (quietFlag==FALSE) fputs (haystack, stdout); /* Avoid any mem leaks */ free(haystack); |