3.4 testlib

"JONATHAN LEONARD, BLOOMBERG/ 731 LEXIN" <[email protected]>
Newsgroups gmane.comp.encryption.cryptlib
Message-ID <4CADC234000490FA003900DF_0_38235@p057>
To get testlib.o to compile, it seems that the -DDATA_ENDIAN define is necessary. To get it to work, I changed the compile rule for testlib.o to:

    $(CC) $(CFLAGS) `tools/ccopts.sh $(CC)` test/testlib.c
    
There's also a problem with wchars on Solaris. They're defined as long in /usr/include/iso/stdlib_iso.h, which conflicts with misc/os_spec.h. It also crashes in utils.c if the address passed to isUnicode() or printComponent() isn't aligned right. This is my quick patch.

Jon

--- misc/os_spec.h.orig 2010-07-06 21:08:14.000000000 -0400
+++ misc/os_spec.h      2010-10-06 13:20:29.000000000 -0400
@@ -815,7 +815,7 @@
         defines it in wchar.h but then defines it differently in stddef.h, and
         in any case has no wchar support present */
   #if !( defined( __APPLE__ ) || defined( __MVS__ ) || \
-                defined( __OpenBSD__ ) || defined( __PALMOS__ ) )
+                defined( __OpenBSD__ ) || defined( __PALMOS__ ) || defined(sun) )
        typedef unsigned short int wchar_t;
   #endif /* __APPLE__ */
   #define WCSIZE       ( sizeof( wchar_t ) )
--- test/utils.c.orig   2010-09-15 19:43:04.000000000 -0400
+++ test/utils.c        2010-10-06 16:21:23.271000000 -0400
@@ -1351,7 +1351,12 @@
 
 static BOOLEAN isUnicode( const BYTE *value, const int length )
        {
+#if defined(__sparc)
+    wchar_t wcValue[(length+sizeof(wchar_t)-1)/sizeof(wchar_t)];
+    memcpy(wcValue, value, length);
+#else
        const wchar_t *wcValue = ( wchar_t * ) value;
+#endif
 
        /* If it's an odd length or too short to reliably guess, report it as 
           non-Unicode */
@@ -1431,7 +1436,12 @@
                }
        if( isUnicode( buffer, length ) )
                {
+#if defined(__sparc)
+               wchar_t wcBuffer[(length+2*sizeof(wchar_t)-1)/sizeof(wchar_t)];
+               memcpy(wcBuffer, buffer, length);
+#else
                wchar_t *wcBuffer = ( wchar_t * ) buffer;
+#endif
 
                wcBuffer[ length / sizeof( wchar_t ) ] = TEXT( '\0' );
                printf( "  %s = %S.\n", prefixString, wcBuffer );
_______________________________________________
Cryptlib mailing list
[email protected] via Mail: [email protected]
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.