diff options
| author | Simon Tatham <anakin@pobox.com> | 2012-08-29 18:13:11 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2012-08-29 18:13:11 +0000 |
| commit | 1489dc15967970576d08f3f2b22c6e1c939bcbcf (patch) | |
| tree | 0b27653cc4d5485e273edbf5e8ade37b26b6b44c /main.c | |
| parent | 17fc8b40eb9b3f03945512bf17be99332aeefecb (diff) | |
| download | halibut-1489dc15967970576d08f3f2b22c6e1c939bcbcf.zip halibut-1489dc15967970576d08f3f2b22c6e1c939bcbcf.tar.gz halibut-1489dc15967970576d08f3f2b22c6e1c939bcbcf.tar.bz2 halibut-1489dc15967970576d08f3f2b22c6e1c939bcbcf.tar.xz | |
Revamp of the Halibut error handling mechanism.
I'm not quite sure why I ever thought it was a good idea to have a
central variadic error() function taking an integer error code
followed by some list of arguments that depend on that code. It now
seems obvious to me that it's a much more sensible idea to have a
separate function per error, so that we can check at compile time that
the arguments to each error call are of the right number and type! So
I've done that instead.
A side effect is that the errors are no longer formatted into a
fixed-size buffer before going to stderr, so I can remove all the
%.200s precautions in the format strings.
[originally from svn r9639]
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -128,11 +128,11 @@ int main(int argc, char **argv) { /* do nothing */; } else if (!strcmp(opt, "-input-charset")) { if (!val) { - errs = TRUE, error(err_optnoarg, opt); + errs = TRUE, err_optnoarg(opt); } else { int charset = charset_from_localenc(val); if (charset == CS_NONE) { - errs = TRUE, error(err_cmdcharset, val); + errs = TRUE, err_cmdcharset(val); } else { input_charset = charset; } @@ -155,7 +155,7 @@ int main(int argc, char **argv) { } else if (!strcmp(opt, "-precise")) { reportcols = 1; } else { - errs = TRUE, error(err_nosuchopt, opt); + errs = TRUE, err_nosuchopt(opt); } } p = NULL; @@ -200,7 +200,7 @@ int main(int argc, char **argv) { char opt[2]; opt[0] = c; opt[1] = '\0'; - errs = TRUE, error(err_optnoarg, opt); + errs = TRUE, err_optnoarg(opt); } /* * Now c is the option and p is the parameter. @@ -224,7 +224,7 @@ int main(int argc, char **argv) { *r = '\0'; /* XXX ad-hoc diagnostic */ if (!strcmp(s, "input-charset")) - error(err_futileopt, "Cinput-charset", + err_futileopt("Cinput-charset", "; use --input-charset"); cmdline_cfg_add(para, s); r = s; @@ -256,7 +256,7 @@ int main(int argc, char **argv) { char opt[2]; opt[0] = c; opt[1] = '\0'; - errs = TRUE, error(err_nosuchopt, opt); + errs = TRUE, err_nosuchopt(opt); } } } @@ -280,7 +280,7 @@ int main(int argc, char **argv) { * Do the work. */ if (nfiles == 0 && !list_fonts) { - error(err_noinput); + err_noinput(); usage(); exit(EXIT_FAILURE); } |