home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
clipper
/
rettig
/
source
/
_tr_scmp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-21
|
1KB
|
50 lines
/*********
*
* _TR_SCMP.C
*
* by Ralph Davis
* modified by Tom Rettig
*
* Placed in the public domain by Tom Rettig Associates, 10/22/1990.
*
* Syntax: _tr_strcmp(cp1, cp2)
* Return: int < 0 if cp1 < cp2, 0 if equal, > 0 if cp1 > cp2
********/
#include "trlib.h"
_tr_strcmp(str1, str2)
char *str1;
char *str2;
{
int i, ret;
for (i = 0; str1[i] == str2[i] && (str1[i] | str2[i]); i++)
;
if ((str1[i] | str2[i]) == 0) /* Are they both '\0'? */
return (0);
else
return ( ret = str1[i] - str2[i] );
}
/********
* Syntax: _tr_strncmp(cp1, cp2, length)
* Return: int < 0 if cp1 < cp2, 0 if equal, > 0 if cp1 > cp2
* Note :
********/
_tr_strncmp(str1, str2, length)
char *str1;
char *str2;
int length;
{
int i, ret;
for (i = 0; (str1[i] == str2[i]) && (str1[i] | str2[i]) && (i < length); i++)
;
if ( ((str1[i] | str2[i]) == 0) || (i == length) )
return (0);
else if (str1[i] == NULLC && str2[i])
return (-1);
else
return ( ret = str1[i] - str2[i] );
}