comparison lib/userspec.c @ 432:a56993d69333

(parse_user_spec): Use strchr, not index. [!HAVE_STRING_H]: Define strchr in terms of index, not the other way around.
author Jim Meyering <jim@meyering.net>
date Sat, 13 May 1995 13:25:42 +0000
parents f9fa66a3a613
children 7e3e0dd559c7
comparison
equal deleted inserted replaced
431:a13a90e8681b 432:a56993d69333
20 #ifdef HAVE_CONFIG_H 20 #ifdef HAVE_CONFIG_H
21 #include <config.h> 21 #include <config.h>
22 #endif 22 #endif
23 23
24 #ifdef __GNUC__ 24 #ifdef __GNUC__
25 #define alloca __builtin_alloca 25 # define alloca __builtin_alloca
26 #else 26 #else
27 #ifdef HAVE_ALLOCA_H 27 # ifdef HAVE_ALLOCA_H
28 #include <alloca.h> 28 # include <alloca.h>
29 #else 29 # else
30 #ifdef _AIX 30 # ifdef _AIX
31 #pragma alloca 31 #pragma alloca
32 #else 32 # else
33 char *alloca (); 33 char *alloca ();
34 #endif 34 # endif
35 #endif 35 # endif
36 #endif 36 #endif
37 37
38 #include <stdio.h> 38 #include <stdio.h>
39 #include <sys/types.h> 39 #include <sys/types.h>
40 #include <pwd.h> 40 #include <pwd.h>
41 #include <grp.h> 41 #include <grp.h>
42 42
43 #if defined(STDC_HEADERS) || defined(HAVE_STRING_H) 43 #ifdef HAVE_STRING_H
44 #include <string.h> 44 # include <string.h>
45 #ifndef index
46 #define index strchr
47 #endif
48 #else 45 #else
49 #include <strings.h> 46 # include <strings.h>
47 # ifndef strchr
48 # define strchr index
49 # endif
50 #endif 50 #endif
51 51
52 #ifdef STDC_HEADERS 52 #ifdef STDC_HEADERS
53 #include <stdlib.h> 53 # include <stdlib.h>
54 #endif 54 #endif
55 55
56 #ifdef HAVE_UNISTD_H 56 #ifdef HAVE_UNISTD_H
57 #include <unistd.h> 57 # include <unistd.h>
58 #endif 58 #endif
59 59
60 #ifndef _POSIX_VERSION 60 #ifndef _POSIX_VERSION
61 struct passwd *getpwnam (); 61 struct passwd *getpwnam ();
62 struct group *getgrnam (); 62 struct group *getgrnam ();
129 groupname = NULL; 129 groupname = NULL;
130 130
131 V_STRDUP (spec, spec_arg); 131 V_STRDUP (spec, spec_arg);
132 132
133 /* Find the separator if there is one. */ 133 /* Find the separator if there is one. */
134 separator = index (spec, ':'); 134 separator = strchr (spec, ':');
135 if (separator == NULL) 135 if (separator == NULL)
136 separator = index (spec, '.'); 136 separator = strchr (spec, '.');
137 137
138 /* Replace separator with a NUL. */ 138 /* Replace separator with a NUL. */
139 if (separator != NULL) 139 if (separator != NULL)
140 *separator = '\0'; 140 *separator = '\0';
141 141