From 45dd6bf764064c3b2a9f087d8206179f514638ac Mon Sep 17 00:00:00 2001 From: Jacob Nevins Date: Thu, 17 Feb 2005 19:00:48 +0000 Subject: Changes/additions to input character set handling: - After discussion with Simon, change the default input charset back to ASCII, rather than trying to work it out from the locale, for the sake of promoting .but file portability. - Add a new command-line option "--input-charset=csname", which overrides the ASCII default for all input files (since there's no other way to use a non-ASCII-compatible input file). - Output a warning if -Cinput-charset:foo is specified that it has no effect. - Update the docs to match all this. Also try to clarify some other things in this area that caught me out. [originally from svn r5332] --- main.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index f09b33e..8334d15 100644 --- a/main.c +++ b/main.c @@ -43,6 +43,7 @@ int main(int argc, char **argv) { int nogo; int errs; int reportcols; + int input_charset; int debug; int backendbits, prebackbits; int k, b; @@ -58,6 +59,7 @@ int main(int argc, char **argv) { nfiles = 0; nogo = errs = FALSE; reportcols = 0; + input_charset = CS_ASCII; debug = 0; backendbits = 0; cfg = cfg_tail = NULL; @@ -113,6 +115,17 @@ int main(int argc, char **argv) { } if (k < (int)lenof(backends)) { /* do nothing */; + } else if (!strcmp(opt, "-input-charset")) { + if (!val) { + errs = TRUE, error(err_optnoarg, opt); + } else { + int charset = charset_from_localenc(val); + if (charset == CS_NONE) { + errs = TRUE, error(err_cmdcharset, val); + } else { + input_charset = charset; + } + } } else if (!strcmp(opt, "-help")) { help(); nogo = TRUE; @@ -193,6 +206,10 @@ int main(int argc, char **argv) { while (*q) { if (*q == ':') { *r = '\0'; + /* XXX ad-hoc diagnostic */ + if (!strcmp(s, "input-charset")) + error(err_futileopt, "Cinput-charset", + "; use --input-charset"); cmdline_cfg_add(para, s); r = s; } else { @@ -263,7 +280,7 @@ int main(int argc, char **argv) { in.pushback = NULL; in.reportcols = reportcols; in.stack = NULL; - in.defcharset = charset_from_locale(); + in.defcharset = input_charset; idx = make_index(); -- cgit v1.1