Zap c_index() and c_rindex(). Bruce prefers these to implicitly convert
a const into a non-const as they do in libc. I feel that defeating the type checking like that quite evil, but that's the way it is.
This commit is contained in:
parent
aa6be122fd
commit
4537138981
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=54411
@ -345,7 +345,7 @@ linker_make_file(const char* pathname, void* priv, struct linker_file_ops* ops)
|
||||
int namelen;
|
||||
const char *filename;
|
||||
|
||||
filename = c_rindex(pathname, '/');
|
||||
filename = rindex(pathname, '/');
|
||||
if (filename && filename[1])
|
||||
filename++;
|
||||
else
|
||||
@ -993,7 +993,7 @@ linker_search_path(const char *name)
|
||||
enum vtype type;
|
||||
|
||||
/* qualified at all? */
|
||||
if (c_index(name, '/'))
|
||||
if (index(name, '/'))
|
||||
return(linker_strdup(name));
|
||||
|
||||
/* traverse the linker path */
|
||||
|
@ -38,27 +38,19 @@
|
||||
|
||||
char *
|
||||
index(p, ch)
|
||||
char *p;
|
||||
int ch;
|
||||
{
|
||||
for (;; ++p) {
|
||||
if (*p == ch)
|
||||
return(p);
|
||||
if (!*p)
|
||||
return(NULL);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
const char *
|
||||
c_index(p, ch)
|
||||
const char *p;
|
||||
int ch;
|
||||
{
|
||||
for (;; ++p) {
|
||||
if (*p == ch)
|
||||
return(p);
|
||||
if (!*p)
|
||||
union {
|
||||
const char *cp;
|
||||
char *p;
|
||||
} u;
|
||||
|
||||
u.cp = p;
|
||||
for (;; ++u.p) {
|
||||
if (*u.p == ch)
|
||||
return(u.p);
|
||||
if (!*u.p)
|
||||
return(NULL);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
|
@ -38,31 +38,20 @@
|
||||
|
||||
char *
|
||||
rindex(p, ch)
|
||||
char *p;
|
||||
int ch;
|
||||
{
|
||||
char *save;
|
||||
|
||||
for (save = NULL;; ++p) {
|
||||
if (*p == ch)
|
||||
save = p;
|
||||
if (!*p)
|
||||
return(save);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
const char *
|
||||
c_rindex(p, ch)
|
||||
const char *p;
|
||||
int ch;
|
||||
{
|
||||
const char *save;
|
||||
union {
|
||||
const char *cp;
|
||||
char *p;
|
||||
} u;
|
||||
char *save;
|
||||
|
||||
for (save = NULL;; ++p) {
|
||||
if (*p == ch)
|
||||
save = p;
|
||||
if (!*p)
|
||||
u.cp = p;
|
||||
for (save = NULL;; ++u.p) {
|
||||
if (*u.p == ch)
|
||||
save = u.p;
|
||||
if (!*u.p)
|
||||
return(save);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
|
@ -73,10 +73,8 @@ int locc __P((int, char *, u_int));
|
||||
void qsort __P((void *base, size_t nmemb, size_t size,
|
||||
int (*compar)(const void *, const void *)));
|
||||
u_long random __P((void));
|
||||
char *index __P((char *, int));
|
||||
char *rindex __P((char *, int));
|
||||
const char *c_index __P((const char *, int));
|
||||
const char *c_rindex __P((const char *, int));
|
||||
char *index __P((const char *, int));
|
||||
char *rindex __P((const char *, int));
|
||||
int scanc __P((u_int, const u_char *, const u_char *, int));
|
||||
int skpc __P((int, int, char *));
|
||||
void srandom __P((u_long));
|
||||
|
Loading…
Reference in New Issue
Block a user