hrp@boring.cray.com (Hal Peterson) (07/26/89)
I am using GhostScript 1.3 with the patches supplied by Tony Li and
snoopy's fix to interp.c. My platform is an 8MB Sun 3/50 running
SunOS 3.5. I am compiling with GCC 1.35.
String comparison was not producing lexical ordering. The function
bytes_compare() was comparing string lengths first rather than last,
which resulted in the program
%!
(aardvark) (zebra) gt ==
returning true, which is wrong; aardvark does not come after zebra in
the dictionary.
--
Hal Peterson Domain: hrp@cray.com
Cray Research Old style: hrp%cray.com@uc.msc.umn.edu
1440 Northland Dr. UUCP: uunet!cray!hrp
Mendota Hts, MN 55120 USA Telephone: +1 612 681 3145
========================================================================
*** iutil-DIST.c Tue Jun 20 07:07:59 1989
--- iutil.c Tue Jul 25 16:20:33 1989
***************
*** 107,120 ****
int
bytes_compare(byte *s1, uint len1, byte *s2, uint len2)
{ register uint len = len1;
! if ( len != len2 ) return (len < len2 ? -1 : 1);
! { register byte *p1 = s1;
! register byte *p2 = s2;
! while ( len-- )
! if ( *p1++ != *p2++ )
! return (p1[-1] < p2[-1] ? -1 : 1);
}
! return 0;
}
/* Compute a hash for a string */
--- 107,125 ----
int
bytes_compare(byte *s1, uint len1, byte *s2, uint len2)
{ register uint len = len1;
! if (len > len2) len = len2;
! /* Compare the contents */
! while (len--)
! { if (*s1 < *s2) return -1;
! else if (*(s1++) > *(s2++)) return 1;
}
! /* Contents are identical; try the lengths. */
! if (len1 > len2)
! return 1;
! else if (len1 < len2)
! return -1;
! else
! return 0;
}
/* Compute a hash for a string */