diff options
| author | Paul Eggert | 2018-11-19 08:32:26 -0800 |
|---|---|---|
| committer | Paul Eggert | 2018-11-19 11:38:19 -0800 |
| commit | 4a5034d84edfc34c1264388ef7cccbd90bdd7d9d (patch) | |
| tree | 40992fad928ecfff18672994d3c8e042be88a320 /lib-src | |
| parent | d3b1d5d262aa9a32ecdf3b1e38539997df5d740d (diff) | |
| download | emacs-4a5034d84edfc34c1264388ef7cccbd90bdd7d9d.tar.gz emacs-4a5034d84edfc34c1264388ef7cccbd90bdd7d9d.zip | |
emacsclient.c: clean up preprocessing directives
* lib-src/emacsclient.c [WINDOWSNT]: Omit duplicate stdlib.h include.
Include min-max.h.
(EXIT_SUCCESS, EXIT_FAILURE, min): Remove; no longer needed.
(AUTH_KEY_LENGTH, SEND_BUFFER_SIZE): Now constants instead of macros.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/emacsclient.c | 141 |
1 files changed, 59 insertions, 82 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 6fbc2300958..5110b4cc9f0 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -27,7 +27,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 27 | # undef _WINSOCK_H | 27 | # undef _WINSOCK_H |
| 28 | 28 | ||
| 29 | # include <malloc.h> | 29 | # include <malloc.h> |
| 30 | # include <stdlib.h> | ||
| 31 | # include <windows.h> | 30 | # include <windows.h> |
| 32 | # include <commctrl.h> | 31 | # include <commctrl.h> |
| 33 | # include <io.h> | 32 | # include <io.h> |
| @@ -37,10 +36,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 37 | 36 | ||
| 38 | # define HSOCKET SOCKET | 37 | # define HSOCKET SOCKET |
| 39 | # define CLOSE_SOCKET closesocket | 38 | # define CLOSE_SOCKET closesocket |
| 40 | # define INITIALIZE() (initialize_sockets ()) | 39 | # define INITIALIZE() initialize_sockets () |
| 41 | 40 | ||
| 42 | char *w32_getenv (const char *); | 41 | char *w32_getenv (const char *); |
| 43 | #define egetenv(VAR) w32_getenv(VAR) | 42 | # define egetenv(VAR) w32_getenv (VAR) |
| 44 | 43 | ||
| 45 | #else /* !WINDOWSNT */ | 44 | #else /* !WINDOWSNT */ |
| 46 | 45 | ||
| @@ -60,52 +59,37 @@ char *w32_getenv (const char *); | |||
| 60 | # endif | 59 | # endif |
| 61 | # include <arpa/inet.h> | 60 | # include <arpa/inet.h> |
| 62 | 61 | ||
| 63 | # define INVALID_SOCKET -1 | 62 | # define INVALID_SOCKET (-1) |
| 64 | # define HSOCKET int | 63 | # define HSOCKET int |
| 65 | # define CLOSE_SOCKET close | 64 | # define CLOSE_SOCKET close |
| 66 | # define INITIALIZE() | 65 | # define INITIALIZE() |
| 67 | 66 | ||
| 68 | #define egetenv(VAR) getenv(VAR) | 67 | # define egetenv(VAR) getenv (VAR) |
| 69 | 68 | ||
| 70 | #endif /* !WINDOWSNT */ | 69 | #endif /* !WINDOWSNT */ |
| 71 | 70 | ||
| 72 | #undef signal | 71 | #undef signal |
| 73 | 72 | ||
| 74 | #include <stdarg.h> | ||
| 75 | #include <ctype.h> | 73 | #include <ctype.h> |
| 76 | #include <stdlib.h> | 74 | #include <errno.h> |
| 77 | #include <string.h> | ||
| 78 | #include <getopt.h> | 75 | #include <getopt.h> |
| 79 | #include <unistd.h> | ||
| 80 | |||
| 81 | #include <pwd.h> | 76 | #include <pwd.h> |
| 82 | #include <sys/stat.h> | ||
| 83 | #include <signal.h> | 77 | #include <signal.h> |
| 84 | #include <errno.h> | 78 | #include <stdarg.h> |
| 79 | #include <stdlib.h> | ||
| 80 | #include <string.h> | ||
| 81 | #include <sys/stat.h> | ||
| 82 | #include <unistd.h> | ||
| 85 | 83 | ||
| 84 | #include <min-max.h> | ||
| 86 | #include <unlocked-io.h> | 85 | #include <unlocked-io.h> |
| 87 | 86 | ||
| 88 | #ifndef VERSION | 87 | #ifndef VERSION |
| 89 | #define VERSION "unspecified" | 88 | #define VERSION "unspecified" |
| 90 | #endif | 89 | #endif |
| 91 | |||
| 92 | |||
| 93 | #ifndef EXIT_SUCCESS | ||
| 94 | #define EXIT_SUCCESS 0 | ||
| 95 | #endif | ||
| 96 | |||
| 97 | #ifndef EXIT_FAILURE | ||
| 98 | #define EXIT_FAILURE 1 | ||
| 99 | #endif | ||
| 100 | 90 | ||
| 101 | /* Additional space when allocating buffers for filenames, etc. */ | 91 | /* Additional space when allocating buffers for filenames, etc. */ |
| 102 | #define EXTRA_SPACE 100 | 92 | #define EXTRA_SPACE 100 |
| 103 | |||
| 104 | #ifdef min | ||
| 105 | #undef min | ||
| 106 | #endif | ||
| 107 | #define min(x, y) (((x) < (y)) ? (x) : (y)) | ||
| 108 | |||
| 109 | 93 | ||
| 110 | /* Name used to invoke this program. */ | 94 | /* Name used to invoke this program. */ |
| 111 | const char *progname; | 95 | const char *progname; |
| @@ -234,7 +218,7 @@ xstrdup (const char *s) | |||
| 234 | } | 218 | } |
| 235 | 219 | ||
| 236 | /* From sysdep.c */ | 220 | /* From sysdep.c */ |
| 237 | #if !defined (HAVE_GET_CURRENT_DIR_NAME) || defined (BROKEN_GET_CURRENT_DIR_NAME) | 221 | #if !defined HAVE_GET_CURRENT_DIR_NAME || defined BROKEN_GET_CURRENT_DIR_NAME |
| 238 | 222 | ||
| 239 | char *get_current_dir_name (void); | 223 | char *get_current_dir_name (void); |
| 240 | 224 | ||
| @@ -256,9 +240,9 @@ get_current_dir_name (void) | |||
| 256 | && stat (".", &dotstat) == 0 | 240 | && stat (".", &dotstat) == 0 |
| 257 | && dotstat.st_ino == pwdstat.st_ino | 241 | && dotstat.st_ino == pwdstat.st_ino |
| 258 | && dotstat.st_dev == pwdstat.st_dev | 242 | && dotstat.st_dev == pwdstat.st_dev |
| 259 | #ifdef MAXPATHLEN | 243 | # ifdef MAXPATHLEN |
| 260 | && strlen (pwd) < MAXPATHLEN | 244 | && strlen (pwd) < MAXPATHLEN |
| 261 | #endif | 245 | # endif |
| 262 | ) | 246 | ) |
| 263 | { | 247 | { |
| 264 | buf = xmalloc (strlen (pwd) + 1); | 248 | buf = xmalloc (strlen (pwd) + 1); |
| @@ -296,7 +280,7 @@ get_current_dir_name (void) | |||
| 296 | 280 | ||
| 297 | #ifdef WINDOWSNT | 281 | #ifdef WINDOWSNT |
| 298 | 282 | ||
| 299 | #define REG_ROOT "SOFTWARE\\GNU\\Emacs" | 283 | # define REG_ROOT "SOFTWARE\\GNU\\Emacs" |
| 300 | 284 | ||
| 301 | char *w32_get_resource (HKEY, const char *, LPDWORD); | 285 | char *w32_get_resource (HKEY, const char *, LPDWORD); |
| 302 | 286 | ||
| @@ -439,8 +423,8 @@ w32_execvp (const char *path, char **argv) | |||
| 439 | return execvp (path, argv); | 423 | return execvp (path, argv); |
| 440 | } | 424 | } |
| 441 | 425 | ||
| 442 | #undef execvp | 426 | # undef execvp |
| 443 | #define execvp w32_execvp | 427 | # define execvp w32_execvp |
| 444 | 428 | ||
| 445 | /* Emulation of ttyname for Windows. */ | 429 | /* Emulation of ttyname for Windows. */ |
| 446 | const char *ttyname (int); | 430 | const char *ttyname (int); |
| @@ -756,8 +740,8 @@ main (int argc, char **argv) | |||
| 756 | 740 | ||
| 757 | #else /* HAVE_SOCKETS && HAVE_INET_SOCKETS */ | 741 | #else /* HAVE_SOCKETS && HAVE_INET_SOCKETS */ |
| 758 | 742 | ||
| 759 | #define AUTH_KEY_LENGTH 64 | 743 | enum { AUTH_KEY_LENGTH = 64 }; |
| 760 | #define SEND_BUFFER_SIZE 4096 | 744 | enum { SEND_BUFFER_SIZE = 4096 }; |
| 761 | 745 | ||
| 762 | /* Buffer to accumulate data to send in TCP connections. */ | 746 | /* Buffer to accumulate data to send in TCP connections. */ |
| 763 | char send_buffer[SEND_BUFFER_SIZE + 1]; | 747 | char send_buffer[SEND_BUFFER_SIZE + 1]; |
| @@ -771,7 +755,7 @@ HSOCKET emacs_socket = 0; | |||
| 771 | static void | 755 | static void |
| 772 | sock_err_message (const char *function_name) | 756 | sock_err_message (const char *function_name) |
| 773 | { | 757 | { |
| 774 | #ifdef WINDOWSNT | 758 | # ifdef WINDOWSNT |
| 775 | char* msg = NULL; | 759 | char* msg = NULL; |
| 776 | 760 | ||
| 777 | FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | 761 | FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM |
| @@ -782,9 +766,9 @@ sock_err_message (const char *function_name) | |||
| 782 | message (true, "%s: %s: %s\n", progname, function_name, msg); | 766 | message (true, "%s: %s: %s\n", progname, function_name, msg); |
| 783 | 767 | ||
| 784 | LocalFree (msg); | 768 | LocalFree (msg); |
| 785 | #else | 769 | # else |
| 786 | message (true, "%s: %s: %s\n", progname, function_name, strerror (errno)); | 770 | message (true, "%s: %s: %s\n", progname, function_name, strerror (errno)); |
| 787 | #endif | 771 | # endif |
| 788 | } | 772 | } |
| 789 | 773 | ||
| 790 | 774 | ||
| @@ -917,7 +901,7 @@ file_name_absolute_p (const char *filename) | |||
| 917 | /* Empty filenames (which shouldn't happen) are relative. */ | 901 | /* Empty filenames (which shouldn't happen) are relative. */ |
| 918 | if (filename[0] == '\0') return false; | 902 | if (filename[0] == '\0') return false; |
| 919 | 903 | ||
| 920 | #ifdef WINDOWSNT | 904 | # ifdef WINDOWSNT |
| 921 | /* X:\xxx is always absolute. */ | 905 | /* X:\xxx is always absolute. */ |
| 922 | if (isalpha ((unsigned char) filename[0]) | 906 | if (isalpha ((unsigned char) filename[0]) |
| 923 | && filename[1] == ':' && (filename[2] == '\\' || filename[2] == '/')) | 907 | && filename[1] == ':' && (filename[2] == '\\' || filename[2] == '/')) |
| @@ -925,12 +909,12 @@ file_name_absolute_p (const char *filename) | |||
| 925 | 909 | ||
| 926 | /* Both \xxx and \\xxx\yyy are absolute. */ | 910 | /* Both \xxx and \\xxx\yyy are absolute. */ |
| 927 | if (filename[0] == '\\') return true; | 911 | if (filename[0] == '\\') return true; |
| 928 | #endif | 912 | # endif |
| 929 | 913 | ||
| 930 | return false; | 914 | return false; |
| 931 | } | 915 | } |
| 932 | 916 | ||
| 933 | #ifdef WINDOWSNT | 917 | # ifdef WINDOWSNT |
| 934 | /* Wrapper to make WSACleanup a cdecl, as required by atexit. */ | 918 | /* Wrapper to make WSACleanup a cdecl, as required by atexit. */ |
| 935 | void __cdecl close_winsock (void); | 919 | void __cdecl close_winsock (void); |
| 936 | void __cdecl | 920 | void __cdecl |
| @@ -954,7 +938,7 @@ initialize_sockets (void) | |||
| 954 | 938 | ||
| 955 | atexit (close_winsock); | 939 | atexit (close_winsock); |
| 956 | } | 940 | } |
| 957 | #endif /* WINDOWSNT */ | 941 | # endif /* WINDOWSNT */ |
| 958 | 942 | ||
| 959 | 943 | ||
| 960 | /* Read the information needed to set up a TCP comm channel with | 944 | /* Read the information needed to set up a TCP comm channel with |
| @@ -984,7 +968,7 @@ get_server_config (const char *config_file, struct sockaddr_in *server, | |||
| 984 | config = fopen (path, "rb"); | 968 | config = fopen (path, "rb"); |
| 985 | free (path); | 969 | free (path); |
| 986 | } | 970 | } |
| 987 | #ifdef WINDOWSNT | 971 | # ifdef WINDOWSNT |
| 988 | if (!config && (home = egetenv ("APPDATA"))) | 972 | if (!config && (home = egetenv ("APPDATA"))) |
| 989 | { | 973 | { |
| 990 | char *path = xmalloc (strlen (home) + strlen (config_file) | 974 | char *path = xmalloc (strlen (home) + strlen (config_file) |
| @@ -995,7 +979,7 @@ get_server_config (const char *config_file, struct sockaddr_in *server, | |||
| 995 | config = fopen (path, "rb"); | 979 | config = fopen (path, "rb"); |
| 996 | free (path); | 980 | free (path); |
| 997 | } | 981 | } |
| 998 | #endif | 982 | # endif |
| 999 | } | 983 | } |
| 1000 | 984 | ||
| 1001 | if (! config) | 985 | if (! config) |
| @@ -1047,9 +1031,9 @@ set_tcp_socket (const char *local_server_file) | |||
| 1047 | yet; popping out a modal dialog at this stage would make -a | 1031 | yet; popping out a modal dialog at this stage would make -a |
| 1048 | option totally useless for emacsclientw -- the user will | 1032 | option totally useless for emacsclientw -- the user will |
| 1049 | still get an error message if the alternate editor fails. */ | 1033 | still get an error message if the alternate editor fails. */ |
| 1050 | #ifdef WINDOWSNT | 1034 | # ifdef WINDOWSNT |
| 1051 | if(!(w32_window_app () && alternate_editor)) | 1035 | if(!(w32_window_app () && alternate_editor)) |
| 1052 | #endif | 1036 | # endif |
| 1053 | sock_err_message ("socket"); | 1037 | sock_err_message ("socket"); |
| 1054 | return INVALID_SOCKET; | 1038 | return INVALID_SOCKET; |
| 1055 | } | 1039 | } |
| @@ -1057,9 +1041,9 @@ set_tcp_socket (const char *local_server_file) | |||
| 1057 | /* Set up the socket. */ | 1041 | /* Set up the socket. */ |
| 1058 | if (connect (s, (struct sockaddr *) &server, sizeof server) < 0) | 1042 | if (connect (s, (struct sockaddr *) &server, sizeof server) < 0) |
| 1059 | { | 1043 | { |
| 1060 | #ifdef WINDOWSNT | 1044 | # ifdef WINDOWSNT |
| 1061 | if(!(w32_window_app () && alternate_editor)) | 1045 | if(!(w32_window_app () && alternate_editor)) |
| 1062 | #endif | 1046 | # endif |
| 1063 | sock_err_message ("connect"); | 1047 | sock_err_message ("connect"); |
| 1064 | return INVALID_SOCKET; | 1048 | return INVALID_SOCKET; |
| 1065 | } | 1049 | } |
| @@ -1138,7 +1122,7 @@ find_tty (const char **tty_type, const char **tty_name, int noabort) | |||
| 1138 | } | 1122 | } |
| 1139 | 1123 | ||
| 1140 | 1124 | ||
| 1141 | #if !defined (NO_SOCKETS_IN_FILE_SYSTEM) | 1125 | # ifndef NO_SOCKETS_IN_FILE_SYSTEM |
| 1142 | 1126 | ||
| 1143 | /* Three possibilities: | 1127 | /* Three possibilities: |
| 1144 | 2 - can't be `stat'ed (sets errno) | 1128 | 2 - can't be `stat'ed (sets errno) |
| @@ -1233,17 +1217,10 @@ handle_sigtstp (int signalnum) | |||
| 1233 | static void | 1217 | static void |
| 1234 | init_signals (void) | 1218 | init_signals (void) |
| 1235 | { | 1219 | { |
| 1236 | /* Set up signal handlers. */ | ||
| 1237 | signal (SIGWINCH, pass_signal_to_emacs); | ||
| 1238 | |||
| 1239 | /* Don't pass SIGINT and SIGQUIT to Emacs, because it has no way of | 1220 | /* Don't pass SIGINT and SIGQUIT to Emacs, because it has no way of |
| 1240 | deciding which terminal the signal came from. C-g is now a | 1221 | deciding which terminal the signal came from. C-g is now a |
| 1241 | normal input event on secondary terminals. */ | 1222 | normal input event on secondary terminals. */ |
| 1242 | #if 0 | 1223 | signal (SIGWINCH, pass_signal_to_emacs); |
| 1243 | signal (SIGINT, pass_signal_to_emacs); | ||
| 1244 | signal (SIGQUIT, pass_signal_to_emacs); | ||
| 1245 | #endif | ||
| 1246 | |||
| 1247 | signal (SIGCONT, handle_sigcont); | 1224 | signal (SIGCONT, handle_sigcont); |
| 1248 | signal (SIGTSTP, handle_sigtstp); | 1225 | signal (SIGTSTP, handle_sigtstp); |
| 1249 | signal (SIGTTOU, handle_sigtstp); | 1226 | signal (SIGTTOU, handle_sigtstp); |
| @@ -1280,10 +1257,10 @@ set_local_socket (const char *local_socket_name) | |||
| 1280 | tmpdir = egetenv ("TMPDIR"); | 1257 | tmpdir = egetenv ("TMPDIR"); |
| 1281 | if (!tmpdir) | 1258 | if (!tmpdir) |
| 1282 | { | 1259 | { |
| 1283 | #ifdef DARWIN_OS | 1260 | # ifdef DARWIN_OS |
| 1284 | #ifndef _CS_DARWIN_USER_TEMP_DIR | 1261 | # ifndef _CS_DARWIN_USER_TEMP_DIR |
| 1285 | #define _CS_DARWIN_USER_TEMP_DIR 65537 | 1262 | # define _CS_DARWIN_USER_TEMP_DIR 65537 |
| 1286 | #endif | 1263 | # endif |
| 1287 | size_t n = confstr (_CS_DARWIN_USER_TEMP_DIR, NULL, (size_t) 0); | 1264 | size_t n = confstr (_CS_DARWIN_USER_TEMP_DIR, NULL, (size_t) 0); |
| 1288 | if (n > 0) | 1265 | if (n > 0) |
| 1289 | { | 1266 | { |
| @@ -1291,7 +1268,7 @@ set_local_socket (const char *local_socket_name) | |||
| 1291 | confstr (_CS_DARWIN_USER_TEMP_DIR, tmpdir_storage, n); | 1268 | confstr (_CS_DARWIN_USER_TEMP_DIR, tmpdir_storage, n); |
| 1292 | } | 1269 | } |
| 1293 | else | 1270 | else |
| 1294 | #endif | 1271 | # endif |
| 1295 | tmpdir = "/tmp"; | 1272 | tmpdir = "/tmp"; |
| 1296 | } | 1273 | } |
| 1297 | socket_name_storage = | 1274 | socket_name_storage = |
| @@ -1392,7 +1369,7 @@ To start the server in Emacs, type \"M-x server-start\".\n", | |||
| 1392 | 1369 | ||
| 1393 | return s; | 1370 | return s; |
| 1394 | } | 1371 | } |
| 1395 | #endif /* ! NO_SOCKETS_IN_FILE_SYSTEM */ | 1372 | # endif /* ! NO_SOCKETS_IN_FILE_SYSTEM */ |
| 1396 | 1373 | ||
| 1397 | static HSOCKET | 1374 | static HSOCKET |
| 1398 | set_socket (int no_exit_if_error) | 1375 | set_socket (int no_exit_if_error) |
| @@ -1402,7 +1379,7 @@ set_socket (int no_exit_if_error) | |||
| 1402 | 1379 | ||
| 1403 | INITIALIZE (); | 1380 | INITIALIZE (); |
| 1404 | 1381 | ||
| 1405 | #ifndef NO_SOCKETS_IN_FILE_SYSTEM | 1382 | # ifndef NO_SOCKETS_IN_FILE_SYSTEM |
| 1406 | /* Explicit --socket-name argument. */ | 1383 | /* Explicit --socket-name argument. */ |
| 1407 | if (!socket_name) | 1384 | if (!socket_name) |
| 1408 | socket_name = egetenv ("EMACS_SOCKET_NAME"); | 1385 | socket_name = egetenv ("EMACS_SOCKET_NAME"); |
| @@ -1416,7 +1393,7 @@ set_socket (int no_exit_if_error) | |||
| 1416 | progname, socket_name); | 1393 | progname, socket_name); |
| 1417 | exit (EXIT_FAILURE); | 1394 | exit (EXIT_FAILURE); |
| 1418 | } | 1395 | } |
| 1419 | #endif | 1396 | # endif |
| 1420 | 1397 | ||
| 1421 | /* Explicit --server-file arg or EMACS_SERVER_FILE variable. */ | 1398 | /* Explicit --server-file arg or EMACS_SERVER_FILE variable. */ |
| 1422 | if (!local_server_file) | 1399 | if (!local_server_file) |
| @@ -1433,12 +1410,12 @@ set_socket (int no_exit_if_error) | |||
| 1433 | exit (EXIT_FAILURE); | 1410 | exit (EXIT_FAILURE); |
| 1434 | } | 1411 | } |
| 1435 | 1412 | ||
| 1436 | #ifndef NO_SOCKETS_IN_FILE_SYSTEM | 1413 | # ifndef NO_SOCKETS_IN_FILE_SYSTEM |
| 1437 | /* Implicit local socket. */ | 1414 | /* Implicit local socket. */ |
| 1438 | s = set_local_socket ("server"); | 1415 | s = set_local_socket ("server"); |
| 1439 | if (s != INVALID_SOCKET) | 1416 | if (s != INVALID_SOCKET) |
| 1440 | return s; | 1417 | return s; |
| 1441 | #endif | 1418 | # endif |
| 1442 | 1419 | ||
| 1443 | /* Implicit server file. */ | 1420 | /* Implicit server file. */ |
| 1444 | s = set_tcp_socket ("server"); | 1421 | s = set_tcp_socket ("server"); |
| @@ -1447,16 +1424,16 @@ set_socket (int no_exit_if_error) | |||
| 1447 | 1424 | ||
| 1448 | /* No implicit or explicit socket, and no alternate editor. */ | 1425 | /* No implicit or explicit socket, and no alternate editor. */ |
| 1449 | message (true, "%s: No socket or alternate editor. Please use:\n\n" | 1426 | message (true, "%s: No socket or alternate editor. Please use:\n\n" |
| 1450 | #ifndef NO_SOCKETS_IN_FILE_SYSTEM | 1427 | # ifndef NO_SOCKETS_IN_FILE_SYSTEM |
| 1451 | "\t--socket-name\n" | 1428 | "\t--socket-name\n" |
| 1452 | #endif | 1429 | # endif |
| 1453 | "\t--server-file (or environment variable EMACS_SERVER_FILE)\n\ | 1430 | "\t--server-file (or environment variable EMACS_SERVER_FILE)\n\ |
| 1454 | \t--alternate-editor (or environment variable ALTERNATE_EDITOR)\n", | 1431 | \t--alternate-editor (or environment variable ALTERNATE_EDITOR)\n", |
| 1455 | progname); | 1432 | progname); |
| 1456 | exit (EXIT_FAILURE); | 1433 | exit (EXIT_FAILURE); |
| 1457 | } | 1434 | } |
| 1458 | 1435 | ||
| 1459 | #ifdef HAVE_NTGUI | 1436 | # ifdef HAVE_NTGUI |
| 1460 | FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */ | 1437 | FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */ |
| 1461 | FARPROC get_wc; /* Pointer to RealGetWindowClassA. */ | 1438 | FARPROC get_wc; /* Pointer to RealGetWindowClassA. */ |
| 1462 | 1439 | ||
| @@ -1540,14 +1517,14 @@ w32_give_focus (void) | |||
| 1540 | && (get_wc = GetProcAddress (user32, "RealGetWindowClassA"))) | 1517 | && (get_wc = GetProcAddress (user32, "RealGetWindowClassA"))) |
| 1541 | EnumWindows (w32_find_emacs_process, (LPARAM) 0); | 1518 | EnumWindows (w32_find_emacs_process, (LPARAM) 0); |
| 1542 | } | 1519 | } |
| 1543 | #endif /* HAVE_NTGUI */ | 1520 | # endif /* HAVE_NTGUI */ |
| 1544 | 1521 | ||
| 1545 | /* Start the emacs daemon and try to connect to it. */ | 1522 | /* Start the emacs daemon and try to connect to it. */ |
| 1546 | 1523 | ||
| 1547 | static void | 1524 | static void |
| 1548 | start_daemon_and_retry_set_socket (void) | 1525 | start_daemon_and_retry_set_socket (void) |
| 1549 | { | 1526 | { |
| 1550 | #ifndef WINDOWSNT | 1527 | # ifndef WINDOWSNT |
| 1551 | pid_t dpid; | 1528 | pid_t dpid; |
| 1552 | int status; | 1529 | int status; |
| 1553 | 1530 | ||
| @@ -1597,7 +1574,7 @@ start_daemon_and_retry_set_socket (void) | |||
| 1597 | execvp ("emacs", d_argv); | 1574 | execvp ("emacs", d_argv); |
| 1598 | message (true, "%s: error starting emacs daemon\n", progname); | 1575 | message (true, "%s: error starting emacs daemon\n", progname); |
| 1599 | } | 1576 | } |
| 1600 | #else /* WINDOWSNT */ | 1577 | # else /* WINDOWSNT */ |
| 1601 | DWORD wait_result; | 1578 | DWORD wait_result; |
| 1602 | HANDLE w32_daemon_event; | 1579 | HANDLE w32_daemon_event; |
| 1603 | STARTUPINFO si; | 1580 | STARTUPINFO si; |
| @@ -1667,7 +1644,7 @@ start_daemon_and_retry_set_socket (void) | |||
| 1667 | "Error: Cannot connect even after starting the Emacs daemon\n"); | 1644 | "Error: Cannot connect even after starting the Emacs daemon\n"); |
| 1668 | exit (EXIT_FAILURE); | 1645 | exit (EXIT_FAILURE); |
| 1669 | } | 1646 | } |
| 1670 | #endif /* WINDOWSNT */ | 1647 | # endif /* WINDOWSNT */ |
| 1671 | } | 1648 | } |
| 1672 | 1649 | ||
| 1673 | int | 1650 | int |
| @@ -1734,10 +1711,10 @@ main (int argc, char **argv) | |||
| 1734 | fail (); | 1711 | fail (); |
| 1735 | } | 1712 | } |
| 1736 | 1713 | ||
| 1737 | #ifdef HAVE_NTGUI | 1714 | # ifdef HAVE_NTGUI |
| 1738 | if (display && !strcmp (display, "w32")) | 1715 | if (display && !strcmp (display, "w32")) |
| 1739 | w32_give_focus (); | 1716 | w32_give_focus (); |
| 1740 | #endif /* HAVE_NTGUI */ | 1717 | # endif /* HAVE_NTGUI */ |
| 1741 | 1718 | ||
| 1742 | /* Send over our environment and current directory. */ | 1719 | /* Send over our environment and current directory. */ |
| 1743 | if (!current_frame) | 1720 | if (!current_frame) |
| @@ -1795,9 +1772,9 @@ main (int argc, char **argv) | |||
| 1795 | 1772 | ||
| 1796 | if (find_tty (&tty_type, &tty_name, !tty)) | 1773 | if (find_tty (&tty_type, &tty_name, !tty)) |
| 1797 | { | 1774 | { |
| 1798 | #if !defined (NO_SOCKETS_IN_FILE_SYSTEM) | 1775 | # ifndef NO_SOCKETS_IN_FILE_SYSTEM |
| 1799 | init_signals (); | 1776 | init_signals (); |
| 1800 | #endif | 1777 | # endif |
| 1801 | send_to_emacs (emacs_socket, "-tty "); | 1778 | send_to_emacs (emacs_socket, "-tty "); |
| 1802 | quote_argument (emacs_socket, tty_name); | 1779 | quote_argument (emacs_socket, tty_name); |
| 1803 | send_to_emacs (emacs_socket, " "); | 1780 | send_to_emacs (emacs_socket, " "); |
| @@ -1836,7 +1813,7 @@ main (int argc, char **argv) | |||
| 1836 | continue; | 1813 | continue; |
| 1837 | } | 1814 | } |
| 1838 | } | 1815 | } |
| 1839 | #ifdef WINDOWSNT | 1816 | # ifdef WINDOWSNT |
| 1840 | else if (! file_name_absolute_p (argv[i]) | 1817 | else if (! file_name_absolute_p (argv[i]) |
| 1841 | && (isalpha (argv[i][0]) && argv[i][1] == ':')) | 1818 | && (isalpha (argv[i][0]) && argv[i][1] == ':')) |
| 1842 | /* Windows can have a different default directory for each | 1819 | /* Windows can have a different default directory for each |
| @@ -1855,7 +1832,7 @@ main (int argc, char **argv) | |||
| 1855 | else | 1832 | else |
| 1856 | free (filename); | 1833 | free (filename); |
| 1857 | } | 1834 | } |
| 1858 | #endif | 1835 | # endif |
| 1859 | 1836 | ||
| 1860 | send_to_emacs (emacs_socket, "-file "); | 1837 | send_to_emacs (emacs_socket, "-file "); |
| 1861 | if (tramp_prefix && file_name_absolute_p (argv[i])) | 1838 | if (tramp_prefix && file_name_absolute_p (argv[i])) |
| @@ -1968,7 +1945,7 @@ main (int argc, char **argv) | |||
| 1968 | needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; | 1945 | needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; |
| 1969 | exit_status = EXIT_FAILURE; | 1946 | exit_status = EXIT_FAILURE; |
| 1970 | } | 1947 | } |
| 1971 | #ifdef SIGSTOP | 1948 | # ifdef SIGSTOP |
| 1972 | else if (strprefix ("-suspend ", p)) | 1949 | else if (strprefix ("-suspend ", p)) |
| 1973 | { | 1950 | { |
| 1974 | /* -suspend: Suspend this terminal, i.e., stop the process. */ | 1951 | /* -suspend: Suspend this terminal, i.e., stop the process. */ |
| @@ -1977,7 +1954,7 @@ main (int argc, char **argv) | |||
| 1977 | needlf = 0; | 1954 | needlf = 0; |
| 1978 | kill (0, SIGSTOP); | 1955 | kill (0, SIGSTOP); |
| 1979 | } | 1956 | } |
| 1980 | #endif | 1957 | # endif |
| 1981 | else | 1958 | else |
| 1982 | { | 1959 | { |
| 1983 | /* Unknown command. */ | 1960 | /* Unknown command. */ |