source: trunk/third/gettext/djgpp/unsetenv.c @ 18200

Revision 18200, 1.0 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18199, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2   libc of DJGPP 2.03 does not offer function unsetenv,
3   so this version from DJGPP 2.04 CVS tree is supplied.
4   This file will become superflous and will be removed
5   from the  distribution as soon as DJGPP 2.04 has been
6   released.
7*/
8
9/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
10
11#include <libc/stubs.h>
12#include <libc/unconst.h>
13#include <errno.h>
14#include <stdlib.h>
15#include <string.h>
16
17extern char **environ;
18
19int
20unsetenv(const char *name)
21{
22  /* No environment == success */
23  if (environ == 0)
24    return 0;
25
26  /* Check for the failure conditions */
27  if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
28  {
29    errno = EINVAL;
30    return -1;
31  }
32
33  /* Let putenv() do the work
34   * Note that we can just pass name directly as our putenv() treats
35   * this the same as passing 'name='. */
36  /* The cast is needed because POSIX specifies putenv() to take a non-const
37   * parameter.  Our putenv is well-behaved, so this is OK.  */
38  putenv (unconst (name, char*));
39
40  return 0;
41}
Note: See TracBrowser for help on using the repository browser.