/[gnats]/gnats/libiberty/setenv.c
ViewVC logotype

Diff of /gnats/libiberty/setenv.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by jsm, Tue Oct 26 07:10:16 1999 UTC revision 1.2 by pdm, Mon Dec 10 23:03:26 2001 UTC
# Line 21  Line 21 
21  #endif  #endif
22    
23  #include "ansidecl.h"  #include "ansidecl.h"
24    #include <sys/types.h> /* For `size_t' */
25    #include <stdio.h>     /* For `NULL' */
26    
27  #include <errno.h>  #include <errno.h>
28  #if !defined(errno) && !defined(HAVE_ERRNO_DECL)  #if !defined(errno) && !defined(HAVE_ERRNO_DECL)
# Line 30  extern int errno; Line 32  extern int errno;
32    
33  #if HAVE_STDLIB_H  #if HAVE_STDLIB_H
34  # include <stdlib.h>  # include <stdlib.h>
 #else  
 #include <sys/types.h> /* For `size_t' */  
 #include <stdio.h>     /* For `NULL' */  
35  #endif  #endif
36  #if HAVE_STRING_H  #if HAVE_STRING_H
37  # include <string.h>  # include <string.h>
# Line 64  setenv (name, value, replace) Line 63  setenv (name, value, replace)
63       const char *value;       const char *value;
64       int replace;       int replace;
65  {  {
66    register char **ep;    register char **ep = 0;
67    register size_t size;    register size_t size;
68    const size_t namelen = strlen (name);    const size_t namelen = strlen (name);
69    const size_t vallen = strlen (value) + 1;    const size_t vallen = strlen (value) + 1;
# Line 73  setenv (name, value, replace) Line 72  setenv (name, value, replace)
72    
73    size = 0;    size = 0;
74    if (__environ != NULL)    if (__environ != NULL)
75      for (ep = __environ; *ep != NULL; ++ep)      {
76        if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')        for (ep = __environ; *ep != NULL; ++ep)
77          break;          if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
78        else            break;
79          ++size;          else
80              ++size;
81        }
82    
83    if (__environ == NULL || *ep == NULL)    if (__environ == NULL || *ep == NULL)
84      {      {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26