diff options
| author | Paul Eggert | 2018-11-19 11:36:50 -0800 |
|---|---|---|
| committer | Paul Eggert | 2018-11-19 11:38:21 -0800 |
| commit | 0e3b24586202fc60e7d8a9bff4640e76e6d54e9c (patch) | |
| tree | 21d981704d5147c60f14df772a84df7b525f7f1f /lib-src | |
| parent | 736f1b364f8d57f7f0ea358d9c024ca628a0dbec (diff) | |
| download | emacs-0e3b24586202fc60e7d8a9bff4640e76e6d54e9c.tar.gz emacs-0e3b24586202fc60e7d8a9bff4640e76e6d54e9c.zip | |
emacsclient.c: file name component fixes
* lib-src/emacsclient.c: Include <dosname.h>.
(file_name_absolute_p): Remove, as a code duplicate.
All uses replaced by IS_ABSOLUTE_FILE_NAME.
(set_local_socket): Don’t treat \ as a file name separator
on GNU and POSIX hosts.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/emacsclient.c | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 5c4e71a4925..808755ef604 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -81,6 +81,7 @@ char *w32_getenv (const char *); | |||
| 81 | #include <sys/stat.h> | 81 | #include <sys/stat.h> |
| 82 | #include <unistd.h> | 82 | #include <unistd.h> |
| 83 | 83 | ||
| 84 | #include <dosname.h> | ||
| 84 | #include <min-max.h> | 85 | #include <min-max.h> |
| 85 | #include <unlocked-io.h> | 86 | #include <unlocked-io.h> |
| 86 | 87 | ||
| @@ -888,31 +889,6 @@ unquote_argument (char *str) | |||
| 888 | } | 889 | } |
| 889 | 890 | ||
| 890 | 891 | ||
| 891 | static bool | ||
| 892 | file_name_absolute_p (const char *filename) | ||
| 893 | { | ||
| 894 | /* Sanity check, it shouldn't happen. */ | ||
| 895 | if (! filename) return false; | ||
| 896 | |||
| 897 | /* /xxx is always an absolute path. */ | ||
| 898 | if (filename[0] == '/') return true; | ||
| 899 | |||
| 900 | /* Empty filenames (which shouldn't happen) are relative. */ | ||
| 901 | if (filename[0] == '\0') return false; | ||
| 902 | |||
| 903 | # ifdef WINDOWSNT | ||
| 904 | /* X:\xxx is always absolute. */ | ||
| 905 | if (isalpha ((unsigned char) filename[0]) | ||
| 906 | && filename[1] == ':' && (filename[2] == '\\' || filename[2] == '/')) | ||
| 907 | return true; | ||
| 908 | |||
| 909 | /* Both \xxx and \\xxx\yyy are absolute. */ | ||
| 910 | if (filename[0] == '\\') return true; | ||
| 911 | # endif | ||
| 912 | |||
| 913 | return false; | ||
| 914 | } | ||
| 915 | |||
| 916 | # ifdef WINDOWSNT | 892 | # ifdef WINDOWSNT |
| 917 | /* Wrapper to make WSACleanup a cdecl, as required by atexit. */ | 893 | /* Wrapper to make WSACleanup a cdecl, as required by atexit. */ |
| 918 | void __cdecl close_winsock (void); | 894 | void __cdecl close_winsock (void); |
| @@ -951,7 +927,7 @@ get_server_config (const char *config_file, struct sockaddr_in *server, | |||
| 951 | char *port; | 927 | char *port; |
| 952 | FILE *config = NULL; | 928 | FILE *config = NULL; |
| 953 | 929 | ||
| 954 | if (file_name_absolute_p (config_file)) | 930 | if (IS_ABSOLUTE_FILE_NAME (config_file)) |
| 955 | config = fopen (config_file, "rb"); | 931 | config = fopen (config_file, "rb"); |
| 956 | else | 932 | else |
| 957 | { | 933 | { |
| @@ -1241,7 +1217,8 @@ set_local_socket (const char *local_socket_name) | |||
| 1241 | char *tmpdir_storage = NULL; | 1217 | char *tmpdir_storage = NULL; |
| 1242 | char *socket_name_storage = NULL; | 1218 | char *socket_name_storage = NULL; |
| 1243 | 1219 | ||
| 1244 | if (!strchr (local_socket_name, '/') && !strchr (local_socket_name, '\\')) | 1220 | if (! (strchr (local_socket_name, '/') |
| 1221 | || (ISSLASH ('\\') && strchr (local_socket_name, '\\')))) | ||
| 1245 | { | 1222 | { |
| 1246 | /* socket_name is a file name component. */ | 1223 | /* socket_name is a file name component. */ |
| 1247 | long uid = geteuid (); | 1224 | long uid = geteuid (); |
| @@ -1809,7 +1786,7 @@ main (int argc, char **argv) | |||
| 1809 | } | 1786 | } |
| 1810 | } | 1787 | } |
| 1811 | # ifdef WINDOWSNT | 1788 | # ifdef WINDOWSNT |
| 1812 | else if (! file_name_absolute_p (argv[i]) | 1789 | else if (! IS_ABSOLUTE_FILE_NAME (argv[i]) |
| 1813 | && (isalpha (argv[i][0]) && argv[i][1] == ':')) | 1790 | && (isalpha (argv[i][0]) && argv[i][1] == ':')) |
| 1814 | /* Windows can have a different default directory for each | 1791 | /* Windows can have a different default directory for each |
| 1815 | drive, so the cwd passed via "-dir" is not sufficient | 1792 | drive, so the cwd passed via "-dir" is not sufficient |
| @@ -1830,7 +1807,7 @@ main (int argc, char **argv) | |||
| 1830 | # endif | 1807 | # endif |
| 1831 | 1808 | ||
| 1832 | send_to_emacs (emacs_socket, "-file "); | 1809 | send_to_emacs (emacs_socket, "-file "); |
| 1833 | if (tramp_prefix && file_name_absolute_p (argv[i])) | 1810 | if (tramp_prefix && IS_ABSOLUTE_FILE_NAME (argv[i])) |
| 1834 | quote_argument (emacs_socket, tramp_prefix); | 1811 | quote_argument (emacs_socket, tramp_prefix); |
| 1835 | quote_argument (emacs_socket, argv[i]); | 1812 | quote_argument (emacs_socket, argv[i]); |
| 1836 | send_to_emacs (emacs_socket, " "); | 1813 | send_to_emacs (emacs_socket, " "); |