diff options
| author | Jacob Nevins <jacobn@chiark.greenend.org.uk> | 2005-02-17 19:00:48 +0000 |
|---|---|---|
| committer | Jacob Nevins <jacobn@chiark.greenend.org.uk> | 2005-02-17 19:00:48 +0000 |
| commit | 45dd6bf764064c3b2a9f087d8206179f514638ac (patch) | |
| tree | 48031c7b55380daef6591727dbd0843af77ee844 /main.c | |
| parent | 4a48e5878f2ededa8bc33e620e26489bf911c5cb (diff) | |
| download | halibut-45dd6bf764064c3b2a9f087d8206179f514638ac.zip halibut-45dd6bf764064c3b2a9f087d8206179f514638ac.tar.gz halibut-45dd6bf764064c3b2a9f087d8206179f514638ac.tar.bz2 halibut-45dd6bf764064c3b2a9f087d8206179f514638ac.tar.xz | |
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]
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -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(); |