aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert2011-02-25 15:55:06 -0800
committerPaul Eggert2011-02-25 15:55:06 -0800
commitb9170155fb2bf850fd4e5fad1e46493b8440fd5b (patch)
treefc94436325d9c8d4628f6c70fa25a27431f63aca /lib-src
parent7e6bb4c94c9b4d78d9e626f32fc930cd76169e76 (diff)
downloademacs-b9170155fb2bf850fd4e5fad1e46493b8440fd5b.tar.gz
emacs-b9170155fb2bf850fd4e5fad1e46493b8440fd5b.zip
* emacsclient.c (xstrdup): Remove; no longer needed.
(get_current_dir_name, w32_getenv, get_server_config, find_tty): (set_local_socket, main): Use const char *, not char *, for pointers that are not assigned through.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ChangeLog5
-rw-r--r--lib-src/emacsclient.c32
2 files changed, 14 insertions, 23 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index d1203b2ff96..46e851faada 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,6 +1,11 @@
12011-02-25 Paul Eggert <eggert@cs.ucla.edu> 12011-02-25 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 * emacsclient.c (main): Avoid dangling 'if'. 3 * emacsclient.c (main): Avoid dangling 'if'.
4 (xstrdup): Remove; no longer needed.
5 (get_current_dir_name, w32_getenv, get_server_config, find_tty):
6 (set_local_socket, main):
7 Use const char *, not char *, for pointers that are not assigned
8 through.
4 9
5 * emacsclient.c: Redo local variables to avoid shadowing problems. 10 * emacsclient.c: Redo local variables to avoid shadowing problems.
6 (message, socket_status, start_daemon_and_retry_set_socket): 11 (message, socket_status, start_daemon_and_retry_set_socket):
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index b0087c124ec..9e59c2a4b58 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -190,20 +190,6 @@ xmalloc (unsigned int size)
190 return result; 190 return result;
191} 191}
192 192
193/* Like strdup but get a fatal error if memory is exhausted. */
194
195static char *
196xstrdup (const char *s)
197{
198 char *result = strdup (s);
199 if (result == NULL)
200 {
201 perror ("strdup");
202 exit (EXIT_FAILURE);
203 }
204 return result;
205}
206
207/* From sysdep.c */ 193/* From sysdep.c */
208#if !defined (HAVE_GET_CURRENT_DIR_NAME) || defined (BROKEN_GET_CURRENT_DIR_NAME) 194#if !defined (HAVE_GET_CURRENT_DIR_NAME) || defined (BROKEN_GET_CURRENT_DIR_NAME)
209 195
@@ -233,7 +219,7 @@ char*
233get_current_dir_name (void) 219get_current_dir_name (void)
234{ 220{
235 char *buf; 221 char *buf;
236 char *pwd; 222 const char *pwd;
237 struct stat dotstat, pwdstat; 223 struct stat dotstat, pwdstat;
238 /* If PWD is accurate, use it instead of calling getwd. PWD is 224 /* If PWD is accurate, use it instead of calling getwd. PWD is
239 sometimes a nicer name, and using it may avoid a fatal error if a 225 sometimes a nicer name, and using it may avoid a fatal error if a
@@ -353,7 +339,7 @@ w32_getenv (char *envvar)
353 { 339 {
354 /* "w32console" is what Emacs on Windows uses for tty-type under -nw. */ 340 /* "w32console" is what Emacs on Windows uses for tty-type under -nw. */
355 if (strcmp (envvar, "TERM") == 0) 341 if (strcmp (envvar, "TERM") == 0)
356 return xstrdup ("w32console"); 342 return "w32console";
357 /* Found neither in the environment nor in the registry. */ 343 /* Found neither in the environment nor in the registry. */
358 return NULL; 344 return NULL;
359 } 345 }
@@ -918,7 +904,7 @@ get_server_config (struct sockaddr_in *server, char *authentication)
918 config = fopen (server_file, "rb"); 904 config = fopen (server_file, "rb");
919 else 905 else
920 { 906 {
921 char *home = egetenv ("HOME"); 907 const char *home = egetenv ("HOME");
922 908
923 if (home) 909 if (home)
924 { 910 {
@@ -1025,10 +1011,10 @@ strprefix (const char *prefix, const char *string)
1025 is zero, or return 0 if NOABORT is non-zero. */ 1011 is zero, or return 0 if NOABORT is non-zero. */
1026 1012
1027static int 1013static int
1028find_tty (char **tty_type, char **tty_name, int noabort) 1014find_tty (const char **tty_type, const char **tty_name, int noabort)
1029{ 1015{
1030 char *type = egetenv ("TERM"); 1016 const char *type = egetenv ("TERM");
1031 char *name = ttyname (fileno (stdout)); 1017 const char *name = ttyname (fileno (stdout));
1032 1018
1033 if (!name) 1019 if (!name)
1034 { 1020 {
@@ -1260,10 +1246,10 @@ set_local_socket (void)
1260 associated with the name. This is reminiscent of the logic 1246 associated with the name. This is reminiscent of the logic
1261 that init_editfns uses to set the global Vuser_full_name. */ 1247 that init_editfns uses to set the global Vuser_full_name. */
1262 1248
1263 char *user_name = (char *) egetenv ("LOGNAME"); 1249 const char *user_name = egetenv ("LOGNAME");
1264 1250
1265 if (!user_name) 1251 if (!user_name)
1266 user_name = (char *) egetenv ("USER"); 1252 user_name = egetenv ("USER");
1267 1253
1268 if (user_name) 1254 if (user_name)
1269 { 1255 {
@@ -1615,7 +1601,7 @@ main (int argc, char **argv)
1615 frame is available. */ 1601 frame is available. */
1616 if (tty || (current_frame && !eval)) 1602 if (tty || (current_frame && !eval))
1617 { 1603 {
1618 char *tty_type, *tty_name; 1604 const char *tty_type, *tty_name;
1619 1605
1620 if (find_tty (&tty_type, &tty_name, !tty)) 1606 if (find_tty (&tty_type, &tty_name, !tty))
1621 { 1607 {