projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tests for module 'unicase/u16-is-uppercase'.
[gnulib.git]
/
lib
/
progreloc.c
diff --git
a/lib/progreloc.c
b/lib/progreloc.c
index
6986e1e
..
a79ef7a
100644
(file)
--- a/
lib/progreloc.c
+++ b/
lib/progreloc.c
@@
-1,11
+1,11
@@
/* Provide relocatable programs.
/* Provide relocatable programs.
- Copyright (C) 2003-200
6
Free Software Foundation, Inc.
+ Copyright (C) 2003-200
9
Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
Written by Bruno Haible <bruno@clisp.org>, 2003.
- This program is free software
;
you can redistribute it and/or modify
+ This program is free software
:
you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version
2, or (at your option)
- any later version.
+ the Free Software Foundation; either version
3 of the License, or
+
(at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-13,13
+13,10
@@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include <config.h>
/* Specification. */
#include "progname.h"
/* Specification. */
#include "progname.h"
@@
-29,9
+26,7
@@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+#include <unistd.h>
#include <sys/stat.h>
/* Get declaration of _NSGetExecutablePath on MacOS X 10.2 or newer. */
#include <sys/stat.h>
/* Get declaration of _NSGetExecutablePath on MacOS X 10.2 or newer. */
@@
-48,11
+43,17
@@
# include <windows.h>
#endif
# include <windows.h>
#endif
-#include "xreadlink.h"
#include "canonicalize.h"
#include "relocatable.h"
#ifdef NO_XMALLOC
#include "canonicalize.h"
#include "relocatable.h"
#ifdef NO_XMALLOC
+# include "areadlink.h"
+# define xreadlink areadlink
+#else
+# include "xreadlink.h"
+#endif
+
+#ifdef NO_XMALLOC
# define xmalloc malloc
# define xstrdup strdup
#else
# define xmalloc malloc
# define xstrdup strdup
#else
@@
-79,6
+80,11
@@
# define FILE_SYSTEM_PREFIX_LEN(P) 0
#endif
# define FILE_SYSTEM_PREFIX_LEN(P) 0
#endif
+/* The results of open() in this file are not used with fchdir,
+ therefore save some unnecessary work in fchdir.c. */
+#undef open
+#undef close
+
#undef set_program_name
#undef set_program_name
@@
-190,10
+196,10
@@
find_executable (const char *argv0)
#endif
#if HAVE_MACH_O_DYLD_H && HAVE__NSGETEXECUTABLEPATH
/* On MacOS X 10.2 or newer, the function
#endif
#if HAVE_MACH_O_DYLD_H && HAVE__NSGETEXECUTABLEPATH
/* On MacOS X 10.2 or newer, the function
- int _NSGetExecutablePath (char *buf, u
nsigned long
*bufsize);
+ int _NSGetExecutablePath (char *buf, u
int32_t
*bufsize);
can be used to retrieve the executable's full path. */
char location[4096];
can be used to retrieve the executable's full path. */
char location[4096];
- unsigned
long
length = sizeof (location);
+ unsigned
int
length = sizeof (location);
if (_NSGetExecutablePath (location, &length) == 0
&& location[0] == '/')
return canonicalize_file_name (location);
if (_NSGetExecutablePath (location, &length) == 0
&& location[0] == '/')
return canonicalize_file_name (location);
@@
-275,7
+281,7
@@
static void
prepare_relocate (const char *orig_installprefix, const char *orig_installdir,
const char *argv0)
{
prepare_relocate (const char *orig_installprefix, const char *orig_installdir,
const char *argv0)
{
- c
onst c
har *curr_prefix;
+ char *curr_prefix;
/* Determine the full pathname of the current executable. */
executable_fullname = find_executable (argv0);
/* Determine the full pathname of the current executable. */
executable_fullname = find_executable (argv0);
@@
-284,8
+290,12
@@
prepare_relocate (const char *orig_installprefix, const char *orig_installdir,
curr_prefix = compute_curr_prefix (orig_installprefix, orig_installdir,
executable_fullname);
if (curr_prefix != NULL)
curr_prefix = compute_curr_prefix (orig_installprefix, orig_installdir,
executable_fullname);
if (curr_prefix != NULL)
- /* Now pass this prefix to all copies of the relocate.c source file. */
- set_relocation_prefix (orig_installprefix, curr_prefix);
+ {
+ /* Now pass this prefix to all copies of the relocate.c source file. */
+ set_relocation_prefix (orig_installprefix, curr_prefix);
+
+ free (curr_prefix);
+ }
}
/* Set program_name, based on argv[0], and original installation prefix and
}
/* Set program_name, based on argv[0], and original installation prefix and