comparison lib/mbscasecmp.c @ 10954:a0bbe1a6f787

Remove HAVE_MBRTOWC conditionals. Use mbrtowc unconditionally.
author Bruno Haible <bruno@clisp.org>
date Mon, 22 Dec 2008 12:11:44 +0100
parents bbbbbf4cd1c5
children e8d2c6fc33ad
comparison
equal deleted inserted replaced
10953:402b52de2fa2 10954:a0bbe1a6f787
1 /* Case-insensitive string comparison function. 1 /* Case-insensitive string comparison function.
2 Copyright (C) 1998-1999, 2005-2007 Free Software Foundation, Inc. 2 Copyright (C) 1998-1999, 2005-2008 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2005, 3 Written by Bruno Haible <bruno@clisp.org>, 2005,
4 based on earlier glibc code. 4 based on earlier glibc code.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
22 #include <string.h> 22 #include <string.h>
23 23
24 #include <ctype.h> 24 #include <ctype.h>
25 #include <limits.h> 25 #include <limits.h>
26 26
27 #if HAVE_MBRTOWC 27 #include "mbuiter.h"
28 # include "mbuiter.h"
29 #endif
30 28
31 #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) 29 #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
32 30
33 /* Compare the character strings S1 and S2, ignoring case, returning less than, 31 /* Compare the character strings S1 and S2, ignoring case, returning less than,
34 equal to or greater than zero if S1 is lexicographically less than, equal to 32 equal to or greater than zero if S1 is lexicographically less than, equal to
42 return 0; 40 return 0;
43 41
44 /* Be careful not to look at the entire extent of s1 or s2 until needed. 42 /* Be careful not to look at the entire extent of s1 or s2 until needed.
45 This is useful because when two strings differ, the difference is 43 This is useful because when two strings differ, the difference is
46 most often already in the very few first characters. */ 44 most often already in the very few first characters. */
47 #if HAVE_MBRTOWC
48 if (MB_CUR_MAX > 1) 45 if (MB_CUR_MAX > 1)
49 { 46 {
50 mbui_iterator_t iter1; 47 mbui_iterator_t iter1;
51 mbui_iterator_t iter2; 48 mbui_iterator_t iter2;
52 49
70 /* s1 terminated before s2. */ 67 /* s1 terminated before s2. */
71 return -1; 68 return -1;
72 return 0; 69 return 0;
73 } 70 }
74 else 71 else
75 #endif
76 { 72 {
77 const unsigned char *p1 = (const unsigned char *) s1; 73 const unsigned char *p1 = (const unsigned char *) s1;
78 const unsigned char *p2 = (const unsigned char *) s2; 74 const unsigned char *p2 = (const unsigned char *) s2;
79 unsigned char c1, c2; 75 unsigned char c1, c2;
80 76