diff options
| author | Yaroslav Tykhiy <ytykhiy@gmail.com> | 2007-06-12 12:05:24 +0000 |
|---|---|---|
| committer | Yaroslav Tykhiy <ytykhiy@gmail.com> | 2007-06-12 12:05:24 +0000 |
| commit | 26a5710c40b83c69c0193be82ffc100b2159fe65 (patch) | |
| tree | 1fc5aa0c7aed36e9c671f4752d0a3f9b2ac0c3fd /usr.bin/sed | |
| parent | 7cd3f6159bf391f641b6e56a172ced8a5ce61a12 (diff) | |
Notes
Diffstat (limited to 'usr.bin/sed')
| -rw-r--r-- | usr.bin/sed/extern.h | 2 | ||||
| -rw-r--r-- | usr.bin/sed/main.c | 2 | ||||
| -rw-r--r-- | usr.bin/sed/process.c | 18 |
3 files changed, 18 insertions, 4 deletions
diff --git a/usr.bin/sed/extern.h b/usr.bin/sed/extern.h index cb4ae163853f..f2bd71bacfa4 100644 --- a/usr.bin/sed/extern.h +++ b/usr.bin/sed/extern.h @@ -52,5 +52,5 @@ char *cu_fgets(char *, int, int *); int mf_fgets(SPACE *, enum e_spflag); int lastline(void); void process(void); -void resetranges(void); +void resetstate(void); char *strregerror(int, regex_t *); diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index e4e426f7c7db..e17741f6257d 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -390,7 +390,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) outfname = tmpfname; if (!ispan) { linenum = 0; - resetranges(); + resetstate(); } } else { outfile = stdout; diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index c8b62c095dbd..ca21ec7e66b9 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -234,6 +234,12 @@ redirect: err(1, "%s", cp->t); break; case 'x': + /* + * If the hold space is null, make it empty + * but not null. Otherwise the pattern space + * will become null after the swap, which is + * an abnormal condition. + */ if (hs == NULL) cspace(&HS, "", 0, REPLACE); tspace = PS; @@ -317,16 +323,24 @@ applies(struct s_command *cp) } /* - * Reset all inrange markers. + * Reset the sed processor to its initial state. */ void -resetranges(void) +resetstate(void) { struct s_command *cp; + /* + * Reset all inrange markers. + */ for (cp = prog; cp; cp = cp->code == '{' ? cp->u.c : cp->next) if (cp->a2) cp->inrange = 0; + + /* + * Clear out the hold space. + */ + cspace(&HS, "", 0, REPLACE); } /* |
