]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/extra/uconv/uconv.cpp
ICU-8.11.tar.gz
[apple/icu.git] / icuSources / extra / uconv / uconv.cpp
index 633bbca3a5241841a333cd05af9399f6bcf03b69..a743daf0df319e6fc4969a60e82e49678d3f5656 100644 (file)
@@ -1,6 +1,6 @@
 /*****************************************************************************
 *
-*   Copyright (C) 1999-2004, International Business Machines
+*   Copyright (C) 1999-2006, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************/
@@ -8,7 +8,7 @@
 /*
  * uconv(1): an iconv(1)-like converter using ICU.
  *
- * Original code by Jonas Utterstrรถm <jonas.utterstrom@vittran.norrnod.se>
+ * Original code by Jonas Utterstr&#x00F6;m <jonas.utterstrom@vittran.norrnod.se>
  * contributed in 1999.
  *
  * Conversion to the C conversion API and many improvements by
 
 #include "unicode/uwmsg.h"
 
-#if (defined(WIN32) || defined(U_CYGWIN)) && !defined(__STRICT_ANSI__)
+#if (defined(U_WINDOWS) || defined(U_CYGWIN)) && !defined(__STRICT_ANSI__)
 #include <io.h>
 #include <fcntl.h>
+#if defined(U_WINDOWS)
 #define USE_FILENO_BINARY_MODE 1
+/* Windows likes to rename Unix-like functions */
+#ifndef fileno
+#define fileno _fileno
+#endif
+#ifndef setmode
+#define setmode _setmode
+#endif
+#ifndef O_BINARY
+#define O_BINARY _O_BINARY
+#endif
+#endif
 #endif
 
 #ifdef UCONVMSG_LINK
@@ -779,7 +791,7 @@ ConvertFile::convertFile(const char *pname,
                 buf + rd, useOffsets ? fromoffsets : NULL, flush, &err);
 
             ulen = (int32_t)(unibufp - unibuf);
-            u.releaseBuffer(ulen);
+            u.releaseBuffer(U_SUCCESS(err) ? ulen : 0);
 
             // fromSawEndOfBytes indicates that ucnv_toUnicode() is done
             // converting all of the input bytes.
@@ -1143,7 +1155,7 @@ main(int argc, char **argv)
 
     // Get and prettify pname.
     pname = uprv_strrchr(*argv, U_FILE_SEP_CHAR);
-#ifdef WIN32
+#ifdef U_WINDOWS
     if (!pname) {
         pname = uprv_strrchr(*argv, '/');
     }