Changeset 26676 in webkit
- Timestamp:
- Oct 16, 2007, 1:13:24 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r26639 r26676 1 2007-10-16 Darin Adler <[email protected]> 2 3 Reviewed by Maciej and Geoff (and looked over by Eric). 4 5 - http://bugs.webkit.org/show_bug.cgi?id=15519 6 eliminate use of <ctype.h> for processing ASCII 7 8 * wtf/ASCIICType.h: Added. 9 * wtf/DisallowCType.h: Added. 10 11 * kjs/config.h: Include DisallowCType.h. 12 13 * kjs/date_object.cpp: 14 (KJS::skipSpacesAndComments): 15 (KJS::findMonth): 16 (KJS::parseDate): 17 * kjs/function.cpp: 18 (KJS::decode): 19 * kjs/ustring.cpp: 20 (KJS::UString::toDouble): 21 Use ASCIICType.h functions instead of ctype.h ones. 22 1 23 2007-10-14 Maciej Stachowiak <[email protected]> 2 24 -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r25786 r26676 218 218 935AF46E09E9D9DB00ACD1D8 /* UnusedParam.h in Headers */ = {isa = PBXBuildFile; fileRef = 935AF46B09E9D9DB00ACD1D8 /* UnusedParam.h */; }; 219 219 935F69FE08245057003D1A45 /* dftables.c in Sources */ = {isa = PBXBuildFile; fileRef = 6541720E039E08B90058BFEB /* dftables.c */; }; 220 938C4F6A0CA06BC700D9310A /* ASCIICType.h in Headers */ = {isa = PBXBuildFile; fileRef = 938C4F690CA06BC700D9310A /* ASCIICType.h */; settings = {ATTRIBUTES = (Private, ); }; }; 221 938C4F6C0CA06BCE00D9310A /* DisallowCType.h in Headers */ = {isa = PBXBuildFile; fileRef = 938C4F6B0CA06BCE00D9310A /* DisallowCType.h */; settings = {ATTRIBUTES = (Private, ); }; }; 220 222 93AA4F780957251F0084B3A7 /* AlwaysInline.h in Headers */ = {isa = PBXBuildFile; fileRef = 93AA4F770957251F0084B3A7 /* AlwaysInline.h */; settings = {ATTRIBUTES = (Private, ); }; }; 221 223 93B6A0DF0AA64DA40076DE27 /* GetPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B6A0DE0AA64DA40076DE27 /* GetPtr.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 570 572 937B63CC09E766D200A671DD /* DerivedSources.make */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = DerivedSources.make; sourceTree = "<group>"; usesTabs = 1; }; 571 573 938772E5038BFE19008635CE /* array_instance.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = array_instance.h; sourceTree = "<group>"; tabWidth = 8; }; 574 938C4F690CA06BC700D9310A /* ASCIICType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASCIICType.h; sourceTree = "<group>"; }; 575 938C4F6B0CA06BCE00D9310A /* DisallowCType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisallowCType.h; sourceTree = "<group>"; }; 572 576 93AA4F770957251F0084B3A7 /* AlwaysInline.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = AlwaysInline.h; sourceTree = "<group>"; tabWidth = 8; }; 573 577 93B6A0DE0AA64DA40076DE27 /* GetPtr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GetPtr.h; sourceTree = "<group>"; }; … … 897 901 isa = PBXGroup; 898 902 children = ( 899 652246A40C8D7A0E007BDAF7 /* HashIterators.h */,900 903 E195678D09E7CF1200B89D13 /* unicode */, 901 904 93AA4F770957251F0084B3A7 /* AlwaysInline.h */, 905 938C4F690CA06BC700D9310A /* ASCIICType.h */, 902 906 65E217B808E7EECC0023E5F6 /* Assertions.cpp */, 903 907 65E217B708E7EECC0023E5F6 /* Assertions.h */, 908 938C4F6B0CA06BCE00D9310A /* DisallowCType.h */, 904 909 65E217B908E7EECC0023E5F6 /* FastMalloc.cpp */, 905 910 65E217BA08E7EECC0023E5F6 /* FastMalloc.h */, … … 909 914 657EEBBF094E445E008C9C7B /* HashCountedSet.h */, 910 915 65DFC92A08EA173A00F7300B /* HashFunctions.h */, 916 652246A40C8D7A0E007BDAF7 /* HashIterators.h */, 911 917 65DFC92B08EA173A00F7300B /* HashMap.h */, 912 918 65DFC92C08EA173A00F7300B /* HashSet.h */, … … 1254 1260 652246A50C8D7A0E007BDAF7 /* HashIterators.h in Headers */, 1255 1261 95C18D490C90E82600E72F73 /* JSRetainPtr.h in Headers */, 1262 938C4F6A0CA06BC700D9310A /* ASCIICType.h in Headers */, 1263 938C4F6C0CA06BCE00D9310A /* DisallowCType.h in Headers */, 1256 1264 ); 1257 1265 runOnlyForDeploymentPostprocessing = 0; -
trunk/JavaScriptCore/kjs/config.h
r26513 r26676 1 1 /* 2 * Copyright (C) 2006 Apple Computer, Inc.2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2006 Samuel Weinig <[email protected]> 4 4 * … … 86 86 #include <wtf/FastMalloc.h> 87 87 #endif 88 89 #include <wtf/DisallowCType.h> -
trunk/JavaScriptCore/kjs/date_object.cpp
r26454 r26676 1 1 /* 2 * This file is part of the KDE libraries3 2 * Copyright (C) 1999-2000 Harri Porten ([email protected]) 4 * Copyright (C) 2004 Apple Computer, Inc.3 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 4 * 6 5 * This library is free software; you can redistribute it and/or … … 41 40 #endif 42 41 43 #include <ctype.h>44 42 #include <float.h> 45 43 #include <limits.h> … … 55 53 #include "DateMath.h" 56 54 55 #include <wtf/ASCIICType.h> 57 56 #include <wtf/MathExtras.h> 58 57 #include <wtf/StringExtras.h> … … 61 60 #include <CoreFoundation/CoreFoundation.h> 62 61 #endif 62 63 using namespace WTF; 63 64 64 65 namespace KJS { … … 743 744 }; 744 745 745 inline static void skipSpacesAndComments(const char *&s)746 inline static void skipSpacesAndComments(const char*& s) 746 747 { 747 748 int nesting = 0; 748 749 char ch; 749 750 while ((ch = *s)) { 750 if (!is space(ch)) {751 if (!isASCIISpace(ch)) { 751 752 if (ch == '(') 752 753 nesting++; … … 761 762 762 763 // returns 0-11 (Jan-Dec); -1 on failure 763 static int findMonth(const char *monthStr)764 static int findMonth(const char* monthStr) 764 765 { 765 766 assert(monthStr); … … 768 769 if (!*monthStr) 769 770 return -1; 770 needle[i] = static_cast<char>(to lower(*monthStr++));771 needle[i] = static_cast<char>(toASCIILower(*monthStr++)); 771 772 } 772 773 needle[3] = '\0'; … … 806 807 const char *wordStart = dateString; 807 808 // Check contents of first words if not number 808 while (*dateString && !is digit(*dateString)) {809 if (is space(*dateString) || *dateString == '(') {809 while (*dateString && !isASCIIDigit(*dateString)) { 810 if (isASCIISpace(*dateString) || *dateString == '(') { 810 811 if (dateString - wordStart >= 3) 811 812 month = findMonth(wordStart); … … 956 957 957 958 // ':40 GMT' 958 if (*dateString && *dateString != ':' && !is space(*dateString))959 if (*dateString && *dateString != ':' && !isASCIISpace(*dateString)) 959 960 return NaN; 960 961 -
trunk/JavaScriptCore/kjs/function.cpp
r26619 r26676 1 1 // -*- c-basic-offset: 2 -*- 2 2 /* 3 * This file is part of the KDE libraries4 3 * Copyright (C) 1999-2002 Harri Porten ([email protected]) 5 4 * Copyright (C) 2001 Peter Kelly ([email protected]) 6 * Copyright (C) 2003 Apple Computer, Inc.5 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 7 6 * Copyright (C) 2007 Cameron Zwarich ([email protected]) 8 7 * … … 41 40 #include <assert.h> 42 41 #include <string.h> 43 #include <ctype.h> 44 42 43 #include <wtf/ASCIICType.h> 45 44 #include <wtf/unicode/Unicode.h> 46 45 … … 583 582 if (c == '%') { 584 583 int charLen = 0; 585 if (k <= len - 3 && is xdigit(p[1].uc) && isxdigit(p[2].uc)) {584 if (k <= len - 3 && isASCIIHexDigit(p[1].uc) && isASCIIHexDigit(p[2].uc)) { 586 585 const char b0 = Lexer::convertHex(p[1].uc, p[2].uc); 587 586 const int sequenceLen = UTF8SequenceLength(b0); … … 592 591 for (int i = 1; i < sequenceLen; ++i) { 593 592 const UChar* q = p + i * 3; 594 if (q[0] == '%' && is xdigit(q[1].uc) && isxdigit(q[2].uc))593 if (q[0] == '%' && isASCIIHexDigit(q[1].uc) && isASCIIHexDigit(q[2].uc)) 595 594 sequence[i] = Lexer::convertHex(q[1].uc, q[2].uc); 596 595 else { … … 620 619 // For that, it's good to support the wonky "%u" syntax for compatibility with WinIE. 621 620 if (k <= len - 6 && p[1] == 'u' 622 && is xdigit(p[2].uc) && isxdigit(p[3].uc)623 && is xdigit(p[4].uc) && isxdigit(p[5].uc)) {621 && isASCIIHexDigit(p[2].uc) && isASCIIHexDigit(p[3].uc) 622 && isASCIIHexDigit(p[4].uc) && isASCIIHexDigit(p[5].uc)) { 624 623 charLen = 6; 625 624 u = Lexer::convertUnicode(p[2].uc, p[3].uc, p[4].uc, p[5].uc); -
trunk/JavaScriptCore/kjs/ustring.cpp
r26182 r26676 1 1 // -*- c-basic-offset: 2 -*- 2 2 /* 3 * This file is part of the KDE libraries4 3 * Copyright (C) 1999-2000 Harri Porten ([email protected]) 5 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. … … 48 47 #endif 49 48 50 using std::max;51 using std::min;49 using namespace WTF; 50 using namespace std; 52 51 53 52 namespace KJS { … … 955 954 956 955 // skip leading white space 957 while (is space(*c))956 while (isASCIISpace(*c)) 958 957 c++; 959 958 … … 1010 1009 1011 1010 // allow trailing white space 1012 while (is space(*c))1011 while (isASCIISpace(*c)) 1013 1012 c++; 1014 1013 // don't allow anything after - unless tolerant=true -
trunk/WebCore/ChangeLog
r26674 r26676 1 2007-10-16 Darin Adler <[email protected]> 2 3 Reviewed by Maciej and Geoff (and looked over by Eric). 4 5 - http://bugs.webkit.org/show_bug.cgi?id=15519 6 eliminate use of <ctype.h> for processing ASCII 7 8 * ForwardingHeaders/wtf/ASCIICType.h: Added. 9 * ForwardingHeaders/wtf/DisallowCType.h: Added. 10 11 * WebCorePrefix.h: Get rid of inclusion of <ctype.h>. 12 * config.h: Include DisallowCType.h. 13 14 * css/CSSParser.cpp: 15 (WebCore::ParseString::lower): 16 * css/CSSPrimitiveValue.cpp: 17 (WebCore::isCSSTokenizerIdentifier): 18 * css/CSSStyleDeclaration.cpp: 19 (WebCore::propertyID): 20 * html/HTMLSelectElement.cpp: 21 (WebCore::stripLeadingWhiteSpace): 22 * html/HTMLTokenizer.cpp: 23 (WebCore::tagMatch): 24 * loader/FTPDirectoryParser.cpp: 25 (WebCore::parseOneFTPLine): 26 * loader/TextResourceDecoder.cpp: 27 (WebCore::TextResourceDecoder::checkForHeadCharset): 28 * platform/DeprecatedCString.cpp: 29 (WebCore::DeprecatedCString::lower): 30 (WebCore::DeprecatedCString::upper): 31 (WebCore::DeprecatedCString::find): 32 (WebCore::DeprecatedCString::contains): 33 * platform/DeprecatedString.cpp: 34 (WebCore::equalCaseInsensitive): 35 (WebCore::isCharacterAllowedInBase): 36 (WebCore::DeprecatedString::find): 37 (WebCore::DeprecatedString::contains): 38 (WebCore::toIntegralType): 39 * platform/DeprecatedString.h: 40 (WebCore::DeprecatedChar::isSpace): 41 (WebCore::DeprecatedChar::lower): 42 (WebCore::DeprecatedChar::upper): 43 * platform/KURL.cpp: 44 (WebCore::KURL::parse): 45 * platform/StringImpl.cpp: 46 (WebCore::isSpace): 47 (WebCore::StringImpl::containsOnlyWhitespace): 48 (WebCore::StringImpl::isLower): 49 (WebCore::StringImpl::lower): 50 (WebCore::StringImpl::find): 51 (WebCore::StringImpl::reverseFind): 52 (WebCore::equalIgnoringCase): 53 * platform/TextEncodingRegistry.cpp: 54 (WebCore::TextEncodingNameHash::equal): 55 (WebCore::TextEncodingNameHash::hash): 56 (WebCore::atomicCanonicalTextEncodingName): 57 * platform/mac/KeyEventMac.mm: 58 (WebCore::keyIdentifierForKeyEvent): 59 * platform/win/KeyEventWin.cpp: 60 (WebCore::keyIdentifierForWindowsKeyCode): 61 * platform/win/PopupMenuWin.cpp: 62 (WebCore::isASCIIPrintable): 63 (WebCore::PopupWndProc): 64 * plugins/win/PluginViewWin.cpp: 65 (WebCore::capitalizeRFC822HeaderFieldName): 66 * rendering/RenderText.cpp: 67 (WebCore::RenderText::widthFromCache): 68 Use ASCIICType.h functions instead of ctype.h ones. 69 1 70 2007-10-16 Mitz Pettel <[email protected]> 2 71 -
trunk/WebCore/WebCorePrefix.h
r25754 r26676 60 60 #endif // defined(WIN32) || defined(_WIN32) 61 61 62 #include <ctype.h>63 62 #include <sys/types.h> 64 63 #include <fcntl.h> … … 84 83 #include <cstddef> 85 84 #include <new> 86 87 /* Work around bug 3553309 by re-including <ctype.h>. */88 #include <cctype>89 #if defined(__APPLE__)90 #define isalnum(c) __istype((c), (_CTYPE_A|_CTYPE_D))91 #define isalpha(c) __istype((c), _CTYPE_A)92 #define iscntrl(c) __istype((c), _CTYPE_C)93 #define isdigit(c) __isctype((c), _CTYPE_D) /* ANSI -- locale independent */94 #define isgraph(c) __istype((c), _CTYPE_G)95 #define islower(c) __istype((c), _CTYPE_L)96 #define isprint(c) __istype((c), _CTYPE_R)97 #define ispunct(c) __istype((c), _CTYPE_P)98 #define isspace(c) __istype((c), _CTYPE_S)99 #define isupper(c) __istype((c), _CTYPE_U)100 #define isxdigit(c) __isctype((c), _CTYPE_X) /* ANSI -- locale independent */101 #define tolower(c) __tolower(c)102 #define toupper(c) __toupper(c)103 #endif104 85 105 86 #endif -
trunk/WebCore/config.h
r25754 r26676 26 26 #define HAVE_FUNC_USLEEP 1 27 27 #endif /* __APPLE__ */ 28 29 28 30 29 #if PLATFORM(WIN_OS) … … 67 66 68 67 #endif 68 69 #include <wtf/DisallowCType.h> 69 70 70 71 #if !COMPILER(MSVC) // can't get this to compile on Visual C++ yet -
trunk/WebCore/css/CSSParser.cpp
r26663 r26676 163 163 else 164 164 for (int i = 0; i < length; i++) 165 characters[i] = to lower(characters[i]);165 characters[i] = toASCIILower(characters[i]); 166 166 } 167 167 -
trunk/WebCore/css/CSSPrimitiveValue.cpp
r25754 r26676 1 /** 2 * This file is part of the DOM implementation for KDE. 3 * 1 /* 4 2 * (C) 1999-2003 Lars Knoll ([email protected]) 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.3 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 6 4 * 7 5 * This library is free software; you can redistribute it and/or … … 32 30 #include "Pair.h" 33 31 #include "RenderStyle.h" 34 #include <ctype.h> 32 #include <wtf/ASCIICType.h> 33 34 using namespace WTF; 35 35 36 36 namespace WebCore { … … 47 47 48 48 // {nmstart} 49 if (p == end || !(p[0] == '_' || p[0] >= 128 || is alpha(p[0])))49 if (p == end || !(p[0] == '_' || p[0] >= 128 || isASCIIAlpha(p[0]))) 50 50 return false; 51 51 ++p; … … 53 53 // {nmchar}* 54 54 for (; p != end; ++p) { 55 if (!(p[0] == '_' || p[0] == '-' || p[0] >= 128 || is alnum(p[0])))55 if (!(p[0] == '_' || p[0] == '-' || p[0] >= 128 || isASCIIAlphanumeric(p[0]))) 56 56 return false; 57 57 } -
trunk/WebCore/css/CSSStyleDeclaration.cpp
r26522 r26676 1 1 /** 2 * This file is part of the DOM implementation for KDE.3 *4 2 * (C) 1999-2003 Lars Knoll ([email protected]) 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.3 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 6 4 * 7 5 * This library is free software; you can redistribute it and/or … … 29 27 #include "CSSRule.h" 30 28 #include "DeprecatedValueList.h" 31 #include <ctype.h> 29 #include <wtf/ASCIICType.h> 30 31 using namespace WTF; 32 32 33 33 namespace WebCore { … … 48 48 if (c == 0 || c >= 0x7F) 49 49 return 0; // illegal character 50 buffer[i] = to lower(c);50 buffer[i] = toASCIILower(c); 51 51 } 52 52 -
trunk/WebCore/html/HTMLSelectElement.cpp
r26665 r26676 908 908 for (i = 0; i < length; ++i) 909 909 if (string[i] != noBreakSpace && 910 (string[i] <= 0x7F ? !is space(string[i]) : (direction(string[i]) != WhiteSpaceNeutral)))910 (string[i] <= 0x7F ? !isASCIISpace(string[i]) : (direction(string[i]) != WhiteSpaceNeutral))) 911 911 break; 912 912 -
trunk/WebCore/html/HTMLTokenizer.cpp
r25754 r26676 1 1 /* 2 This file is part of the KDE libraries3 4 2 Copyright (C) 1997 Martin Jones ([email protected]) 5 3 (C) 1997 Torben Weis ([email protected]) … … 8 6 (C) 1999 Antti Koivisto ([email protected]) 9 7 (C) 2001 Dirk Mueller ([email protected]) 10 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. 8 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 11 9 Copyright (C) 2005, 2006 Alexey Proskuryakov ([email protected]) 12 10 … … 47 45 #include "SystemTime.h" 48 46 #include "kjs_proxy.h" 47 #include <wtf/ASCIICType.h> 49 48 50 49 #include "HTMLEntityNames.c" … … 62 61 63 62 using namespace std; 63 using namespace WTF; 64 64 65 65 namespace WebCore { … … 120 120 for (unsigned i = 0; i != length; ++i) { 121 121 unsigned char c1 = s1[i]; 122 unsigned char uc1 = to upper(c1);122 unsigned char uc1 = toASCIIUpper(static_cast<char>(c1)); 123 123 UChar c2 = s2[i]; 124 124 if (c1 != c2 && uc1 != c2) -
trunk/WebCore/loader/FTPDirectoryParser.cpp
r26185 r26676 25 25 #include "FTPDirectoryParser.h" 26 26 27 #include "DeprecatedString.h" 27 #include <wtf/ASCIICType.h> 28 29 using namespace WTF; 28 30 29 31 namespace WebCore { … … 128 130 else if (*p == 'm') 129 131 { 130 if (is digit(line[pos]))131 { 132 while (pos < linelen && is digit(line[pos]))132 if (isASCIIDigit(line[pos])) 133 { 134 while (pos < linelen && isASCIIDigit(line[pos])) 133 135 pos++; 134 136 if (pos < linelen && line[pos] == ',') … … 146 148 else if (*p == 's') 147 149 { 148 if (is digit(line[pos]))149 { 150 while (pos < linelen && is digit(line[pos]))150 if (isASCIIDigit(line[pos])) 151 { 152 while (pos < linelen && isASCIIDigit(line[pos])) 151 153 pos++; 152 154 if (pos < linelen && line[pos] == ',') … … 154 156 } 155 157 } 156 else if (is alpha(*p)) /* 'i'/'up' or unknown "fact" (property) */158 else if (isASCIIAlpha(*p)) /* 'i'/'up' or unknown "fact" (property) */ 157 159 { 158 160 while (pos < linelen && *++p != ',') … … 232 234 } 233 235 else if (p[pos] != '.' && p[pos] != '~' && 234 !is digit(p[pos]) && !isalpha(p[pos]))236 !isASCIIDigit(p[pos]) && !isASCIIAlpha(p[pos])) 235 237 break; 236 else if (is alpha(p[pos]) && p[pos] != toupper(p[pos]))238 else if (isASCIIAlpha(p[pos]) && p[pos] != toASCIIUpper(p[pos])) 237 239 break; 238 240 } … … 250 252 pos--; 251 253 if (p[pos] != '$' && p[pos] != '_' && p[pos] != '-' && 252 p[pos] != '~' && !is digit(p[pos]) && !isalpha(p[pos]))254 p[pos] != '~' && !isASCIIDigit(p[pos]) && !isASCIIAlpha(p[pos])) 253 255 break; 254 else if (is alpha(p[pos]) && p[pos] != toupper(p[pos]))256 else if (isASCIIAlpha(p[pos]) && p[pos] != toASCIIUpper(p[pos])) 255 257 break; 256 258 } … … 288 290 (tokens[3][toklen[3]-3]) == '.' ) 289 291 ) && /* time in [H]H:MM[:SS[.CC]] format */ 290 is digit(*tokens[1]) && /* size */291 is digit(*tokens[2]) && /* date */292 is digit(*tokens[3]) /* time */292 isASCIIDigit(*tokens[1]) && /* size */ 293 isASCIIDigit(*tokens[2]) && /* date */ 294 isASCIIDigit(*tokens[3]) /* time */ 293 295 ) 294 296 { … … 327 329 { 328 330 if (*p != '$' && *p != '.' && *p != '_' && *p != '-' && 329 *p != '~' && !is digit(*p) && !isalpha(*p))331 *p != '~' && !isASCIIDigit(*p) && !isASCIIAlpha(*p)) 330 332 lstyle = 0; 331 333 pos++; … … 342 344 { 343 345 if (*p != '$' && *p != '.' && *p != '_' && *p != '-' && 344 *p != '~' && !is digit(*p) && !isalpha(*p))346 *p != '~' && !isASCIIDigit(*p) && !isASCIIAlpha(*p)) 345 347 lstyle = 0; 346 else if (is alpha(*p) && *p != toupper(*p))348 else if (isASCIIAlpha(*p) && *p != toASCIIUpper(*p)) 347 349 lstyle = 0; 348 350 p++; … … 355 357 for (pos++;lstyle && pos < toklen[0];pos++) 356 358 { 357 if (!is digit(tokens[0][pos]))359 if (!isASCIIDigit(tokens[0][pos])) 358 360 lstyle = 0; 359 361 } … … 378 380 return FTPJunkEntry; /* tell caller to treat as junk */ 379 381 } 380 else if (is digit(*tokens[1])) /* not no-privs message */382 else if (isASCIIDigit(*tokens[1])) /* not no-privs message */ 381 383 { 382 384 for (pos = 0; lstyle && pos < (toklen[1]); pos++) 383 385 { 384 if (!is digit((tokens[1][pos])) && (tokens[1][pos]) != '/')386 if (!isASCIIDigit((tokens[1][pos])) && (tokens[1][pos]) != '/') 385 387 lstyle = 0; 386 388 } … … 403 405 state.listStyle = lstyle; 404 406 405 if (is digit(*tokens[1])) /* not permission denied etc */407 if (isASCIIDigit(*tokens[1])) /* not permission denied etc */ 406 408 { 407 409 /* strip leading directory name */ … … 494 496 p++; 495 497 tbuf[0] = p[0]; 496 tbuf[1] = to lower(p[1]);497 tbuf[2] = to lower(p[2]);498 tbuf[1] = toASCIILower(p[1]); 499 tbuf[2] = toASCIILower(p[2]); 498 500 month_num = 0; 499 501 for (pos = 0; pos < (12*3); pos+=3) … … 521 523 return result.type; 522 524 523 } /* if (is digit(*tokens[1])) */525 } /* if (isASCIIDigit(*tokens[1])) */ 524 526 525 527 return FTPJunkEntry; /* junk */ … … 578 580 *tokens[pos+2] == '-' && 579 581 *tokens[pos+3] == '-') || 580 (is digit(*tokens[pos+1]) &&581 is digit(*tokens[pos+2]) &&582 is digit(*tokens[pos+3])) )582 (isASCIIDigit(*tokens[pos+1]) && 583 isASCIIDigit(*tokens[pos+2]) && 584 isASCIIDigit(*tokens[pos+3])) ) 583 585 { 584 586 lstyle = 'C'; … … 596 598 for (pos = 0, p = tokens[0]; lstyle && pos < toklen[0]; pos++, p++) 597 599 { 598 if (is alpha(*p) && toupper(*p) != *p)600 if (isASCIIAlpha(*p) && toASCIIUpper(*p) != *p) 599 601 lstyle = 0; 600 602 } … … 605 607 for (p = tokens[pos]; lstyle && p<(tokens[pos]+toklen[pos]); p++) 606 608 { 607 if (!is digit(*p))609 if (!isASCIIDigit(*p)) 608 610 lstyle = 0; 609 611 } … … 626 628 lstyle = 0; 627 629 } 628 else if (*p != '-' && !is digit(*p))630 else if (*p != '-' && !isASCIIDigit(*p)) 629 631 lstyle = 0; 630 632 else if (*p == '-' && pos != 4 && pos != 7) … … 634 636 lstyle && pos < toklen[tokmarker+5]; pos++, p++) 635 637 { 636 if (*p != ':' && !is digit(*p))638 if (*p != ':' && !isASCIIDigit(*p)) 637 639 lstyle = 0; 638 640 else if (*p == ':' && pos != (toklen[tokmarker+5]-3) … … 721 723 */ 722 724 if ((numtoks >= 4) && toklen[0] == 8 && toklen[1] == 7 && 723 (*tokens[2] == '<' || is digit(*tokens[2])) )725 (*tokens[2] == '<' || isASCIIDigit(*tokens[2])) ) 724 726 { 725 727 p = tokens[0]; 726 if ( is digit(p[0]) && isdigit(p[1]) && p[2]=='-' &&727 is digit(p[3]) && isdigit(p[4]) && p[5]=='-' &&728 is digit(p[6]) && isdigit(p[7]) )728 if ( isASCIIDigit(p[0]) && isASCIIDigit(p[1]) && p[2]=='-' && 729 isASCIIDigit(p[3]) && isASCIIDigit(p[4]) && p[5]=='-' && 730 isASCIIDigit(p[6]) && isASCIIDigit(p[7]) ) 729 731 { 730 732 p = tokens[1]; 731 if ( is digit(p[0]) && isdigit(p[1]) && p[2]==':' &&732 is digit(p[3]) && isdigit(p[4]) &&733 if ( isASCIIDigit(p[0]) && isASCIIDigit(p[1]) && p[2]==':' && 734 isASCIIDigit(p[3]) && isASCIIDigit(p[4]) && 733 735 (p[5]=='A' || p[5]=='P') && p[6]=='M') 734 736 { … … 742 744 for (pos = 1; (lstyle && pos < toklen[2]); pos++) 743 745 { 744 if (!is digit(*++p))746 if (!isASCIIDigit(*++p)) 745 747 lstyle = 0; 746 748 } … … 846 848 p = &(line[toklen[0]]); 847 849 /* \s(\d\d-\d\d-\d\d)\s+(\d\d:\d\d)\s */ 848 if (numtoks >= 4 && toklen[0] <= 18 && is digit(*tokens[0]) &&850 if (numtoks >= 4 && toklen[0] <= 18 && isASCIIDigit(*tokens[0]) && 849 851 (linelen - toklen[0]) >= (53-18) && 850 852 p[18-18] == ' ' && p[34-18] == ' ' && 851 853 p[37-18] == '-' && p[40-18] == '-' && p[43-18] == ' ' && 852 854 p[45-18] == ' ' && p[48-18] == ':' && p[51-18] == ' ' && 853 is digit(p[35-18]) && isdigit(p[36-18])&&854 is digit(p[38-18]) && isdigit(p[39-18])&&855 is digit(p[41-18]) && isdigit(p[42-18])&&856 is digit(p[46-18]) && isdigit(p[47-18])&&857 is digit(p[49-18]) && isdigit(p[50-18])855 isASCIIDigit(p[35-18]) && isASCIIDigit(p[36-18]) && 856 isASCIIDigit(p[38-18]) && isASCIIDigit(p[39-18]) && 857 isASCIIDigit(p[41-18]) && isASCIIDigit(p[42-18]) && 858 isASCIIDigit(p[46-18]) && isASCIIDigit(p[47-18]) && 859 isASCIIDigit(p[49-18]) && isASCIIDigit(p[50-18]) 858 860 ) 859 861 { … … 863 865 for (pos = 1; lstyle && pos < toklen[0]; pos++) 864 866 { 865 if (!is digit(tokens[0][pos]))867 if (!isASCIIDigit(tokens[0][pos])) 866 868 lstyle = 0; 867 869 } … … 1003 1005 * \s+(.+)$ 1004 1006 */ 1005 if (is digit(*tokens[pos]) /* size */1007 if (isASCIIDigit(*tokens[pos]) /* size */ 1006 1008 /* (\w\w\w) */ 1007 && toklen[pos+1] == 3 && is alpha(*tokens[pos+1]) &&1008 is alpha(tokens[pos+1][1]) && isalpha(tokens[pos+1][2])1009 && toklen[pos+1] == 3 && isASCIIAlpha(*tokens[pos+1]) && 1010 isASCIIAlpha(tokens[pos+1][1]) && isASCIIAlpha(tokens[pos+1][2]) 1009 1011 /* (\d|\d\d) */ 1010 && is digit(*tokens[pos+2]) &&1012 && isASCIIDigit(*tokens[pos+2]) && 1011 1013 (toklen[pos+2] == 1 || 1012 (toklen[pos+2] == 2 && is digit(tokens[pos+2][1])))1013 && toklen[pos+3] >= 4 && is digit(*tokens[pos+3])1014 (toklen[pos+2] == 2 && isASCIIDigit(tokens[pos+2][1]))) 1015 && toklen[pos+3] >= 4 && isASCIIDigit(*tokens[pos+3]) 1014 1016 /* (\d\:\d\d\:\d\d|\d\d\:\d\d\:\d\d) */ 1015 1017 && (toklen[pos+3] <= 5 || ( 1016 1018 (toklen[pos+3] == 7 || toklen[pos+3] == 8) && 1017 1019 (tokens[pos+3][toklen[pos+3]-3]) == ':')) 1018 && is digit(tokens[pos+3][toklen[pos+3]-2])1019 && is digit(tokens[pos+3][toklen[pos+3]-1])1020 && isASCIIDigit(tokens[pos+3][toklen[pos+3]-2]) 1021 && isASCIIDigit(tokens[pos+3][toklen[pos+3]-1]) 1020 1022 && ( 1021 1023 /* (\d\d\d\d) */ 1022 1024 ((toklen[pos+3] == 4 || toklen[pos+3] == 5) && 1023 is digit(tokens[pos+3][1]) &&1024 is digit(tokens[pos+3][2]) )1025 isASCIIDigit(tokens[pos+3][1]) && 1026 isASCIIDigit(tokens[pos+3][2]) ) 1025 1027 /* (\d\:\d\d|\d\:\d\d\:\d\d) */ 1026 1028 || ((toklen[pos+3] == 4 || toklen[pos+3] == 7) && 1027 1029 (tokens[pos+3][1]) == ':' && 1028 is digit(tokens[pos+3][2]) && isdigit(tokens[pos+3][3]))1030 isASCIIDigit(tokens[pos+3][2]) && isASCIIDigit(tokens[pos+3][3])) 1029 1031 /* (\d\d\:\d\d|\d\d\:\d\d\:\d\d) */ 1030 1032 || ((toklen[pos+3] == 5 || toklen[pos+3] == 8) && 1031 is digit(tokens[pos+3][1]) && (tokens[pos+3][2]) == ':' &&1032 is digit(tokens[pos+3][3]) && isdigit(tokens[pos+3][4]))1033 isASCIIDigit(tokens[pos+3][1]) && (tokens[pos+3][2]) == ':' && 1034 isASCIIDigit(tokens[pos+3][3]) && isASCIIDigit(tokens[pos+3][4])) 1033 1035 ) 1034 1036 ) … … 1041 1043 for (pos = 0; lstyle && pos < toklen[tokmarker]; pos++) 1042 1044 { 1043 if (!is digit(*p++))1045 if (!isASCIIDigit(*p++)) 1044 1046 lstyle = 0; 1045 1047 } … … 1201 1203 */ 1202 1204 if (numtoks >= 4 && toklen[0] < 13 && 1203 ((toklen[1] == 5 && *tokens[1] == '<') || is digit(*tokens[1])) )1205 ((toklen[1] == 5 && *tokens[1] == '<') || isASCIIDigit(*tokens[1])) ) 1204 1206 { 1205 1207 if (numtoks == 4 … … 1209 1211 && (toklen[3] == 4 || toklen[3] == 5) 1210 1212 && (tokens[3][toklen[3]-3]) == ':' 1211 && is digit(tokens[2][0]) && isdigit(tokens[2][1])1212 && is digit(tokens[2][3]) && isdigit(tokens[2][4])1213 && is digit(tokens[2][6]) && isdigit(tokens[2][7])1214 && (toklen[2] < 9 || is digit(tokens[2][8]))1215 && is digit(tokens[3][toklen[3]-1]) && isdigit(tokens[3][toklen[3]-2])1216 && is digit(tokens[3][toklen[3]-4]) && isdigit(*tokens[3])1213 && isASCIIDigit(tokens[2][0]) && isASCIIDigit(tokens[2][1]) 1214 && isASCIIDigit(tokens[2][3]) && isASCIIDigit(tokens[2][4]) 1215 && isASCIIDigit(tokens[2][6]) && isASCIIDigit(tokens[2][7]) 1216 && (toklen[2] < 9 || isASCIIDigit(tokens[2][8])) 1217 && isASCIIDigit(tokens[3][toklen[3]-1]) && isASCIIDigit(tokens[3][toklen[3]-2]) 1218 && isASCIIDigit(tokens[3][toklen[3]-4]) && isASCIIDigit(*tokens[3]) 1217 1219 ) 1218 1220 { … … 1223 1225 && toklen[4] == 4 && toklen[5] == 5 1224 1226 && (tokens[5][2]) == ':' 1225 && is alpha(tokens[2][0]) && isalpha(tokens[2][1])1226 && is alpha(tokens[2][2])1227 && is digit(tokens[3][0]) && isdigit(tokens[3][1])1228 && is digit(tokens[4][0]) && isdigit(tokens[4][1])1229 && is digit(tokens[4][2]) && isdigit(tokens[4][3])1230 && is digit(tokens[5][0]) && isdigit(tokens[5][1])1231 && is digit(tokens[5][3]) && isdigit(tokens[5][4])1227 && isASCIIAlpha(tokens[2][0]) && isASCIIAlpha(tokens[2][1]) 1228 && isASCIIAlpha(tokens[2][2]) 1229 && isASCIIDigit(tokens[3][0]) && isASCIIDigit(tokens[3][1]) 1230 && isASCIIDigit(tokens[4][0]) && isASCIIDigit(tokens[4][1]) 1231 && isASCIIDigit(tokens[4][2]) && isASCIIDigit(tokens[4][3]) 1232 && isASCIIDigit(tokens[5][0]) && isASCIIDigit(tokens[5][1]) 1233 && isASCIIDigit(tokens[5][3]) && isASCIIDigit(tokens[5][4]) 1232 1234 /* could also check that (&(tokens[5][5]) - tokens[2]) == 17 */ 1233 1235 ) … … 1243 1245 for (pos = 0; lstyle && pos < toklen[1]; pos++) 1244 1246 { 1245 if (!is digit(*p++))1247 if (!isASCIIDigit(*p++)) 1246 1248 lstyle = 0; 1247 1249 } … … 1261 1263 1262 1264 p = tokens[1]; 1263 if (is digit(*p))1265 if (isASCIIDigit(*p)) 1264 1266 { 1265 1267 result.type = FTPFileEntry; … … 1271 1273 if (toklen[2] == 3) /* Chameleon */ 1272 1274 { 1273 tbuf[0] = to upper(p[0]);1274 tbuf[1] = to lower(p[1]);1275 tbuf[2] = to lower(p[2]);1275 tbuf[0] = toASCIIUpper(p[0]); 1276 tbuf[1] = toASCIILower(p[1]); 1277 tbuf[2] = toASCIILower(p[2]); 1276 1278 for (pos = 0; pos < (12*3); pos+=3) 1277 1279 { … … 1392 1394 { 1393 1395 p = &line[pos]; 1394 if ((*p == '-' || *p == '=' || is digit(*p)) &&1396 if ((*p == '-' || *p == '=' || isASCIIDigit(*p)) && 1395 1397 ((linelen == (pos+1)) || 1396 1398 (linelen >= (pos+3) && p[1] == ' ' && p[2] == ' ')) ) … … 1419 1421 for (pos = 0; lstyle && pos < toklen[tokmarker]; pos++) 1420 1422 { 1421 if (!is digit(tokens[tokmarker][pos]))1423 if (!isASCIIDigit(tokens[tokmarker][pos])) 1422 1424 lstyle = 0; 1423 1425 } … … 1476 1478 } 1477 1479 } 1478 else if (is digit(*tokens[tokmarker]))1480 else if (isASCIIDigit(*tokens[tokmarker])) 1479 1481 { 1480 1482 pos = toklen[tokmarker]; … … 1491 1493 1492 1494 if ((pos == 4 || pos == 5) 1493 && is digit(*p) && isdigit(p[pos-1]) && isdigit(p[pos-2])1495 && isASCIIDigit(*p) && isASCIIDigit(p[pos-1]) && isASCIIDigit(p[pos-2]) 1494 1496 && ((pos == 5 && p[2] == ':') || 1495 (pos == 4 && (is digit(p[1]) || p[1] == ':')))1497 (pos == 4 && (isASCIIDigit(p[1]) || p[1] == ':'))) 1496 1498 ) 1497 1499 { 1498 1500 month_num = tokmarker+1; /* assumed position of month field */ 1499 1501 pos = tokmarker+2; /* assumed position of mday field */ 1500 if (is digit(*tokens[month_num])) /* positions are reversed */1502 if (isASCIIDigit(*tokens[month_num])) /* positions are reversed */ 1501 1503 { 1502 1504 month_num++; … … 1504 1506 } 1505 1507 p = tokens[month_num]; 1506 if (is digit(*tokens[pos])1508 if (isASCIIDigit(*tokens[pos]) 1507 1509 && (toklen[pos] == 1 || 1508 (toklen[pos] == 2 && is digit(tokens[pos][1])))1510 (toklen[pos] == 2 && isASCIIDigit(tokens[pos][1]))) 1509 1511 && toklen[month_num] == 3 1510 && is alpha(*p) && isalpha(p[1]) && isalpha(p[2]) )1512 && isASCIIAlpha(*p) && isASCIIAlpha(p[1]) && isASCIIAlpha(p[2]) ) 1511 1513 { 1512 1514 pos = atoi(tokens[pos]); … … 1602 1604 1603 1605 #endif // ENABLE(FTPDIR) 1604 -
trunk/WebCore/loader/TextResourceDecoder.cpp
r25754 r26676 1 1 /* 2 This file is part of the KDE libraries3 4 2 Copyright (C) 1999 Lars Knoll ([email protected]) 5 Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.3 Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 6 4 Copyright (C) 2005, 2006, 2007 Alexey Proskuryakov ([email protected]) 7 5 … … 32 30 #include "HTMLNames.h" 33 31 #include "TextCodec.h" 32 #include <wtf/ASCIICType.h> 33 34 using namespace WTF; 34 35 35 36 namespace WebCore { … … 650 651 tag != titleTag && tag != baseTag && 651 652 (end || tag != htmlTag) && !enclosingTagName && 652 (tag != headTag) && is alpha(tagBuffer[0])) {653 (tag != headTag) && isASCIIAlpha(tagBuffer[0])) { 653 654 m_checkedForHeadCharset = true; 654 655 return true; -
trunk/WebCore/platform/DeprecatedCString.cpp
r15286 r26676 1 1 /* 2 * Copyright (C) 2003 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #include "DeprecatedCString.h" 28 28 29 #include <wtf/ASCIICType.h> 29 30 #include <wtf/Assertions.h> 30 #include <ctype.h> 31 32 using namespace WTF; 31 33 32 34 namespace WebCore { … … 112 114 while( *str != 0 ) 113 115 { 114 *str = to lower(*str);116 *str = toASCIILower(*str); 115 117 str++; 116 118 } … … 129 131 while( *str != 0 ) 130 132 { 131 *str = to upper(*str);133 *str = toASCIIUpper(*str); 132 134 str++; 133 135 } … … 185 187 pos++, index++; 186 188 else 187 while( (a=sub[pos]) && (b=str[index]) && to lower(a)==tolower(b) )189 while( (a=sub[pos]) && (b=str[index]) && toASCIILower(a)==toASCIILower(b) ) 188 190 pos++, index++; 189 191 … … 212 214 } 213 215 } else { 214 c = to lower(c);216 c = toASCIILower(c); 215 217 216 218 for (unsigned i = 0; i != len; ++i) { 217 219 char chr = str[i]; 218 chr = to lower(chr);220 chr = toASCIILower(chr); 219 221 found += chr == c; 220 222 } -
trunk/WebCore/platform/DeprecatedString.cpp
r25643 r26676 1 1 /* 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 50 50 using namespace std; 51 51 using namespace KJS; 52 using namespace WTF; 52 53 53 54 namespace WebCore { … … 136 137 } 137 138 138 139 139 static bool equal(const DeprecatedChar *a, const char *b, int l) 140 140 { … … 154 154 ASSERT(l >= 0); 155 155 while (l--) { 156 if (to lower(*a) != tolower(*b))156 if (toASCIILower(*a) != toASCIILower(*b)) 157 157 return false; 158 158 a++; b++; … … 165 165 ASSERT(l >= 0); 166 166 while (l--) { 167 if (to lower(a->unicode()) != tolower(*b))167 if (toASCIILower(a->unicode()) != static_cast<unsigned char>(toASCIILower(*b))) 168 168 return false; 169 169 a++; b++; … … 176 176 ASSERT(l >= 0); 177 177 while (l--) { 178 if (to lower(a->unicode()) != tolower(b->unicode()))178 if (toASCIILower(a->unicode()) != toASCIILower(b->unicode())) 179 179 return false; 180 180 a++; b++; … … 185 185 static inline bool equalCaseInsensitive(char c1, char c2) 186 186 { 187 return to lower(c1) == tolower(c2);187 return toASCIILower(c1) == toASCIILower(c2); 188 188 } 189 189 190 190 static inline bool equalCaseInsensitive(DeprecatedChar c1, char c2) 191 191 { 192 return to lower(c1.unicode()) == tolower(static_cast<unsigned char>(c2));192 return toASCIILower(c1.unicode()) == static_cast<unsigned char>(toASCIILower(c2)); 193 193 } 194 194 195 195 static bool isCharacterAllowedInBase(DeprecatedChar c, int base) 196 196 { 197 intuc = c.unicode();197 ::UChar uc = c.unicode(); 198 198 if (uc > 0x7F) 199 199 return false; 200 if (is digit(uc))200 if (isASCIIDigit(uc)) 201 201 return uc - '0' < base; 202 if (is alpha(uc)) {202 if (isASCIIAlpha(uc)) { 203 203 if (base > 36) 204 204 base = 36; … … 974 974 } else { 975 975 for ( i = 0; i < lstr; i++ ) { 976 hthis += to lower(uthis[i].unicode());977 hstr += to lower(ustr[i].unicode());976 hthis += toASCIILower(uthis[i].unicode()); 977 hstr += toASCIILower(ustr[i].unicode()); 978 978 } 979 979 i = 0; … … 983 983 if ( i == delta ) 984 984 return -1; 985 hthis += to lower(uthis[i + lstr].unicode());986 hthis -= to lower(uthis[i].unicode());985 hthis += toASCIILower(uthis[i + lstr].unicode()); 986 hthis -= toASCIILower(uthis[i].unicode()); 987 987 i++; 988 988 } … … 1022 1022 } while (--n); 1023 1023 } else { 1024 int lc = tolower(*chs);1024 unsigned char lc = toASCIILower(*chs); 1025 1025 do { 1026 if (to lower(*++ptr) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne)) {1026 if (toASCIILower(*++ptr) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne)) { 1027 1027 return data->_length - chsLength - n + 1; 1028 1028 } … … 1041 1041 } while (--n); 1042 1042 } else { 1043 int lc = tolower((unsigned char)*chs);1043 unsigned char lc = toASCIILower(*chs); 1044 1044 do { 1045 if (to lower((++ptr)->unicode()) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne)) {1045 if (toASCIILower((++ptr)->unicode()) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne)) { 1046 1046 return data->_length - chsLength - n + 1; 1047 1047 } … … 1163 1163 count += *cPtr++ == ac; 1164 1164 } else { // case insensitive 1165 int lc = tolower(ac);1165 unsigned char lc = toASCIILower(ac); 1166 1166 while (n--) { 1167 count += to lower(*cPtr++) == lc;1167 count += toASCIILower(*cPtr++) == lc; 1168 1168 } 1169 1169 } … … 1176 1176 count += *uc++ == c; 1177 1177 } else { // case insensitive 1178 int lc = tolower(c.unicode());1178 ::UChar lc = toASCIILower(c.unicode()); 1179 1179 while (n--) { 1180 count += to lower(uc->unicode()) == lc;1180 count += toASCIILower(uc->unicode()) == lc; 1181 1181 uc++; 1182 1182 } … … 1217 1217 } while (--n); 1218 1218 } else { 1219 int lc = tolower(c);1219 char lc = toASCIILower(c); 1220 1220 do { 1221 count += to lower(*p) == lc && equalCaseInsensitive(p + 1, str + 1, len - 1);1221 count += toASCIILower(*p) == lc && equalCaseInsensitive(p + 1, str + 1, len - 1); 1222 1222 p++; 1223 1223 } while (--n); … … 1232 1232 } while (--n); 1233 1233 } else { 1234 int lc = tolower(c);1234 unsigned char lc = toASCIILower(c); 1235 1235 do { 1236 count += to lower(p->unicode()) == lc && equalCaseInsensitive(p + 1, str + 1, len - 1);1236 count += toASCIILower(p->unicode()) == lc && equalCaseInsensitive(p + 1, str + 1, len - 1); 1237 1237 p++; 1238 1238 } while (--n); … … 1415 1415 length--; 1416 1416 IntegralType digitValue; 1417 intc = p->unicode();1418 if (is digit(c))1417 ::UChar c = p->unicode(); 1418 if (isASCIIDigit(c)) 1419 1419 digitValue = c - '0'; 1420 1420 else if (c >= 'a') -
trunk/WebCore/platform/DeprecatedString.h
r25321 r26676 1 1 /* 2 * Copyright (C) 2005, 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 29 29 #include "DeprecatedCString.h" 30 30 #include <wtf/ASCIICType.h> 31 31 #include <wtf/unicode/Unicode.h> 32 33 #include <ctype.h>34 32 35 33 /* On some ARM platforms GCC won't pack structures by default so sizeof(DeprecatedChar) … … 124 122 // Use isspace() for basic Latin-1. 125 123 // This will include newlines, which aren't included in unicode DirWS. 126 return c <= 0x7F ? isspace(c) : (u_charDirection(c) == U_WHITE_SPACE_NEUTRAL);124 return c <= 0x7F ? WTF::isASCIISpace(c) : (u_charDirection(c) == U_WHITE_SPACE_NEUTRAL); 127 125 #elif USE(QT4_UNICODE) 128 126 return QChar(c).isSpace(); … … 134 132 #if USE(ICU_UNICODE) 135 133 // FIXME: If fast enough, we should just call u_tolower directly. 136 return c <= 0x7F ? tolower(c) : u_tolower(c);134 return c <= 0x7F ? WTF::toASCIILower(c) : u_tolower(c); 137 135 #elif USE(QT4_UNICODE) 138 136 return QChar(c).toLower().unicode(); … … 144 142 #if USE(ICU_UNICODE) 145 143 // FIXME: If fast enough, we should just call u_toupper directly. 146 return c <= 0x7F ? toupper(c) : u_toupper(c);144 return c <= 0x7F ? WTF::toASCIIUpper(c) : u_toupper(c); 147 145 #elif USE(QT4_UNICODE) 148 146 return QChar(c).toUpper().unicode(); -
trunk/WebCore/platform/KURL.cpp
r25085 r26676 39 39 40 40 using namespace std; 41 using namespace WTF; 41 42 42 43 namespace WebCore { … … 1031 1032 // possible start of port 1032 1033 portEnd = portStart; 1033 while (is digit(url[portEnd])) {1034 while (isASCIIDigit(url[portEnd])) { 1034 1035 portEnd++; 1035 1036 } -
trunk/WebCore/platform/StringImpl.cpp
r25754 r26676 52 52 // Use isspace() for basic Latin-1. 53 53 // This will include newlines, which aren't included in unicode DirWS. 54 return c <= 0x7F ? is space(c) : direction(c) == WhiteSpaceNeutral;54 return c <= 0x7F ? isASCIISpace(c) : direction(c) == WhiteSpaceNeutral; 55 55 } 56 56 … … 258 258 // FIXME: No range checking here. 259 259 for (unsigned i = from; i < len; i++) 260 if (m_data[i] > 0x7F || !is space(m_data[i]))260 if (m_data[i] > 0x7F || !isASCIISpace(m_data[i])) 261 261 return false; 262 262 return true; … … 390 390 for (unsigned i = 0; i < m_length; i++) { 391 391 UChar c = m_data[i]; 392 // The islower function is only guaranteed to work correctly and 393 // in a locale-independent fashion for ASCII characters. We mask 394 // to guarantee we don't pass any non-ASCII values in. 395 allLower = allLower && islower(c & 0x7F); 392 allLower = allLower && isASCIILower(c); 396 393 ored |= c; 397 394 } … … 427 424 UChar c = m_data[i]; 428 425 ored |= c; 429 // The tolower function is only guaranteed to work correctly and 430 // in a locale-independent fashion for ASCII characters. We mask 431 // to guarantee we don't pass any non-ASCII values in. 432 data[i] = tolower(c & 0x7F); 426 data[i] = toASCIILower(c); 433 427 } 434 428 if (!(ored & ~0x7F)) … … 814 808 } else { 815 809 for (int i = 0; i < lstr; i++ ) { 816 hthis += to lower(uthis[i]);817 hstr += to lower(ustr[i]);810 hthis += toASCIILower(uthis[i]); 811 hstr += toASCIILower(ustr[i]); 818 812 } 819 813 int i = 0; … … 823 817 if (i == delta) 824 818 return -1; 825 hthis += to lower(uthis[i + lstr]);826 hthis -= to lower(uthis[i]);819 hthis += toASCIILower(uthis[i + lstr]); 820 hthis -= toASCIILower(uthis[i]); 827 821 i++; 828 822 } … … 886 880 } else { 887 881 for (i = 0; i < lstr; i++) { 888 hthis += to lower(uthis[index + i]);889 hstr += to lower(ustr[i]);882 hthis += toASCIILower(uthis[index + i]); 883 hstr += toASCIILower(ustr[i]); 890 884 } 891 885 i = index; … … 896 890 return -1; 897 891 i--; 898 hthis -= to lower(uthis[i + lstr]);899 hthis += to lower(uthis[i]);892 hthis -= toASCIILower(uthis[i + lstr]); 893 hthis += toASCIILower(uthis[i]); 900 894 } 901 895 } … … 1086 1080 bool equal = true; 1087 1081 for (unsigned i = 0; i != length; ++i) { 1088 unsignedchar bc = b[i];1082 char bc = b[i]; 1089 1083 if (!bc) 1090 1084 return false; 1091 1085 UChar ac = as[i]; 1092 1086 ored |= ac; 1093 // The tolower function is only guaranteed to work correctly and 1094 // in a locale-independent fashion for ASCII characters. We mask 1095 // to guarantee we don't pass any non-ASCII values in. 1096 ASSERT(!(bc & ~0x7F)); 1097 equal = equal && (tolower(ac & 0x7F) == tolower(bc)); 1087 equal = equal && (toASCIILower(ac) == toASCIILower(bc)); 1098 1088 } 1099 1089 -
trunk/WebCore/platform/TextEncodingRegistry.cpp
r24203 r26676 30 30 #include "TextCodecLatin1.h" 31 31 #include "TextCodecUTF16.h" 32 #include < ctype.h>32 #include <wtf/ASCIICType.h> 33 33 #include <wtf/Assertions.h> 34 34 #include <wtf/HashMap.h> … … 43 43 #include "qt/TextCodecQt.h" 44 44 #endif 45 46 using namespace WTF; 45 47 46 48 namespace WebCore { … … 65 67 do 66 68 c1 = *s1++; 67 while (c1 && !is alnum(c1));69 while (c1 && !isASCIIAlphanumeric(c1)); 68 70 do 69 71 c2 = *s2++; 70 while (c2 && !is alnum(c2));71 if (to lower(c1) != tolower(c2))72 while (c2 && !isASCIIAlphanumeric(c2)); 73 if (toASCIILower(c1) != toASCIILower(c2)) 72 74 return false; 73 75 } while (c1 && c2); … … 91 93 return h; 92 94 } 93 } while (!is alnum(c));94 h += to lower(c);95 } while (!isASCIIAlphanumeric(c)); 96 h += toASCIILower(c); 95 97 h += (h << 10); 96 98 h ^= (h >> 6); … … 219 221 for (size_t i = 0; i < length; ++i) { 220 222 UChar c = characters[i]; 221 if (is alnum(c)) {223 if (isASCIIAlphanumeric(c)) { 222 224 if (j == maxEncodingNameLength) 223 225 return 0; -
trunk/WebCore/platform/mac/KeyEventMac.mm
r21445 r26676 1 1 /* 2 * Copyright (C) 2004, 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 29 29 #import "Logging.h" 30 #import <wtf/ASCIICType.h> 31 32 using namespace WTF; 30 33 31 34 namespace WebCore { … … 323 326 // For now, just fall through to the default. 324 327 default: 325 return String::format("U+%04X", to upper(c));328 return String::format("U+%04X", toASCIIUpper(c)); 326 329 } 327 330 } -
trunk/WebCore/platform/win/KeyEventWin.cpp
r25520 r26676 1 1 /* 2 * Copyright (C) 2006, 2007 Apple Inc. 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #include "config.h" 27 27 #include "PlatformKeyboardEvent.h" 28 28 29 #include <windows.h> 30 #include <wtf/ASCIICType.h> 29 31 30 #define REPEAT_COUNT_MASK 0x0000FFFF 31 #define NEW_RELEASE_STATE_MASK 0x80000000 32 #define PREVIOUS_DOWN_STATE_MASK 0x40000000 33 34 #define HIGH_BIT_MASK_SHORT 0x8000 32 using namespace WTF; 35 33 36 34 namespace WebCore { 35 36 static const unsigned REPEAT_COUNT_MASK = 0x0000FFFF; 37 static const unsigned NEW_RELEASE_STATE_MASK = 0x80000000; 38 static const unsigned PREVIOUS_DOWN_STATE_MASK = 0x40000000; 39 40 static const unsigned short HIGH_BIT_MASK_SHORT = 0x8000; 37 41 38 42 // FIXME: This is incomplete. We could change this to mirror 39 43 // more like what Firefox does, and generate these switch statements 40 44 // at build time. 41 static String keyIdentifierForWindowsKeyCode( short keyCode)45 static String keyIdentifierForWindowsKeyCode(unsigned short keyCode) 42 46 { 43 47 switch (keyCode) { … … 130 134 return "U+007F"; 131 135 default: 132 return String::format("U+%04X", to upper(keyCode));136 return String::format("U+%04X", toASCIIUpper(keyCode)); 133 137 } 134 138 } -
trunk/WebCore/platform/win/PopupMenuWin.cpp
r26484 r26676 60 60 static LRESULT CALLBACK PopupWndProc(HWND, UINT, WPARAM, LPARAM); 61 61 62 // FIXME: Remove this as soon as practical. 63 static inline bool isASCIIPrintable(unsigned c) 64 { 65 return c >= 0x20 && c <= 0x7E; 66 } 67 62 68 PopupMenu::PopupMenu(PopupMenuClient* client) 63 69 : m_popupClient(client) … … 674 680 break; 675 681 default: 676 if (is print(::MapVirtualKey(LOWORD(wParam), 2)))682 if (isASCIIPrintable(::MapVirtualKey(LOWORD(wParam), 2))) 677 683 // Send the keydown to the WebView so it can be used for type-ahead find 678 684 ::SendMessage(popup->client()->clientDocument()->view()->containingWindow(), message, wParam, lParam); -
trunk/WebCore/plugins/win/PluginViewWin.cpp
r26632 r26676 1 1 /* 2 * Copyright (C) 2006, 2007 Apple Inc. 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 57 57 #include <kjs/JSLock.h> 58 58 #include <kjs/value.h> 59 #include <wtf/ASCIICType.h> 59 60 60 61 using KJS::ExecState; … … 67 68 68 69 using std::min; 70 71 using namespace WTF; 69 72 70 73 namespace WebCore { … … 943 946 944 947 if (capitalizeCharacter && name[i] >= 'a' && name[i] <= 'z') 945 c = to upper(name[i]);948 c = toASCIIUpper(name[i]); 946 949 else if (!capitalizeCharacter && name[i] >= 'A' && name[i] <= 'Z') 947 c = to lower(name[i]);950 c = toASCIILower(name[i]); 948 951 else 949 952 c = name[i]; -
trunk/WebCore/rendering/RenderText.cpp
r26384 r26676 405 405 else 406 406 w += monospaceCharacterWidth; 407 if (is space(c) && !isspace(previousChar))407 if (isASCIISpace(c) && !isASCIISpace(previousChar)) 408 408 w += f.wordSpacing(); 409 409 } -
trunk/WebKit/ChangeLog
r26661 r26676 1 2007-10-16 Darin Adler <[email protected]> 2 3 Reviewed by Maciej and Geoff (and looked over by Eric). 4 5 - http://bugs.webkit.org/show_bug.cgi?id=15519 6 eliminate use of <ctype.h> for processing ASCII 7 8 * ForwardingHeaders/wtf/ASCIICType.h: Added. 9 * ForwardingHeaders/wtf/DisallowCType.h: Added. 10 11 * WebKitPrefix.h: Include DisallowCType.h. 12 13 * Misc/WebNSURLExtras.mm: (-[NSURL _web_URLWithLowercasedScheme]): Use toASCIILower. 14 * WebView/WebHTMLView.mm: 15 (-[WebHTMLView callWebCoreCommand:]): Use toASCIIUpper. 16 (-[WebTextCompleteController filterKeyDown:]): Add a list of specific character codes, 17 instead of using ispunct. 18 1 19 2007-10-16 John Sullivan <[email protected]> 2 20 -
trunk/WebKit/Misc/WebNSURLExtras.mm
r24818 r26676 1 1 /* 2 * Copyright (C) 2005 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2005, 2007 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2006 Alexey Proskuryakov ([email protected]) 4 4 * … … 28 28 */ 29 29 30 #import <WebKit/WebNSURLExtras.h> 31 30 #import "WebNSURLExtras.h" 31 32 #import "WebKitNSStringExtras.h" 33 #import "WebLocalizableStrings.h" 34 #import "WebNSDataExtras.h" 35 #import "WebNSObjectExtras.h" 36 #import "WebSystemInterface.h" 37 #import <Foundation/NSURLRequest.h> 32 38 #import <JavaScriptCore/Assertions.h> 33 #import <WebKit/WebKitNSStringExtras.h>34 #import <WebKit/WebNSDataExtras.h>35 #import <WebKit/WebNSObjectExtras.h>36 #import <WebKit/WebLocalizableStrings.h>37 39 #import <WebCore/KURL.h> 38 40 #import <WebCore/LoaderNSURLExtras.h> 39 40 41 #import <WebKitSystemInterface.h> 41 #import "WebSystemInterface.h"42 43 #import <Foundation/NSURLRequest.h>44 45 42 #import <unicode/uchar.h> 46 43 #import <unicode/uidna.h> … … 48 45 49 46 using namespace WebCore; 47 using namespace WTF; 50 48 51 49 typedef void (* StringRangeApplierFunction)(NSString *string, NSRange range, void *context); … … 605 603 BOOL changed = NO; 606 604 for (i = 0; i < range.length; ++i) { 607 UInt8c = buffer[range.location + i];608 UInt8 lower = tolower(c);605 char c = buffer[range.location + i]; 606 char lower = toASCIILower(c); 609 607 if (c != lower) { 610 608 buffer[range.location + i] = lower; -
trunk/WebKit/WebKitPrefix.h
r25000 r26676 77 77 #endif 78 78 79 #include <wtf/DisallowCType.h> 80 79 81 /* Work around bug with C++ library that screws up Objective-C++ when exception support is disabled. */ 80 82 #undef try -
trunk/WebKit/WebView/WebHTMLView.mm
r26629 r26676 113 113 using namespace WebCore; 114 114 using namespace HTMLNames; 115 using namespace WTF; 115 116 116 117 @interface NSWindow (BorderViewAccess) … … 2071 2072 ASSERT(selectorName[selectorNameLength - 1] == ':'); 2072 2073 Vector<char, 256> commandName(selectorNameLength - 1 + 1); 2073 commandName[0] = to upper(selectorName[0]);2074 commandName[0] = toASCIIUpper(selectorName[0]); 2074 2075 memcpy(&commandName[1], &selectorName[1], selectorNameLength - 2); 2075 2076 commandName[selectorNameLength - 1] = 0; … … 5916 5917 } 5917 5918 5918 // WebHTMLView gives us a crack at key events it sees. 5919 // WebHTMLView gives us a crack at key events it sees. Return whether we consumed the event. 5919 5920 // The features for the various keys mimic NSTextView. 5920 5921 - (BOOL)filterKeyDown:(NSEvent *)event 5921 5922 { 5922 if (_popupWindow) { 5923 NSString *string = [event charactersIgnoringModifiers]; 5924 unichar c = [string characterAtIndex:0]; 5925 if (c == NSUpArrowFunctionKey) { 5926 int selectedRow = [_tableView selectedRow]; 5927 if (0 < selectedRow) { 5928 [_tableView selectRow:selectedRow-1 byExtendingSelection:NO]; 5929 [_tableView scrollRowToVisible:selectedRow-1]; 5930 } 5931 return YES; 5932 } else if (c == NSDownArrowFunctionKey) { 5933 int selectedRow = [_tableView selectedRow]; 5934 if (selectedRow < (int)[_completions count]-1) { 5935 [_tableView selectRow:selectedRow+1 byExtendingSelection:NO]; 5936 [_tableView scrollRowToVisible:selectedRow+1]; 5937 } 5938 return YES; 5939 } else if (c == NSRightArrowFunctionKey || c == '\n' || c == '\r' || c == '\t') { 5940 [self endRevertingChange:NO moveLeft:NO]; 5941 return YES; 5942 } else if (c == NSLeftArrowFunctionKey) { 5943 [self endRevertingChange:NO moveLeft:YES]; 5944 return YES; 5945 } else if (c == 0x1b || c == NSF5FunctionKey) { 5946 [self endRevertingChange:YES moveLeft:NO]; 5947 return YES; 5948 } else if (c == ' ' || ispunct(c)) { 5949 [self endRevertingChange:NO moveLeft:NO]; 5950 return NO; // let the char get inserted 5923 if (!_popupWindow) 5924 return NO; 5925 NSString *string = [event charactersIgnoringModifiers]; 5926 if (![string length]) 5927 return NO; 5928 unichar c = [string characterAtIndex:0]; 5929 if (c == NSUpArrowFunctionKey) { 5930 int selectedRow = [_tableView selectedRow]; 5931 if (0 < selectedRow) { 5932 [_tableView selectRow:selectedRow - 1 byExtendingSelection:NO]; 5933 [_tableView scrollRowToVisible:selectedRow - 1]; 5951 5934 } 5935 return YES; 5936 } 5937 if (c == NSDownArrowFunctionKey) { 5938 int selectedRow = [_tableView selectedRow]; 5939 if (selectedRow < (int)[_completions count] - 1) { 5940 [_tableView selectRow:selectedRow + 1 byExtendingSelection:NO]; 5941 [_tableView scrollRowToVisible:selectedRow + 1]; 5942 } 5943 return YES; 5944 } 5945 if (c == NSRightArrowFunctionKey || c == '\n' || c == '\r' || c == '\t') { 5946 // FIXME: What about backtab? 5947 [self endRevertingChange:NO moveLeft:NO]; 5948 return YES; 5949 } 5950 if (c == NSLeftArrowFunctionKey) { 5951 [self endRevertingChange:NO moveLeft:YES]; 5952 return YES; 5953 } 5954 if (c == 0x1B || c == NSF5FunctionKey) { 5955 // FIXME: F5? 5956 [self endRevertingChange:YES moveLeft:NO]; 5957 return YES; 5958 } 5959 if (c == ' ' || c >= 0x21 && c <= 0x2F || c >= 0x3A && c <= 0x40 || c >= 0x5B && c <= 0x60 || c >= 0x7B && c <= 0x7D) { 5960 // FIXME: Is the above list of keys really definitive? 5961 // Originally this code called ispunct; aren't there other punctuation keys on international keyboards? 5962 [self endRevertingChange:NO moveLeft:NO]; 5963 return NO; // let the char get inserted 5952 5964 } 5953 5965 return NO;
Note:
See TracChangeset
for help on using the changeset viewer.