annotate lib/setenv.h @ 6186:7a0537a5ad1b

* lib/regex_internal.c (re_string_reconstruct): Don't assume buffer lengths fit in regoff_t; this isn't true if regoff_t is the same width as size_t. * lib/regex.c (re_search_internal): 5th arg is LAST_START (= START + RANGE) instead of RANGE. This avoids overflow problems when regoff_t is the same width as size_t. All callers changed. (re_search_2_stub): Check for overflow when adding the sizes of the two strings. (re_search_stub): Check for overflow when adding START to RANGE; if it occurs, substitute the extreme value. * config/srclist.txt: Add glibc bug 1284.
author Paul Eggert <eggert@cs.ucla.edu>
date Thu, 01 Sep 2005 07:03:01 +0000
parents a48fb0e98c8c
children 4ec84f742938
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4084
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
1 /* Setting environment variables.
5381
20b173a370ec Provide a return value for unsetenv() if the system doesn't.
Bruno Haible <bruno@clisp.org>
parents: 4591
diff changeset
2 Copyright (C) 2001-2004 Free Software Foundation, Inc.
4084
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
3
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
4 This program is free software; you can redistribute it and/or modify
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
5 it under the terms of the GNU General Public License as published by
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
6 the Free Software Foundation; either version 2, or (at your option)
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
7 any later version.
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
8
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
9 This program is distributed in the hope that it will be useful,
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
12 GNU General Public License for more details.
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
13
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
14 You should have received a copy of the GNU General Public License
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
15 along with this program; if not, write to the Free Software Foundation,
5848
a48fb0e98c8c *** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents: 5381
diff changeset
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
4084
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
17
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
18 #if HAVE_SETENV || HAVE_UNSETENV
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
19
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
20 /* Get setenv(), unsetenv() declarations. */
4591
e2dea0e5b24a Indent nested cpp directive.
Jim Meyering <jim@meyering.net>
parents: 4084
diff changeset
21 # include <stdlib.h>
575
Jim Meyering <jim@meyering.net>
parents:
diff changeset
22
4084
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
23 #endif
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
24
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
25 #ifdef __cplusplus
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
26 extern "C" {
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
27 #endif
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
28
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
29 #if !HAVE_SETENV
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
30
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
31 /* Set NAME to VALUE in the environment.
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
32 If REPLACE is nonzero, overwrite an existing value. */
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
33 extern int setenv (const char *name, const char *value, int replace);
575
Jim Meyering <jim@meyering.net>
parents:
diff changeset
34
4084
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
35 #endif
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
36
5381
20b173a370ec Provide a return value for unsetenv() if the system doesn't.
Bruno Haible <bruno@clisp.org>
parents: 4591
diff changeset
37 #if HAVE_UNSETENV
20b173a370ec Provide a return value for unsetenv() if the system doesn't.
Bruno Haible <bruno@clisp.org>
parents: 4591
diff changeset
38
20b173a370ec Provide a return value for unsetenv() if the system doesn't.
Bruno Haible <bruno@clisp.org>
parents: 4591
diff changeset
39 # if VOID_UNSETENV
20b173a370ec Provide a return value for unsetenv() if the system doesn't.
Bruno Haible <bruno@clisp.org>
parents: 4591
diff changeset
40 /* On some systems, unsetenv() returns void.
20b173a370ec Provide a return value for unsetenv() if the system doesn't.
Bruno Haible <bruno@clisp.org>
parents: 4591
diff changeset
41 This is the case for FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4. */
20b173a370ec Provide a return value for unsetenv() if the system doesn't.
Bruno Haible <bruno@clisp.org>
parents: 4591
diff changeset
42 # define unsetenv(name) ((unsetenv)(name), 0)
20b173a370ec Provide a return value for unsetenv() if the system doesn't.
Bruno Haible <bruno@clisp.org>
parents: 4591
diff changeset
43 # endif
20b173a370ec Provide a return value for unsetenv() if the system doesn't.
Bruno Haible <bruno@clisp.org>
parents: 4591
diff changeset
44
20b173a370ec Provide a return value for unsetenv() if the system doesn't.
Bruno Haible <bruno@clisp.org>
parents: 4591
diff changeset
45 #else
575
Jim Meyering <jim@meyering.net>
parents:
diff changeset
46
4084
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
47 /* Remove the variable NAME from the environment. */
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
48 extern int unsetenv (const char *name);
575
Jim Meyering <jim@meyering.net>
parents:
diff changeset
49
4084
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
50 #endif
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
51
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
52 #ifdef __cplusplus
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
53 }
5248d7d55666 Rewritten to cope with systems that have setenv() but not unsetenv().
Bruno Haible <bruno@clisp.org>
parents: 653
diff changeset
54 #endif