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/] [stdlib/] [putenv_r.c] - Blame information for rev 158

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* This file may have been modified by DJ Delorie (Jan 1991).  If so,
2
** these modifications are Copyright (C) 1991 DJ Delorie.
3
*/
4
 
5
/*-
6
 * Copyright (c) 1988 The Regents of the University of California.
7
 * All rights reserved.
8
 *
9
 * Redistribution and use in source and binary forms are permitted
10
 * provided that: (1) source distributions retain this entire copyright
11
 * notice and comment, and (2) distributions including binaries display
12
 * the following acknowledgement:  ``This product includes software
13
 * developed by the University of California, Berkeley and its contributors''
14
 * in the documentation or other materials provided with the distribution
15
 * and in all advertising materials mentioning features or use of this
16
 * software. Neither the name of the University nor the names of its
17
 * contributors may be used to endorse or promote products derived
18
 * from this software without specific prior written permission.
19
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
20
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
21
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22
 */
23
 
24
#include <reent.h>
25
#include <stdlib.h>
26
#include <string.h>
27
 
28
#include "envlock.h"
29
 
30
/* _putenv_r - reentrant version of putenv that either adds
31
               or replaces the environment variable "name"
32
               with "value" which is specified by str as "name=value". */
33
int
34
_DEFUN (_putenv_r, (reent_ptr, str),
35
        struct _reent *reent_ptr _AND
36
        char   *str)
37
{
38
  register char *p, *equal;
39
  int rval;
40
 
41
  p = _strdup_r (reent_ptr, str);
42
 
43
  if (!p)
44
    return 1;
45
 
46
  if (!(equal = index (p, '=')))
47
    {
48
      (void) _free_r (reent_ptr, p);
49
      return 1;
50
    }
51
 
52
  *equal = '\0';
53
  rval = _setenv_r (reent_ptr, p, equal + 1, 1);
54
  (void) _free_r (reent_ptr, p);
55
 
56
  return rval;
57
}

powered by: WebSVN 2.1.0

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