summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1999-06-09 00:07:10 +0000
committerache <ache@FreeBSD.org>1999-06-09 00:07:10 +0000
commitf6ef6875616b27561cbd9f7f0e44643ea8c07154 (patch)
tree90b6fdcc3328c311f916442d5735ba395d54e956 /gnu
parentb5ed987df095feb40573ae128ef77174046ba3be (diff)
downloadFreeBSD-src-f6ef6875616b27561cbd9f7f0e44643ea8c07154.zip
FreeBSD-src-f6ef6875616b27561cbd9f7f0e44643ea8c07154.tar.gz
little optimization of locale sensing code
Diffstat (limited to 'gnu')
-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 0ecae7f..800a585 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)
OpenPOWER on IntegriCloud