annotate lib/xreadlink.c @ 8263:0b51384602a2

Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
author Bruno Haible <bruno@clisp.org>
date Thu, 01 Mar 2007 00:07:34 +0000
parents
children fb6ff6e4ca87
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8263
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* xreadlink.c -- readlink wrapper to return the link name in malloc'd storage
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 Copyright (C) 2001, 2003-2007 Free Software Foundation, Inc.
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 any later version.
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 GNU General Public License for more details.
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 along with this program; see the file COPYING.
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 If not, write to the Free Software Foundation,
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 /* Written by Jim Meyering <jim@meyering.net>
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 and Bruno Haible <bruno@clisp.org>. */
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <config.h>
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 /* Specification. */
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #include "xreadlink.h"
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #include <stdio.h>
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 #include <string.h>
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 #include <errno.h>
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 #include <limits.h>
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 #include <sys/types.h>
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 #include <stdlib.h>
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 #if HAVE_UNISTD_H
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 # include <unistd.h>
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 #endif
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 #ifndef SIZE_MAX
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 # define SIZE_MAX ((size_t) -1)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 #endif
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 #ifndef SSIZE_MAX
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 #endif
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 #ifdef NO_XMALLOC
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 # define xmalloc malloc
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 #else
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 # include "xalloc.h"
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 #endif
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 /* Call readlink to get the symbolic link value of FILENAME.
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 Return a pointer to that NUL-terminated string in malloc'd storage.
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 If readlink fails, return NULL (caller may use errno to diagnose).
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 If realloc fails, or if the link value is longer than SIZE_MAX :-),
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 give a diagnostic and exit. */
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 char *
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 xreadlink (char const *filename)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 {
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 /* The initial buffer size for the link value. A power of 2
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 detects arithmetic overflow earlier, but is not required. */
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 #define INITIAL_BUF_SIZE 1024
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 /* Allocate the initial buffer on the stack. This way, in the common
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 case of a symlink of small size, we get away with a single small malloc()
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 instead of a big malloc() followed by a shrinking realloc(). */
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 char initial_buf[INITIAL_BUF_SIZE];
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 char *buffer = initial_buf;
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 size_t buf_size = sizeof (initial_buf);
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 while (1)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 {
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 /* Attempt to read the link into the current buffer. */
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 ssize_t link_length = readlink (filename, buffer, buf_size);
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 with errno == ERANGE if the buffer is too small. */
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 if (link_length < 0 && errno != ERANGE)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 {
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 if (buffer != initial_buf)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 {
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 int saved_errno = errno;
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 free (buffer);
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 errno = saved_errno;
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 }
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 return NULL;
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 }
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 if ((size_t) link_length < buf_size)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 {
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 buffer[link_length++] = '\0';
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 /* Return it in a chunk of memory as small as possible. */
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 if (buffer == initial_buf)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 {
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 buffer = (char *) xmalloc (link_length);
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 #ifdef NO_XMALLOC
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 if (buffer == NULL)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 return NULL;
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 #endif
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 memcpy (buffer, initial_buf, link_length);
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 }
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 else
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 {
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 /* Shrink buffer before returning it. */
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 if ((size_t) link_length < buf_size)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108 {
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 char *smaller_buffer = (char *) realloc (buffer, link_length);
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 if (smaller_buffer != NULL)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112 buffer = smaller_buffer;
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 }
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 }
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115 return buffer;
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 }
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 if (buffer != initial_buf)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119 free (buffer);
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 buf_size *= 2;
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 if (SSIZE_MAX < buf_size || (SIZE_MAX / 2 < SSIZE_MAX && buf_size == 0))
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122 #ifdef NO_XMALLOC
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123 return NULL;
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 #else
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 xalloc_die ();
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 #endif
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 buffer = (char *) xmalloc (buf_size);
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128 #ifdef NO_XMALLOC
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 if (buffer == NULL)
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 return NULL;
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131 #endif
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132 }
0b51384602a2 Add the xreadlink module from GNU gettext (based on code from Jim Meyering).
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 }