Pass our idea of a manpage's locale from man(1) down to mdoc(7).

This commit is contained in:
Ruslan Ermilov 2002-09-30 11:00:04 +00:00
parent e00e16ad7f
commit b660485bd4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=104203
2 changed files with 16 additions and 5 deletions

View File

@ -56,9 +56,9 @@
.ec .ec
. .
.\" Locale support .\" Locale support
.if d doc-lang \{\ .if d doc-locale \{\
. ie "\*[doc-lang]"ru.KOI8-R" \ . ie "\*[doc-locale]"ru.KOI8-R" \
. mso mdoc/koi8-r . mso mdoc/koi8-r
. el \{ .if "\*[doc-lang]"fr.ISO8859-1" \ . el \{ .if "\*[doc-locale]"fr.ISO8859-1" \
. mso mdoc/fr.ISO8859-1 . mso mdoc/fr.ISO8859-1
.\}\} .\}\}

View File

@ -89,6 +89,8 @@ static int print_where;
#ifdef __FreeBSD__ #ifdef __FreeBSD__
static char *locale, *locale_opts, *locale_nroff, *locale_codeset; static char *locale, *locale_opts, *locale_nroff, *locale_codeset;
static char locale_terr[3], locale_lang[3]; static char locale_terr[3], locale_lang[3];
static char *man_locale;
static int use_man_locale;
static int use_original; static int use_original;
struct ltable { struct ltable {
char *lcode; char *lcode;
@ -443,6 +445,7 @@ man_getopt (argc, argv)
break; break;
} }
} }
asprintf(&man_locale, "%s.%s", locale_lang, locale_codeset);
} }
} else { } else {
if (locale == NULL) { if (locale == NULL) {
@ -1030,8 +1033,10 @@ parse_roff_directive (cp, file, buf, bufsize)
#ifdef __FreeBSD__ #ifdef __FreeBSD__
char lbuf[FILENAME_MAX]; char lbuf[FILENAME_MAX];
snprintf(lbuf, sizeof(lbuf), "%s -T%s", NROFF, snprintf(lbuf, sizeof(lbuf), "%s -T%s%s%s", NROFF,
locale_opts == NULL ? "ascii" : locale_opts); locale_opts == NULL ? "ascii" : locale_opts,
use_man_locale ? " -dlocale=" : "",
use_man_locale ? man_locale : "");
add_directive (&first, lbuf, file, buf, bufsize); add_directive (&first, lbuf, file, buf, bufsize);
#else #else
add_directive (&first, NROFF " -Tascii", file, buf, bufsize); add_directive (&first, NROFF " -Tascii", file, buf, bufsize);
@ -1583,6 +1588,7 @@ man (name)
l_found = 0; l_found = 0;
if (locale != NULL) { if (locale != NULL) {
locale_opts = locale_nroff; locale_opts = locale_nroff;
use_man_locale = 1;
if (*locale_lang != '\0' && *locale_terr != '\0') { if (*locale_lang != '\0' && *locale_terr != '\0') {
snprintf(buf, sizeof(buf), "%s/%s_%s.%s", *mp, snprintf(buf, sizeof(buf), "%s/%s_%s.%s", *mp,
locale_lang, locale_terr, locale_codeset); locale_lang, locale_terr, locale_codeset);
@ -1596,6 +1602,7 @@ man (name)
if (is_directory (buf) == 1) if (is_directory (buf) == 1)
l_found = try_section (buf, shortsec, longsec, name, glob); l_found = try_section (buf, shortsec, longsec, name, glob);
} }
use_man_locale = 0;
if (!l_found && strcmp(locale_lang, "en") != 0) { if (!l_found && strcmp(locale_lang, "en") != 0) {
snprintf(buf, sizeof(buf), "%s/en.%s", *mp, snprintf(buf, sizeof(buf), "%s/en.%s", *mp,
locale_codeset); locale_codeset);
@ -1604,6 +1611,7 @@ man (name)
} }
} }
locale_opts = NULL; locale_opts = NULL;
use_man_locale = 0;
} }
if (!l_found) { if (!l_found) {
#endif #endif
@ -1632,6 +1640,7 @@ man (name)
l_found = 0; l_found = 0;
if (locale != NULL) { if (locale != NULL) {
locale_opts = locale_nroff; locale_opts = locale_nroff;
use_man_locale = 1;
if (*locale_lang != '\0' && *locale_terr != '\0') { if (*locale_lang != '\0' && *locale_terr != '\0') {
snprintf(buf, sizeof(buf), "%s/%s_%s.%s", *mp, snprintf(buf, sizeof(buf), "%s/%s_%s.%s", *mp,
locale_lang, locale_terr, locale_codeset); locale_lang, locale_terr, locale_codeset);
@ -1645,6 +1654,7 @@ man (name)
if (is_directory (buf) == 1) if (is_directory (buf) == 1)
l_found = try_section (buf, *sp, longsec, name, glob); l_found = try_section (buf, *sp, longsec, name, glob);
} }
use_man_locale = 0;
if (!l_found && strcmp(locale_lang, "en") != 0) { if (!l_found && strcmp(locale_lang, "en") != 0) {
snprintf(buf, sizeof(buf), "%s/en.%s", *mp, snprintf(buf, sizeof(buf), "%s/en.%s", *mp,
locale_codeset); locale_codeset);
@ -1653,6 +1663,7 @@ man (name)
} }
} }
locale_opts = NULL; locale_opts = NULL;
use_man_locale = 0;
} }
if (!l_found) { if (!l_found) {
#endif #endif