| 1 | /* $Id: kHlpStrNICompAscii.c 3574 2007-09-02 19:30:58Z bird $ */
|
|---|
| 2 | /** @file
|
|---|
| 3 | * kHlpString - kHlpStrNICompAscii.
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /*
|
|---|
| 7 | * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
|
|---|
| 8 | *
|
|---|
| 9 | * This file is part of kStuff.
|
|---|
| 10 | *
|
|---|
| 11 | * kStuff is free software; you can redistribute it and/or
|
|---|
| 12 | * modify it under the terms of the GNU Lesser General Public
|
|---|
| 13 | * License as published by the Free Software Foundation; either
|
|---|
| 14 | * version 2.1 of the License, or (at your option) any later version.
|
|---|
| 15 | *
|
|---|
| 16 | * kStuff is distributed in the hope that it will be useful,
|
|---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 19 | * Lesser General Public License for more details.
|
|---|
| 20 | *
|
|---|
| 21 | * You should have received a copy of the GNU Lesser General Public
|
|---|
| 22 | * License along with kStuff; if not, write to the Free Software
|
|---|
| 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|---|
| 24 | *
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | /*******************************************************************************
|
|---|
| 28 | * Header Files *
|
|---|
| 29 | *******************************************************************************/
|
|---|
| 30 | #include <k/kHlpString.h>
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | KHLP_DECL(int) kHlpStrNICompAscii(const char *psz1, const char *psz2, KSIZE cb)
|
|---|
| 34 | {
|
|---|
| 35 | while (cb-- > 0)
|
|---|
| 36 | {
|
|---|
| 37 | char ch1 = *psz1;
|
|---|
| 38 | char ch2 = *psz2;
|
|---|
| 39 | if (ch1 != ch2)
|
|---|
| 40 | {
|
|---|
| 41 | if (ch1 <= 'Z' && ch1 >= 'A')
|
|---|
| 42 | ch1 += 'a' - 'A';
|
|---|
| 43 | if (ch2 <= 'Z' && ch2 >= 'A')
|
|---|
| 44 | ch2 += 'a' - 'A';
|
|---|
| 45 | if (ch1 != ch2)
|
|---|
| 46 | return ch1 > ch2 ? 1 : -1;
|
|---|
| 47 | }
|
|---|
| 48 | if (!ch1)
|
|---|
| 49 | break;
|
|---|
| 50 | psz1++;
|
|---|
| 51 | psz2++;
|
|---|
| 52 | }
|
|---|
| 53 | return 0;
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|