From: Michael R Sweet Date: Mon, 30 Aug 2021 20:28:57 +0000 (-0400) Subject: Fix lpc prompt (Apple #5946) X-Git-Tag: v2.4b1~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6be10920ca49e93beafdfa29a0e0e71d2d7d487;p=thirdparty%2Fcups.git Fix lpc prompt (Apple #5946) --- diff --git a/CHANGES.md b/CHANGES.md index 733669d636..a2b393a1d4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -40,6 +40,7 @@ CUPS v2.4rc1 (Pending) - Now use a 60 second timeout for reading USB backchannel data (Issue #160) - The USB backend now tries harder to find a serial number (Issue #170) - Fixed `@IF(name)` handling in `cupsd.conf` (Apple #5918) +- Fixed the `lpc` command prompt (Apple #5946) - Now always pass "localhost" in the `Host:` header when talking over a domain socket or the loopback interface (Issue #185) - Fixed a job history update issue in the scheduler (Issue #187) diff --git a/berkeley/lpc.c b/berkeley/lpc.c index 7ab43ea123..7af10354fc 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> ")); } } @@ -200,6 +201,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. */