]> wimlib.net Git - wimlib/blobdiff - src/util.c
wimlib_vmsg(): fflush stderr
[wimlib] / src / util.c
index b688ac216f4be3e490480d220984bea5833af0b8..4733ba335644507b1cbd1039a6f8c0cb84290350 100644 (file)
@@ -80,20 +80,25 @@ special:
                        tchar *tstr;
                        size_t tstr_nbytes;
                        utf16lechar *ucs = va_arg(va, utf16lechar*);
                        tchar *tstr;
                        size_t tstr_nbytes;
                        utf16lechar *ucs = va_arg(va, utf16lechar*);
-                       size_t ucs_nbytes = utf16le_strlen(ucs);
 
 
-                       ret = utf16le_to_tstr(ucs, ucs_nbytes,
-                                             &tstr, &tstr_nbytes);
-                       if (ret) {
-                               ret = tfprintf(fp, T("??????"));
+                       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 {
                        } else {
-                               ret = tfprintf(fp, T("%"TS), tstr);
-                               FREE(tstr);
+                               n += tfprintf(fp, T("(null)"));
                        }
                        }
-                       if (ret < 0)
-                               return -1;
-                       else
-                               n += ret;
                        p++;
                } else {
                        if (tputc(*p, fp) == EOF)
                        p++;
                } else {
                        if (tputc(*p, fp) == EOF)
@@ -153,6 +158,7 @@ wimlib_vmsg(const tchar *tag, const tchar *format,
                        tfprintf(stderr, T(": %"TS), buf);
                }
                tputc(T('\n'), stderr);
                        tfprintf(stderr, T(": %"TS), buf);
                }
                tputc(T('\n'), stderr);
+               fflush(stderr);
                errno = errno_save;
 #ifndef DEBUG
        }
                errno = errno_save;
 #ifndef DEBUG
        }
@@ -172,7 +178,7 @@ wimlib_error(const tchar *format, ...)
        va_list va;
 
        va_start(va, format);
        va_list va;
 
        va_start(va, format);
-       wimlib_vmsg(T("[ERROR] "), format, va, false);
+       wimlib_vmsg(T("\r[ERROR] "), format, va, false);
        va_end(va);
 }
 
        va_end(va);
 }
 
@@ -182,7 +188,7 @@ wimlib_error_with_errno(const tchar *format, ...)
        va_list va;
 
        va_start(va, format);
        va_list va;
 
        va_start(va, format);
-       wimlib_vmsg(T("[ERROR] "), format, va, true);
+       wimlib_vmsg(T("\r[ERROR] "), format, va, true);
        va_end(va);
 }
 
        va_end(va);
 }
 
@@ -192,7 +198,7 @@ wimlib_warning(const tchar *format, ...)
        va_list va;
 
        va_start(va, format);
        va_list va;
 
        va_start(va, format);
-       wimlib_vmsg(T("[WARNING] "), format, va, false);
+       wimlib_vmsg(T("\r[WARNING] "), format, va, false);
        va_end(va);
 }
 
        va_end(va);
 }
 
@@ -202,7 +208,7 @@ wimlib_warning_with_errno(const tchar *format, ...)
        va_list va;
 
        va_start(va, format);
        va_list va;
 
        va_start(va, format);
-       wimlib_vmsg(T("[WARNING] "), format, va, true);
+       wimlib_vmsg(T("\r[WARNING] "), format, va, true);
        va_end(va);
 }
 
        va_end(va);
 }
 
@@ -212,11 +218,10 @@ wimlib_warning_with_errno(const tchar *format, ...)
 void wimlib_debug(const tchar *file, int line, const char *func,
                  const tchar *format, ...)
 {
 void wimlib_debug(const tchar *file, int line, const char *func,
                  const tchar *format, ...)
 {
-
        va_list va;
        tchar buf[tstrlen(file) + strlen(func) + 30];
 
        va_list va;
        tchar buf[tstrlen(file) + strlen(func) + 30];
 
-       tsprintf(buf, "[%"TS" %d] %s(): ", file, line, func);
+       tsprintf(buf, T("[%"TS" %d] %s(): "), file, line, func);
 
        va_start(va, format);
        wimlib_vmsg(buf, format, va, false);
 
        va_start(va, format);
        wimlib_vmsg(buf, format, va, false);
@@ -358,6 +363,8 @@ static const tchar *error_strings[] = {
                = T("The WIM file is marked with an unknown version number"),
        [WIMLIB_ERR_UNSUPPORTED]
                = T("The requested operation is unsupported"),
                = T("The WIM file is marked with an unknown version number"),
        [WIMLIB_ERR_UNSUPPORTED]
                = T("The requested operation is unsupported"),
+       [WIMLIB_ERR_VOLUME_LACKS_FEATURES]
+               = T("The volume did not support a feature necessary to complete the operation"),
        [WIMLIB_ERR_WRITE]
                = T("Failed to write data to a file"),
        [WIMLIB_ERR_XML]
        [WIMLIB_ERR_WRITE]
                = T("Failed to write data to a file"),
        [WIMLIB_ERR_XML]