Module Name:    src
Committed By:   kre
Date:           Sat Aug  3 03:05:58 UTC 2024

Modified Files:
        src/bin/sh: eval.c eval.h input.c input.h

Log Message:
Change the "string" argument to evalstring() and setinputstring()
from being "char *" to being "const char *".

This is needed for a forthcoming change which needs to pass a const char *
to evalstring (and through it to setinputstring) and be assured that
nothing will alter the characters in the string supplied.

This is (aside from the additional compile time protection provided)
a no-op change, all evalstring() does with its string is pass it to
setinputstring() and all that does with it is determine its length
(strlen() which expects a const char *) and assign the string pointer
to parsenextc which is already a const char * - there never has been
any reason for these two functions to not include the "const" in
the arg declaration -- except that when originally written (early
1990's) I suspect "const" either didn't exist at all, or wasn't
supported by relevant compilers.

NFCI.   Most probably (though I didn't check) no binary change at all.


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/bin/sh/eval.c
cvs rdiff -u -r1.23 -r1.24 src/bin/sh/eval.h
cvs rdiff -u -r1.73 -r1.74 src/bin/sh/input.c
cvs rdiff -u -r1.21 -r1.22 src/bin/sh/input.h

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/eval.c
diff -u src/bin/sh/eval.c:1.192 src/bin/sh/eval.c:1.193
--- src/bin/sh/eval.c:1.192	Sat Jun 15 05:18:48 2024
+++ src/bin/sh/eval.c	Sat Aug  3 03:05:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: eval.c,v 1.192 2024/06/15 05:18:48 kre Exp $	*/
+/*	$NetBSD: eval.c,v 1.193 2024/08/03 03:05:58 kre Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)eval.c	8.9 (Berkeley) 6/8/95";
 #else
-__RCSID("$NetBSD: eval.c,v 1.192 2024/06/15 05:18:48 kre Exp $");
+__RCSID("$NetBSD: eval.c,v 1.193 2024/08/03 03:05:58 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -213,7 +213,7 @@ evalcmd(int argc, char **argv)
  */
 
 void
-evalstring(char *s, int flag)
+evalstring(const char *s, int flag)
 {
 	union node *n;
 	struct stackmark smark;

Index: src/bin/sh/eval.h
diff -u src/bin/sh/eval.h:1.23 src/bin/sh/eval.h:1.24
--- src/bin/sh/eval.h:1.23	Mon Feb  4 11:16:41 2019
+++ src/bin/sh/eval.h	Sat Aug  3 03:05:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: eval.h,v 1.23 2019/02/04 11:16:41 kre Exp $	*/
+/*	$NetBSD: eval.h,v 1.24 2024/08/03 03:05:58 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -47,7 +47,7 @@ struct backcmd {		/* result of evalbackc
 	struct job *jp;		/* job structure for command */
 };
 
-void evalstring(char *, int);
+void evalstring(const char *, int);
 union node;	/* BLETCH for ansi C */
 void evaltree(union node *, int);
 void evalbackcmd(union node *, struct backcmd *);

Index: src/bin/sh/input.c
diff -u src/bin/sh/input.c:1.73 src/bin/sh/input.c:1.74
--- src/bin/sh/input.c:1.73	Sat Jul 13 13:43:58 2024
+++ src/bin/sh/input.c	Sat Aug  3 03:05:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: input.c,v 1.73 2024/07/13 13:43:58 kre Exp $	*/
+/*	$NetBSD: input.c,v 1.74 2024/08/03 03:05:58 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.73 2024/07/13 13:43:58 kre Exp $");
+__RCSID("$NetBSD: input.c,v 1.74 2024/08/03 03:05:58 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -571,7 +571,7 @@ setinputfd(int fd, int push)
  */
 
 void
-setinputstring(char *string, int push, int line1)
+setinputstring(const char *string, int push, int line1)
 {
 
 	INTOFF;

Index: src/bin/sh/input.h
diff -u src/bin/sh/input.h:1.21 src/bin/sh/input.h:1.22
--- src/bin/sh/input.h:1.21	Sun Aug 19 23:50:27 2018
+++ src/bin/sh/input.h	Sat Aug  3 03:05:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: input.h,v 1.21 2018/08/19 23:50:27 kre Exp $	*/
+/*	$NetBSD: input.h,v 1.22 2024/08/03 03:05:58 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -59,7 +59,7 @@ void pushstring(const char *, int, struc
 void popstring(void);
 void setinputfile(const char *, int);
 void setinputfd(int, int);
-void setinputstring(char *, int, int);
+void setinputstring(const char *, int, int);
 void popfile(void);
 struct parsefile *getcurrentfile(void);
 void popfilesupto(struct parsefile *);

Reply via email to