with strict C99 the tests/mpz/convert.c needs #include <strings.h>

Vincent Lefevre vincent at vinc17.net
Mon Nov 9 07:53:52 UTC 2020


Hi,

On 2020-11-09 06:29:47 +0100, Marco Bodrato wrote:
> That file will be changed in the next release. Please look if the applied
> patch fits your needs.
> https://gmplib.org/repo/gmp-6.2/rev/ad3ca09cfa38

/* This is similar to POSIX strcasecmp except that we don't do the comparison
   with unsigned char.  We avoid strcasecmp for C standard conformance.  */
static int
str_casecmp (const char *s1, const char *s2)
{
  size_t i;
  for (i = 0;; i++)
    {
      int c1 = s1[i];
      int c2 = s2[i];
      if (c1 == 0 || tolower (c1) != tolower (c2))
	return c1 - c2;
    }
}

Is there a reason not to do the comparison with unsigned char?

In the context of the call, the values will always be nonnegative
so that this is OK, but there is a risk that some future developer
might reuse this function in another context, where it would be
incorrect on platforms with signed char (in particular, there is
no warning in the comment).

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the gmp-bugs mailing list