Add a `--list-charsets' option to Halibut to enumerate canonical names of known
authorjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Fri, 18 Feb 2005 13:17:28 +0000 (13:17 +0000)
committerjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Fri, 18 Feb 2005 13:17:28 +0000 (13:17 +0000)
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
doc/input.but
doc/manpage.but
doc/running.but
halibut.h
help.c
main.c

index 102788a..8fb29ae 100644 (file)
@@ -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
index 978db0c..2d6d489 100644 (file)
@@ -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
index 5e5d5f4..4cf4737 100644 (file)
@@ -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
index f1a3c8c..458d444 100644 (file)
@@ -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
index 8c7caed..1cdddeb 100644 (file)
--- 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 (file)
--- 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 (file)
--- 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 {