Back to index

tetex-bin  3.0
Defines | Functions
strcasecmp.c File Reference
#include <stddef.h>
#include <ctype.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define STRXCASECMP_FUNCTION   strcasecmp
#define STRXCASECMP_DECLARE_N   /* empty */
#define LENGTH_LIMIT_EXPR(Expr)   0
#define TOLOWER(Ch)   (isupper (Ch) ? tolower (Ch) : (Ch))

Functions

int STRXCASECMP_FUNCTION (const char *s1, const char *s2 STRXCASECMP_DECLARE_N)

Define Documentation

#define LENGTH_LIMIT_EXPR (   Expr)    0

Definition at line 29 of file strcasecmp.c.

#define STRXCASECMP_DECLARE_N   /* empty */

Definition at line 28 of file strcasecmp.c.

Definition at line 27 of file strcasecmp.c.

#define TOLOWER (   Ch)    (isupper (Ch) ? tolower (Ch) : (Ch))

Definition at line 35 of file strcasecmp.c.


Function Documentation

int STRXCASECMP_FUNCTION ( const char *  s1,
const char *s2  STRXCASECMP_DECLARE_N 
)

Definition at line 43 of file strcasecmp.c.

{
  register const unsigned char *p1 = (const unsigned char *) s1;
  register const unsigned char *p2 = (const unsigned char *) s2;
  unsigned char c1, c2;

  if (p1 == p2 || LENGTH_LIMIT_EXPR (n == 0))
    return 0;

  do
    {
      c1 = TOLOWER (*p1);
      c2 = TOLOWER (*p2);

      if (LENGTH_LIMIT_EXPR (--n == 0) || c1 == '\0')
       break;

      ++p1;
      ++p2;
    }
  while (c1 == c2);

  return c1 - c2;
}