diff options
| author | Eli Zaretskii | 2011-02-26 09:44:38 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2011-02-26 09:44:38 +0200 |
| commit | a54af40e14bbddbe836aecff0f9308a01c477ca2 (patch) | |
| tree | 7a11ed2372080ce37cbea2b82a76e2dedd02cf96 | |
| parent | ae3f8fbfc330c91272411720263bd9eb0c5bb82a (diff) | |
| download | emacs-a54af40e14bbddbe836aecff0f9308a01c477ca2.tar.gz emacs-a54af40e14bbddbe836aecff0f9308a01c477ca2.zip | |
Fix the MS-Windows build after 2011-02-26T05:54:36Z!eggert@cs.ucla.edu.
emacsclient.c (xstrdup) [WINDOWSNT]: Function added back.
(w32_getenv): Use xstrdup to return all values in malloc'ed
storage.
| -rw-r--r-- | lib-src/ChangeLog | 6 | ||||
| -rw-r--r-- | lib-src/emacsclient.c | 29 |
2 files changed, 29 insertions, 6 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index ba77a92cf17..b330a447d54 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2011-02-26 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * emacsclient.c (xstrdup) [WINDOWSNT]: Function added back. | ||
| 4 | (w32_getenv): Use xstrdup to return all values in malloc'ed | ||
| 5 | storage. | ||
| 6 | |||
| 1 | 2011-02-26 Paul Eggert <eggert@cs.ucla.edu> | 7 | 2011-02-26 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 8 | ||
| 3 | * ebrowse.c (parse_qualified_param_ident_or_type): Make it clear | 9 | * ebrowse.c (parse_qualified_param_ident_or_type): Make it clear |
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 251f35873e3..836891ae6aa 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -293,6 +293,20 @@ get_current_dir_name (void) | |||
| 293 | 293 | ||
| 294 | #ifdef WINDOWSNT | 294 | #ifdef WINDOWSNT |
| 295 | 295 | ||
| 296 | /* Like strdup but get a fatal error if memory is exhausted. */ | ||
| 297 | |||
| 298 | char * | ||
| 299 | xstrdup (const char *s) | ||
| 300 | { | ||
| 301 | char *result = strdup (s); | ||
| 302 | if (result == NULL) | ||
| 303 | { | ||
| 304 | perror ("strdup"); | ||
| 305 | exit (EXIT_FAILURE); | ||
| 306 | } | ||
| 307 | return result; | ||
| 308 | } | ||
| 309 | |||
| 296 | #define REG_ROOT "SOFTWARE\\GNU\\Emacs" | 310 | #define REG_ROOT "SOFTWARE\\GNU\\Emacs" |
| 297 | 311 | ||
| 298 | /* Retrieve an environment variable from the Emacs subkeys of the registry. | 312 | /* Retrieve an environment variable from the Emacs subkeys of the registry. |
| @@ -328,9 +342,11 @@ w32_get_resource (HKEY predefined, char *key, LPDWORD type) | |||
| 328 | /* | 342 | /* |
| 329 | getenv wrapper for Windows | 343 | getenv wrapper for Windows |
| 330 | 344 | ||
| 331 | This is needed to duplicate Emacs's behavior, which is to look for environment | 345 | Value is allocated on the heap, and can be free'd. |
| 332 | variables in the registry if they don't appear in the environment. | 346 | |
| 333 | */ | 347 | This is needed to duplicate Emacs's behavior, which is to look for |
| 348 | environment variables in the registry if they don't appear in the | ||
| 349 | environment. */ | ||
| 334 | char * | 350 | char * |
| 335 | w32_getenv (char *envvar) | 351 | w32_getenv (char *envvar) |
| 336 | { | 352 | { |
| @@ -338,15 +354,16 @@ w32_getenv (char *envvar) | |||
| 338 | DWORD dwType; | 354 | DWORD dwType; |
| 339 | 355 | ||
| 340 | if (value = getenv (envvar)) | 356 | if (value = getenv (envvar)) |
| 341 | /* Found in the environment. */ | 357 | /* Found in the environment. strdup it, because values returned |
| 342 | return value; | 358 | by getenv cannot be free'd. */ |
| 359 | return xstrdup (value); | ||
| 343 | 360 | ||
| 344 | if (! (value = w32_get_resource (HKEY_CURRENT_USER, envvar, &dwType)) && | 361 | if (! (value = w32_get_resource (HKEY_CURRENT_USER, envvar, &dwType)) && |
| 345 | ! (value = w32_get_resource (HKEY_LOCAL_MACHINE, envvar, &dwType))) | 362 | ! (value = w32_get_resource (HKEY_LOCAL_MACHINE, envvar, &dwType))) |
| 346 | { | 363 | { |
| 347 | /* "w32console" is what Emacs on Windows uses for tty-type under -nw. */ | 364 | /* "w32console" is what Emacs on Windows uses for tty-type under -nw. */ |
| 348 | if (strcmp (envvar, "TERM") == 0) | 365 | if (strcmp (envvar, "TERM") == 0) |
| 349 | return "w32console"; | 366 | return xstrdup ("w32console"); |
| 350 | /* Found neither in the environment nor in the registry. */ | 367 | /* Found neither in the environment nor in the registry. */ |
| 351 | return NULL; | 368 | return NULL; |
| 352 | } | 369 | } |