Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!alberta!hoover From: hoover@cs.UAlberta.CA (Jim Hoover) Newsgroups: comp.lang.perl Subject: Yet another perl portability bug Message-ID: <1990Dec11.052604.21319@cs.UAlberta.CA> Date: 11 Dec 90 05:26:04 GMT Sender: news@cs.UAlberta.CA (News Administrator) Organization: University of Alberta, Edmonton, Canada Lines: 33 Larry: On my SCO box, perl failed the lib.big test for big integers. In tracking down the failure I discovered a bug in the implementation of cmp or of str_cmp (take your pick). The cmp operator implementation assumes that str_cmp (in str.c) returns one of -1 0 +1. str_cmp is implemented with memcmp, which is specified (on my SCO box) only to return a negative, zero, or positive value. It says nothing about the range of values. SCO's version returns various postive and negative values. Jim Hoover Here is my fix to str_cmp: 741c741,742 < return retval; --- > /* FIX - memcmp is not guaranteed to return -1 0 +1, just sign */ > return (retval > 0) ? +1 : -1; 746c747,748 < return retval; --- > /* FIX - memcmp is not guaranteed to return -1 0 +1, just sign */ > return (retval > 0) ? +1 : -1; -- Prof. Jim Hoover | Office +1 403 492 5401 or 5290 Dept. of Computing Science | FAX +1 403 492 1071 University of Alberta | hoover@cs.ualberta.ca Edmonton, Alberta, Canada T6G 2H1 |