SCCS-vsn: usr.bin/sed/compile.c 5.5
SCCS-vsn: usr.bin/sed/extern.h 5.5
SCCS-vsn: usr.bin/sed/main.c 5.6
SCCS-vsn: usr.bin/sed/process.c 5.8
-static char sccsid[] = "@(#)compile.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)compile.c 5.5 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
static char *duptoeol __P((char *));
static struct s_command
*findlabel __P((struct s_command *, struct s_command *));
static char *duptoeol __P((char *));
static struct s_command
*findlabel __P((struct s_command *, struct s_command *));
-static void fixuplabel __P((struct s_command *, struct s_command *));
+static void fixuplabel __P((struct s_command *, struct s_command *,
+ struct s_command *));
/*
* Command specification. This is used to drive the command parser.
/*
* Command specification. This is used to drive the command parser.
compile()
{
*compile_stream(NULL, &prog, NULL) = NULL;
compile()
{
*compile_stream(NULL, &prog, NULL) = NULL;
- fixuplabel(prog, prog);
+ fixuplabel(prog, prog, NULL);
appends = xmalloc(sizeof(struct s_appends) * appendnum);
match = xmalloc((maxnsub + 1) * sizeof(regmatch_t));
}
appends = xmalloc(sizeof(struct s_appends) * appendnum);
match = xmalloc((maxnsub + 1) * sizeof(regmatch_t));
}
* TODO: Remove } nodes
*/
static void
* TODO: Remove } nodes
*/
static void
-fixuplabel(root, cp)
- struct s_command *root, *cp;
+fixuplabel(root, cp, end)
+ struct s_command *root, *cp, *end;
- for (; cp; cp = cp->next)
+ for (; cp != end; cp = cp->next)
switch (cp->code) {
case ':':
if (findlabel(cp, root))
switch (cp->code) {
case ':':
if (findlabel(cp, root))
cp->u.c = cp2;
break;
case '{':
cp->u.c = cp2;
break;
case '{':
- fixuplabel(root, cp->u.c);
+ fixuplabel(root, cp->u.c, cp->next);
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)extern.h 5.4 (Berkeley) %G%
+ * @(#)extern.h 5.5 (Berkeley) %G%
*/
extern struct s_command *prog;
*/
extern struct s_command *prog;
char *strregerror __P((int, regex_t *));
void *xmalloc __P((u_int));
void *xrealloc __P((void *, u_int));
char *strregerror __P((int, regex_t *));
void *xmalloc __P((u_int));
void *xrealloc __P((void *, u_int));
-void cfclose __P((struct s_command *));
+void cfclose __P((struct s_command *, struct s_command *));
void cspace __P((SPACE *, char *, size_t, enum e_spflag));
void cspace __P((SPACE *, char *, size_t, enum e_spflag));
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c 5.6 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
else
add_file(NULL);
process();
else
add_file(NULL);
process();
if (fclose(stdout))
err(FATAL, "stdout: %s", strerror(errno));
exit (0);
if (fclose(stdout))
err(FATAL, "stdout: %s", strerror(errno));
exit (0);
-static char sccsid[] = "@(#)process.c 5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)process.c 5.8 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
* Close all cached opened files and report any errors
*/
void
* Close all cached opened files and report any errors
*/
void
-cfclose(cp)
- register struct s_command *cp;
+cfclose(cp, end)
+ register struct s_command *cp, *end;
- for (; cp != NULL; cp = cp->next)
+ for (; cp != end; cp = cp->next)
switch(cp->code) {
case 's':
if (cp->u.s->wfd != -1 && close(cp->u.s->wfd))
switch(cp->code) {
case 's':
if (cp->u.s->wfd != -1 && close(cp->u.s->wfd))
cp->u.fd = -1;
break;
case '{':
cp->u.fd = -1;
break;
case '{':
+ cfclose(cp->u.c, cp->next);