BOOTSTRAP (kutils) functions


LIBRARY ROUTINE

kstrncasecmp - do a case insensitive string compare on n characters

LIBRARY CALL

int kstrncasecmp(
   const char *istr1,
   const char *istr2,
   size_t      num)

INPUT

OUTPUT

none

RETURN VALUE

If the two strings are identical up to the specified byte, or end of string the value of 0 is returned. If the two strings differ, the ASCII value difference of the first character that differs in the two strings will be returned. If the ASCII value of the differing character in 'istr1' is greater than the one in 'istr2', then the return value is positive, and implies that 'istr1' is greater than 'istr2'. If the difference between the two ASCII values is negative, the return value implies that 'istr2' is greater than 'istr1'.

DESCRIPTION

This routine does a case insensitive comparison of two strings for a specified number of bytes. This routine is a replacement for the system strncasecmp(). It does a character by character case insensitive comparison of both input strings until the current character for one string does not equal the current character of the other string, until the end of the input strings are reached, or until num characters have been compared. It protects against NULL on the input strings by replacing NULL pointers with a reference to an empty string.

ADDITIONAL INFORMATION

none

EXAMPLES

This example uses strcasecmp twice on the same strings and different 'num' values.
char *s1 = "SAME-DIFFERENT";
char *s2 = "Same-Really Different";
int same, different;

same = kstrncasecmp(s1, s2, 5); different = kstrncasecmp(s1, s2, 10); printf("same is %d\ndifferent is %d\n", same, different);

the resulting output will be:

same is 0 different is -14

because up to the fifth character they are the same, and on the sixth character the returned result will be 'D' - 'R'.

SIDE EFFECTS

none

RESTRICTIONS

none

MODIFICATION

none

FILES

$BOOTSTRAP/objects/library/kutils/src/strings.c

SEE ALSO

kutils(3)

COPYRIGHT

Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.