57 lines
1.2 KiB
Diff
57 lines
1.2 KiB
Diff
From 756acc92c9d6bea9929d9105207e081054be05fb Mon Sep 17 00:00:00 2001
|
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
|
Date: Mon, 6 Nov 2023 11:44:08 -0800
|
|
Subject: [PATCH] Some constifying.
|
|
|
|
---
|
|
filename.c | 15 ++++++++-------
|
|
1 file changed, 8 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/filename.c b/filename.c
|
|
index 2ce7070..482d264 100644
|
|
--- a/filename.c
|
|
+++ b/filename.c
|
|
@@ -142,10 +142,11 @@ metachar(c)
|
|
shell_quote(s)
|
|
char *s;
|
|
{
|
|
- char *p;
|
|
+ constant char *p;
|
|
+ char *np;
|
|
char *newstr;
|
|
int len;
|
|
- char *esc = get_meta_escape();
|
|
+ constant char *esc = get_meta_escape();
|
|
int esclen = (int) strlen(esc);
|
|
int use_quotes = 0;
|
|
int have_quotes = 0;
|
|
@@ -189,7 +190,7 @@ shell_quote(s)
|
|
/*
|
|
* Allocate and construct the new string.
|
|
*/
|
|
- newstr = p = (char *) ecalloc(len, sizeof(char));
|
|
+ newstr = np = (char *) ecalloc(len, sizeof(char));
|
|
if (use_quotes)
|
|
{
|
|
SNPRINTF3(newstr, len, "%c%s%c", openquote, s, closequote);
|
|
@@ -202,12 +203,12 @@ shell_quote(s)
|
|
/*
|
|
* Add the escape char.
|
|
*/
|
|
- strcpy(p, esc);
|
|
- p += esclen;
|
|
+ strcpy(np, esc);
|
|
+ np += esclen;
|
|
}
|
|
- *p++ = *s++;
|
|
+ *np++ = *s++;
|
|
}
|
|
- *p = '\0';
|
|
+ *np = '\0';
|
|
}
|
|
return (newstr);
|
|
}
|
|
--
|
|
2.43.0
|
|
|