Deleted Added
full compact
36,38d35
< #if HAVE_LIMITS_H
< #include <limits.h>
< #endif
236,265d232
< * Return the largest possible number that can fit in a long.
< */
< static long
< get_maxlong()
< {
< #ifdef LONG_MAX
< return (LONG_MAX);
< #else
< #ifdef MAXLONG
< return (MAXLONG);
< #else
< long n, n2;
<
< /*
< * Keep doubling n until we overflow.
< * {{ This actually only returns the largest power of two that
< * can fit in a long, but percentage() doesn't really need
< * it any more accurate than that. }}
< */
< n2 = 128; /* Hopefully no maxlong is less than 128! */
< do {
< n = n2;
< n2 *= 2;
< } while (n2 / 2 == n);
< return (n);
< #endif
< #endif
< }
<
< /*
273,274c240,243
< if (num <= get_maxlong() / 100)
< return ((100 * num) / den);
---
> POSITION num100 = num * 100;
>
> if (num100 / 100 == num)
> return (num100 / den);
281d249
< * {{ Assumes a POSITION is a long int. }}
288,289c256,261
< if (pos <= get_maxlong() / 100)
< return ((percent * pos) / 100);
---
> POSITION result100;
>
> if (percent == 0)
> return (0);
> else if ((result100 = pos * percent) / percent == pos)
> return (result100 / 100);
293a266,300
> #if !HAVE_STRCHR
> /*
> * strchr is used by regexp.c.
> */
> char *
> strchr(s, c)
> char *s;
> int c;
> {
> for ( ; *s != '\0'; s++)
> if (*s == c)
> return (s);
> if (c == '\0')
> return (s);
> return (NULL);
> }
> #endif
>
> #if !HAVE_MEMCPY
> VOID_POINTER
> memcpy(dst, src, len)
> VOID_POINTER dst;
> VOID_POINTER src;
> int len;
> {
> char *dstp = (char *) dst;
> char *srcp = (char *) src;
> int i;
>
> for (i = 0; i < len; i++)
> dstp[i] = srcp[i];
> return (dst);
> }
> #endif
>
309c316
< public int
---
> int