diff options
Diffstat (limited to 'src/lib/libc/stdlib/getenv.c')
-rw-r--r-- | src/lib/libc/stdlib/getenv.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/lib/libc/stdlib/getenv.c b/src/lib/libc/stdlib/getenv.c index 09d47f2149..d1487a7afc 100644 --- a/src/lib/libc/stdlib/getenv.c +++ b/src/lib/libc/stdlib/getenv.c | |||
@@ -33,27 +33,13 @@ | |||
33 | 33 | ||
34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | /*static char *sccsid = "from: @(#)getenv.c 5.8 (Berkeley) 2/23/91";*/ | 35 | /*static char *sccsid = "from: @(#)getenv.c 5.8 (Berkeley) 2/23/91";*/ |
36 | static char *rcsid = "$Id: getenv.c,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $"; | 36 | static char *rcsid = "$Id: getenv.c,v 1.2 1996/03/25 22:16:38 tholo Exp $"; |
37 | #endif /* LIBC_SCCS and not lint */ | 37 | #endif /* LIBC_SCCS and not lint */ |
38 | 38 | ||
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | #include <string.h> | 40 | #include <string.h> |
41 | 41 | ||
42 | /* | 42 | /* |
43 | * getenv -- | ||
44 | * Returns ptr to value associated with name, if any, else NULL. | ||
45 | */ | ||
46 | char * | ||
47 | getenv(name) | ||
48 | const char *name; | ||
49 | { | ||
50 | int offset; | ||
51 | char *__findenv(); | ||
52 | |||
53 | return(__findenv(name, &offset)); | ||
54 | } | ||
55 | |||
56 | /* | ||
57 | * __findenv -- | 43 | * __findenv -- |
58 | * Returns pointer to value associated with name, if any, else NULL. | 44 | * Returns pointer to value associated with name, if any, else NULL. |
59 | * Sets offset to be the offset of the name/value combination in the | 45 | * Sets offset to be the offset of the name/value combination in the |
@@ -64,14 +50,15 @@ getenv(name) | |||
64 | */ | 50 | */ |
65 | char * | 51 | char * |
66 | __findenv(name, offset) | 52 | __findenv(name, offset) |
67 | register char *name; | 53 | register const char *name; |
68 | int *offset; | 54 | int *offset; |
69 | { | 55 | { |
70 | extern char **environ; | 56 | extern char **environ; |
71 | register int len; | 57 | register int len; |
72 | register char **P, *C; | 58 | register char **P, *C; |
59 | register const char *cp; | ||
73 | 60 | ||
74 | for (C = name, len = 0; *C && *C != '='; ++C, ++len); | 61 | for (cp = name, len = 0; *cp != '\0' && *cp != '='; ++cp, ++len); |
75 | for (P = environ; *P; ++P) | 62 | for (P = environ; *P; ++P) |
76 | if (!strncmp(*P, name, len)) | 63 | if (!strncmp(*P, name, len)) |
77 | if (*(C = *P + len) == '=') { | 64 | if (*(C = *P + len) == '=') { |
@@ -80,3 +67,17 @@ __findenv(name, offset) | |||
80 | } | 67 | } |
81 | return(NULL); | 68 | return(NULL); |
82 | } | 69 | } |
70 | |||
71 | /* | ||
72 | * getenv -- | ||
73 | * Returns ptr to value associated with name, if any, else NULL. | ||
74 | */ | ||
75 | char * | ||
76 | getenv(name) | ||
77 | const char *name; | ||
78 | { | ||
79 | int offset; | ||
80 | char *__findenv(); | ||
81 | |||
82 | return(__findenv(name, &offset)); | ||
83 | } | ||