1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

emacsclient: one ‘main’ function

* lib-src/emacsclient.c (main): Simplify by having just one
‘main’ function instead of two.  Don’t assume argc is positive (!).
This commit is contained in:
Paul Eggert 2018-11-23 00:12:54 -08:00
parent 5daba9d8a5
commit ef1f60301a

View file

@ -732,21 +732,7 @@ fail (void)
}
#if !defined (HAVE_SOCKETS) || !defined (HAVE_INET_SOCKETS)
int
main (int argc, char **argv)
{
main_argc = argc;
main_argv = argv;
progname = argv[0];
message (true, ("%s: Sorry, the Emacs server is supported only\n"
"on systems with Berkeley sockets.\n"),
argv[0]);
fail ();
}
#else /* HAVE_SOCKETS && HAVE_INET_SOCKETS */
#if defined HAVE_SOCKETS && defined HAVE_INET_SOCKETS
enum { AUTH_KEY_LENGTH = 64 };
@ -1605,19 +1591,25 @@ start_daemon_and_retry_set_socket (void)
}
# endif /* WINDOWSNT */
}
#endif /* HAVE_SOCKETS && HAVE_INET_SOCKETS */
int
main (int argc, char **argv)
{
main_argc = argc;
main_argv = argv;
progname = argv[0] ? argv[0] : "emacsclient";
#if ! (defined HAVE_SOCKETS && defined HAVE_INET_SOCKETS)
message (true, "%s: Sorry, support for Berkeley sockets is required.\n",
progname);
fail ();
#else /* HAVE_SOCKETS && HAVE_INET_SOCKETS */
int rl = 0;
bool skiplf = true;
char string[BUFSIZ + 1];
int exit_status = EXIT_SUCCESS;
main_argc = argc;
main_argv = argv;
progname = argv[0];
# ifdef HAVE_NTGUI
/* On Windows 7 and later, we need to explicitly associate
emacsclient with emacs so the UI behaves sensibly. This
@ -1935,6 +1927,5 @@ main (int argc, char **argv)
CLOSE_SOCKET (emacs_socket);
return exit_status;
}
#endif /* HAVE_SOCKETS && HAVE_INET_SOCKETS */
}