summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Nevins <jacobn@chiark.greenend.org.uk>2005-02-18 13:17:28 +0000
committerJacob Nevins <jacobn@chiark.greenend.org.uk>2005-02-18 13:17:28 +0000
commit1fa5a06bb8ef61eb1a736641138221b1dc16b49e (patch)
treec94b1d4f8bd70c719594a1937c674e61274f2ad9
parentf55620a931827ff666e910a7b1ce2b233738cf06 (diff)
downloadhalibut-1fa5a06bb8ef61eb1a736641138221b1dc16b49e.zip
halibut-1fa5a06bb8ef61eb1a736641138221b1dc16b49e.tar.gz
halibut-1fa5a06bb8ef61eb1a736641138221b1dc16b49e.tar.bz2
halibut-1fa5a06bb8ef61eb1a736641138221b1dc16b49e.tar.xz
Add a `--list-charsets' option to Halibut to enumerate canonical names of known
character sets. (Also make libcharset `return_in_enum' values saner.) [originally from svn r5341] [this svn revision also touched charset,filter,timber]
m---------charset0
-rw-r--r--doc/index.but1
-rw-r--r--doc/input.but2
-rw-r--r--doc/manpage.but4
-rw-r--r--doc/running.but4
-rw-r--r--halibut.h1
-rw-r--r--help.c11
-rw-r--r--main.c3
8 files changed, 26 insertions, 0 deletions
diff --git a/charset b/charset
-Subproject e855edd2c6c22c38997ad7bdc69ea9296c3ab71
+Subproject c98bc7ce138a1f3d73864ac0ad7fe0abeb34791
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 {