summaryrefslogtreecommitdiff
path: root/src/libstddjb/case_diffs.c
blob: bf72472fe8bc08840f61abf79d4564735bdfe80a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* 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