Page 1 of 1

Bug in Local/newlib/include/ctype.h

Posted: Fri May 30, 2014 11:37 am
by phx
I just wondered why toupper/tolower() are not working when compiling with vbcc and linking with newlib.
Then I found the problem: somebody copied the toupper/tolower assembler inlines from the vclib ctype.h, but didn't notice that __ctype_ptr is a pointer to the ctypes-array and not the address of it!

The following modification will fix it:

Code: Select all

--- Devel:SDK/OS4/Local/newlib/include/ctype.h  2013-03-05 16:15:10 
+++ sys:work/SDK/newlib/include/ctype.h 2014-05-30 12:11:23 
@@ -63,18 +63,18 @@
 
 #elif defined(__VBCC__)
 int __asm_toupper(__reg("r3") int) =
-        "\t.extern\t__ctype_ptr\n"
-        "\tlis\t11,(__ctype_ptr)@ha\n"
-        "\taddi\t11,11,(__ctype_ptr)@l\n"
+        "\t.extern\t_ctype_\n"
+        "\tlis\t11,(_ctype_+1)@ha\n"
+        "\taddi\t11,11,(_ctype_+1)@l\n"
         "\tlbzx\t12,11,3\n"
         "\tandi.\t12,12,2\n"
         "\tbeq\t$+8\n"
         "\tsubi\t3,3,0x20\n"
         "#barrier";
 int __asm_tolower(__reg("r3") int) =
-        "\t.extern\t__ctype_ptr\n"
-        "\tlis\t11,(__ctype_ptr)@ha\n"
-        "\taddi\t11,11,(__ctype_ptr)@l\n"
+        "\t.extern\t_ctype_\n"
+        "\tlis\t11,(_ctype_+1)@ha\n"
+        "\taddi\t11,11,(_ctype_+1)@l\n"
         "\tlbzx\t12,11,3\n"
         "\tandi.\t12,12,1\n"
         "\tbeq\t$+8\n"
Would be nice to fix that for the next SDK. Thanks!

Re: Bug in Local/newlib/include/ctype.h

Posted: Fri May 30, 2014 3:27 pm
by ssolie
Bug report submitted.