some C99 changes

Instead of using index() macro defined to strchr, use C99 strchr.
Instead of using rindex() macro defined to strrchr, use C99 strrchr.

If you want to try building on a platform that doesn't offer those
two functions, these are available:
    define NOT_C99       /* to make some non-C99 code available */
    define NEED_INDEX    /* to define a macro for index()  */
    define NEED_RINDX    /* to define a macro for rindex() */
This commit is contained in:
nhmall
2022-10-29 10:54:25 -04:00
parent 943c1bc3c3
commit 99a93fe50b
99 changed files with 463 additions and 460 deletions

View File

@@ -117,13 +117,13 @@ vms_creat(const char *file, unsigned int mode)
{
char filnambuf[BUFSIZ]; /*(not BUFSZ)*/
if (index(file, ';')) {
if (strchr(file, ';')) {
/* assumes remove or delete, not vms_unlink */
if (!unlink(file)) {
(void) sleep(1);
(void) unlink(file);
}
} else if (!index(file, '.')) {
} else if (!strchr(file, '.')) {
/* force some punctuation to be present */
file = strcat(strcpy(filnambuf, file), ".");
}
@@ -142,7 +142,7 @@ vms_open(const char *file, int flags, unsigned int mode)
char filnambuf[BUFSIZ]; /*(not BUFSZ)*/
int fd;
if (!index(file, '.') && !index(file, ';')) {
if (!strchr(file, '.') && !strchr(file, ';')) {
/* force some punctuation to be present to make sure that
the file name can't accidentally match a logical name */
file = strcat(strcpy(filnambuf, file), ";0");
@@ -163,7 +163,7 @@ vms_fopen(const char *file, const char *mode)
char filnambuf[BUFSIZ]; /*(not BUFSZ)*/
FILE *fp;
if (!index(file, '.') && !index(file, ';')) {
if (!strchr(file, '.') && !strchr(file, ';')) {
/* force some punctuation to be present to make sure that
the file name can't accidentally match a logical name */
file = strcat(strcpy(filnambuf, file), ";0");

View File

@@ -392,8 +392,8 @@ check_user_string(const char *userlist)
return TRUE;
/* doesn't match full word, but maybe we got a false hit when
looking for "jane" in the list "janedoe jane" so keep going */
p = index(sptr + 1, ' ');
q = index(sptr + 1, ',');
p = strchr(sptr + 1, ' ');
q = strchr(sptr + 1, ',');
if (!p || (q && q < p))
p = q;
if (!p)