Build problem on amd64 (cs/test_crc.cs failes) - patch included

Thomas Regner <[email protected]> Wed, 30 Apr 2008 21:02:45 +0200
Newsgroups gmane.text.clearsilver.general
Message-ID <[email protected]>
Hello,

the code in cs/ does not pass it's testsuite on amd64 machines, at least not 
on mine and a quick search on the net confirmed that others have the problem 
too.

The crc32 result is assigned to a long field and therfore does not "wrap 
around" (get negative).

I was able to solve this issue by explicitly casting the ne_crc()-result to 
INT32 (as typedef'ed in neo_misc.h) when assigned to result->n (a long 
field).

The code compiles and runs just fine and passes the testsuite.

The simple patch:
---------------------%<--------------------
*** cs/csparse.c.orig   2007-07-12 04:37:34.000000000 +0200
--- cs/csparse.c        2008-04-30 20:39:42.000000000 +0200
***************
*** 3717,3723 ****
    if (val.op_type & (CS_TYPE_VAR | CS_TYPE_STRING))
    {
      char *s = arg_eval(parse, &val);
!     if (s) result->n = ne_crc((unsigned char *)s, strlen(s));
    }
    if (val.alloc) free(val.s);
    return STATUS_OK;
--- 3717,3723 ----
    if (val.op_type & (CS_TYPE_VAR | CS_TYPE_STRING))
    {
      char *s = arg_eval(parse, &val);
!     if (s) result->n = (INT32) ne_crc((unsigned char *)s, strlen(s));
    }
    if (val.alloc) free(val.s);
    return STATUS_OK;
---------------------%<--------------------

If there is a problem with this I don't see, please comment so that I can 
search for another solution.

kind regards,
Tom Regner