From: Eric Biggers Date: Tue, 13 May 2014 07:47:21 +0000 (-0500) Subject: Remove printf extension X-Git-Tag: v1.7.0~187 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=edf0f7f5331e626b55819dcafa88e202cdb82a32 Remove printf extension Only one place used %WS to print an UTF-16LE string. Get rid of it. --- diff --git a/include/wimlib/error.h b/include/wimlib/error.h index 24f09de9..a36f8028 100644 --- a/include/wimlib/error.h +++ b/include/wimlib/error.h @@ -7,18 +7,6 @@ #include -#ifdef __WIN32__ -# define wimlib_fprintf fwprintf -# define wimlib_printf wprintf -#else /* __WIN32__ */ -extern int -wimlib_fprintf(FILE *fp, const tchar *format, ...) _format_attribute(printf, 2, 3); - -extern int -wimlib_printf(const tchar *format, ...) _format_attribute(printf, 1, 2); -#endif /* !__WIN32__ */ - - static inline int _format_attribute(printf, 1, 2) dummy_tprintf(const tchar *format, ...) { diff --git a/include/wimlib_tchar.h b/include/wimlib_tchar.h index 519c425d..8acaee1e 100644 --- a/include/wimlib_tchar.h +++ b/include/wimlib_tchar.h @@ -15,7 +15,6 @@ typedef wchar_t tchar; # define T(text) _T(text) /* Make a string literal into a wide string */ # define TS "ls" /* Format a string of "tchar" */ # define TC "lc" /* Format a "tchar" */ -# define WS "ls" /* Format a UTF-16LE string (same as above) */ /* For Windows builds, the following definitions replace the "tchar" functions * with the "wide-character" functions. */ @@ -76,11 +75,6 @@ typedef char tchar; # define TS "s" /* Similarly, a string of "tchar" is printed just as a normal string. */ # define TC "c" /* Print a single character */ -# define WS "W" /* UTF-16LE strings must be printed using a special - extension implemented by wimlib itself. Note that - "ls" will not work here because a string of wide - characters on non-Windows systems is typically not - UTF-16LE. */ /* For non-Windows builds, replace the "tchar" functions with the regular old * string functions. */ # define tmemchr memchr diff --git a/src/dentry.c b/src/dentry.c index 123ae908..13f36ca6 100644 --- a/src/dentry.c +++ b/src/dentry.c @@ -1306,9 +1306,6 @@ read_dentry(const u8 * restrict buf, size_t buf_len, inode, buf_len - offset - dentry->length))) { - ERROR("Failed to read alternate data stream " - "entries of WIM dentry \"%"WS"\"", - dentry->file_name); goto err_free_dentry; } } diff --git a/src/encoding.c b/src/encoding.c index 927cb5da..8edf2288 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -119,11 +119,6 @@ put_iconv(iconv_t *cd) errno = errno_save; } -/* Prevent printing an error message if a character conversion error occurs - * while printing an error message. (This variable is not per-thread but it - * doesn't matter too much since it's just the error messages.) */ -static bool error_message_being_printed = false; - #define DEFINE_CHAR_CONVERSION_FUNCTIONS(varname1, longname1, chartype1,\ varname2, longname2, chartype2,\ earlyreturn_on_utf8_locale, \ @@ -167,11 +162,7 @@ varname1##_to_##varname2##_nbytes(const chartype1 *in, size_t in_nbytes,\ \ len = iconv(*cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); \ if (len == (size_t)-1) { \ - if (!error_message_being_printed) { \ - error_message_being_printed = true; \ - err_msg; \ - error_message_being_printed = false; \ - } \ + err_msg; \ ret = err_return; \ } else { \ *out_nbytes_ret = bufsize - outbytesleft; \ @@ -201,11 +192,7 @@ varname1##_to_##varname2##_buf(const chartype1 *in, size_t in_nbytes, \ \ len = iconv(*cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); \ if (len == (size_t)-1) { \ - if (!error_message_being_printed) { \ - error_message_being_printed = true; \ - err_msg; \ - error_message_being_printed = false; \ - } \ + err_msg; \ ret = err_return; \ } else { \ out[(LARGE_NUMBER-outbytesleft)/sizeof(chartype2)] = 0; \ diff --git a/src/inode.c b/src/inode.c index bb953c57..a8214b3c 100644 --- a/src/inode.c +++ b/src/inode.c @@ -314,8 +314,6 @@ inode_remove_ads(struct wim_inode *inode, u16 idx, ads_entry = &inode->i_ads_entries[idx]; - DEBUG("Remove alternate data stream \"%"WS"\"", ads_entry->stream_name); - lte = ads_entry->lte; if (lte) lte_decrement_refcnt(lte, lookup_table); diff --git a/src/util.c b/src/util.c index 6cc8cf44..1addc857 100644 --- a/src/util.c +++ b/src/util.c @@ -63,87 +63,6 @@ utf16le_strlen(const utf16lechar *s) return (p - s) * sizeof(utf16lechar); } -#ifdef __WIN32__ -# define wimlib_vfprintf vfwprintf -#else -/* Handle %W for UTF16-LE printing. - * - * TODO: this is not yet done properly--- it's assumed that if the format string - * contains %W, then it contains no other format specifiers. - */ -static int -wimlib_vfprintf(FILE *fp, const tchar *format, va_list va) -{ - const tchar *p; - int n; - - for (p = format; *p; p++) - if (*p == T('%') && *(p + 1) == T('W')) - goto special; - return tvfprintf(fp, format, va); -special: - n = 0; - for (p = format; *p; p++) { - if (*p == T('%') && (*(p + 1) == T('W'))) { - int ret; - tchar *tstr; - size_t tstr_nbytes; - utf16lechar *ucs = va_arg(va, utf16lechar*); - - if (ucs) { - size_t ucs_nbytes = utf16le_strlen(ucs); - - ret = utf16le_to_tstr(ucs, ucs_nbytes, - &tstr, &tstr_nbytes); - if (ret) { - ret = tfprintf(fp, T("??????")); - } else { - ret = tfprintf(fp, T("%"TS), tstr); - FREE(tstr); - } - if (ret < 0) - return -1; - else - n += ret; - } else { - n += tfprintf(fp, T("(null)")); - } - p++; - } else { - if (tputc(*p, fp) == EOF) - return -1; - n++; - } - } - return n; -} - -int -wimlib_printf(const tchar *format, ...) -{ - int ret; - va_list va; - - va_start(va, format); - ret = wimlib_vfprintf(stdout, format, va); - va_end(va); - return ret; -} - -int -wimlib_fprintf(FILE *fp, const tchar *format, ...) -{ - int ret; - va_list va; - - va_start(va, format); - ret = wimlib_vfprintf(fp, format, va); - va_end(va); - return ret; -} - -#endif /* __WIN32__ */ - #ifdef ENABLE_ERROR_MESSAGES bool wimlib_print_errors = false; #endif @@ -160,7 +79,7 @@ wimlib_vmsg(const tchar *tag, const tchar *format, int errno_save = errno; fflush(stdout); tfputs(tag, stderr); - wimlib_vfprintf(stderr, format, va); + tvfprintf(stderr, format, va); if (perror && errno_save != 0) { tchar buf[64]; int res;