Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/csh sprinkle const, no functional change intended.
details: https://anonhg.NetBSD.org/src/rev/608f0ccb128a
branches: trunk
changeset: 783537:608f0ccb128a
user: christos <christos%NetBSD.org@localhost>
date: Thu Dec 27 21:19:20 2012 +0000
description:
sprinkle const, no functional change intended.
diffstat:
bin/csh/extern.h | 36 +++++++++++++-------------
bin/csh/str.c | 73 +++++++++++++++++++++++++++++--------------------------
2 files changed, 56 insertions(+), 53 deletions(-)
diffs (282 lines):
diff -r 1cc1cd1b147e -r 608f0ccb128a bin/csh/extern.h
--- a/bin/csh/extern.h Thu Dec 27 21:17:47 2012 +0000
+++ b/bin/csh/extern.h Thu Dec 27 21:19:20 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.24 2011/11/09 19:16:01 christos Exp $ */
+/* $NetBSD: extern.h,v 1.25 2012/12/27 21:19:20 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -307,27 +307,27 @@
* str.c:
*/
#ifdef SHORT_STRINGS
-Char *s_strchr(Char *, int);
-Char *s_strrchr(Char *, int);
-Char *s_strcat(Char *, Char *);
+Char *s_strchr(const Char *, int);
+Char *s_strrchr(const Char *, int);
+Char *s_strcat(Char *, const Char *);
#ifdef NOTUSED
-Char *s_strncat(Char *, Char *, size_t);
+Char *s_strncat(Char *, const Char *, size_t);
#endif
-Char *s_strcpy(Char *, Char *);
-Char *s_strncpy(Char *, Char *, size_t);
-Char *s_strspl(Char *, Char *);
-size_t s_strlen(Char *);
-int s_strcmp(Char *, Char *);
-int s_strncmp(Char *, Char *, size_t);
-Char *s_strsave(Char *);
-Char *s_strend(Char *);
-Char *s_strstr(Char *, Char *);
+Char *s_strcpy(Char *, const Char *);
+Char *s_strncpy(Char *, const Char *, size_t);
+Char *s_strspl(const Char *, const Char *);
+size_t s_strlen(const Char *);
+int s_strcmp(const Char *, const Char *);
+int s_strncmp(const Char *, const Char *, size_t);
+Char *s_strsave(const Char *);
+Char *s_strend(const Char *);
+Char *s_strstr(const Char *, const Char *);
Char *str2short(const char *);
Char **blk2short(char **);
-char *short2str(Char *);
-char **short2blk(Char **);
+char *short2str(const Char *);
+char **short2blk(Char * const *);
#endif
-char *short2qstr(Char *);
-char *vis_str(Char *);
+char *short2qstr(const Char *);
+char *vis_str(const Char *);
#endif /* !_EXTERN_H_ */
diff -r 1cc1cd1b147e -r 608f0ccb128a bin/csh/str.c
--- a/bin/csh/str.c Thu Dec 27 21:17:47 2012 +0000
+++ b/bin/csh/str.c Thu Dec 27 21:19:20 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: str.c,v 1.13 2003/08/07 09:05:07 agc Exp $ */
+/* $NetBSD: str.c,v 1.14 2012/12/27 21:19:20 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)str.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: str.c,v 1.13 2003/08/07 09:05:07 agc Exp $");
+__RCSID("$NetBSD: str.c,v 1.14 2012/12/27 21:19:20 christos Exp $");
#endif
#endif /* not lint */
@@ -75,7 +75,7 @@
}
char **
-short2blk(Char **src)
+short2blk(Char *const *src)
{
char **dst, **sdst;
size_t n;
@@ -125,7 +125,7 @@
}
char *
-short2str(Char *src)
+short2str(const Char *src)
{
static char *sdst = NULL;
static size_t dstsize = 0;
@@ -155,7 +155,7 @@
}
Char *
-s_strcpy(Char *dst, Char *src)
+s_strcpy(Char *dst, const Char *src)
{
Char *sdst;
@@ -166,7 +166,7 @@
}
Char *
-s_strncpy(Char *dst, Char *src, size_t n)
+s_strncpy(Char *dst, const Char *src, size_t n)
{
Char *sdst;
@@ -185,7 +185,7 @@
}
Char *
-s_strcat(Char *dst, Char *src)
+s_strcat(Char *dst, const Char *src)
{
short *sdst;
@@ -226,30 +226,30 @@
#endif
Char *
-s_strchr(Char *str, int ch)
+s_strchr(const Char *str, int ch)
{
do
if (*str == ch)
- return (str);
+ return __UNCONST(str);
while (*str++);
return (NULL);
}
Char *
-s_strrchr(Char *str, int ch)
+s_strrchr(const Char *str, int ch)
{
- Char *rstr;
+ const Char *rstr;
rstr = NULL;
do
if (*str == ch)
rstr = str;
while (*str++);
- return (rstr);
+ return __UNCONST(rstr);
}
size_t
-s_strlen(Char *str)
+s_strlen(const Char *str)
{
size_t n;
@@ -259,7 +259,7 @@
}
int
-s_strcmp(Char *str1, Char *str2)
+s_strcmp(const Char *str1, const Char *str2)
{
for (; *str1 && *str1 == *str2; str1++, str2++)
continue;
@@ -279,7 +279,7 @@
}
int
-s_strncmp(Char *str1, Char *str2, size_t n)
+s_strncmp(const Char *str1, const Char *str2, size_t n)
{
if (n == 0)
return (0);
@@ -305,24 +305,26 @@
}
Char *
-s_strsave(Char *s)
+s_strsave(const Char *s)
{
- Char *n, *p;
+ const Char *p;
+ Char *n;
if (s == 0)
s = STRNULL;
for (p = s; *p++;)
continue;
- n = p = (Char *)xmalloc((size_t)((p - s) * sizeof(Char)));
- while ((*p++ = *s++) != '\0')
+ p = n = xmalloc((size_t)((p - s) * sizeof(Char)));
+ while ((*n++ = *s++) != '\0')
continue;
- return (n);
+ return __UNCONST(p);
}
Char *
-s_strspl(Char *cp, Char *dp)
+s_strspl(const Char *cp, const Char *dp)
{
- Char *ep, *p, *q;
+ Char *ep, *d;
+ const Char *p, *q;
if (!cp)
cp = STRNULL;
@@ -332,34 +334,34 @@
continue;
for (q = dp; *q++;)
continue;
- ep = (Char *)xmalloc((size_t)(((p - cp) + (q - dp) - 1) * sizeof(Char)));
- for (p = ep, q = cp; (*p++ = *q++) != '\0';)
+ ep = xmalloc((size_t)(((p - cp) + (q - dp) - 1) * sizeof(Char)));
+ for (d = ep, q = cp; (*d++ = *q++) != '\0';)
continue;
- for (p--, q = dp; (*p++ = *q++) != '\0';)
+ for (d--, q = dp; (*d++ = *q++) != '\0';)
continue;
return (ep);
}
Char *
-s_strend(Char *cp)
+s_strend(const Char *cp)
{
if (!cp)
- return (cp);
+ return __UNCONST(cp);
while (*cp)
cp++;
- return (cp);
+ return __UNCONST(cp);
}
Char *
-s_strstr(Char *s, Char *t)
+s_strstr(const Char *s, const Char *t)
{
do {
- Char *ss = s;
- Char *tt = t;
+ const Char *ss = s;
+ const Char *tt = t;
do
if (*tt == '\0')
- return (s);
+ return __UNCONST(s);
while (*ss++ == *tt++);
} while (*s++ != '\0');
return (NULL);
@@ -367,7 +369,7 @@
#endif /* SHORT_STRINGS */
char *
-short2qstr(Char *src)
+short2qstr(const Char *src)
{
static char *sdst = NULL;
static size_t dstsize = 0;
@@ -383,6 +385,7 @@
dst = sdst;
edst = &dst[dstsize];
while (*src) {
+
if (*src & QUOTE) {
*dst++ = '\\';
if (dst == edst) {
@@ -410,11 +413,11 @@
* XXX: Should we worry about QUOTE'd chars?
*/
char *
-vis_str(Char *cp)
+vis_str(const Char *cp)
{
static char *sdst = NULL;
static size_t dstsize = 0;
- Char *dp;
+ const Char *dp;
size_t n;
if (cp == NULL)
Home |
Main Index |
Thread Index |
Old Index