Add a "can_display_utf8" flag based on the current locale, for future use.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user