Add a "can_display_utf8" flag based on the current locale, for future use.

This commit is contained in:
Andrew Wood
2024-12-09 23:23:07 +00:00
parent 06eca8cefa
commit 51a5de71c1
14 changed files with 63 additions and 41 deletions
+1
View File
@@ -33,6 +33,7 @@ AC_CHECK_FUNCS([setitimer])
AC_CHECK_FUNCS([setproctitle])
AC_CHECK_HEADERS([getopt.h])
AC_CHECK_HEADERS([limits.h])
AC_CHECK_HEADERS([langinfo.h])
AC_CHECK_HEADERS([wctype.h])
AC_CHECK_HEADERS([termios.h])
AC_CHECK_HEADERS([libgen.h])
+5 -5
View File
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: pv@ivarch.com\n"
"POT-Creation-Date: 2024-12-09 21:44+0000\n"
"POT-Creation-Date: 2024-12-09 23:15+0000\n"
"PO-Revision-Date: 2024-10-13 20:43+0000\n"
"Last-Translator: mmatous <mmatous@users.noreply.translate.codeberg.org>\n"
"Language-Team: Czech <https://translate.codeberg.org/projects/pv/pv/cs/>\n"
@@ -269,11 +269,11 @@ msgstr ""
msgid "Please report any bugs to: %s"
msgstr "Prosím, hlašte veškeré chyby na: %s"
#: src/main/main.c:230
#: src/main/main.c:232
msgid "(input)"
msgstr "(vstup)"
#: src/main/main.c:319
#: src/main/main.c:328
msgid "state allocation failed"
msgstr "selhala alokace stavu"
@@ -407,7 +407,7 @@ msgstr "yzafpnum kMGTPEZY"
msgid "yzafpnum KMGTPEZY"
msgstr "yzafpnum KMGTPEZY"
#: src/pv/display.c:890 src/pv/transfer.c:1056
#: src/pv/display.c:891 src/pv/transfer.c:1056
msgid "buffer allocation failed"
msgstr "selhala alokace vyrovnávací paměti"
@@ -490,7 +490,7 @@ msgstr "pid"
msgid "history structure allocation failed"
msgstr "selhala alokace struktury historie"
#: src/pv/state.c:572 src/pv/state.c:583
#: src/pv/state.c:576 src/pv/state.c:587
msgid "file list allocation failed"
msgstr "selhala alokace seznamu souborů"
+5 -5
View File
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: pv@ivarch.com\n"
"POT-Creation-Date: 2024-12-09 21:44+0000\n"
"POT-Creation-Date: 2024-12-09 23:15+0000\n"
"PO-Revision-Date: 2024-10-13 20:43+0000\n"
"Last-Translator: fnetX <otto@codeberg.org>\n"
"Language-Team: German <https://translate.codeberg.org/projects/pv/pv/de/>\n"
@@ -287,11 +287,11 @@ msgstr ""
msgid "Please report any bugs to: %s"
msgstr "Bitte senden Sie Fehlerberichte an %s"
#: src/main/main.c:230
#: src/main/main.c:232
msgid "(input)"
msgstr "(eingabe)"
#: src/main/main.c:319
#: src/main/main.c:328
msgid "state allocation failed"
msgstr "Speicherzuweisung für `state' fehlgeschlagen"
@@ -430,7 +430,7 @@ msgstr "yzafpnµm kMGTPEZY"
msgid "yzafpnum KMGTPEZY"
msgstr "yzafpnµm KMGTPEZY"
#: src/pv/display.c:890 src/pv/transfer.c:1056
#: src/pv/display.c:891 src/pv/transfer.c:1056
msgid "buffer allocation failed"
msgstr "Speicherzuweisung für den Puffer fehlgeschlagen"
@@ -514,7 +514,7 @@ msgstr "pid"
msgid "history structure allocation failed"
msgstr "Speicherzuweisung für `history' fehlgeschlagen"
#: src/pv/state.c:572 src/pv/state.c:583
#: src/pv/state.c:576 src/pv/state.c:587
msgid "file list allocation failed"
msgstr "Speicherzuweisung für die Dateiliste fehlgeschlagen"
+5 -5
View File
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: pv@ivarch.com\n"
"POT-Creation-Date: 2024-12-09 21:44+0000\n"
"POT-Creation-Date: 2024-12-09 23:15+0000\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -263,11 +263,11 @@ msgstr ""
msgid "Please report any bugs to: %s"
msgstr ""
#: src/main/main.c:230
#: src/main/main.c:232
msgid "(input)"
msgstr ""
#: src/main/main.c:319
#: src/main/main.c:328
msgid "state allocation failed"
msgstr ""
@@ -399,7 +399,7 @@ msgstr ""
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/display.c:890 src/pv/transfer.c:1056
#: src/pv/display.c:891 src/pv/transfer.c:1056
msgid "buffer allocation failed"
msgstr ""
@@ -482,7 +482,7 @@ msgstr ""
msgid "history structure allocation failed"
msgstr ""
#: src/pv/state.c:572 src/pv/state.c:583
#: src/pv/state.c:576 src/pv/state.c:587
msgid "file list allocation failed"
msgstr ""
+5 -5
View File
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: pv@ivarch.com\n"
"POT-Creation-Date: 2024-12-09 21:44+0000\n"
"POT-Creation-Date: 2024-12-09 23:15+0000\n"
"PO-Revision-Date: 2024-10-12 11:13+0000\n"
"Last-Translator: a-j-wood <a-j-wood@users.noreply.translate.codeberg.org>\n"
"Language-Team: French <https://translate.codeberg.org/projects/pv/pv/fr/>\n"
@@ -288,11 +288,11 @@ msgstr ""
msgid "Please report any bugs to: %s"
msgstr "SVP rapporter tous bogues à %s"
#: src/main/main.c:230
#: src/main/main.c:232
msgid "(input)"
msgstr "(entrée)"
#: src/main/main.c:319
#: src/main/main.c:328
msgid "state allocation failed"
msgstr "échec de l'allocation de mémoire de condition"
@@ -434,7 +434,7 @@ msgstr ""
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/display.c:890 src/pv/transfer.c:1056
#: src/pv/display.c:891 src/pv/transfer.c:1056
msgid "buffer allocation failed"
msgstr "échec de l'allocation de mémoire tampon"
@@ -517,7 +517,7 @@ msgstr ""
msgid "history structure allocation failed"
msgstr "l'allocation de la structure de l'historique a échoué"
#: src/pv/state.c:572 src/pv/state.c:583
#: src/pv/state.c:576 src/pv/state.c:587
msgid "file list allocation failed"
msgstr "échec de l'allocation de la liste de fichiers"
+5 -5
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: pv@ivarch.com\n"
"POT-Creation-Date: 2024-12-09 21:44+0000\n"
"POT-Creation-Date: 2024-12-09 23:15+0000\n"
"PO-Revision-Date: 2024-10-20 14:07+0000\n"
"Last-Translator: coralpink <coralpink@users.noreply.translate.codeberg.org>\n"
"Language-Team: Polish <https://translate.codeberg.org/projects/pv/pv/pl/>\n"
@@ -282,11 +282,11 @@ msgstr ""
msgid "Please report any bugs to: %s"
msgstr "Proszę przesyłać zgłoszenia błędów do %s"
#: src/main/main.c:230
#: src/main/main.c:232
msgid "(input)"
msgstr "(wejście)"
#: src/main/main.c:319
#: src/main/main.c:328
msgid "state allocation failed"
msgstr "alokacja stanu programu nie powiodła się"
@@ -425,7 +425,7 @@ msgstr "yzafpnum kMGTPEZY"
msgid "yzafpnum KMGTPEZY"
msgstr "yzafpnum KMGTPEZY"
#: src/pv/display.c:890 src/pv/transfer.c:1056
#: src/pv/display.c:891 src/pv/transfer.c:1056
msgid "buffer allocation failed"
msgstr "nie udało się zaalokować bufora"
@@ -509,7 +509,7 @@ msgstr "pid"
msgid "history structure allocation failed"
msgstr "nie udało się zaalokować struktury historii"
#: src/pv/state.c:572 src/pv/state.c:583
#: src/pv/state.c:576 src/pv/state.c:587
msgid "file list allocation failed"
msgstr "nie udało się zaalokować listy plików"
+5 -5
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: pv@ivarch.com\n"
"POT-Creation-Date: 2024-12-09 21:44+0000\n"
"POT-Creation-Date: 2024-12-09 23:15+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -273,11 +273,11 @@ msgstr ""
msgid "Please report any bugs to: %s"
msgstr "Por favor, reporte quaisquer defeitos para %s"
#: src/main/main.c:230
#: src/main/main.c:232
msgid "(input)"
msgstr ""
#: src/main/main.c:319
#: src/main/main.c:328
msgid "state allocation failed"
msgstr "alocação de memória de status falhou"
@@ -413,7 +413,7 @@ msgstr ""
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/display.c:890 src/pv/transfer.c:1056
#: src/pv/display.c:891 src/pv/transfer.c:1056
msgid "buffer allocation failed"
msgstr "erro alocando o buffer"
@@ -496,7 +496,7 @@ msgstr ""
msgid "history structure allocation failed"
msgstr ""
#: src/pv/state.c:572 src/pv/state.c:583
#: src/pv/state.c:576 src/pv/state.c:587
msgid "file list allocation failed"
msgstr ""
+5 -5
View File
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: pv@ivarch.com\n"
"POT-Creation-Date: 2024-12-09 21:44+0000\n"
"POT-Creation-Date: 2024-12-09 23:15+0000\n"
"PO-Revision-Date: 2024-10-22 18:07+0000\n"
"Last-Translator: 0ko <0ko@users.noreply.translate.codeberg.org>\n"
"Language-Team: Russian <https://translate.codeberg.org/projects/pv/pv/ru/>\n"
@@ -270,11 +270,11 @@ msgstr ""
msgid "Please report any bugs to: %s"
msgstr "Сообщайте о проблемах на: %s"
#: src/main/main.c:230
#: src/main/main.c:232
msgid "(input)"
msgstr "(ввод)"
#: src/main/main.c:319
#: src/main/main.c:328
msgid "state allocation failed"
msgstr ""
@@ -408,7 +408,7 @@ msgstr ""
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/display.c:890 src/pv/transfer.c:1056
#: src/pv/display.c:891 src/pv/transfer.c:1056
msgid "buffer allocation failed"
msgstr "не удалось выделить память для буфера"
@@ -491,7 +491,7 @@ msgstr "ИДпр"
msgid "history structure allocation failed"
msgstr "не удалось выделить память для структуры истории"
#: src/pv/state.c:572 src/pv/state.c:583
#: src/pv/state.c:576 src/pv/state.c:587
msgid "file list allocation failed"
msgstr "не удалось выделить память для списка файлов"
+5 -5
View File
@@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: pv 1.8.14\n"
"Report-Msgid-Bugs-To: pv@ivarch.com\n"
"POT-Creation-Date: 2024-12-09 21:44+0000\n"
"POT-Creation-Date: 2024-12-09 23:15+0000\n"
"PO-Revision-Date: 2024-10-12 23:51+0000\n"
"Last-Translator: a-j-wood <a-j-wood@users.noreply.translate.codeberg.org>\n"
"Language-Team: Turkish <https://translate.codeberg.org/projects/pv/pv/tr/>\n"
@@ -270,11 +270,11 @@ msgstr ""
msgid "Please report any bugs to: %s"
msgstr "Lütfen hataları şu adrese bildirin: %s"
#: src/main/main.c:230
#: src/main/main.c:232
msgid "(input)"
msgstr "(giriş)"
#: src/main/main.c:319
#: src/main/main.c:328
msgid "state allocation failed"
msgstr "durum tahsisi başarısız oldu"
@@ -409,7 +409,7 @@ msgstr "yzafpnum kMGTPEZY"
msgid "yzafpnum KMGTPEZY"
msgstr "yzafpnum KMGTPEZY"
#: src/pv/display.c:890 src/pv/transfer.c:1056
#: src/pv/display.c:891 src/pv/transfer.c:1056
msgid "buffer allocation failed"
msgstr "arabellek tahsisi başarısız oldu"
@@ -492,7 +492,7 @@ msgstr "pid"
msgid "history structure allocation failed"
msgstr "geçmiş yapısı tahsisi başarısız oldu"
#: src/pv/state.c:572 src/pv/state.c:583
#: src/pv/state.c:576 src/pv/state.c:587
msgid "file list allocation failed"
msgstr "dosya listesi tahsisi başarısız oldu"
+3
View File
@@ -65,6 +65,9 @@
/* IPC support enabled */
#undef HAVE_IPC
/* Define to 1 if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
/* Define to 1 if you have the <libgen.h> header file. */
#undef HAVE_LIBGEN_H
+1
View File
@@ -132,6 +132,7 @@ struct pvstate_s {
bool no_splice; /* never use splice() */
bool discard_input; /* write nothing to stdout */
bool show_stats; /* show statistics on exit */
bool can_display_utf8; /* whether UTF-8 output is permitted */
bool width_set_manually; /* width was set manually, not detected */
bool height_set_manually; /* height was set manually, not detected */
} control;
+1
View File
@@ -230,6 +230,7 @@ extern void pv_state_watch_pid_set(pvstate_t, pid_t);
extern void pv_state_watch_fd_set(pvstate_t, int);
extern void pv_state_output_set(pvstate_t, int, const char *);
extern void pv_state_average_rate_window_set(pvstate_t, unsigned int);
extern void pv_state_set_can_display_utf8(pvstate_t, bool);
extern void pv_state_inputfiles(pvstate_t, unsigned int, const char **);
+13 -1
View File
@@ -19,7 +19,9 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif
int pv_remote_set(opts_t, pvstate_t);
void pv_remote_init(void);
@@ -279,6 +281,7 @@ int main(int argc, char **argv)
/*@only@ */ pvstate_t state = NULL;
int retcode = 0;
bool can_have_eta = true;
bool can_display_utf8 = false;
#if ! HAVE_SETPROCTITLE
initproctitle(argc, argv);
@@ -289,6 +292,12 @@ int main(int argc, char **argv)
(void) setlocale(LC_ALL, "");
(void) bindtextdomain(PACKAGE, LOCALEDIR);
(void) textdomain(PACKAGE);
#ifdef HAVE_LANGINFO_H
/*@-mustfreefresh@ *//* splint thinks nl_langinfo() leaks memory */
if (0 == strcmp(nl_langinfo(CODESET), "UTF-8"))
can_display_utf8 = true;
/*@+mustfreefresh@ */
#endif
#endif
/* Parse the command line arguments. */
@@ -503,6 +512,9 @@ int main(int argc, char **argv)
can_have_eta ? opts->fineta : false, opts->rate, opts->average_rate,
opts->bytes, opts->bufpercent, opts->lastwritten, opts->name);
debug("%s: %s", "can_display_utf8", can_display_utf8 ? "true" : "false");
pv_state_set_can_display_utf8(state, can_display_utf8);
/* Initialise the signal handling. */
pv_sig_init(state);
+4
View File
@@ -543,6 +543,10 @@ void pv_state_average_rate_window_set(pvstate_t state, unsigned int val)
pv_alloc_history(state);
}
void pv_state_set_can_display_utf8(pvstate_t state, bool val)
{
state->control.can_display_utf8 = val;
}
/*
* Set the array of input files.