diff options
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/emacsclient.c | 47 | ||||
| -rw-r--r-- | lib-src/etags.c | 4 | ||||
| -rw-r--r-- | lib-src/pop.c | 10 |
3 files changed, 37 insertions, 24 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index ba2721e8bc9..e9469f77c5e 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -914,22 +914,38 @@ initialize_sockets (void) | |||
| 914 | #endif /* WINDOWSNT */ | 914 | #endif /* WINDOWSNT */ |
| 915 | 915 | ||
| 916 | 916 | ||
| 917 | /* If the home directory is HOME, return the configuration file with | 917 | /* If the home directory is HOME, and XDG_CONFIG_HOME's value is XDG, |
| 918 | basename CONFIG_FILE. Fail if there is no home directory or if the | 918 | return the configuration file with basename CONFIG_FILE. Fail if |
| 919 | configuration file could not be opened. */ | 919 | the configuration file could not be opened. */ |
| 920 | 920 | ||
| 921 | static FILE * | 921 | static FILE * |
| 922 | open_config (char const *home, char const *config_file) | 922 | open_config (char const *home, char const *xdg, char const *config_file) |
| 923 | { | 923 | { |
| 924 | if (!home) | 924 | ptrdiff_t xdgsubdirsize = xdg ? strlen (xdg) + sizeof "/emacs/server/" : 0; |
| 925 | return NULL; | 925 | ptrdiff_t homesuffixsizemax = max (sizeof "/.config/emacs/server/", |
| 926 | ptrdiff_t homelen = strlen (home); | 926 | sizeof "/.emacs.d/server/"); |
| 927 | static char const emacs_d_server[] = "/.emacs.d/server/"; | 927 | ptrdiff_t homesubdirsizemax = home ? strlen (home) + homesuffixsizemax : 0; |
| 928 | ptrdiff_t suffixsize = sizeof emacs_d_server + strlen (config_file); | 928 | char *configname = xmalloc (max (xdgsubdirsize, homesubdirsizemax) |
| 929 | char *configname = xmalloc (homelen + suffixsize); | 929 | + strlen (config_file)); |
| 930 | strcpy (stpcpy (stpcpy (configname, home), emacs_d_server), config_file); | 930 | FILE *config; |
| 931 | 931 | if (xdg || home) | |
| 932 | FILE *config = fopen (configname, "rb"); | 932 | { |
| 933 | strcpy ((xdg | ||
| 934 | ? stpcpy (stpcpy (configname, xdg), "/emacs/server/") | ||
| 935 | : stpcpy (stpcpy (configname, home), "/.config/emacs/server/")), | ||
| 936 | config_file); | ||
| 937 | config = fopen (configname, "rb"); | ||
| 938 | } | ||
| 939 | else | ||
| 940 | config = NULL; | ||
| 941 | |||
| 942 | if (! config && home) | ||
| 943 | { | ||
| 944 | strcpy (stpcpy (stpcpy (configname, home), "/.emacs.d/server/"), | ||
| 945 | config_file); | ||
| 946 | config = fopen (configname, "rb"); | ||
| 947 | } | ||
| 948 | |||
| 933 | free (configname); | 949 | free (configname); |
| 934 | return config; | 950 | return config; |
| 935 | } | 951 | } |
| @@ -949,10 +965,11 @@ get_server_config (const char *config_file, struct sockaddr_in *server, | |||
| 949 | config = fopen (config_file, "rb"); | 965 | config = fopen (config_file, "rb"); |
| 950 | else | 966 | else |
| 951 | { | 967 | { |
| 952 | config = open_config (egetenv ("HOME"), config_file); | 968 | char const *xdg = egetenv ("XDG_CONFIG_HOME"); |
| 969 | config = open_config (egetenv ("HOME"), xdg, config_file); | ||
| 953 | #ifdef WINDOWSNT | 970 | #ifdef WINDOWSNT |
| 954 | if (!config) | 971 | if (!config) |
| 955 | config = open_config (egetenv ("APPDATA"), config_file); | 972 | config = open_config (egetenv ("APPDATA"), xdg, config_file); |
| 956 | #endif | 973 | #endif |
| 957 | } | 974 | } |
| 958 | 975 | ||
diff --git a/lib-src/etags.c b/lib-src/etags.c index 036c485d0bb..6409407e466 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -1146,7 +1146,6 @@ main (int argc, char **argv) | |||
| 1146 | { | 1146 | { |
| 1147 | error ("-o option may only be given once."); | 1147 | error ("-o option may only be given once."); |
| 1148 | suggest_asking_for_help (); | 1148 | suggest_asking_for_help (); |
| 1149 | /* NOTREACHED */ | ||
| 1150 | } | 1149 | } |
| 1151 | tagfile = optarg; | 1150 | tagfile = optarg; |
| 1152 | break; | 1151 | break; |
| @@ -1208,7 +1207,6 @@ main (int argc, char **argv) | |||
| 1208 | case 'w': no_warnings = true; break; | 1207 | case 'w': no_warnings = true; break; |
| 1209 | default: | 1208 | default: |
| 1210 | suggest_asking_for_help (); | 1209 | suggest_asking_for_help (); |
| 1211 | /* NOTREACHED */ | ||
| 1212 | } | 1210 | } |
| 1213 | 1211 | ||
| 1214 | /* No more options. Store the rest of arguments. */ | 1212 | /* No more options. Store the rest of arguments. */ |
| @@ -1227,13 +1225,11 @@ main (int argc, char **argv) | |||
| 1227 | 1225 | ||
| 1228 | if (help_asked) | 1226 | if (help_asked) |
| 1229 | print_help (argbuffer); | 1227 | print_help (argbuffer); |
| 1230 | /* NOTREACHED */ | ||
| 1231 | 1228 | ||
| 1232 | if (nincluded_files == 0 && file_count == 0) | 1229 | if (nincluded_files == 0 && file_count == 0) |
| 1233 | { | 1230 | { |
| 1234 | error ("no input files specified."); | 1231 | error ("no input files specified."); |
| 1235 | suggest_asking_for_help (); | 1232 | suggest_asking_for_help (); |
| 1236 | /* NOTREACHED */ | ||
| 1237 | } | 1233 | } |
| 1238 | 1234 | ||
| 1239 | if (tagfile == NULL) | 1235 | if (tagfile == NULL) |
diff --git a/lib-src/pop.c b/lib-src/pop.c index e4bd6c04965..9a0dd8ca704 100644 --- a/lib-src/pop.c +++ b/lib-src/pop.c | |||
| @@ -1275,7 +1275,7 @@ pop_getline (popserver server, char **line) | |||
| 1275 | server->buffer_index = 0; | 1275 | server->buffer_index = 0; |
| 1276 | } | 1276 | } |
| 1277 | 1277 | ||
| 1278 | while (1) | 1278 | while (true) |
| 1279 | { | 1279 | { |
| 1280 | /* There's a "- 1" here to leave room for the null that we put | 1280 | /* There's a "- 1" here to leave room for the null that we put |
| 1281 | at the end of the read data below. We put the null there so | 1281 | at the end of the read data below. We put the null there so |
| @@ -1288,7 +1288,7 @@ pop_getline (popserver server, char **line) | |||
| 1288 | { | 1288 | { |
| 1289 | strcpy (pop_error, "Out of memory in pop_getline"); | 1289 | strcpy (pop_error, "Out of memory in pop_getline"); |
| 1290 | pop_trash (server); | 1290 | pop_trash (server); |
| 1291 | return (-1); | 1291 | break; |
| 1292 | } | 1292 | } |
| 1293 | } | 1293 | } |
| 1294 | ret = RECV (server->file, server->buffer + server->data, | 1294 | ret = RECV (server->file, server->buffer + server->data, |
| @@ -1298,13 +1298,13 @@ pop_getline (popserver server, char **line) | |||
| 1298 | snprintf (pop_error, ERROR_MAX, "%s%s", | 1298 | snprintf (pop_error, ERROR_MAX, "%s%s", |
| 1299 | GETLINE_ERROR, strerror (errno)); | 1299 | GETLINE_ERROR, strerror (errno)); |
| 1300 | pop_trash (server); | 1300 | pop_trash (server); |
| 1301 | return (-1); | 1301 | break; |
| 1302 | } | 1302 | } |
| 1303 | else if (ret == 0) | 1303 | else if (ret == 0) |
| 1304 | { | 1304 | { |
| 1305 | strcpy (pop_error, "Unexpected EOF from server in pop_getline"); | 1305 | strcpy (pop_error, "Unexpected EOF from server in pop_getline"); |
| 1306 | pop_trash (server); | 1306 | pop_trash (server); |
| 1307 | return (-1); | 1307 | break; |
| 1308 | } | 1308 | } |
| 1309 | else | 1309 | else |
| 1310 | { | 1310 | { |
| @@ -1332,7 +1332,7 @@ pop_getline (popserver server, char **line) | |||
| 1332 | } | 1332 | } |
| 1333 | } | 1333 | } |
| 1334 | 1334 | ||
| 1335 | /* NOTREACHED */ | 1335 | return -1; |
| 1336 | } | 1336 | } |
| 1337 | 1337 | ||
| 1338 | /* | 1338 | /* |