summaryrefslogtreecommitdiff
path: root/src/libstddjb/case_diffs.c
blob: 621a8fa7b5fc5ae39ed9dac3384a996cb2c62e9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* ISC license. */

#include <skalibs/config.h>
#include <skalibs/bytestr.h>

#ifdef SKALIBS_FLAG_REPLACE_LIBC

int case_diffs (char const *s, char const *t)
{
  register unsigned char x = 1, y = 1 ;
  unsigned char const d = 'a' - 'A' ;

  while (x && (x == y))
  {
    x = *s++ ;
    if (('a' <= x) && (x <= 'z')) x -= d ;
    y = *t++ ;
    if (('a' <= y) && (y <= 'z')) y -= d ;
  }
  return (int)(x - y) ;
}

#endif