mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
bb0b1004f8
The code assumed that printing numbers with thousand separators and decimal points would always produce only US-ASCII characters. This was used for buffer sizes (with snprintf(), no overflows) and aligning columns of the progress indicator and --list. That assumption was wrong (e.g. LC_ALL=fi_FI.UTF-8 with glibc), so multibyte character support was added in this commit. The old way is used if the operating system doesn't have enough multibyte support (e.g. lacks wcwidth()). The sizes of buffers were increased to accomodate multibyte characters. I don't know how big they should be exactly, but they aren't used for anything critical, so it's not too bad. If they still aren't big enough, I hopefully get a bug report. snprintf() takes care of avoiding buffer overflows. Some static buffers were replaced with buffers allocated on stack. double_to_str() was removed. uint64_to_str() and uint64_to_nicestr() now share the static buffer and test for thousand separator support. Integrity check names "None" and "Unknown-N" (2 <= N <= 15) were marked to be translated. I had forgot these, plus they wouldn't have worked correctly anyway before this commit, because printing tables with multibyte strings didn't work. Thanks to Marek Černocký for reporting the bug about misaligned table columns in --list output.
57 lines
1.2 KiB
C
57 lines
1.2 KiB
C
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
/// \file private.h
|
|
/// \brief Common includes, definions, and prototypes
|
|
//
|
|
// Author: Lasse Collin
|
|
//
|
|
// This file has been put into the public domain.
|
|
// You can do whatever you want with this file.
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "sysdefs.h"
|
|
#include "mythread.h"
|
|
#include "lzma.h"
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <errno.h>
|
|
#include <signal.h>
|
|
#include <locale.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
#include "tuklib_gettext.h"
|
|
#include "tuklib_progname.h"
|
|
#include "tuklib_exit.h"
|
|
#include "tuklib_mbstr.h"
|
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
# define WIN32_LEAN_AND_MEAN
|
|
# include <windows.h>
|
|
#endif
|
|
|
|
#ifndef STDIN_FILENO
|
|
# define STDIN_FILENO (fileno(stdin))
|
|
#endif
|
|
|
|
#ifndef STDOUT_FILENO
|
|
# define STDOUT_FILENO (fileno(stdout))
|
|
#endif
|
|
|
|
#ifndef STDERR_FILENO
|
|
# define STDERR_FILENO (fileno(stderr))
|
|
#endif
|
|
|
|
#include "main.h"
|
|
#include "coder.h"
|
|
#include "message.h"
|
|
#include "args.h"
|
|
#include "hardware.h"
|
|
#include "file_io.h"
|
|
#include "options.h"
|
|
#include "signals.h"
|
|
#include "suffix.h"
|
|
#include "util.h"
|
|
#include "list.h"
|