OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [argz/] [envz_strip.c] - Blame information for rev 461

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* Copyright (C) 2002 by  Red Hat, Incorporated. All rights reserved.
2
 *
3
 * Permission to use, copy, modify, and distribute this software
4
 * is freely granted, provided that this notice is preserved.
5
 */
6
 
7
#include <errno.h>
8
#include <sys/types.h>
9
#include <string.h>
10
#include <stdlib.h>
11
#include <argz.h>
12
#include <envz.h>
13
 
14
void
15
_DEFUN (envz_strip, (envz, envz_len),
16
       char **envz _AND
17
       size_t *envz_len)
18
{
19
  char *entry = 0;
20
  int len = 0;
21
  int null_found = 0;
22
 
23
  while((entry = argz_next(*envz, *envz_len, entry)))
24
    {
25
      if(!strchr(entry, '='))
26
        {
27
          null_found = 1;
28
          len = strlen(entry) + 1;
29
          /* Make sure this is not the last entry in envz. If it is, it
30
           will be chopped off by the realloc anyway.*/
31
          if(*envz + *envz_len != entry + len - 1)
32
            {
33
              memmove(entry, entry + len, *envz + *envz_len - entry - len);
34
            }
35
          *envz_len -= len;
36
        }
37
    }
38
  if(null_found)
39
    {
40
      *envz = (char *)realloc(*envz, *envz_len);
41
    }
42
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.