aboutsummaryrefslogtreecommitdiff
path: root/gnu/usr.bin
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1999-06-09 00:07:10 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1999-06-09 00:07:10 +0000
commit24c56392dec4cd4862c75bc2471253fdbfb4f6ba (patch)
treea93b60cc66185a126ae0d46e4871b4c2ffdefb78 /gnu/usr.bin
parent68645f3954c0cdeb0d8cc853e41ad365d4cd3739 (diff)
downloadsrc-24c56392dec4cd4862c75bc2471253fdbfb4f6ba.tar.gz
src-24c56392dec4cd4862c75bc2471253fdbfb4f6ba.zip
little optimization of locale sensing code
Notes
Notes: svn path=/head/; revision=47845
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r--gnu/usr.bin/man/man/man.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/gnu/usr.bin/man/man/man.c b/gnu/usr.bin/man/man/man.c
index 0ecae7f224de..800a58579e60 100644
--- a/gnu/usr.bin/man/man/man.c
+++ b/gnu/usr.bin/man/man/man.c
@@ -448,47 +448,30 @@ man_getopt (argc, argv)
}
}
- if (pager == NULL || *pager == '\0')
- if ((pager = getenv ("PAGER")) == NULL)
- pager = strdup (PAGER);
-
- if (debug)
- fprintf (stderr, "\nusing %s as pager\n", pager);
-
- if (manp == NULL)
- {
- if ((manp = manpath (0)) == NULL)
- gripe_manpath ();
-
- if (debug)
- fprintf (stderr,
- "\nsearch path for pages determined by manpath is\n%s\n\n",
- manp);
- }
-
#ifdef __FreeBSD__
if (!use_original && (locale = setlocale(LC_CTYPE, NULL)) != NULL) {
char *tmp;
struct ltable *pltable;
- if ((short_locale = strdup(locale)) == NULL) {
- perror ("ctype locale strdup");
- exit (1);
- }
- if ((tmp = strchr(short_locale, '_')) == NULL
- || tmp != short_locale + 2
+ if ((tmp = strchr(locale, '_')) == NULL
+ || tmp != locale + 2
|| strlen(tmp + 1) < 4
|| tmp[3] != '.') {
if (debug) {
errno = EINVAL;
perror ("ctype locale env");
}
- free(short_locale);
locale = NULL;
} else {
- tmp[1] = short_locale[0];
- tmp[2] = short_locale[1];
- short_locale = tmp + 1;
+ if ((short_locale = strdup(locale)) == NULL) {
+ perror ("ctype locale strdup");
+ exit (1);
+ }
+ tmp = short_locale + 3;
+ tmp[0] = short_locale[0];
+ tmp[1] = short_locale[1];
+ short_locale = tmp;
+
tmp = short_locale + 3;
for (pltable = ltable; pltable->lcode != NULL; pltable++) {
if (strcmp(pltable->lcode, tmp) == 0) {
@@ -500,6 +483,24 @@ man_getopt (argc, argv)
}
#endif
+ if (pager == NULL || *pager == '\0')
+ if ((pager = getenv ("PAGER")) == NULL)
+ pager = strdup (PAGER);
+
+ if (debug)
+ fprintf (stderr, "\nusing %s as pager\n", pager);
+
+ if (manp == NULL)
+ {
+ if ((manp = manpath (0)) == NULL)
+ gripe_manpath ();
+
+ if (debug)
+ fprintf (stderr,
+ "\nsearch path for pages determined by manpath is\n%s\n\n",
+ manp);
+ }
+
#ifdef ALT_SYSTEMS
if (alt_system_name == NULL || *alt_system_name == '\0')
if ((alt_system_name = getenv ("SYSTEM")) != NULL)