On Tue, Dec 21, 2010 at 11:55:34PM +0100, Jakub Wilk wrote:
> * brian m. carlson <sand...@crustytoothpaste.net>, 2010-12-21, 21:39:
> >diff -ur libuninum.old/unicode.h libuninum-2.7/unicode.h
> >--- libuninum.old/unicode.h  2010-12-21 21:35:42.000000000 +0000
> >+++ libuninum-2.7/unicode.h  2010-12-21 21:36:04.000000000 +0000
> >@@ -1,4 +1,4 @@
> >-typedef unsigned long       UTF32;  /* at least 32 bits */
> >+typedef unsigned int        UTF32;  /* at least 32 bits */
> >typedef unsigned short       UTF16;  /* at least 16 bits */
> >typedef unsigned short       UCS2;   /* at least 16 bits */
> >typedef unsigned char        UTF8;   /* 8 bits */
> 
> While I can image that this patch make things better, please note
> that it also breaks ABI (on 64-bit arches).

Okay.  I've looked, and I'm certain this has never worked on a 64-bit
machine:

  uninum.c: In function ‘wcsrev’:
  uninum.c:192:3: warning: passing argument 1 of ‘wcslen’ from incompatible 
pointer type
  /usr/include/wchar.h:284:15: note: expected ‘const wchar_t *’ but argument is 
of type ‘long int *’
  uninum.c:193:3: warning: passing argument 1 of ‘wcslen’ from incompatible 
pointer type
  /usr/include/wchar.h:284:15: note: expected ‘const wchar_t *’ but argument is 
of type ‘long int *’

These are just a few of the myriad warnings.  sizeof(wchar_t) is 4 and
sizeof(long) is 8 on 64-bit machines, so anything using these functions
is going to fail.  Theoretically, these functions could be patched to
convert the data on-the-fly or could be manually rewritten using static
functions that handle longs instead of wchar_ts, but I'm not a
masochist, so I'm not going to do it.

I've attached a patch that uses <stdint.h> to define these types so we
don't have this problem again.  It also fixes some areas I didn't get
before.  They aren't actually problems, since they're incorrect pointer
casts and the wcs* functions handle them correctly, but it prevents a
lot of the warning messages from above.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
diff -ur libuninum.old/unicode.h libuninum-2.7/unicode.h
--- libuninum.old/unicode.h	2010-12-21 21:35:42.000000000 +0000
+++ libuninum-2.7/unicode.h	2010-12-21 23:57:33.000000000 +0000
@@ -1,8 +1,10 @@
-typedef unsigned long	UTF32;	/* at least 32 bits */
-typedef unsigned short	UTF16;	/* at least 16 bits */
-typedef unsigned short	UCS2;	/* at least 16 bits */
-typedef unsigned char	UTF8;	/* 8 bits */
-typedef unsigned char	Boolean; /* 0 or 1 */
+#include <stdint.h>
+
+typedef uint32_t	UTF32;	/* at least 32 bits */
+typedef uint16_t	UTF16;	/* at least 16 bits */
+typedef uint16_t	UCS2;	/* at least 16 bits */
+typedef uint8_t	UTF8;	/* 8 bits */
+typedef uint8_t	Boolean; /* 0 or 1 */
 
 #define UNI_MAX_ASCII (UTF32)0x0000007F 
 #define UNI_MAX_BMP   (UTF32)0x0000FFFF
diff -ur libuninum.old/uninum.c libuninum-2.7/uninum.c
--- libuninum.old/uninum.c	2010-12-21 21:35:42.000000000 +0000
+++ libuninum-2.7/uninum.c	2010-12-22 00:00:14.000000000 +0000
@@ -35,11 +35,11 @@
  */
 
 
-#define ucslen(x) wcslen((signed long *) x)
-#define ucscpy(x,y) (UTF32 *)wcscpy((signed long *)x,(signed long *)y)
-#define ucscat(x,y) (UTF32 *)wcscat((signed long *)x,(signed long *)y)
-#define ucschr(x,y) (UTF32 *)wcschr((signed long *)x,(signed long)y)
-#define ucsrchr(x,y) (UTF32 *)wcsrchr((signed long *)x,(signed long)y)
+#define ucslen(x) wcslen((wchar_t *) x)
+#define ucscpy(x,y) (UTF32 *)wcscpy((wchar_t *)x,(wchar_t *)y)
+#define ucscat(x,y) (UTF32 *)wcscat((wchar_t *)x,(wchar_t *)y)
+#define ucschr(x,y) (UTF32 *)wcschr((wchar_t *)x,(wchar_t)y)
+#define ucsrchr(x,y) (UTF32 *)wcsrchr((wchar_t *)x,(wchar_t)y)
 
 #define UNINUM
 

Attachment: signature.asc
Description: Digital signature

Reply via email to