fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / argz / envz_entry.c
blob3d1986ba7c3999cf4841053a1a1981a47c02c0cd
1 /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
3 * Permission to use, copy, modify, and distribute this software
4 * is freely granted, provided that this notice is preserved.
5 */
7 #include <errno.h>
8 #include <sys/types.h>
9 #include <string.h>
10 #include <stdlib.h>
11 #include <envz.h>
13 #include "buf_findstr.h"
15 char *
16 _DEFUN (envz_entry, (envz, envz_len, name),
17 const char *envz _AND
18 size_t envz_len _AND
19 const char *name)
21 char *buf_ptr = (char *)envz;
22 size_t buf_len = envz_len;
24 while(buf_len)
26 if (_buf_findstr(name, &buf_ptr, &buf_len))
28 if (buf_ptr)
30 if (*buf_ptr == '=' || *buf_ptr == '\0')
32 buf_ptr--;
34 /* Move buf_ptr back to start of entry. */
35 while(*buf_ptr != '\0' && buf_ptr != envz) buf_ptr--;
37 if(*buf_ptr == '\0')
38 buf_ptr++;
40 return (char *)buf_ptr;
45 return 0;