diff options
author | Michael R Sweet <michael.r.sweet@gmail.com> | 2021-08-30 16:27:44 -0400 |
---|---|---|
committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2021-08-30 16:27:44 -0400 |
commit | 9d4e1ef79a96008a747ddaab9578157db4c65515 (patch) | |
tree | d92fd4beb01fd62c37b2caaf63f8a69af702c8e0 | |
parent | aebec23082fbe84234df9f2efbc1f78f6ef3f76c (diff) | |
download | cups-9d4e1ef79a96008a747ddaab9578157db4c65515.tar.gz |
Fix lpc prompt (Issue #5946)
-rw-r--r-- | CHANGES.md | 1 | ||||
-rw-r--r-- | berkeley/lpc.c | 31 |
2 files changed, 29 insertions, 3 deletions
diff --git a/CHANGES.md b/CHANGES.md index cfaa55456..0ad355204 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -83,6 +83,7 @@ Changes in CUPS v2.3.5 directive in `cupsd.conf` (Issue #5733) - Fixed `@IF(name)` handling in `cupsd.conf` (Issue #5918) - The scheduler now supports the "everywhere" model directly (Issue #5919) +- Fixed the `lpc` command prompt (Issue #5946) - Fixed `job-pages-per-set` value for duplex print jobs. diff --git a/berkeley/lpc.c b/berkeley/lpc.c index 7ab43ea12..7af10354f 100644 --- a/berkeley/lpc.c +++ b/berkeley/lpc.c @@ -21,6 +21,7 @@ static int compare_strings(const char *, const char *, size_t); static void do_command(http_t *, const char *, const char *); static void show_help(const char *); +static void show_prompt(const char *message); static void show_status(http_t *, const char *); @@ -59,7 +60,7 @@ main(int argc, /* I - Number of command-line arguments */ * Do the command prompt thing... */ - _cupsLangPuts(stdout, _("lpc> ")); /* TODO: Need no-newline version */ + show_prompt(_("lpc> ")); while (fgets(line, sizeof(line), stdin) != NULL) { /* @@ -87,7 +88,7 @@ main(int argc, /* I - Number of command-line arguments */ * Nothing left, just show a prompt... */ - _cupsLangPuts(stdout, _("lpc> ")); /* TODO: Need no newline version */ + show_prompt(_("lpc> ")); continue; } @@ -123,7 +124,7 @@ main(int argc, /* I - Number of command-line arguments */ * Put another prompt out to the user... */ - _cupsLangPuts(stdout, _("lpc> ")); /* TODO: Need no newline version */ + show_prompt(_("lpc> ")); } } @@ -201,6 +202,30 @@ show_help(const char *command) /* I - Command to describe or NULL */ /* + * 'show_prompt()' - Show a localized prompt message. + */ + +static void +show_prompt(const char *message) /* I - Message string to use */ +{ + ssize_t bytes; /* Number of bytes formatted */ + char output[8192]; /* Message buffer */ + cups_lang_t *lang = cupsLangDefault(); + /* Default language */ + + /* + * Transcode to the destination charset and write the prompt... + */ + + if ((bytes = cupsUTF8ToCharset(output, (cups_utf8_t *)_cupsLangString(lang, message), sizeof(output), lang->encoding)) > 0) + { + fwrite(output, 1, (size_t)bytes, stdout); + fflush(stdout); + } +} + + +/* * 'show_status()' - Show printers. */ |