head 1.4; access; symbols str_init:1.1.1.1 str:1.1.1; locks; strict; comment @ * @; 1.4 date 99.12.27.13.43.06; author rse; state dead; branches; next 1.3; 1.3 date 99.12.25.18.33.25; author rse; state Exp; branches; next 1.2; 1.2 date 99.12.25.18.23.02; author rse; state Exp; branches; next 1.1; 1.1 date 99.11.22.17.29.12; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 99.11.22.17.29.12; author rse; state Exp; branches; next ; desc @@ 1.4 log @. @ text @/* ** Str - String Library ** Copyright (c) 1999 Ralf S. Engelschall ** ** This file is part of Str, a string handling and manipulation ** library which can be found at http://www.engelschall.com/sw/str/. ** ** Permission to use, copy, modify, and distribute this software for ** any purpose with or without fee is hereby granted, provided that ** the above copyright notice and this permission notice appear in all ** copies. ** ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** ** str_compare.h: comparison functions */ #include "str_p.h" int str_compare( const char *s1, const char *s2, str_size_t n, int mode) { int rv; if (n == 0) return 0; rv = 0; if (mode & STR_NOCASE) { /* compare case insensitive */ do { if (str_tolower(*s1) != str_tolower(*s2++)) { rv = ((str_tolower(*s1) - str_tolower(*--s2)) < 0 ? -1 : +1); break; } if (*s1++ == NUL) break; } while (--n > 0); } else { /* compare case sensitive */ do { if (*s1 != *s2++) { rv = ((*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1)) < 0 ? -1 : +1); break; } if (*s1++ == NUL) break; } while (--n > 0); } return rv; } @ 1.3 log @*** empty log message *** @ text @@ 1.2 log @*** empty log message *** @ text @d29 1 a29 5 #include "str.h" #define _str_tolower(ch) \ (isupper((unsigned char)(ch)) ? \ tolower((unsigned char)(ch)) : (ch)) d32 3 a34 3 register const char *s1, register const char *s2, register str_size_t n, d45 3 a47 3 if (_str_tolower(*s1) != _str_tolower(*s2++)) { rv = ((_str_tolower(*s1) - _str_tolower(*--s2)) < 0 ? -1 : +1); @ 1.1 log @Initial revision @ text @d1 3 a3 2 /* ** str_compare.c -- String Comparison d5 2 a6 2 ** ==================================================================== ** Copyright (c) 1999 Ralf S. Engelschall. All rights reserved. d8 4 a11 3 ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: d13 12 a24 2 ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. d26 1 a26 18 ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** ** THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY ** EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RALF S. ENGELSCHALL OR ** ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ** STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED ** OF THE POSSIBILITY OF SUCH DAMAGE. ** ==================================================================== @ 1.1.1.1 log @ @ text @@