Remove printf extension
authorEric Biggers <ebiggers3@gmail.com>
Tue, 13 May 2014 07:47:21 +0000 (02:47 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 13 May 2014 07:47:21 +0000 (02:47 -0500)
Only one place used %WS to print an UTF-16LE string.  Get rid of it.

include/wimlib/error.h
include/wimlib_tchar.h
src/dentry.c
src/encoding.c
src/inode.c
src/util.c

index 24f09de..a36f802 100644 (file)
@@ -7,18 +7,6 @@
 
 #include <stdio.h>
 
-#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, ...)
 {
index 519c425..8acaee1 100644 (file)
@@ -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
index 123ae90..13f36ca 100644 (file)
@@ -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;
                }
        }
index 927cb5d..8edf228 100644 (file)
@@ -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; \
index bb953c5..a8214b3 100644 (file)
@@ -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);
index 6cc8cf4..1addc85 100644 (file)
@@ -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;