Module Name:    src
Committed By:   kre
Date:           Mon Oct 14 08:11:57 UTC 2024

Modified Files:
        src/bin/sh: input.c var.c

Log Message:
#       $NetBSD: Makefile,v 1.123 2023/10/19 04:27:24 mrg Exp $
#       @(#)Makefile    8.4 (Berkeley) 5/5/95

.include <bsd.own.mk>

PROG=   sh
SHSRCS= alias.c arith_token.c arithmetic.c cd.c echo.c error.c eval.c exec.c \
        expand.c histedit.c input.c jobs.c mail.c main.c memalloc.c \
        miscbltin.c mystring.c options.c parser.c redir.c show.c trap.c \
        output.c var.c test.c kill.c syntax.c
GENSRCS=builtins.c init.c nodes.c
GENHDRS=builtins.h nodes.h token.h nodenames.h optinit.h
SRCS=   ${SHSRCS} ${GENSRCS}

DPSRCS+=${GENHDRS}

LDADD+= -ledit -lterminfo
DPADD+= ${LIBEDIT} ${LIBTERMINFO}

# Environment for scripts executed during build.
SCRIPT_ENV= \
        AWK=${TOOL_AWK:Q} \
        MKTEMP=${TOOL_MKTEMP:Q} \
        SED=${TOOL_SED:Q}

CPPFLAGS+=-DSHELL -I. -I${.CURDIR} -I${NETBSDSRCDIR}/lib/libedit
CPPFLAGS+= -DUSE_LRAND48
CPPFLAGS+= -DREJECT_NULS

#XXX: For testing only.
#CPPFLAGS+=-DDEBUG=1
#COPTS+=-g
#CFLAGS+=-funsigned-char
#TARGET_CHARFLAG?= -DTARGET_CHAR="unsigned char" -funsigned-char

# Reproducible build parameters ... export into sh for NETBSD_SHELL setting
.if ${MKREPRO_TIMESTAMP:Uno} != "no"
BUILD_DATE!=    ${TOOL_DATE} -u -r "${MKREPRO_TIMESTAMP}" "+%Y%m%d%H%M%S"
# These are (should be) equivalent, but the 2nd is easier to understand
#CPPFLAGS+= -DBUILD_DATE='"${BUILD_DATE:C/([^0]0?)(00)*$/\1/}Z"'
CPPFLAGS+= -DBUILD_DATE='"${BUILD_DATE:S/00$//:S/00$//:S/00$//}Z"'
.endif

.ifdef SMALLPROG
CPPFLAGS+=-DSMALL
.endif
.ifdef TINYPROG
CPPFLAGS+=-DTINY
.else
SRCS+=printf.c
.endif

.PATH:  ${.CURDIR}/bltin ${NETBSDSRCDIR}/bin/test \
        ${NETBSDSRCDIR}/usr.bin/printf \
        ${NETBSDSRCDIR}/bin/kill

CLEANFILES+= ${GENSRCS} ${GENHDRS} sh.html1
CLEANFILES+= trace.*

token.h: mktokens
        ${_MKTARGET_CREATE}
        ${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC}

.ORDER: builtins.h builtins.c
builtins.h builtins.c: mkbuiltins shell.h builtins.def
        ${_MKTARGET_CREATE}
        ${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC} ${.OBJDIR}
        [ -f builtins.h ]

init.c: mkinit.sh ${SHSRCS}
        ${_MKTARGET_CREATE}
        ${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC}

.ORDER: nodes.h nodes.c
nodes.c nodes.h: mknodes.sh nodetypes nodes.c.pat
        ${_MKTARGET_CREATE}
        ${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC} ${.OBJDIR}
        [ -f nodes.h ]

nodenames.h: mknodenames.sh nodes.h
        ${_MKTARGET_CREATE}
        ${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC} > ${.TARGET}

optinit.h: mkoptions.sh option.list
        ${_MKTARGET_CREATE}
        ${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC} ${.TARGET} ${.OBJDIR}

.if ${USETOOLS} == "yes"
NBCOMPATLIB=   -L${TOOLDIR}/lib -lnbcompat
.endif

SUBDIR.roff+=USD.doc

COPTS.printf.c = -Wno-format-nonliteral
COPTS.jobs.c = -Wno-format-nonliteral
COPTS.var.c = -Wno-format-nonliteral

# XXXGCC12 - only on some targets
COPTS.parser.c+=        ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? 
-Wno-error=clobbered :}

.include <bsd.prog.mk>
.include <bsd.subdir.mk>

${OBJS}: Makefile


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/bin/sh/input.c
cvs rdiff -u -r1.84 -r1.85 src/bin/sh/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/sh/input.c
diff -u src/bin/sh/input.c:1.74 src/bin/sh/input.c:1.75
--- src/bin/sh/input.c:1.74	Sat Aug  3 03:05:58 2024
+++ src/bin/sh/input.c	Mon Oct 14 08:11:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: input.c,v 1.74 2024/08/03 03:05:58 kre Exp $	*/
+/*	$NetBSD: input.c,v 1.75 2024/10/14 08:11:57 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)input.c	8.3 (Berkeley) 6/9/95";
 #else
-__RCSID("$NetBSD: input.c,v 1.74 2024/08/03 03:05:58 kre Exp $");
+__RCSID("$NetBSD: input.c,v 1.75 2024/10/14 08:11:57 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -293,9 +293,15 @@ preadbuffer(void)
 	for (more = 1; more;) {
 		switch (*p) {
 		case '\0':
+#ifdef REJECT_NULS
+			parsenleft = parselleft = 0;
+			error("nul ('\\0') in shell input");
+			/* NOTREACHED */
+#else
 			p++;	/* Skip nul */
 			parsefile->nskip++;
 			goto check;
+#endif
 
 		case '\t':
 		case ' ':
@@ -318,7 +324,9 @@ preadbuffer(void)
 		else
 			q = ++p;
 
- check:
+#ifndef REJECT_NULS
+ check:;
+#endif
 		if (--parselleft <= 0) {
 			parsenleft = q - parsenextc - 1;
 			if (parsenleft < 0)

Index: src/bin/sh/var.c
diff -u src/bin/sh/var.c:1.84 src/bin/sh/var.c:1.85
--- src/bin/sh/var.c:1.84	Sat Jul 13 13:43:58 2024
+++ src/bin/sh/var.c	Mon Oct 14 08:11:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.84 2024/07/13 13:43:58 kre Exp $	*/
+/*	$NetBSD: var.c,v 1.85 2024/10/14 08:11:57 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: var.c,v 1.84 2024/07/13 13:43:58 kre Exp $");
+__RCSID("$NetBSD: var.c,v 1.85 2024/10/14 08:11:57 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -290,6 +290,12 @@ INIT {
 #ifdef BOGUS_NOT_COMMAND
 		" BOGUS_NOT"
 #endif
+#ifdef REJECT_NULS
+		" REJECT_NULS"
+#endif
+#ifdef RESCUEDIR
+		" RESCUE"
+#endif
 		    , VTEXTFIXED|VREADONLY|VNOEXPORT);
 
 	setvar("LINENO", "1", VTEXTFIXED);

Reply via email to