[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r103425: Fix the MS-Windows build aft
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r103425: Fix the MS-Windows build after revision 103424. |
Date: |
Sat, 26 Feb 2011 09:44:38 +0200 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 103425
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Sat 2011-02-26 09:44:38 +0200
message:
Fix the MS-Windows build after revision 103424.
emacsclient.c (xstrdup) [WINDOWSNT]: Function added back.
(w32_getenv): Use xstrdup to return all values in malloc'ed
storage.
modified:
lib-src/ChangeLog
lib-src/emacsclient.c
=== modified file 'lib-src/ChangeLog'
--- a/lib-src/ChangeLog 2011-02-26 05:43:51 +0000
+++ b/lib-src/ChangeLog 2011-02-26 07:44:38 +0000
@@ -1,3 +1,9 @@
+2011-02-26 Eli Zaretskii <address@hidden>
+
+ * emacsclient.c (xstrdup) [WINDOWSNT]: Function added back.
+ (w32_getenv): Use xstrdup to return all values in malloc'ed
+ storage.
+
2011-02-26 Paul Eggert <address@hidden>
* ebrowse.c (parse_qualified_param_ident_or_type): Make it clear
=== modified file 'lib-src/emacsclient.c'
--- a/lib-src/emacsclient.c 2011-02-26 00:17:02 +0000
+++ b/lib-src/emacsclient.c 2011-02-26 07:44:38 +0000
@@ -293,6 +293,20 @@
#ifdef WINDOWSNT
+/* Like strdup but get a fatal error if memory is exhausted. */
+
+char *
+xstrdup (const char *s)
+{
+ char *result = strdup (s);
+ if (result == NULL)
+ {
+ perror ("strdup");
+ exit (EXIT_FAILURE);
+ }
+ return result;
+}
+
#define REG_ROOT "SOFTWARE\\GNU\\Emacs"
/* Retrieve an environment variable from the Emacs subkeys of the registry.
@@ -328,9 +342,11 @@
/*
getenv wrapper for Windows
- This is needed to duplicate Emacs's behavior, which is to look for
environment
- variables in the registry if they don't appear in the environment.
-*/
+ Value is allocated on the heap, and can be free'd.
+
+ This is needed to duplicate Emacs's behavior, which is to look for
+ environment variables in the registry if they don't appear in the
+ environment. */
char *
w32_getenv (char *envvar)
{
@@ -338,15 +354,16 @@
DWORD dwType;
if (value = getenv (envvar))
- /* Found in the environment. */
- return value;
+ /* Found in the environment. strdup it, because values returned
+ by getenv cannot be free'd. */
+ return xstrdup (value);
if (! (value = w32_get_resource (HKEY_CURRENT_USER, envvar, &dwType)) &&
! (value = w32_get_resource (HKEY_LOCAL_MACHINE, envvar, &dwType)))
{
/* "w32console" is what Emacs on Windows uses for tty-type under -nw. */
if (strcmp (envvar, "TERM") == 0)
- return "w32console";
+ return xstrdup ("w32console");
/* Found neither in the environment nor in the registry. */
return NULL;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r103425: Fix the MS-Windows build after revision 103424.,
Eli Zaretskii <=