Bug in Local/newlib/include/ctype.h

Have a question about our Software Developer Kit? Ask them here.
Post Reply
phx
Posts: 10
Joined: Sun Jul 17, 2011 7:55 pm

Bug in Local/newlib/include/ctype.h

Post 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!
User avatar
ssolie
Beta Tester
Beta Tester
Posts: 1010
Joined: Mon Dec 20, 2010 8:51 pm
Location: Canada
Contact:

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

Post by ssolie »

Bug report submitted.
ExecSG Team Lead
Post Reply