diff options
| author | Karl Heuer | 1997-10-31 23:01:48 +0000 |
|---|---|---|
| committer | Karl Heuer | 1997-10-31 23:01:48 +0000 |
| commit | 960d894c38f6c0982e4227231b5db7f85fa93919 (patch) | |
| tree | 1f0b717ee37ec361e52d2a3a493f7361f032d25d /src | |
| parent | 13d603a9949f402c098cb9922dfe787bdcd82545 (diff) | |
| download | emacs-960d894c38f6c0982e4227231b5db7f85fa93919.tar.gz emacs-960d894c38f6c0982e4227231b5db7f85fa93919.zip | |
(init_system_name): If gethostname gives a proper
domain name, don't look farther for one.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sysdep.c | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/src/sysdep.c b/src/sysdep.c index e8e1db80ec0..e8176753b3a 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -2241,53 +2241,54 @@ init_system_name () | |||
| 2241 | #ifndef CANNOT_DUMP | 2241 | #ifndef CANNOT_DUMP |
| 2242 | if (initialized) | 2242 | if (initialized) |
| 2243 | #endif /* not CANNOT_DUMP */ | 2243 | #endif /* not CANNOT_DUMP */ |
| 2244 | { | 2244 | if (! index (hostname, '.')) |
| 2245 | struct hostent *hp; | 2245 | { |
| 2246 | int count; | 2246 | struct hostent *hp; |
| 2247 | for (count = 0;; count++) | 2247 | int count; |
| 2248 | { | 2248 | for (count = 0;; count++) |
| 2249 | { | ||
| 2249 | #ifdef TRY_AGAIN | 2250 | #ifdef TRY_AGAIN |
| 2250 | h_errno = 0; | 2251 | h_errno = 0; |
| 2251 | #endif | 2252 | #endif |
| 2252 | hp = gethostbyname (hostname); | 2253 | hp = gethostbyname (hostname); |
| 2253 | #ifdef TRY_AGAIN | 2254 | #ifdef TRY_AGAIN |
| 2254 | if (! (hp == 0 && h_errno == TRY_AGAIN)) | 2255 | if (! (hp == 0 && h_errno == TRY_AGAIN)) |
| 2255 | #endif | 2256 | #endif |
| 2256 | break; | 2257 | break; |
| 2257 | if (count >= 5) | 2258 | if (count >= 5) |
| 2258 | break; | 2259 | break; |
| 2259 | Fsleep_for (make_number (1), Qnil); | 2260 | Fsleep_for (make_number (1), Qnil); |
| 2260 | } | 2261 | } |
| 2261 | if (hp) | 2262 | if (hp) |
| 2262 | { | 2263 | { |
| 2263 | char *fqdn = (char *) hp->h_name; | 2264 | char *fqdn = (char *) hp->h_name; |
| 2264 | char *p; | 2265 | char *p; |
| 2265 | 2266 | ||
| 2266 | if (!index (fqdn, '.')) | 2267 | if (!index (fqdn, '.')) |
| 2267 | { | 2268 | { |
| 2268 | /* We still don't have a fully qualified domain name. | 2269 | /* We still don't have a fully qualified domain name. |
| 2269 | Try to find one in the list of alternate names */ | 2270 | Try to find one in the list of alternate names */ |
| 2270 | char **alias = hp->h_aliases; | 2271 | char **alias = hp->h_aliases; |
| 2271 | while (*alias && !index (*alias, '.')) | 2272 | while (*alias && !index (*alias, '.')) |
| 2272 | alias++; | 2273 | alias++; |
| 2273 | if (*alias) | 2274 | if (*alias) |
| 2274 | fqdn = *alias; | 2275 | fqdn = *alias; |
| 2275 | } | 2276 | } |
| 2276 | hostname = fqdn; | 2277 | hostname = fqdn; |
| 2277 | #if 0 | 2278 | #if 0 |
| 2278 | /* Convert the host name to lower case. */ | 2279 | /* Convert the host name to lower case. */ |
| 2279 | /* Using ctype.h here would introduce a possible locale | 2280 | /* Using ctype.h here would introduce a possible locale |
| 2280 | dependence that is probably wrong for hostnames. */ | 2281 | dependence that is probably wrong for hostnames. */ |
| 2281 | p = hostname; | 2282 | p = hostname; |
| 2282 | while (*p) | 2283 | while (*p) |
| 2283 | { | 2284 | { |
| 2284 | if (*p >= 'A' && *p <= 'Z') | 2285 | if (*p >= 'A' && *p <= 'Z') |
| 2285 | *p += 'a' - 'A'; | 2286 | *p += 'a' - 'A'; |
| 2286 | p++; | 2287 | p++; |
| 2287 | } | 2288 | } |
| 2288 | #endif | 2289 | #endif |
| 2289 | } | 2290 | } |
| 2290 | } | 2291 | } |
| 2291 | #endif /* HAVE_SOCKETS */ | 2292 | #endif /* HAVE_SOCKETS */ |
| 2292 | /* We used to try using getdomainname as an alternative | 2293 | /* We used to try using getdomainname as an alternative |
| 2293 | to sysinfo, here, but NIIBE Yutaka <gniibe@etl.go.jp> says that | 2294 | to sysinfo, here, but NIIBE Yutaka <gniibe@etl.go.jp> says that |