summaryrefslogtreecommitdiff
path: root/src/libstddjb/case_diffs.c
blob: 2731408cf1aba1346fa9a49ed9758901794f9ae9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* ISC license. */

#include <skalibs/bytestr.h>

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) ;
}