diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/sed/compile.c | 20 | ||||
-rw-r--r-- | usr.bin/sed/process.c | 22 |
2 files changed, 21 insertions, 21 deletions
diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c index 07528611..f0a6c9b 100644 --- a/usr.bin/sed/compile.c +++ b/usr.bin/sed/compile.c @@ -171,14 +171,14 @@ compile_stream(struct s_command **link) } semicolon: EATSPACE(); - if (p) { - if (*p == '#' || *p == '\0') - continue; - else if (*p == ';') { - p++; - goto semicolon; - } - } + if (p) { + if (*p == '#' || *p == '\0') + continue; + else if (*p == ';') { + p++; + goto semicolon; + } + } if ((*link = cmd = malloc(sizeof(struct s_command))) == NULL) err(1, "malloc"); link = &cmd->next; @@ -284,7 +284,7 @@ nonsel: /* Now parse the command */ cmd->t = duptoeol(p, "w command"); if (aflag) cmd->u.fd = -1; - else if ((cmd->u.fd = open(p, + else if ((cmd->u.fd = open(p, O_WRONLY|O_APPEND|O_CREAT|O_TRUNC, DEFFILEMODE)) == -1) err(1, "%s", p); @@ -317,7 +317,7 @@ nonsel: /* Now parse the command */ p++; if (*p == '\0' || *p == '\\') errx(1, -"%lu: %s: substitute pattern can not be delimited by newline or backslash", +"%lu: %s: substitute pattern can not be delimited by newline or backslash", linenum, fname); if ((cmd->u.s = malloc(sizeof(struct s_subst))) == NULL) err(1, "malloc"); diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index bbad994..5baed7a 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -337,14 +337,14 @@ substitute(struct s_command *cp) if (!regexec_e(re, s, 0, 0, psl)) return (0); - SS.len = 0; /* Clean substitute space. */ - slen = psl; - n = cp->u.s->n; + SS.len = 0; /* Clean substitute space. */ + slen = psl; + n = cp->u.s->n; lastempty = 1; - switch (n) { - case 0: /* Global */ - do { + switch (n) { + case 0: /* Global */ + do { if (lastempty || match[0].rm_so != match[0].rm_eo) { /* Locate start of replaced string. */ re_off = match[0].rm_so; @@ -371,7 +371,7 @@ substitute(struct s_command *cp) /* Copy trailing retained string. */ if (slen > 0) cspace(&SS, s, slen, APPEND); - break; + break; default: /* Nth occurrence */ while (--n) { if (match[0].rm_eo == match[0].rm_so) @@ -567,12 +567,12 @@ regsub(SPACE *sp, char *string, char *src) else no = -1; if (no < 0) { /* Ordinary character. */ - if (c == '\\' && (*src == '\\' || *src == '&')) - c = *src++; + if (c == '\\' && (*src == '\\' || *src == '&')) + c = *src++; NEEDSP(1); - *dst++ = c; + *dst++ = c; ++sp->len; - } else if (match[no].rm_so != -1 && match[no].rm_eo != -1) { + } else if (match[no].rm_so != -1 && match[no].rm_eo != -1) { len = match[no].rm_eo - match[no].rm_so; NEEDSP(len); memmove(dst, string + match[no].rm_so, len); |