]> granicus.if.org Git - python/commitdiff
OS/2 EMX port changes (Objects part of patch #450267):
authorAndrew MacIntyre <andymac@bullseye.apana.org.au>
Tue, 26 Feb 2002 11:36:35 +0000 (11:36 +0000)
committerAndrew MacIntyre <andymac@bullseye.apana.org.au>
Tue, 26 Feb 2002 11:36:35 +0000 (11:36 +0000)
  Objects/
    fileobject.c
    stringobject.c
    unicodeobject.c

This commit doesn't include the cleanup patches for stringobject.c and
unicodeobject.c which are shown separately in the patch manager.  Those
patches will be regenerated and applied in a subsequent commit, so as
to preserve a fallback position (this commit to those files).

Objects/fileobject.c
Objects/stringobject.c
Objects/unicodeobject.c

index 125da700b89c5d41101ccb151a7bb373fdd66a88..d6b22297ff4da68e831be0ada187bf57c883d282 100644 (file)
 #define NO_FOPEN_ERRNO
 #endif
 
+#if defined(PYOS_OS2) && defined(PYCC_GCC)
+#include <io.h>
+#endif
+
 #define BUF(v) PyString_AS_STRING((PyStringObject *)v)
 
 #ifndef DONT_HAVE_ERRNO_H
index ae08910b87f70e384bc59dcdee208fc009538fcd..2824857186a59f4215e8fd4608b651cccc3980a1 100644 (file)
@@ -3100,6 +3100,15 @@ formatint(char *buf, size_t buflen, int flags,
                buf[0] = '0';
                buf[1] = (char)type;
        }
+#if defined(PYOS_OS2) && defined(PYCC_GCC)
+       /* unfortunately, the EMX C runtime gives us '0x' as the base
+        * marker for %X when we expect/want '0X'
+        */
+       else if ((flags & F_ALT) && (type == 'X')) {
+               assert(buf[1] == 'x');
+               buf[1] = (char)type;
+       }
+#endif
        return strlen(buf);
 }
 
index 1d0508cc8b3ad36d3a8e0692cc2148ed8080a94d..f214c20749595d164d0beb876c6afe8a6164dc09 100644 (file)
@@ -5162,6 +5162,15 @@ formatint(Py_UNICODE *buf,
      * Compaq Tru64) violate the std by converting 0 w/ leading 0x anyway.
      * So add it only if the platform doesn't already.
      */
+#if defined(PYOS_OS2) && defined(PYCC_GCC)
+    if ((flags & F_ALT) && (type == 'x' || type == 'X')) {
+        /* the EMX runtime gives 0x as the base marker when we want 0X
+         * so we cover all bets by supplying our own for both cases.
+         */
+        use_native_c_format = 0;
+        PyOS_snprintf(fmt, sizeof(fmt), "0%c%%.%dl%c", type, prec, type);
+    }
+#else
     if (x == 0 && (flags & F_ALT) && (type == 'x' || type == 'X')) {
         /* Only way to know what the platform does is to try it. */
         PyOS_snprintf(fmt, sizeof(fmt), type == 'x' ? "%#x" : "%#X", 0);
@@ -5171,6 +5180,7 @@ formatint(Py_UNICODE *buf,
             PyOS_snprintf(fmt, sizeof(fmt), "0%c%%#.%dl%c", type, prec, type);
         }
     }
+#endif
     if (use_native_c_format)
          PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%dl%c",
                       (flags & F_ALT) ? "#" : "", prec, type);