From f336fa9a110d8da793932b803ed0b5ad7fe72826 Mon Sep 17 00:00:00 2001 From: jacob Date: Fri, 18 Feb 2005 13:17:28 +0000 Subject: [PATCH] Add a `--list-charsets' option to Halibut to enumerate canonical names of known character sets. (Also make libcharset `return_in_enum' values saner.) git-svn-id: svn://svn.tartarus.org/sgt/halibut@5341 cda61777-01e9-0310-a592-d414129be87e --- doc/index.but | 1 + doc/input.but | 2 ++ doc/manpage.but | 4 ++++ doc/running.but | 4 ++++ halibut.h | 1 + help.c | 11 +++++++++++ main.c | 3 +++ 7 files changed, 26 insertions(+) diff --git a/doc/index.but b/doc/index.but index 102788a..8fb29ae 100644 --- a/doc/index.but +++ b/doc/index.but @@ -538,6 +538,7 @@ directive \IM{--help} \c{--help} command-line option \IM{--version} \c{--version} command-line option \IM{--licence} \c{--licence} command-line option +\IM{--list-charsets} \c{--list-charsets} command-line option \IM{--precise} \c{--precise} command-line option \IM{command syntax} commands, general syntax of diff --git a/doc/input.but b/doc/input.but index 978db0c..2d6d489 100644 --- a/doc/input.but +++ b/doc/input.but @@ -1338,6 +1338,8 @@ input file in. By default, it is assumed to be US-ASCII (meaning You can specify any well-known name for any supported character set. For example, \c{iso-8859-1}, \c{iso8859-1} and \c{iso_8859-1} are all recognised, \c{GB2312} and \c{EUC-CN} both work, and so on. +(You can list character sets known to Halibut with by invoking it +with the \cw{--list-charsets} option; see \k{running-options}.) This directive takes effect immediately after the \c{\\cfg} command. All text after that until the end of the input file is expected to be diff --git a/doc/manpage.but b/doc/manpage.but index 5e5d5f4..4cf4737 100644 --- a/doc/manpage.but +++ b/doc/manpage.but @@ -113,6 +113,10 @@ extra input file to the command line which contains the directive \dd Changes the assumed character set for input files from the default of ASCII. +\dt \cw{--list-charsets} + +\dd Makes Halibut list character sets known to it. + \dt \cw{--precise} \dd Makes Halibut report the column number as well as the line diff --git a/doc/running.but b/doc/running.but index f1a3c8c..458d444 100644 --- a/doc/running.but +++ b/doc/running.but @@ -200,6 +200,10 @@ See \k{input-config} for more information about the input character set. } +\dt \I{character sets, enumerating}\i\cw{--list-charsets} + +\dd List character sets known to Halibut. + \dt \i\cw{--help} \dd Print a brief help message and exit immediately. (Don't confuse diff --git a/halibut.h b/halibut.h index 8c7caed..1cdddeb 100644 --- a/halibut.h +++ b/halibut.h @@ -316,6 +316,7 @@ int ustrwid(wchar_t const *s, int charset); void help(void); void usage(void); void showversion(void); +void listcharsets(void); /* * licence.c diff --git a/help.c b/help.c index 7235032..e31f784 100644 --- a/help.c +++ b/help.c @@ -16,6 +16,7 @@ static char *helptext[] = { " --pdf[=filename] generate PDF output", " -Cfoo:bar:baz append \\cfg{foo}{bar}{baz} to input", " --input-charset=cs change default input file charset", + " --list-charsets display supported character set names", " --precise report column numbers in error messages", " --help display this text", " --version display version number", @@ -43,3 +44,13 @@ void usage(void) { void showversion(void) { printf("Halibut, %s\n", version); } + +void listcharsets(void) { + int i = 0, c; + do { + c = charset_localenc_nth(i); + if (c == CS_NONE) break; + printf("%s\n", charset_to_localenc(c)); + i++; + } while (1); +} diff --git a/main.c b/main.c index 8334d15..4304c7c 100644 --- a/main.c +++ b/main.c @@ -136,6 +136,9 @@ int main(int argc, char **argv) { !strcmp(opt, "-license")) { licence(); nogo = TRUE; + } else if (!strcmp(opt, "-list-charsets")) { + listcharsets(); + nogo = TRUE; } else if (!strcmp(opt, "-precise")) { reportcols = 1; } else { -- 2.11.0