summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1999-06-07 18:36:00 +0000
committerache <ache@FreeBSD.org>1999-06-07 18:36:00 +0000
commitdc1229d27bddbf962473577c7831b6e2b035b441 (patch)
tree5f6d294f69103c3b4e48ee86c7ca9ee4140d3598 /gnu
parentdcb08e10ae76c01a5ada8606d738723a94a91fc3 (diff)
downloadFreeBSD-src-dc1229d27bddbf962473577c7831b6e2b035b441.zip
FreeBSD-src-dc1229d27bddbf962473577c7831b6e2b035b441.tar.gz
Add ability to read/write localized manpages
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/man/Makefile.inc3
-rw-r--r--gnu/usr.bin/man/man/man.c152
-rw-r--r--gnu/usr.bin/man/man/man.man10
3 files changed, 163 insertions, 2 deletions
diff --git a/gnu/usr.bin/man/Makefile.inc b/gnu/usr.bin/man/Makefile.inc
index 7159325..25ba7bb 100644
--- a/gnu/usr.bin/man/Makefile.inc
+++ b/gnu/usr.bin/man/Makefile.inc
@@ -7,7 +7,8 @@ bindir= ${BINDIR}
pager= more -s
manpath_config_file= /etc/manpath.config
troff= /usr/bin/groff -man
-nroff= /usr/bin/groff -Wall -mtty-char -Tascii -man
+# -Tascii or localized encoding added automatically
+nroff= /usr/bin/groff -Wall -mtty-char -man
apropos= /usr/bin/apropos
whatis= /usr/bin/whatis
neqn= /usr/bin/eqn -Tascii
diff --git a/gnu/usr.bin/man/man/man.c b/gnu/usr.bin/man/man/man.c
index 6d2aacd..d380477 100644
--- a/gnu/usr.bin/man/man/man.c
+++ b/gnu/usr.bin/man/man/man.c
@@ -85,23 +85,54 @@ static int alt_system;
static char *alt_system_name;
#endif
+#ifdef __FreeBSD__
+/* short_locale without country suffix */
+static char *locale, *short_locale, *locale_opts, *locale_nroff;
+static int use_original;
+struct ltable {
+ char *lcode;
+ char *nroff;
+};
+static struct ltable ltable[] = {
+ {"KOI8-R", " -Tkoi8-r"},
+ {"ISO_8859-1", " -Tlatin1"},
+ {NULL, NULL}
+};
+#endif
+
static int troff = 0;
int debug;
#ifdef HAS_TROFF
#ifdef ALT_SYSTEMS
+#ifdef __FreeBSD__
+static char args[] = "M:P:S:adfhkm:op:tw?";
+#else
static char args[] = "M:P:S:adfhkm:p:tw?";
+#endif
+#else
+#ifdef __FreeBSD__
+static char args[] = "M:P:S:adfhkop:tw?";
#else
static char args[] = "M:P:S:adfhkp:tw?";
#endif
+#endif
#else
#ifdef ALT_SYSTEMS
+#ifdef __FreeBSD__
+static char args[] = "M:P:S:adfhkm:op:w?";
+#else
static char args[] = "M:P:S:adfhkm:p:w?";
+#endif
+#else
+#ifdef __FreeBSD__
+static char args[] = "M:P:S:adfhkop:w?";
#else
static char args[] = "M:P:S:adfhkp:w?";
#endif
#endif
+#endif
#ifdef SETREUID
uid_t ruid;
@@ -203,25 +234,49 @@ usage ()
#ifdef HAS_TROFF
#ifdef ALT_SYSTEMS
+#ifdef __FreeBSD__
+ static char s1[] =
+ "usage: %s [-adfhkotw] [section] [-M path] [-P pager] [-S list]\n\
+ [-m system] [-p string] name ...\n\n";
+#else
static char s1[] =
"usage: %s [-adfhktw] [section] [-M path] [-P pager] [-S list]\n\
[-m system] [-p string] name ...\n\n";
+#endif
+#else
+#ifdef __FreeBSD__
+ static char s1[] =
+ "usage: %s [-adfhkotw] [section] [-M path] [-P pager] [-S list]\n\
+ [-p string] name ...\n\n";
#else
static char s1[] =
"usage: %s [-adfhktw] [section] [-M path] [-P pager] [-S list]\n\
[-p string] name ...\n\n";
#endif
+#endif
#else
#ifdef ALT_SYSTEMS
+#ifdef __FreeBSD__
+ static char s1[] =
+ "usage: %s [-adfhkow] [section] [-M path] [-P pager] [-S list]\n\
+ [-m system] [-p string] name ...\n\n";
+#else
static char s1[] =
"usage: %s [-adfhkw] [section] [-M path] [-P pager] [-S list]\n\
[-m system] [-p string] name ...\n\n";
+#endif
+#else
+#ifdef __FreeBSD__
+ static char s1[] =
+ "usage: %s [-adfhkow] [section] [-M path] [-P pager] [-S list]\n\
+ [-p string] name ...\n\n";
#else
static char s1[] =
"usage: %s [-adfhkw] [section] [-M path] [-P pager] [-S list]\n\
[-p string] name ...\n\n";
#endif
#endif
+#endif
static char s2[] = " a : find all matching entries\n\
d : print gobs of debugging information\n\
@@ -229,6 +284,10 @@ static char s2[] = " a : find all matching entries\n\
h : print this help message\n\
k : same as apropos(1)\n";
+#ifdef __FreeBSD__
+ static char s21[] = " o : use original, non-localized manpages\n";
+#endif
+
#ifdef HAS_TROFF
static char s3[] = " t : use troff to format pages for printing\n";
#endif
@@ -248,6 +307,9 @@ static char s2[] = " a : find all matching entries\n\
strcat (usage_string, s1);
strcat (usage_string, s2);
+#ifdef __FreeBSD__
+ strcat (usage_string, s21);
+#endif
#ifdef HAS_TROFF
strcat (usage_string, s3);
@@ -352,6 +414,9 @@ man_getopt (argc, argv)
alt_system_name = strdup (optarg);
break;
#endif
+ case 'o':
+ use_original++;
+ break;
case 'p':
roff_directive = strdup (optarg);
break;
@@ -401,6 +466,36 @@ man_getopt (argc, argv)
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
+ || strlen(tmp + 1) < 4
+ || tmp[3] != '.') {
+ errno = EINVAL;
+ perror ("bad ctype locale env");
+ exit (1);
+ }
+ tmp[1] = short_locale[0];
+ tmp[2] = short_locale[1];
+ short_locale = tmp + 1;
+ tmp = short_locale + 3;
+ for (pltable = ltable; pltable->lcode != NULL; pltable++) {
+ if (strcmp(pltable->lcode, tmp) == 0) {
+ locale_nroff = pltable->nroff;
+ break;
+ }
+ }
+ }
+#endif
+
#ifdef ALT_SYSTEMS
if (alt_system_name == NULL || *alt_system_name == '\0')
if ((alt_system_name = getenv ("SYSTEM")) != NULL)
@@ -907,6 +1002,12 @@ parse_roff_directive (cp, file, buf, bufsize)
{
strncat (buf, " | ", bufsize-strlen(buf)-1);
strncat (buf, NROFF, bufsize-strlen(buf)-1);
+#ifdef __FreeBSD__
+ if (locale_opts != NULL)
+ strncat (buf, locale_opts, bufsize-strlen(buf)-1);
+ else
+#endif
+ strncat (buf, " -Tascii", bufsize-strlen(buf)-1);
}
if (tbl_found && !troff && strcmp (COL, "") != 0)
{
@@ -1018,6 +1119,13 @@ make_roff_command (file)
strncpy (buf, NROFF, sizeof(buf));
}
+#ifdef __FreeBSD__
+ if (locale_opts != NULL)
+ strncat (buf, locale_opts, sizeof(buf)-strlen(buf)-1);
+ else
+#endif
+ strncat (buf, " -Tascii", sizeof(buf)-strlen(buf)-1);
+
if (strcmp (COL, "") != 0)
{
strncat (buf, " | ", sizeof(buf)-strlen(buf)-1);
@@ -1463,6 +1571,10 @@ man (name)
register int glob;
register char **mp;
register char **sp;
+#ifdef __FreeBSD__
+ int l_found;
+ char buf[FILENAME_MAX];
+#endif
found = 0;
@@ -1476,7 +1588,27 @@ man (name)
glob = 1;
+#ifdef __FreeBSD__
+ l_found = 0;
+ if (locale != NULL) {
+ locale_opts = locale_nroff;
+ snprintf(buf, sizeof(buf), "%s/%s", *mp, locale);
+ if (is_directory (buf))
+ l_found = try_section (buf, section, name, glob);
+ if (!l_found) {
+ snprintf(buf, sizeof(buf), "%s/%s", *mp, short_locale);
+ if (is_directory (buf))
+ l_found = try_section (buf, section, name, glob);
+ }
+ locale_opts = NULL;
+ }
+ if (!l_found) {
+#endif
found += try_section (*mp, section, name, glob);
+#ifdef __FreeBSD__
+ } else
+ found += l_found;
+#endif
if (found && !findall) /* i.e. only do this section... */
return found;
@@ -1493,7 +1625,27 @@ man (name)
glob = 1;
+#ifdef __FreeBSD__
+ l_found = 0;
+ if (locale != NULL) {
+ locale_opts = locale_nroff;
+ snprintf(buf, sizeof(buf), "%s/%s", *mp, locale);
+ if (is_directory (buf))
+ l_found = try_section (buf, *sp, name, glob);
+ if (!l_found) {
+ snprintf(buf, sizeof(buf), "%s/%s", *mp, short_locale);
+ if (is_directory (buf))
+ l_found = try_section (buf, *sp, name, glob);
+ }
+ locale_opts = NULL;
+ }
+ if (!l_found) {
+#endif
found += try_section (*mp, *sp, name, glob);
+#ifdef __FreeBSD__
+ } else
+ found += l_found;
+#endif
if (found && !findall) /* i.e. only do this section... */
return found;
diff --git a/gnu/usr.bin/man/man/man.man b/gnu/usr.bin/man/man/man.man
index b597929..b3b49a9 100644
--- a/gnu/usr.bin/man/man/man.man
+++ b/gnu/usr.bin/man/man/man.man
@@ -19,7 +19,7 @@
.Nd format and display the on-line manual pages
.Sh SYNOPSIS
.Nm man
-.Op Fl adfhktw
+.Op Fl adfhkotw
.Op Fl m Ar system
.Op Fl p Ar string
.Op Fl M Ar path
@@ -83,6 +83,14 @@ Equivalent to
.It Fl m Ar system
Specify an alternate set of man pages to search based on the system
name given.
+.It Fl o
+Use original, non-localized manpages. By default, man searches
+for localized subdirectories of each manpath component, subdirectory
+name is determined by the
+.Ev LANG
+or
+.Ev LC_CTYPE
+environment variables.
.It Fl p Ar string
Specify the sequence of preprocessors to run before nroff or troff.
Not all installations will have a full set of preprocessors.
OpenPOWER on IntegriCloud