]> wimlib.net Git - wimlib/commitdiff
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 24f09de97633b69d79ab90274af9373c6c7abf02..a36f8028c0ffde1100d4e9366ce36c50c0a45f52 100644 (file)
@@ -7,18 +7,6 @@
 
 #include <stdio.h>
 
 
 #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, ...)
 {
 static inline int _format_attribute(printf, 1, 2)
 dummy_tprintf(const tchar *format, ...)
 {
index 519c425d675b102d995b248388b9f5206dc7b641..8acaee1e5b6109fc19000a640979ec93a4e10560 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 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. */
 
 /* 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 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
 /* For non-Windows builds, replace the "tchar" functions with the regular old
  * string functions. */
 #  define tmemchr      memchr
index 123ae90874fdefd62936bc4e254ab41be369b589..13f36ca645e1e20f7ebfb02169a4a544db54d02c 100644 (file)
@@ -1306,9 +1306,6 @@ read_dentry(const u8 * restrict buf, size_t buf_len,
                                            inode,
                                            buf_len - offset - dentry->length)))
                {
                                            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;
                }
        }
                        goto err_free_dentry;
                }
        }
index 927cb5dad342128017133ad903530643c246b056..8edf228817cba16e659ca47caed8d492e1de95cf 100644 (file)
@@ -119,11 +119,6 @@ put_iconv(iconv_t *cd)
        errno = errno_save;
 }
 
        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,    \
 #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) {                                        \
                                                                        \
        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;               \
                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) {                                        \
                                                                        \
        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; \
                ret = err_return;                                       \
        } else {                                                        \
                out[(LARGE_NUMBER-outbytesleft)/sizeof(chartype2)] = 0; \
index bb953c57bfd2d1308fea4700c924c95688dd957a..a8214b3c371bf52888dc3711b5ea17d77a0190fa 100644 (file)
@@ -314,8 +314,6 @@ inode_remove_ads(struct wim_inode *inode, u16 idx,
 
        ads_entry = &inode->i_ads_entries[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);
        lte = ads_entry->lte;
        if (lte)
                lte_decrement_refcnt(lte, lookup_table);
index 6cc8cf441fc0abb74d810f7eec1b384939a9f5bc..1addc857a5675ca0cc8f5ed8b4c1c230712ac637 100644 (file)
@@ -63,87 +63,6 @@ utf16le_strlen(const utf16lechar *s)
        return (p - s) * sizeof(utf16lechar);
 }
 
        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
 #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);
                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;
                if (perror && errno_save != 0) {
                        tchar buf[64];
                        int res;