~ubuntu-branches/ubuntu/trusty/libidn/trusty

« back to all changes in this revision

Viewing changes to gl/m4/setenv.m4

  • Committer: Bazaar Package Importer
  • Author(s): Simon Josefsson
  • Date: 2011-03-01 16:14:24 UTC
  • mfrom: (1.2.14 upstream) (3.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110301161424-6vh7822t8aderzap
Tags: 1.20-1
* New upstream release.
* Moved from experimental to unstable after testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# setenv.m4 serial 15
2
 
dnl Copyright (C) 2001-2004, 2006-2010 Free Software Foundation, Inc.
 
1
# setenv.m4 serial 21
 
2
dnl Copyright (C) 2001-2004, 2006-2011 Free Software Foundation, Inc.
3
3
dnl This file is free software; the Free Software Foundation
4
4
dnl gives unlimited permission to copy and/or distribute it,
5
5
dnl with or without modifications, as long as this notice is preserved.
16
16
AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
17
17
[
18
18
  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
 
19
  AC_CHECK_DECLS_ONCE([setenv])
 
20
  if test $ac_cv_have_decl_setenv = no; then
 
21
    HAVE_DECL_SETENV=0
 
22
  fi
19
23
  AC_CHECK_FUNCS_ONCE([setenv])
20
24
  if test $ac_cv_func_setenv = no; then
21
25
    HAVE_SETENV=0
25
29
      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
26
30
       #include <stdlib.h>
27
31
       #include <errno.h>
 
32
       #include <string.h>
28
33
      ]], [[
29
 
       if (setenv ("", "", 0) != -1) return 1;
30
 
       if (errno != EINVAL) return 2;
31
 
       if (setenv ("a", "=", 1) != 0) return 3;
32
 
       if (strcmp (getenv ("a"), "=") != 0) return 4;
 
34
       int result = 0;
 
35
       {
 
36
         if (setenv ("", "", 0) != -1)
 
37
           result |= 1;
 
38
         else if (errno != EINVAL)
 
39
           result |= 2;
 
40
       }
 
41
       {
 
42
         if (setenv ("a", "=", 1) != 0)
 
43
           result |= 4;
 
44
         else if (strcmp (getenv ("a"), "=") != 0)
 
45
           result |= 8;
 
46
       }
 
47
       return result;
33
48
      ]])],
34
49
      [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no],
35
50
      [gl_cv_func_setenv_works="guessing no"])])
44
59
AC_DEFUN([gl_FUNC_UNSETENV],
45
60
[
46
61
  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
 
62
  AC_CHECK_DECLS_ONCE([unsetenv])
 
63
  if test $ac_cv_have_decl_unsetenv = no; then
 
64
    HAVE_DECL_UNSETENV=0
 
65
  fi
47
66
  AC_CHECK_FUNCS([unsetenv])
48
67
  if test $ac_cv_func_unsetenv = no; then
49
 
    HAVE_UNSETENV=0
50
68
    AC_LIBOBJ([unsetenv])
51
69
    gl_PREREQ_UNSETENV
52
70
  else
53
71
    dnl Some BSDs return void, failing to do error checking.
54
72
    AC_CACHE_CHECK([for unsetenv() return type], [gt_cv_func_unsetenv_ret],
55
 
      [AC_TRY_COMPILE([#include <stdlib.h>
 
73
      [AC_COMPILE_IFELSE(
 
74
         [AC_LANG_PROGRAM(
 
75
            [[
 
76
#undef _BSD
 
77
#define _BSD 1 /* unhide unsetenv declaration in OSF/1 5.1 <stdlib.h> */
 
78
#include <stdlib.h>
56
79
extern
57
80
#ifdef __cplusplus
58
81
"C"
62
85
#else
63
86
int unsetenv();
64
87
#endif
65
 
], , gt_cv_func_unsetenv_ret='int', gt_cv_func_unsetenv_ret='void')])
 
88
            ]],
 
89
            [[]])],
 
90
         [gt_cv_func_unsetenv_ret='int'],
 
91
         [gt_cv_func_unsetenv_ret='void'])])
66
92
    if test $gt_cv_func_unsetenv_ret = 'void'; then
67
93
      AC_DEFINE([VOID_UNSETENV], [1], [Define to 1 if unsetenv returns void
68
94
       instead of int.])
71
97
    fi
72
98
 
73
99
    dnl Solaris 10 unsetenv does not remove all copies of a name.
74
 
    AC_CACHE_CHECK([whether unsetenv works on duplicates],
 
100
    dnl Haiku alpha 2 unsetenv gets confused by assignment to environ.
 
101
    dnl OpenBSD 4.7 unsetenv("") does not fail.
 
102
    AC_CACHE_CHECK([whether unsetenv obeys POSIX],
75
103
      [gl_cv_func_unsetenv_works],
76
104
      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
77
105
       #include <stdlib.h>
 
106
       #include <errno.h>
 
107
       extern char **environ;
78
108
      ]], [[
79
 
       char entry[] = "b=2";
 
109
       char entry1[] = "a=1";
 
110
       char entry2[] = "b=2";
 
111
       char *env[] = { entry1, entry2, NULL };
80
112
       if (putenv ((char *) "a=1")) return 1;
81
 
       if (putenv (entry)) return 2;
82
 
       entry[0] = 'a';
 
113
       if (putenv (entry2)) return 2;
 
114
       entry2[0] = 'a';
83
115
       unsetenv ("a");
84
116
       if (getenv ("a")) return 3;
 
117
       if (!unsetenv ("") || errno != EINVAL) return 4;
 
118
       entry2[0] = 'b';
 
119
       environ = env;
 
120
       if (!getenv ("a")) return 5;
 
121
       entry2[0] = 'a';
 
122
       unsetenv ("a");
 
123
       if (getenv ("a")) return 6;
85
124
      ]])],
86
125
      [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no],
87
126
      [gl_cv_func_unsetenv_works="guessing no"])])