]> wimlib.net Git - wimlib/commitdiff
Fixes
authorEric Biggers <ebiggers3@gmail.com>
Wed, 20 Mar 2013 15:40:47 +0000 (10:40 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Wed, 20 Mar 2013 15:40:47 +0000 (10:40 -0500)
src/add_image.c
src/dentry.c
src/encoding.c
src/util.c
src/util.h

index 0d410a16a655c0adb134029e0384c239c60a513a..ab4adc97176e459bc38f27406a4d186b6b92df29 100644 (file)
@@ -109,7 +109,7 @@ err:
  *             modified if successful.  Set to NULL if the file or directory was
  *             excluded from capture.
  *
- * @root_disk_path:  The path to the root of the directory tree on disk (UTF-8).
+ * @root_disk_path:  The path to the root of the directory tree on disk.
  *
  * @lookup_table: The lookup table for the WIM file.  For each file added to the
  *             dentry tree being built, an entry is added to the lookup table,
index 683a11e6f618db93c1996ed57e51804e687fcf4e..f46e628c07e957fd300ea54c2eea2eeded00f033 100644 (file)
@@ -592,7 +592,7 @@ print_dentry(struct wim_dentry *dentry, void *lookup_table)
        for (u16 i = 0; i < inode->i_num_ads; i++) {
                printf("[Alternate Stream Entry %u]\n", i);
                wimlib_printf("Name = \"%W\"\n", inode->i_ads_entries[i].stream_name);
-               printf("Name Length (UTF16) = %u\n",
+               printf("Name Length (UTF16 bytes) = %hu\n",
                       inode->i_ads_entries[i].stream_name_nbytes);
                hash = inode_stream_hash(inode, i + 1);
                if (hash) {
index 980e4cfcac00f5b2d3855346eb01d14370d3a147..e8bc40273f4180ab19f6a83cc0e178a5b84ce756 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <iconv.h>
 #include <stdlib.h>
+#include <errno.h>
 
 bool wimlib_mbs_is_utf8 = false;
 
@@ -256,7 +257,7 @@ utf8_str_contains_nonascii_chars(const utf8char *utf8_str)
 {
        do {
                if ((unsigned char)*utf8_str > 127)
-                       return false;
+                       return true;
        } while (*++utf8_str);
-       return true;
+       return false;
 }
index 3c682ce0d6b68971d95b4784e7175d6d12c84df5..d43d8def01d7c514a95945a061038812ff866421 100644 (file)
@@ -48,7 +48,8 @@
 #  define strerror_r(errnum, buf, bufsize) strerror_s(buf, bufsize, errnum)
 #endif
 
-static size_t utf16le_strlen(const utf16lechar *s)
+static size_t
+utf16le_strlen(const utf16lechar *s)
 {
        const utf16lechar *p = s;
        while (*p)
@@ -58,8 +59,8 @@ static size_t utf16le_strlen(const utf16lechar *s)
 
 /* Handle %W for UTF16-LE printing and %U for UTF-8 printing.
  *
- * WARNING: this is not yet done properly--- it's assumed that if the format
- * string contains %W and/or %U, then it contains no other format specifiers.
+ * TODO: this is not yet done properly--- it's assumed that if the format string
+ * contains %W and/or %U, then it contains no other format specifiers.
  */
 static int
 wimlib_vfprintf(FILE *fp, const char *format, va_list va)
@@ -134,17 +135,14 @@ wimlib_fprintf(FILE *fp, const char *format, ...)
        return ret;
 }
 
-/* True if wimlib is to print an informational message when an error occurs.
- * This can be turned off by calling wimlib_set_print_errors(false). */
-#ifdef ENABLE_ERROR_MESSAGES
-#include <stdarg.h>
-static bool wimlib_print_errors = false;
-
+#if defined(ENABLE_ERROR_MESSAGES) || defined(ENABLE_DEBUG)
 static void
 wimlib_vmsg(const char *tag, const char *format,
            va_list va, bool perror)
 {
+#ifndef DEBUG
        if (wimlib_print_errors) {
+#endif
                int errno_save = errno;
                fflush(stdout);
                fputs(tag, stderr);
@@ -161,8 +159,17 @@ wimlib_vmsg(const char *tag, const char *format,
                }
                putc('\n', stderr);
                errno = errno_save;
+#ifndef DEBUG
        }
+#endif
 }
+#endif
+
+/* True if wimlib is to print an informational message when an error occurs.
+ * This can be turned off by calling wimlib_set_print_errors(false). */
+#ifdef ENABLE_ERROR_MESSAGES
+static bool wimlib_print_errors = false;
+
 
 void
 wimlib_error(const char *format, ...)
@@ -206,6 +213,21 @@ wimlib_warning_with_errno(const char *format, ...)
 
 #endif
 
+#ifdef ENABLE_DEBUG
+void wimlib_debug(const char *file, int line, const char *func,
+                 const char *format, ...)
+{
+
+       va_list va;
+       char buf[strlen(file) + strlen(func) + 30];
+
+       sprintf(buf, "[%s %d] %s(): ", file, line, func);
+       va_start(va, format);
+       wimlib_vmsg(buf, format, va, false);
+       va_end(va);
+}
+#endif
+
 WIMLIBAPI int
 wimlib_set_print_errors(bool show_error_messages)
 {
index 58a2f2b45279bf43155ac8c839d1b59773b9b031..50b78bb944247bd7a006e86aab119b36d31b6f8d 100644 (file)
@@ -158,50 +158,45 @@ wimlib_warning(const char *format, ...) FORMAT(printf, 1, 2) COLD;
 
 extern void
 wimlib_warning_with_errno(const char *format, ...) FORMAT(printf, 1, 2) COLD;
-#      define ERROR                    wimlib_error
-#      define ERROR_WITH_ERRNO         wimlib_error_with_errno
-#      define WARNING                  wimlib_warning
-#      define WARNING_WITH_ERRNO       wimlib_warning
-#else
-#      define ERROR(format, ...)               dummy_printf(format, ## __VA_ARGS__)
-#      define ERROR_WITH_ERRNO(format, ...)    dummy_printf(format, ## __VA_ARGS__)
-#      define WARNING(format, ...)             dummy_printf(format, ## __VA_ARGS__)
-#      define WARNING_WITH_ERRNO(format, ...)  dummy_printf(format, ## __VA_ARGS__)
-#endif /* ENABLE_ERROR_MESSAGES */
+#  define ERROR                        wimlib_error
+#  define ERROR_WITH_ERRNO     wimlib_error_with_errno
+#  define WARNING              wimlib_warning
+#  define WARNING_WITH_ERRNO   wimlib_warning
+#else /* ENABLE_ERROR_MESSAGES */
+#  define ERROR(format, ...)                   dummy_printf(format, ## __VA_ARGS__)
+#  define ERROR_WITH_ERRNO(format, ...)                dummy_printf(format, ## __VA_ARGS__)
+#  define WARNING(format, ...)                 dummy_printf(format, ## __VA_ARGS__)
+#  define WARNING_WITH_ERRNO(format, ...)      dummy_printf(format, ## __VA_ARGS__)
+#endif /* !ENABLE_ERROR_MESSAGES */
 
 #if defined(ENABLE_DEBUG) || defined(ENABLE_MORE_DEBUG)
-#      include <errno.h>
-#      define DEBUG(format, ...)                                       \
-       ({                                                              \
-               int __errno_save = errno;                               \
-               wimlib_fprintf(stdout, "[%s %d] %s(): " format,         \
-                       __FILE__, __LINE__, __func__, ## __VA_ARGS__);  \
-               putchar('\n');                                          \
-               fflush(stdout);                                         \
-               errno = __errno_save;                                   \
-       })
+extern void
+wimlib_debug(const char *file, int line, const char *func,
+            const char *format, ...);
+#  define DEBUG(format, ...) \
+               wimlib_debug(__FILE__, __LINE__, __func__, format, ## __VA_ARGS__);
 
 #else
-#      define DEBUG(format, ...) dummy_printf(format, ## __VA_ARGS__)
+#  define DEBUG(format, ...) dummy_printf(format, ## __VA_ARGS__)
 #endif /* ENABLE_DEBUG || ENABLE_MORE_DEBUG */
 
 #ifdef ENABLE_MORE_DEBUG
-#      define DEBUG2(format, ...) DEBUG(format, ## __VA_ARGS__)
+#  define DEBUG2(format, ...) DEBUG(format, ## __VA_ARGS__)
 #else
-#      define DEBUG2(format, ...) dummy_printf(format, ## __VA_ARGS__)
+#  define DEBUG2(format, ...) dummy_printf(format, ## __VA_ARGS__)
 #endif /* ENABLE_DEBUG */
 
 #ifdef ENABLE_ASSERTIONS
 #include <assert.h>
-#      define wimlib_assert(expr) assert(expr)
+#  define wimlib_assert(expr) assert(expr)
 #else
-#      define wimlib_assert(expr)
+#  define wimlib_assert(expr)
 #endif
 
 #ifdef ENABLE_MORE_ASSERTIONS
-#define wimlib_assert2(expr) wimlib_assert(expr)
+#  define wimlib_assert2(expr) wimlib_assert(expr)
 #else
-#define wimlib_assert2(expr)
+#  define wimlib_assert2(expr)
 #endif
 
 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
@@ -212,20 +207,20 @@ extern void (*wimlib_free_func)(void *);
 extern void *(*wimlib_realloc_func)(void *, size_t);
 extern void *wimlib_calloc(size_t nmemb, size_t size);
 extern char *wimlib_strdup(const char *str);
-#      define  MALLOC  wimlib_malloc_func
-#      define  FREE    wimlib_free_func
-#      define  REALLOC wimlib_realloc_func
-#      define  CALLOC  wimlib_calloc
-#      define  STRDUP  wimlib_strdup
-#else
-#      include <stdlib.h>
-#      include <string.h>
-#      define  MALLOC  malloc
-#      define  FREE    free
-#      define  REALLOC realloc
-#      define  CALLOC  calloc
-#      define  STRDUP  strdup
-#endif /* ENABLE_CUSTOM_MEMORY_ALLOCATOR */
+#  define      MALLOC  wimlib_malloc_func
+#  define      FREE    wimlib_free_func
+#  define      REALLOC wimlib_realloc_func
+#  define      CALLOC  wimlib_calloc
+#  define      STRDUP  wimlib_strdup
+#else /* ENABLE_CUSTOM_MEMORY_ALLOCATOR */
+#  include <stdlib.h>
+#  include <string.h>
+#  define      MALLOC  malloc
+#  define      FREE    free
+#  define      REALLOC realloc
+#  define      CALLOC  calloc
+#  define      STRDUP  strdup
+#endif /* !ENABLE_CUSTOM_MEMORY_ALLOCATOR */
 
 
 /* util.c */