diff options
author | Alexey Gladkov <gladkov.alexey@gmail.com> | 2020-06-02 13:14:28 +0200 |
---|---|---|
committer | Alexey Gladkov <gladkov.alexey@gmail.com> | 2020-06-02 13:14:28 +0200 |
commit | c784dde1b5aee91373bac8f4e175f99988d61c90 (patch) | |
tree | 89d164e3ee09a513a052ffcab163ec7be1799b32 | |
parent | 8bd44e14fdf6c68db8552cce9ccef1d6e24c3a8f (diff) | |
download | kbd-c784dde1b5aee91373bac8f4e175f99988d61c90.tar.gz |
Improve and unify error some messages
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
-rw-r--r-- | src/chvt.c | 10 | ||||
-rw-r--r-- | src/clrunimap.c | 2 | ||||
-rw-r--r-- | src/deallocvt.c | 4 | ||||
-rw-r--r-- | src/dumpkeys.c | 4 | ||||
-rw-r--r-- | src/fgconsole.c | 2 | ||||
-rw-r--r-- | src/getkeycodes.c | 2 | ||||
-rw-r--r-- | src/getunimap.c | 2 | ||||
-rw-r--r-- | src/kbd_mode.c | 26 | ||||
-rw-r--r-- | src/kbdinfo.c | 12 | ||||
-rw-r--r-- | src/libcommon/getfd.c | 2 | ||||
-rw-r--r-- | src/libkfont/loadunimap.c | 9 | ||||
-rw-r--r-- | src/libkfont/mapscrn.c | 6 | ||||
-rw-r--r-- | src/libkfont/setfont.c | 8 | ||||
-rw-r--r-- | src/loadkeys.c | 65 | ||||
-rw-r--r-- | src/loadunimap.c | 2 | ||||
-rw-r--r-- | src/mapscrn.c | 2 | ||||
-rw-r--r-- | src/openvt.c | 5 | ||||
-rw-r--r-- | src/psfxtable.c | 8 | ||||
-rw-r--r-- | src/resizecons.c | 12 | ||||
-rw-r--r-- | src/screendump.c | 14 | ||||
-rw-r--r-- | src/setfont.c | 16 | ||||
-rw-r--r-- | src/setkeycodes.c | 2 | ||||
-rw-r--r-- | src/setleds.c | 11 | ||||
-rw-r--r-- | src/setlogcons.c | 2 | ||||
-rw-r--r-- | src/setmetamode.c | 11 | ||||
-rw-r--r-- | src/setpalette.c | 2 | ||||
-rw-r--r-- | src/setvesablank.c | 4 | ||||
-rw-r--r-- | src/setvtrgb.c | 6 | ||||
-rw-r--r-- | src/showconsolefont.c | 10 | ||||
-rw-r--r-- | src/showkey.c | 8 | ||||
-rw-r--r-- | src/totextmode.c | 2 |
31 files changed, 123 insertions, 148 deletions
@@ -95,12 +95,12 @@ int main(int argc, char *argv[]) } if (argc == optind) { - fprintf(stderr, _("Argument required\n")); + kbd_warning(0, _("Not enough arguments.")); usage(EX_USAGE, opthelp); } if ((fd = getfd(NULL)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); num = atoi(argv[optind]); @@ -109,14 +109,14 @@ int main(int argc, char *argv[]) sigemptyset(&sa.sa_mask); if (sigaction(SIGALRM, &sa, NULL) < 0) - kbd_error(EXIT_FAILURE, errno, "sigaction"); + kbd_error(EXIT_FAILURE, errno, _("Unable to set signal handler")); sev.sigev_notify = SIGEV_SIGNAL; sev.sigev_signo = SIGALRM; sev.sigev_value.sival_ptr = &timerid; if (timer_create(CLOCK_REALTIME, &sev, &timerid) < 0) - kbd_error(EXIT_FAILURE, errno, "timer_create"); + kbd_error(EXIT_FAILURE, errno, _("Unable to create timer")); its.it_value.tv_sec = 1; its.it_value.tv_nsec = 0; @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) its.it_interval.tv_nsec = its.it_value.tv_nsec; if (timer_settime(timerid, 0, &its, NULL) < 0) - kbd_error(EXIT_FAILURE, errno, "timer_settimer"); + kbd_error(EXIT_FAILURE, errno, _("Unable to set timer")); do { errno = 0; diff --git a/src/clrunimap.c b/src/clrunimap.c index 7791be7f..430cf0be 100644 --- a/src/clrunimap.c +++ b/src/clrunimap.c @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) console = argv[2]; if ((fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); int ret; struct kfont_context *ctx; diff --git a/src/deallocvt.c b/src/deallocvt.c index e1a24f0a..10dfedd3 100644 --- a/src/deallocvt.c +++ b/src/deallocvt.c @@ -85,13 +85,13 @@ int main(int argc, char *argv[]) for (i = optind; i < argc; i++) { if (!isdigit(argv[i][0])) { - fprintf(stderr, _("%s: unknown option\n"), get_progname()); + kbd_warning(0, _("Unrecognized argument: %s"), argv[i]); return EX_USAGE; } } if ((fd = getfd(NULL)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); if (argc == 1) { /* deallocate all unused consoles */ diff --git a/src/dumpkeys.c b/src/dumpkeys.c index 9bcc5d15..9395db9b 100644 --- a/src/dumpkeys.c +++ b/src/dumpkeys.c @@ -187,11 +187,11 @@ int main(int argc, char *argv[]) usage(EX_USAGE, opthelp); if ((fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); /* check whether the keyboard is in Unicode mode */ if (ioctl(fd, KDGKBMODE, &kbd_mode)) - kbd_error(EXIT_FAILURE, errno, _("error reading keyboard mode")); + kbd_error(EXIT_FAILURE, errno, _("Unable to read keyboard mode")); if (kbd_mode == K_UNICODE) { lk_set_parser_flags(ctx, LK_FLAG_PREFER_UNICODE); diff --git a/src/fgconsole.c b/src/fgconsole.c index ce50e9ed..e11b847c 100644 --- a/src/fgconsole.c +++ b/src/fgconsole.c @@ -93,7 +93,7 @@ int main(int argc, char **argv) } if ((fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); if (show_vt) { if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) || vtno == -1) { diff --git a/src/getkeycodes.c b/src/getkeycodes.c index 6cbf5262..ae127031 100644 --- a/src/getkeycodes.c +++ b/src/getkeycodes.c @@ -84,7 +84,7 @@ int main(int argc, char **argv) } if ((fd = getfd(NULL)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); /* Old kernels don't support changing scancodes below SC_LIM. */ a.scancode = 0; diff --git a/src/getunimap.c b/src/getunimap.c index 3812ccd8..4937794d 100644 --- a/src/getunimap.c +++ b/src/getunimap.c @@ -110,7 +110,7 @@ int main(int argc, char **argv) usage(EX_USAGE, opthelp); if ((fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); int ret; struct kfont_context *kfont; diff --git a/src/kbd_mode.c b/src/kbd_mode.c index 90a2f15c..603c6408 100644 --- a/src/kbd_mode.c +++ b/src/kbd_mode.c @@ -57,20 +57,21 @@ fprint_mode(FILE *stream, int mode) { switch (mode) { case K_RAW: - fprintf(stream, _("The keyboard is in raw (scancode) mode\n")); + fprintf(stream, _("The keyboard is in raw (scancode) mode")); break; case K_MEDIUMRAW: - fprintf(stream, _("The keyboard is in mediumraw (keycode) mode\n")); + fprintf(stream, _("The keyboard is in mediumraw (keycode) mode")); break; case K_XLATE: - fprintf(stream, _("The keyboard is in the default (ASCII) mode\n")); + fprintf(stream, _("The keyboard is in the default (ASCII) mode")); break; case K_UNICODE: - fprintf(stream, _("The keyboard is in Unicode (UTF-8) mode\n")); + fprintf(stream, _("The keyboard is in Unicode (UTF-8) mode")); break; default: - fprintf(stream, _("The keyboard is in some unknown mode\n")); - } + fprintf(stream, _("The keyboard is in some unknown mode")); + } + printf("\n"); } int main(int argc, char *argv[]) @@ -152,22 +153,21 @@ int main(int argc, char *argv[]) } if ((fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); if (n == 0) { /* report mode */ - if (ioctl(fd, KDGKBMODE, &mode)) { - kbd_error(EXIT_FAILURE, errno, "ioctl KDGKBMODE"); - } + if (ioctl(fd, KDGKBMODE, &mode)) + kbd_error(EXIT_FAILURE, errno, _("Unable to read keyboard mode")); + fprint_mode(stdout, mode); return EXIT_SUCCESS; } if (force == 0) { /* only perform safe mode switches */ - if (ioctl(fd, KDGKBMODE, &orig_mode)) { - kbd_error(EXIT_FAILURE, errno, "ioctl KDGKBMODE"); - } + if (ioctl(fd, KDGKBMODE, &orig_mode)) + kbd_error(EXIT_FAILURE, errno, _("Unable to read keyboard mode")); if (mode == orig_mode) { /* skip mode change */ diff --git a/src/kbdinfo.c b/src/kbdinfo.c index 4dbbf90e..ceeb5e88 100644 --- a/src/kbdinfo.c +++ b/src/kbdinfo.c @@ -119,11 +119,11 @@ int main(int argc, char **argv) value = argv[optind++]; if ((fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); if (!strcasecmp("GETMODE", action)) { if (ioctl(fd, KDGETMODE, &mode) == -1) - kbd_error(EXIT_FAILURE, errno, "ioctl KDGETMODE"); + kbd_error(EXIT_FAILURE, errno, _("Unable to read console mode")); switch (mode) { case KD_TEXT: @@ -136,7 +136,7 @@ int main(int argc, char **argv) } else if (!strcasecmp("GKBMODE", action)) { if (ioctl(fd, KDGKBMODE, &mode) == -1) - kbd_error(EXIT_FAILURE, errno, "ioctl KDGKBMODE"); + kbd_error(EXIT_FAILURE, errno, _("Unable to read keyboard mode")); switch (mode) { case K_RAW: @@ -155,7 +155,7 @@ int main(int argc, char **argv) } else if (!strcasecmp("GKBMETA", action)) { if (ioctl(fd, KDGKBMETA, &mode) == -1) - kbd_error(EXIT_FAILURE, errno, "ioctl KDGKBMETA"); + kbd_error(EXIT_FAILURE, errno, _("Unable to read meta key handling mode")); switch (mode) { case K_METABIT: @@ -168,7 +168,7 @@ int main(int argc, char **argv) } else if (!strcasecmp("GKBLED", action)) { if (ioctl(fd, KDGKBLED, &flags) == -1) - kbd_error(EXIT_FAILURE, errno, "ioctl KDGKBLED"); + kbd_error(EXIT_FAILURE, errno, _("Unable to read keyboard flags")); mode = (flags & 0x7); @@ -185,7 +185,7 @@ int main(int argc, char **argv) } } else { - kbd_warning(0, _("Unrecognized action: %s"), action); + kbd_warning(0, _("Unrecognized argument: %s"), action); } close(fd); diff --git a/src/libcommon/getfd.c b/src/libcommon/getfd.c index b65d927a..fab49c73 100644 --- a/src/libcommon/getfd.c +++ b/src/libcommon/getfd.c @@ -85,7 +85,7 @@ getfd(const char *fnam) return fd; fprintf(stderr, - _("Couldn't get a file descriptor referring to the console")); + _("Couldn't get a file descriptor referring to the console.")); fprintf(stderr, "\n"); /* total failure */ diff --git a/src/libkfont/loadunimap.c b/src/libkfont/loadunimap.c index 285cbe9b..bb60c898 100644 --- a/src/libkfont/loadunimap.c +++ b/src/libkfont/loadunimap.c @@ -300,10 +300,9 @@ getunicodemap(struct kfont_context *ctx, int fd, struct unimapdesc *unimap_descr if (kfont_get_unicodemap(ctx, fd, unimap_descr)) return -1; -#ifdef MAIN - fprintf(stderr, "# %d %s\n", unimap_descr->entry_ct, - (unimap_descr->entry_ct == 1) ? _("entry") : _("entries")); -#endif + if (ctx->verbose) + KFONT_INFO(ctx, P_("# %d entry", "# %d entries", unimap_descr->entry_ct), + unimap_descr->entry_ct); return 0; } @@ -317,7 +316,7 @@ kfont_save_unicodemap(struct kfont_context *ctx, int consolefd, int i, ret; if ((fpo = fopen(filename, "w")) == NULL) { - KFONT_ERR(ctx, "Unable to open file: %s", filename); + KFONT_ERR(ctx, _("Unable to open file: %s: %m"), filename); return -EX_DATAERR; } diff --git a/src/libkfont/mapscrn.c b/src/libkfont/mapscrn.c index ae5ce81d..682691af 100644 --- a/src/libkfont/mapscrn.c +++ b/src/libkfont/mapscrn.c @@ -93,13 +93,13 @@ readnewmapfromfile(struct kfont_context *ctx, const char *mfil, } if (kbdfile_find(mfil, ctx->mapdirpath, ctx->mapsuffixes, fp)) { - KFONT_ERR(ctx, _("Cannot open map file: %s"), mfil); + KFONT_ERR(ctx, _("Unable to find file: %s"), mfil); ret = -EX_DATAERR; goto end; } if (stat(kbdfile_get_pathname(fp), &stbuf)) { - KFONT_ERR(ctx, _("Cannot open map file: %s"), kbdfile_get_pathname(fp)); + KFONT_ERR(ctx, _("Unable to open file: %s: %m"), kbdfile_get_pathname(fp)); ret = -EX_DATAERR; goto end; } @@ -231,7 +231,7 @@ kfont_save_consolemap(struct kfont_context *ctx, int fd, const char *omfil) int ret = 0; if ((fp = fopen(omfil, "w")) == NULL) { - KFONT_ERR(ctx, "Unable to open file: %s: %m", omfil); + KFONT_ERR(ctx, _("Unable to open file: %s: %m"), omfil); return -EX_DATAERR; } diff --git a/src/libkfont/setfont.c b/src/libkfont/setfont.c index 8fa2bed8..d48f37f6 100644 --- a/src/libkfont/setfont.c +++ b/src/libkfont/setfont.c @@ -298,7 +298,7 @@ kfont_load_fonts(struct kfont_context *ctx, ifil = ifiles[i]; if (findfont(ctx, ifil, fp) && findpartialfont(ctx,ifil, fp)) { - KFONT_ERR(ctx, _("Cannot open font file %s"), ifil); + KFONT_ERR(ctx, _("Unable to find file: %s"), ifil); ret = -EX_NOINPUT; goto end; } @@ -411,14 +411,14 @@ kfont_load_font(struct kfont_context *ctx, int fd, const char *ifil, sprintf(defname, "default8x%u", iunit); if (findfont(ctx, ifil = defname, fp) && findfont(ctx, ifil = "default", fp)) { - KFONT_ERR(ctx, _("Cannot find %s font"), ifil); + KFONT_ERR(ctx, _("Unable to find file: %s"), ifil); ret = -EX_NOINPUT; goto end; } } } else { if (findfont(ctx, ifil, fp)) { - KFONT_ERR(ctx, _("Cannot open font file %s"), ifil); + KFONT_ERR(ctx, _("Unable to find file: %s"), ifil); ret = -EX_NOINPUT; goto end; } @@ -653,7 +653,7 @@ kfont_save_font(struct kfont_context *ctx, int consolefd, const char *filename, FILE *fpo = fopen(filename, "w"); if (!fpo) { - KFONT_ERR(ctx, "unable to open: %s: %m", filename); + KFONT_ERR(ctx, "Unable to open file: %s: %m", filename); return -EX_CANTCREAT; } diff --git a/src/loadkeys.c b/src/loadkeys.c index 82f1f055..c27bf7e0 100644 --- a/src/loadkeys.c +++ b/src/loadkeys.c @@ -142,11 +142,8 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (!(fctx = kbdfile_context_new())) { - fprintf(stderr, "%s: Unable to create kbdfile context: %m\n", - get_progname()); - exit(EXIT_FAILURE); - } + if (!(fctx = kbdfile_context_new())) + kbd_error(EXIT_FAILURE, errno, _("Unable to create kbdfile context")); while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) { switch (c) { @@ -197,29 +194,26 @@ int main(int argc, char *argv[]) } } - if ((options & OPT_U) && (options & OPT_A)) { - fprintf(stderr, - _("%s: Options --unicode and --ascii are mutually exclusive\n"), - get_progname()); - exit(EXIT_FAILURE); - } + if ((options & OPT_U) && (options & OPT_A)) + kbd_error(EXIT_FAILURE, 0, _("Options %s and %s are mutually exclusive."), + "--unicode", "--ascii"); if (!(options & OPT_M) && !(options & OPT_B)) { /* get console */ if ((fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); /* check whether the keyboard is in Unicode mode */ - if (ioctl(fd, KDGKBMODE, &kbd_mode) || - ioctl(fd, KDGETMODE, &kd_mode)) - kbd_error(EXIT_FAILURE, errno, _("error reading keyboard mode")); + if (ioctl(fd, KDGKBMODE, &kbd_mode)) + kbd_error(EXIT_FAILURE, errno, _("Unable to read keyboard mode")); + if (ioctl(fd, KDGETMODE, &kd_mode)) + kbd_error(EXIT_FAILURE, errno, _("Unable to read console mode")); if (kbd_mode == K_UNICODE) { if (options & OPT_A) { - fprintf(stderr, - _("%s: warning: loading non-Unicode keymap on Unicode console\n" - " (perhaps you want to do `kbd_mode -a'?)\n"), - get_progname()); + kbd_warning(0, + _("Warning: loading non-Unicode keymap on Unicode console\n" + " (perhaps you want to do `kbd_mode -a'?)")); } else { flags |= LK_FLAG_PREFER_UNICODE; } @@ -228,10 +222,9 @@ int main(int argc, char *argv[]) flags ^= LK_FLAG_UNICODE_MODE; } else if (options & OPT_U && kd_mode != KD_GRAPHICS) { - fprintf(stderr, - _("%s: warning: loading Unicode keymap on non-Unicode console\n" - " (perhaps you want to do `kbd_mode -u'?)\n"), - get_progname()); + kbd_warning(0, + _("Warning: loading Unicode keymap on non-Unicode console\n" + " (perhaps you want to do `kbd_mode -u'?)")); } } @@ -244,17 +237,12 @@ int main(int argc, char *argv[]) } if (options & OPT_D) { - if (!(fp = kbdfile_new(fctx))) { - fprintf(stderr, "%s: Unable to create kbdfile instance: %m\n", - get_progname()); - exit(EXIT_FAILURE); - } + if (!(fp = kbdfile_new(fctx))) + kbd_error(EXIT_FAILURE, 0, _("Unable to create kbdfile instance: %m")); /* first read default map - search starts in . */ - if (kbdfile_find(DEFMAP, dirpath, suffixes, fp)) { - fprintf(stderr, _("Cannot find %s\n"), DEFMAP); - exit(EXIT_FAILURE); - } + if (kbdfile_find(DEFMAP, dirpath, suffixes, fp)) + kbd_error(EXIT_FAILURE, 0, _("Unable to find file: %s"), DEFMAP); rc = lk_parse_keymap(ctx, fp); kbdfile_free(fp); @@ -263,11 +251,8 @@ int main(int argc, char *argv[]) goto fail; } else if (optind == argc) { - if (!(fp = kbdfile_new(fctx))) { - fprintf(stderr, "%s: Unable to create kbdfile instance: %m\n", - get_progname()); - exit(EXIT_FAILURE); - } + if (!(fp = kbdfile_new(fctx))) + kbd_error(EXIT_FAILURE, 0, _("Unable to create kbdfile instance: %m")); kbdfile_set_file(fp, stdin); kbdfile_set_pathname(fp, "<stdin>"); @@ -281,9 +266,7 @@ int main(int argc, char *argv[]) for (i = optind; argv[i]; i++) { if (!(fp = kbdfile_new(fctx))) { - fprintf(stderr, "%s: Unable to create kbdfile instance: %m\n", - get_progname()); - exit(EXIT_FAILURE); + kbd_error(EXIT_FAILURE, 0, _("Unable to create kbdfile instance: %m")); } if (!strcmp(argv[i], "-")) { @@ -291,7 +274,7 @@ int main(int argc, char *argv[]) kbdfile_set_pathname(fp, "<stdin>"); } else if (kbdfile_find(argv[i], dirpath, suffixes, fp)) { - fprintf(stderr, _("cannot open file %s\n"), argv[i]); + kbd_warning(0, _("Unable to open file: %s: %m"), argv[i]); goto fail; } diff --git a/src/loadunimap.c b/src/loadunimap.c index ad3bc122..3cb847b0 100644 --- a/src/loadunimap.c +++ b/src/loadunimap.c @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) usage(EX_USAGE, opthelp); if ((fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); struct kfont_context *kfont; diff --git a/src/mapscrn.c b/src/mapscrn.c index 4fde680d..a29ef15b 100644 --- a/src/mapscrn.c +++ b/src/mapscrn.c @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) } if ((fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); if (outfnam && (ret = kfont_save_consolemap(kfont, fd, outfnam)) < 0) return -ret; diff --git a/src/openvt.c b/src/openvt.c index c260bb28..dd244b51 100644 --- a/src/openvt.c +++ b/src/openvt.c @@ -349,7 +349,7 @@ int main(int argc, char *argv[]) } if ((consfd = getfd(NULL)) < 0) - kbd_error(2, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(2, 0, _("Couldn't get a file descriptor referring to the console.")); if (ioctl(consfd, VT_GETSTATE, &vtstat) < 0) kbd_error(4, errno, "ioctl(VT_GETSTATE)"); @@ -433,7 +433,8 @@ int main(int argc, char *argv[]) } snprintf(vtname, PATH_MAX, VTNAME, vtno); } - kbd_error(5, errsv, _("Unable to open %s"), vtname); + errno = errsv; + kbd_error(5, 0, _("Unable to open file: %s: %m"), vtname); } got_vtno: if (verbose) diff --git a/src/psfxtable.c b/src/psfxtable.c index d8dff10e..a88f6d58 100644 --- a/src/psfxtable.c +++ b/src/psfxtable.c @@ -117,14 +117,14 @@ int main(int argc, char **argv) if (!strcmp(ifname, "-")) ifil = stdin; else if (!(ifil = fopen(ifname, "r"))) - kbd_error(EX_NOINPUT, errno, _("Unable to open: %s"), ifname); + kbd_error(EX_NOINPUT, 0, _("Unable to open file: %s: %m"), ifname); if (!itname) /* nothing */; else if (!strcmp(itname, "-")) itab = stdin; else if (!(itab = fopen(itname, "r"))) - kbd_error(EX_NOINPUT, errno, _("Unable to open: %s"), itname); + kbd_error(EX_NOINPUT, 0, _("Unable to open file: %s: %m"), itname); /* Refuse ifil == itab == stdin ? Perhaps not. */ @@ -133,14 +133,14 @@ int main(int argc, char **argv) else if (!strcmp(ofname, "-")) ofil = stdout; else if (!(ofil = fopen(ofname, "w"))) - kbd_error(EX_CANTCREAT, errno, _("Unable to open: %s"), ofname); + kbd_error(EX_CANTCREAT, 0, _("Unable to open file: %s: %m"), ofname); if (!otname) /* nothing */; else if (!strcmp(otname, "-")) otab = stdout; else if (!(otab = fopen(otname, "w"))) - kbd_error(EX_CANTCREAT, errno, _("Unable to open: %s"), otname); + kbd_error(EX_CANTCREAT, 0, _("Unable to open file: %s: %m"), otname); if (kfont_read_psffont(kfont, ifil, &inbuf, &inbuflth, &fontbuf, &fontbuflth, &width, &fontlen, 0, diff --git a/src/resizecons.c b/src/resizecons.c index cec54701..40be4b89 100644 --- a/src/resizecons.c +++ b/src/resizecons.c @@ -146,29 +146,29 @@ int main(int argc, char **argv) usage(); if (cc <= 0 || cc > USHRT_MAX) { - kbd_error(EXIT_FAILURE, 0, _("resizecons: invalid columns number %d\n"), cc); + kbd_error(EXIT_FAILURE, 0, _("resizecons: invalid columns number %d"), cc); usage(); } if (rr <= 0 || rr > USHRT_MAX) { - kbd_error(EXIT_FAILURE, 0, _("resizecons: invalid rows number %d\n"), rr); + kbd_error(EXIT_FAILURE, 0, _("resizecons: invalid rows number %d"), rr); usage(); } if (!(fp = kbdfile_new(NULL))) - kbd_error(EXIT_FAILURE, 0, "Unable to create kbdfile instance: %m\n"); + kbd_error(EXIT_FAILURE, errno, "Unable to create kbdfile instance"); if (mode == MODE_RESTORETEXTMODE) { /* prepare for: restoretextmode -r 80x25 */ sprintf(infile, "%dx%d", cc, rr); if (kbdfile_find(infile, dirpath, suffixes, fp)) { - kbd_error(EXIT_FAILURE, 0, _("resizecons: cannot find videomode file %s\n"), infile); + kbd_error(EXIT_FAILURE, 0, _("resizecons: cannot find videomode file %s"), infile); } kbdfile_close(fp); } if ((fd = getfd(NULL)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); if (ioctl(fd, TIOCGWINSZ, &winsize)) { kbd_error(EXIT_FAILURE, errno, "ioctl TIOCGWINSZ"); @@ -179,7 +179,7 @@ int main(int argc, char **argv) cc = winsize.ws_col; if (rr != 25 && rr != 28 && rr != 30 && rr != 34 && rr != 36 && rr != 40 && rr != 44 && rr != 50 && rr != 60) { - kbd_error(EXIT_FAILURE, 0, _("Invalid number of lines\n")); + kbd_error(EXIT_FAILURE, 0, _("Invalid number of lines")); } } diff --git a/src/screendump.c b/src/screendump.c index 8e24b801..6eb8acb3 100644 --- a/src/screendump.c +++ b/src/screendump.c @@ -73,10 +73,10 @@ int main(int argc, char **argv) goto try_ioctl; if (!(inbuf = malloc(rows * cols * 2))) - kbd_error(EXIT_FAILURE, errno, "malloc"); + kbd_error(EXIT_FAILURE, errno, _("out of memory")); if (!(outbuf = malloc(rows * (cols + 1)))) - kbd_error(EXIT_FAILURE, errno, "malloc"); + kbd_error(EXIT_FAILURE, errno, _("out of memory")); if (read(fd, inbuf, rows * cols * 2) != (ssize_t)(rows * cols * 2)) { kbd_error(EXIT_FAILURE, errno, _("Error reading %s"), infile); @@ -118,7 +118,7 @@ try_ioctl : { screenbuf = malloc(2 + (size_t)(win.ws_row * win.ws_col)); if (!screenbuf) - kbd_error(EXIT_FAILURE, errno, "malloc"); + kbd_error(EXIT_FAILURE, errno, _("out of memory")); screenbuf[0] = 0; screenbuf[1] = (unsigned char)cons; @@ -127,13 +127,13 @@ try_ioctl : { (!fd || ioctl(0, TIOCLINUX, screenbuf))) { #if 0 perror("TIOCLINUX"); - fprintf(stderr,_("couldn't read %s, and cannot ioctl dump\n"), + fprintf(stderr,"couldn't read %s, and cannot ioctl dump\n", infile); #else /* we tried this just to be sure, but TIOCLINUX function 0 has been disabled since 1.1.92 Do not mention `ioctl dump' in error msg */ - kbd_warning(0, _("couldn't read %s"), infile); + kbd_warning(0, _("Couldn't read %s"), infile); #endif return EXIT_FAILURE; } @@ -148,7 +148,7 @@ try_ioctl : { outbuf = malloc(rows * (cols + 1)); if (!outbuf) - kbd_error(EXIT_FAILURE, errno, "malloc"); + kbd_error(EXIT_FAILURE, errno, _("out of memory")); p = ((char *)screenbuf) + 2; q = outbuf; @@ -163,7 +163,7 @@ try_ioctl : { } done: if (write(1, outbuf, (size_t) (q - outbuf)) != q - outbuf) { - kbd_error(EXIT_FAILURE, 0, _("Error writing screendump\n")); + kbd_error(EXIT_FAILURE, errno, _("Error writing screendump")); } return EXIT_SUCCESS; diff --git a/src/setfont.c b/src/setfont.c index 73a78b24..a6e8a53b 100644 --- a/src/setfont.c +++ b/src/setfont.c @@ -134,22 +134,18 @@ int main(int argc, char *argv[]) usage(); iunit = (unsigned int)tmp; } else { - if (ifilct == MAXIFILES) { - fprintf(stderr, _("setfont: too many input files\n")); - return EX_USAGE; - } + if (ifilct == MAXIFILES) + kbd_error(EX_USAGE, 0, _("Too many input files.")); ifiles[ifilct++] = argv[i]; } } - if (ifilct && restore) { - fprintf(stderr, _("setfont: cannot both restore from character ROM" - " and from file. Font unchanged.\n")); - exit(EX_USAGE); - } + if (ifilct && restore) + kbd_error(EX_USAGE, 0, _("Cannot both restore from character ROM" + " and from file. Font unchanged.")); if ((fd = getfd(console)) < 0) - kbd_error(EX_OSERR, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EX_OSERR, 0, _("Couldn't get a file descriptor referring to the console.")); int kd_mode = -1; if (!ioctl(fd, KDGETMODE, &kd_mode) && (kd_mode == KD_GRAPHICS)) { diff --git a/src/setkeycodes.c b/src/setkeycodes.c index 74c9caf5..9dfc15d0 100644 --- a/src/setkeycodes.c +++ b/src/setkeycodes.c @@ -136,7 +136,7 @@ int main(int argc, char **argv) } if ((fd = getfd(console)) < 0) - kbd_error(EX_OSERR, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EX_OSERR, 0, _("Couldn't get a file descriptor referring to the console.")); while (argc > 2) { if (str_to_uint(argv[1], 16, &a.scancode) < 0) diff --git a/src/setleds.c b/src/setleds.c index 9cbb27e0..83632dd3 100644 --- a/src/setleds.c +++ b/src/setleds.c @@ -137,11 +137,8 @@ setleds(unsigned char cur_leds) static void getflags(unsigned char *flags) { - if (ioctl(0, KDGKBLED, flags)) { - kbd_error(EX_OSERR, errno, _("Error reading current flags setting. " - "Maybe you are not on the console?: " - "ioctl KDGKBLED")); - } + if (ioctl(0, KDGKBLED, flags)) + kbd_error(EX_OSERR, errno, _("Unable to read keyboard flags")); } static int sunkbdfd = -1; @@ -285,7 +282,7 @@ int main(int argc, char **argv) usage(EX_OK, opthelp); break; default: - kbd_warning(0, _("unrecognized argument: %s"), argv[1]); + kbd_warning(0, _("Unrecognized argument: %s"), argv[1]); usage(EX_USAGE, opthelp); } @@ -293,7 +290,7 @@ int main(int argc, char **argv) } if (parse_let_option(argv[1], &nval, &ndef, &nsunval, &nsundef) < 0) { - kbd_warning(0, _("unrecognized argument: %s"), argv[1]); + kbd_warning(0, _("Unrecognized argument: %s"), argv[1]); usage(EX_USAGE, opthelp); } diff --git a/src/setlogcons.c b/src/setlogcons.c index 3bbbf23d..1a5bccce 100644 --- a/src/setlogcons.c +++ b/src/setlogcons.c @@ -55,7 +55,7 @@ int main(int argc, char **argv) (argc == 2) ? argv[1] : "0"); if ((fd = getfd(NULL)) < 0) - kbd_error(EX_OSERR, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EX_OSERR, 0, _("Couldn't get a file descriptor referring to the console.")); arg.fn = TIOCL_SETKMSGREDIRECT; /* redirect kernel messages */ arg.subarg = (char) cons; /* to specified console */ diff --git a/src/setmetamode.c b/src/setmetamode.c index 9ef2acf9..253aaf66 100644 --- a/src/setmetamode.c +++ b/src/setmetamode.c @@ -136,12 +136,10 @@ int main(int argc, char **argv) } if (console && (fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); - if (ioctl(fd, KDGKBMETA, &ometa)) { - kbd_error(EXIT_FAILURE, errno, _("Error reading current setting. Maybe stdin is not a VT?: " - "ioctl KDGKBMETA")); - } + if (ioctl(fd, KDGKBMETA, &ometa)) + kbd_error(EXIT_FAILURE, errno, _("Unable to read meta key handling mode")); if (optind == argc) { report(ometa); @@ -155,7 +153,8 @@ int main(int argc, char **argv) goto end; } } - fprintf(stderr, _("unrecognized argument: _%s_\n\n"), argv[1]); + fprintf(stderr, _("Unrecognized argument: %s"), argv[1]); + fprintf(stderr, "\n\n"); usage(EXIT_FAILURE, opthelp); end: diff --git a/src/setpalette.c b/src/setpalette.c index 92dce236..6b69e1db 100644 --- a/src/setpalette.c +++ b/src/setpalette.c @@ -33,7 +33,7 @@ int main(int argc, char **argv) } if ((fd = getfd(NULL)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); if (ioctl(fd, GIO_CMAP, cmap)) kbd_error(EXIT_FAILURE, errno, "ioctl GIO_CMAP"); diff --git a/src/setvesablank.c b/src/setvesablank.c index 162d4545..8c5a2322 100644 --- a/src/setvesablank.c +++ b/src/setvesablank.c @@ -24,12 +24,12 @@ int main(int argc, char *argv[]) setuplocale(); if (argc != 2) { - fprintf(stderr, _("usage: %s\n"), "setvesablank ON|on|off"); + fprintf(stderr, _("Usage: %s ON|on|off\n"), get_progname()); return EXIT_FAILURE; } if ((fd = getfd(NULL)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); arg.ten = 10; arg.onoff = 0; diff --git a/src/setvtrgb.c b/src/setvtrgb.c index b3ceda0e..de47d838 100644 --- a/src/setvtrgb.c +++ b/src/setvtrgb.c @@ -102,11 +102,11 @@ parse_file(FILE *fd, const char *filename) } if ((c = fgetc(fd)) == EOF) - kbd_error(EXIT_FAILURE, 0, _("Error: %s: Line %u has ended unexpectedly.\n"), + kbd_error(EXIT_FAILURE, 0, _("Error: %s: Line %u has ended unexpectedly."), filename, rows + 1); if (c != '\n') - kbd_error(EXIT_FAILURE, 0, _("Error: %s: Line %u is too long.\n"), + kbd_error(EXIT_FAILURE, 0, _("Error: %s: Line %u is too long."), filename, rows + 1); } } @@ -175,7 +175,7 @@ int main(int argc, char **argv) } if ((fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); /* Apply the color map to the tty via ioctl */ if (ioctl(fd, PIO_CMAP, colormap) == -1) diff --git a/src/showconsolefont.c b/src/showconsolefont.c index 9c7a637c..ac0afb32 100644 --- a/src/showconsolefont.c +++ b/src/showconsolefont.c @@ -32,11 +32,11 @@ static void __attribute__((noreturn)) leave(struct kfont_context *ctx, int n) { if (have_obuf && kfont_put_uniscrnmap(ctx, fd, obuf)) { - kbd_warning(0, _("failed to restore original translation table\n")); + kbd_warning(0, _("failed to restore original translation table")); n = EXIT_FAILURE; } if (have_ounimap && kfont_put_unicodemap(ctx, fd, NULL, &ounimap)) { - kbd_warning(0, _("failed to restore original unimap\n")); + kbd_warning(0, _("failed to restore original unimap")); n = EXIT_FAILURE; } exit(n); @@ -55,7 +55,7 @@ settrivialscreenmap(struct kfont_context *ctx) nbuf[i] = i; if (kfont_put_uniscrnmap(ctx, fd, nbuf)) { - kbd_error(EXIT_FAILURE, 0, _("cannot change translation table\n")); + kbd_error(EXIT_FAILURE, 0, _("cannot change translation table")); } } @@ -191,10 +191,10 @@ int main(int argc, char **argv) usage(EX_USAGE, opthelp); if ((fd = getfd(console)) < 0) - kbd_error(EX_OSERR, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EX_OSERR, 0, _("Couldn't get a file descriptor referring to the console.")); if (ioctl(fd, KDGKBMODE, &mode)) { - kbd_warning(errno, "ioctl KDGKBMODE"); + kbd_warning(errno, _("Unable to read keyboard mode")); leave(kfont, EX_OSERR); } if (mode == K_UNICODE) diff --git a/src/showkey.c b/src/showkey.c index 7ab44f8b..3d7de5c1 100644 --- a/src/showkey.c +++ b/src/showkey.c @@ -31,9 +31,9 @@ get_mode(void) { const char *m; - if (ioctl(fd, KDGKBMODE, &oldkbmode)) { - kbd_error(EXIT_FAILURE, errno, "ioctl KDGKBMODE"); - } + if (ioctl(fd, KDGKBMODE, &oldkbmode)) + kbd_error(EXIT_FAILURE, errno, _("Unable to read keyboard mode")); + switch (oldkbmode) { case K_RAW: m = "RAW"; @@ -208,7 +208,7 @@ int main(int argc, char *argv[]) } if ((fd = getfd(NULL)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); /* the program terminates when there is no input for 10 secs */ signal(SIGALRM, watch_dog); diff --git a/src/totextmode.c b/src/totextmode.c index 520a4a65..f0570d9d 100644 --- a/src/totextmode.c +++ b/src/totextmode.c @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) } if ((fd = getfd(NULL)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); + kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); num = atoi(argv[1]); if (ioctl(fd, KDSETMODE, KD_TEXT)) { |