+2007-10-16 Darin Adler <darin@apple.com>
+
+ Reviewed by Maciej and Geoff (and looked over by Eric).
+
+ - http://bugs.webkit.org/show_bug.cgi?id=15519
+ eliminate use of <ctype.h> for processing ASCII
+
+ * wtf/ASCIICType.h: Added.
+ * wtf/DisallowCType.h: Added.
+
+ * kjs/config.h: Include DisallowCType.h.
+
+ * kjs/date_object.cpp:
+ (KJS::skipSpacesAndComments):
+ (KJS::findMonth):
+ (KJS::parseDate):
+ * kjs/function.cpp:
+ (KJS::decode):
+ * kjs/ustring.cpp:
+ (KJS::UString::toDouble):
+ Use ASCIICType.h functions instead of ctype.h ones.
+
2007-10-14 Maciej Stachowiak <mjs@apple.com>
Reviewed by Darin.
935AF46C09E9D9DB00ACD1D8 /* Forward.h in Headers */ = {isa = PBXBuildFile; fileRef = 935AF46909E9D9DB00ACD1D8 /* Forward.h */; settings = {ATTRIBUTES = (Private, ); }; };
935AF46E09E9D9DB00ACD1D8 /* UnusedParam.h in Headers */ = {isa = PBXBuildFile; fileRef = 935AF46B09E9D9DB00ACD1D8 /* UnusedParam.h */; };
935F69FE08245057003D1A45 /* dftables.c in Sources */ = {isa = PBXBuildFile; fileRef = 6541720E039E08B90058BFEB /* dftables.c */; };
+ 938C4F6A0CA06BC700D9310A /* ASCIICType.h in Headers */ = {isa = PBXBuildFile; fileRef = 938C4F690CA06BC700D9310A /* ASCIICType.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 938C4F6C0CA06BCE00D9310A /* DisallowCType.h in Headers */ = {isa = PBXBuildFile; fileRef = 938C4F6B0CA06BCE00D9310A /* DisallowCType.h */; settings = {ATTRIBUTES = (Private, ); }; };
93AA4F780957251F0084B3A7 /* AlwaysInline.h in Headers */ = {isa = PBXBuildFile; fileRef = 93AA4F770957251F0084B3A7 /* AlwaysInline.h */; settings = {ATTRIBUTES = (Private, ); }; };
93B6A0DF0AA64DA40076DE27 /* GetPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B6A0DE0AA64DA40076DE27 /* GetPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
93E26BCA08B1511900F85226 /* pcre_ord2utf8.c in Sources */ = {isa = PBXBuildFile; fileRef = 93E26BC908B1511900F85226 /* pcre_ord2utf8.c */; };
9374D3A8038D9D74008635CE /* scope_chain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = scope_chain.cpp; sourceTree = "<group>"; tabWidth = 8; };
937B63CC09E766D200A671DD /* DerivedSources.make */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = DerivedSources.make; sourceTree = "<group>"; usesTabs = 1; };
938772E5038BFE19008635CE /* array_instance.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = array_instance.h; sourceTree = "<group>"; tabWidth = 8; };
+ 938C4F690CA06BC700D9310A /* ASCIICType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASCIICType.h; sourceTree = "<group>"; };
+ 938C4F6B0CA06BCE00D9310A /* DisallowCType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisallowCType.h; sourceTree = "<group>"; };
93AA4F770957251F0084B3A7 /* AlwaysInline.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = AlwaysInline.h; sourceTree = "<group>"; tabWidth = 8; };
93B6A0DE0AA64DA40076DE27 /* GetPtr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GetPtr.h; sourceTree = "<group>"; };
93E26BC908B1511900F85226 /* pcre_ord2utf8.c */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.c; name = pcre_ord2utf8.c; path = pcre/pcre_ord2utf8.c; sourceTree = "<group>"; tabWidth = 8; };
65162EF108E6A21C007556CD /* wtf */ = {
isa = PBXGroup;
children = (
- 652246A40C8D7A0E007BDAF7 /* HashIterators.h */,
E195678D09E7CF1200B89D13 /* unicode */,
93AA4F770957251F0084B3A7 /* AlwaysInline.h */,
+ 938C4F690CA06BC700D9310A /* ASCIICType.h */,
65E217B808E7EECC0023E5F6 /* Assertions.cpp */,
65E217B708E7EECC0023E5F6 /* Assertions.h */,
+ 938C4F6B0CA06BCE00D9310A /* DisallowCType.h */,
65E217B908E7EECC0023E5F6 /* FastMalloc.cpp */,
65E217BA08E7EECC0023E5F6 /* FastMalloc.h */,
9302043A0B790750000C6115 /* FastMallocPCRE.cpp */,
93B6A0DE0AA64DA40076DE27 /* GetPtr.h */,
657EEBBF094E445E008C9C7B /* HashCountedSet.h */,
65DFC92A08EA173A00F7300B /* HashFunctions.h */,
+ 652246A40C8D7A0E007BDAF7 /* HashIterators.h */,
65DFC92B08EA173A00F7300B /* HashMap.h */,
65DFC92C08EA173A00F7300B /* HashSet.h */,
65DFC92D08EA173A00F7300B /* HashTable.cpp */,
5DBD18B00C5401A700C15EAE /* MallocZoneSupport.h in Headers */,
652246A50C8D7A0E007BDAF7 /* HashIterators.h in Headers */,
95C18D490C90E82600E72F73 /* JSRetainPtr.h in Headers */,
+ 938C4F6A0CA06BC700D9310A /* ASCIICType.h in Headers */,
+ 938C4F6C0CA06BCE00D9310A /* DisallowCType.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/*
- * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
*
* This library is free software; you can redistribute it and/or
#undef delete
#include <wtf/FastMalloc.h>
#endif
+
+#include <wtf/DisallowCType.h>
/*
- * This file is part of the KDE libraries
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2004 Apple Computer, Inc.
+ * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include <sys/timeb.h>
#endif
-#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <locale.h>
#include "operations.h"
#include "DateMath.h"
+#include <wtf/ASCIICType.h>
#include <wtf/MathExtras.h>
#include <wtf/StringExtras.h>
#include <CoreFoundation/CoreFoundation.h>
#endif
+using namespace WTF;
+
namespace KJS {
static double parseDate(const UString&);
{ "PDT", -420 }
};
-inline static void skipSpacesAndComments(const char *&s)
+inline static void skipSpacesAndComments(const char*& s)
{
int nesting = 0;
char ch;
while ((ch = *s)) {
- if (!isspace(ch)) {
+ if (!isASCIISpace(ch)) {
if (ch == '(')
nesting++;
else if (ch == ')' && nesting > 0)
}
// returns 0-11 (Jan-Dec); -1 on failure
-static int findMonth(const char *monthStr)
+static int findMonth(const char* monthStr)
{
assert(monthStr);
char needle[4];
for (int i = 0; i < 3; ++i) {
if (!*monthStr)
return -1;
- needle[i] = static_cast<char>(tolower(*monthStr++));
+ needle[i] = static_cast<char>(toASCIILower(*monthStr++));
}
needle[3] = '\0';
const char *haystack = "janfebmaraprmayjunjulaugsepoctnovdec";
long month = -1;
const char *wordStart = dateString;
// Check contents of first words if not number
- while (*dateString && !isdigit(*dateString)) {
- if (isspace(*dateString) || *dateString == '(') {
+ while (*dateString && !isASCIIDigit(*dateString)) {
+ if (isASCIISpace(*dateString) || *dateString == '(') {
if (dateString - wordStart >= 3)
month = findMonth(wordStart);
skipSpacesAndComments(dateString);
return NaN;
// ':40 GMT'
- if (*dateString && *dateString != ':' && !isspace(*dateString))
+ if (*dateString && *dateString != ':' && !isASCIISpace(*dateString))
return NaN;
// seconds are optional in rfc822 + rfc2822
// -*- c-basic-offset: 2 -*-
/*
- * This file is part of the KDE libraries
* Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)
*
* This library is free software; you can redistribute it and/or
#include <stdlib.h>
#include <assert.h>
#include <string.h>
-#include <ctype.h>
+#include <wtf/ASCIICType.h>
#include <wtf/unicode/Unicode.h>
using namespace WTF;
UChar c = *p;
if (c == '%') {
int charLen = 0;
- if (k <= len - 3 && isxdigit(p[1].uc) && isxdigit(p[2].uc)) {
+ if (k <= len - 3 && isASCIIHexDigit(p[1].uc) && isASCIIHexDigit(p[2].uc)) {
const char b0 = Lexer::convertHex(p[1].uc, p[2].uc);
const int sequenceLen = UTF8SequenceLength(b0);
if (sequenceLen != 0 && k <= len - sequenceLen * 3) {
sequence[0] = b0;
for (int i = 1; i < sequenceLen; ++i) {
const UChar* q = p + i * 3;
- if (q[0] == '%' && isxdigit(q[1].uc) && isxdigit(q[2].uc))
+ if (q[0] == '%' && isASCIIHexDigit(q[1].uc) && isASCIIHexDigit(q[2].uc))
sequence[i] = Lexer::convertHex(q[1].uc, q[2].uc);
else {
charLen = 0;
// The only case where we don't use "strict" mode is the "unescape" function.
// For that, it's good to support the wonky "%u" syntax for compatibility with WinIE.
if (k <= len - 6 && p[1] == 'u'
- && isxdigit(p[2].uc) && isxdigit(p[3].uc)
- && isxdigit(p[4].uc) && isxdigit(p[5].uc)) {
+ && isASCIIHexDigit(p[2].uc) && isASCIIHexDigit(p[3].uc)
+ && isASCIIHexDigit(p[4].uc) && isASCIIHexDigit(p[5].uc)) {
charLen = 6;
u = Lexer::convertUnicode(p[2].uc, p[3].uc, p[4].uc, p[5].uc);
}
// -*- c-basic-offset: 2 -*-
/*
- * This file is part of the KDE libraries
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)
#include <strings.h>
#endif
-using std::max;
-using std::min;
+using namespace WTF;
+using namespace std;
namespace KJS {
const char *c = ascii();
// skip leading white space
- while (isspace(*c))
+ while (isASCIISpace(*c))
c++;
// empty string ?
}
// allow trailing white space
- while (isspace(*c))
+ while (isASCIISpace(*c))
c++;
// don't allow anything after - unless tolerant=true
if (!tolerateTrailingJunk && *c != '\0')
--- /dev/null
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS 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 APPLE 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.
+ */
+
+#ifndef WTF_ASCIICType_h
+#define WTF_ASCIICType_h
+
+// The behavior of many of the functions in the <ctype.h> header is dependent
+// on the current locale. But in the WebKit project, all uses of those functions
+// are in code processing something that's not locale-specific. These equivalents
+// for some of the <ctype.h> functions are named more explicitly, not dependent
+// on the C library locale, and we should also optimize them as needed.
+
+// All functions return false or leave the character unchanged if passed a character
+// that is outside the range 0-7F. So they can be used on Unicode strings or
+// characters if the intent is to do processing only if the character is ASCII.
+
+namespace WTF {
+
+ inline bool isASCIIAlpha(char c) { return (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; }
+ inline bool isASCIIAlpha(unsigned short c) { return (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; }
+ inline bool isASCIIAlpha(wchar_t c) { return (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; }
+
+ inline bool isASCIIAlphanumeric(char c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; }
+ inline bool isASCIIAlphanumeric(unsigned short c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; }
+ inline bool isASCIIAlphanumeric(wchar_t c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; }
+
+ inline bool isASCIIDigit(char c) { return c >= '0' && c <= '9'; }
+ inline bool isASCIIDigit(unsigned short c) { return c >= '0' && c <= '9'; }
+ inline bool isASCIIDigit(wchar_t c) { return c >= '0' && c <= '9'; }
+
+ inline bool isASCIIHexDigit(char c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'f'; }
+ inline bool isASCIIHexDigit(unsigned short c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'f'; }
+ inline bool isASCIIHexDigit(wchar_t c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'f'; }
+
+ inline bool isASCIILower(char c) { return c >= 'a' && c <= 'z'; }
+ inline bool isASCIILower(unsigned short c) { return c >= 'a' && c <= 'z'; }
+ inline bool isASCIILower(wchar_t c) { return c >= 'a' && c <= 'z'; }
+
+ inline bool isASCIISpace(char c) { return c == '\t' || c == '\n' || c == '\v' || c =='\f' || c == '\r' || c == ' '; }
+ inline bool isASCIISpace(unsigned short c) { return c == '\t' || c == '\n' || c == '\v' || c =='\f' || c == '\r' || c == ' '; }
+ inline bool isASCIISpace(wchar_t c) { return c == '\t' || c == '\n' || c == '\v' || c =='\f' || c == '\r' || c == ' '; }
+
+ inline char toASCIILower(char c) { return c | ((c >= 'A' && c <= 'Z') << 5); }
+ inline unsigned short toASCIILower(unsigned short c) { return c | ((c >= 'A' && c <= 'Z') << 5); }
+ inline wchar_t toASCIILower(wchar_t c) { return c | ((c >= 'A' && c <= 'Z') << 5); }
+
+ inline char toASCIIUpper(char c) { return static_cast<char>(c & ~((c >= 'a' && c <= 'z') << 5)); }
+ inline unsigned short toASCIIUpper(unsigned short c) { return static_cast<unsigned short>(c & ~((c >= 'a' && c <= 'z') << 5)); }
+ inline wchar_t toASCIIUpper(wchar_t c) { return static_cast<wchar_t>(c & ~((c >= 'a' && c <= 'z') << 5)); }
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS 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 APPLE 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.
+ */
+
+#ifndef WTF_DisallowCType_h
+#define WTF_DisallowCType_h
+
+// The behavior of many of the functions in the <ctype.h> header is dependent
+// on the current locale. But almost all uses of these functions are for
+// locale-independent, ASCII-specific purposes. In WebKit code we use our own
+// ASCII-specific functions instead. This header makes sure we get a compile-time
+// error if we use one of the <ctype.h> functions by accident.
+
+#include <ctype.h>
+
+#undef isalnum
+#undef isalpha
+#undef isascii
+#undef isblank
+#undef iscntrl
+#undef isdigit
+#undef isgraph
+#undef islower
+#undef isprint
+#undef ispunct
+#undef isspace
+#undef isupper
+#undef isxdigit
+#undef toascii
+#undef tolower
+#undef toupper
+
+#define isalnum WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define isalpha WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define isascii WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define isblank WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define iscntrl WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define isdigit WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define isgraph WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define islower WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define isprint WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define ispunct WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define isspace WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define isupper WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define isxdigit WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define toascii WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define tolower WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+#define toupper WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h
+
+#endif
+2007-10-16 Darin Adler <darin@apple.com>
+
+ Reviewed by Maciej and Geoff (and looked over by Eric).
+
+ - http://bugs.webkit.org/show_bug.cgi?id=15519
+ eliminate use of <ctype.h> for processing ASCII
+
+ * ForwardingHeaders/wtf/ASCIICType.h: Added.
+ * ForwardingHeaders/wtf/DisallowCType.h: Added.
+
+ * WebCorePrefix.h: Get rid of inclusion of <ctype.h>.
+ * config.h: Include DisallowCType.h.
+
+ * css/CSSParser.cpp:
+ (WebCore::ParseString::lower):
+ * css/CSSPrimitiveValue.cpp:
+ (WebCore::isCSSTokenizerIdentifier):
+ * css/CSSStyleDeclaration.cpp:
+ (WebCore::propertyID):
+ * html/HTMLSelectElement.cpp:
+ (WebCore::stripLeadingWhiteSpace):
+ * html/HTMLTokenizer.cpp:
+ (WebCore::tagMatch):
+ * loader/FTPDirectoryParser.cpp:
+ (WebCore::parseOneFTPLine):
+ * loader/TextResourceDecoder.cpp:
+ (WebCore::TextResourceDecoder::checkForHeadCharset):
+ * platform/DeprecatedCString.cpp:
+ (WebCore::DeprecatedCString::lower):
+ (WebCore::DeprecatedCString::upper):
+ (WebCore::DeprecatedCString::find):
+ (WebCore::DeprecatedCString::contains):
+ * platform/DeprecatedString.cpp:
+ (WebCore::equalCaseInsensitive):
+ (WebCore::isCharacterAllowedInBase):
+ (WebCore::DeprecatedString::find):
+ (WebCore::DeprecatedString::contains):
+ (WebCore::toIntegralType):
+ * platform/DeprecatedString.h:
+ (WebCore::DeprecatedChar::isSpace):
+ (WebCore::DeprecatedChar::lower):
+ (WebCore::DeprecatedChar::upper):
+ * platform/KURL.cpp:
+ (WebCore::KURL::parse):
+ * platform/StringImpl.cpp:
+ (WebCore::isSpace):
+ (WebCore::StringImpl::containsOnlyWhitespace):
+ (WebCore::StringImpl::isLower):
+ (WebCore::StringImpl::lower):
+ (WebCore::StringImpl::find):
+ (WebCore::StringImpl::reverseFind):
+ (WebCore::equalIgnoringCase):
+ * platform/TextEncodingRegistry.cpp:
+ (WebCore::TextEncodingNameHash::equal):
+ (WebCore::TextEncodingNameHash::hash):
+ (WebCore::atomicCanonicalTextEncodingName):
+ * platform/mac/KeyEventMac.mm:
+ (WebCore::keyIdentifierForKeyEvent):
+ * platform/win/KeyEventWin.cpp:
+ (WebCore::keyIdentifierForWindowsKeyCode):
+ * platform/win/PopupMenuWin.cpp:
+ (WebCore::isASCIIPrintable):
+ (WebCore::PopupWndProc):
+ * plugins/win/PluginViewWin.cpp:
+ (WebCore::capitalizeRFC822HeaderFieldName):
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::widthFromCache):
+ Use ASCIICType.h functions instead of ctype.h ones.
+
2007-10-16 Mitz Pettel <mitz@webkit.org>
Reviewed by Dave Hyatt.
--- /dev/null
+#include <JavaScriptCore/ASCIICType.h>
--- /dev/null
+#include <JavaScriptCore/DisallowCType.h>
#endif // defined(WIN32) || defined(_WIN32)
-#include <ctype.h>
#include <sys/types.h>
#include <fcntl.h>
#include <pthread.h>
#include <cstddef>
#include <new>
-/* Work around bug 3553309 by re-including <ctype.h>. */
-#include <cctype>
-#if defined(__APPLE__)
-#define isalnum(c) __istype((c), (_CTYPE_A|_CTYPE_D))
-#define isalpha(c) __istype((c), _CTYPE_A)
-#define iscntrl(c) __istype((c), _CTYPE_C)
-#define isdigit(c) __isctype((c), _CTYPE_D) /* ANSI -- locale independent */
-#define isgraph(c) __istype((c), _CTYPE_G)
-#define islower(c) __istype((c), _CTYPE_L)
-#define isprint(c) __istype((c), _CTYPE_R)
-#define ispunct(c) __istype((c), _CTYPE_P)
-#define isspace(c) __istype((c), _CTYPE_S)
-#define isupper(c) __istype((c), _CTYPE_U)
-#define isxdigit(c) __isctype((c), _CTYPE_X) /* ANSI -- locale independent */
-#define tolower(c) __tolower(c)
-#define toupper(c) __toupper(c)
-#endif
-
#endif
#include <sys/types.h>
#define HAVE_FUNC_USLEEP 1
#endif /* __APPLE__ */
-
#if PLATFORM(WIN_OS)
#ifndef _WIN32_WINNT
#endif
+#include <wtf/DisallowCType.h>
+
#if !COMPILER(MSVC) // can't get this to compile on Visual C++ yet
#define AVOID_STATIC_CONSTRUCTORS 1
#endif
characters[i] = Unicode::toLower(characters[i]);
else
for (int i = 0; i < length; i++)
- characters[i] = tolower(characters[i]);
+ characters[i] = toASCIILower(characters[i]);
}
void CSSParser::setupParser(const char* prefix, const String& string, const char* suffix)
-/**
- * This file is part of the DOM implementation for KDE.
- *
+/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#include "ExceptionCode.h"
#include "Pair.h"
#include "RenderStyle.h"
-#include <ctype.h>
+#include <wtf/ASCIICType.h>
+
+using namespace WTF;
namespace WebCore {
++p;
// {nmstart}
- if (p == end || !(p[0] == '_' || p[0] >= 128 || isalpha(p[0])))
+ if (p == end || !(p[0] == '_' || p[0] >= 128 || isASCIIAlpha(p[0])))
return false;
++p;
// {nmchar}*
for (; p != end; ++p) {
- if (!(p[0] == '_' || p[0] == '-' || p[0] >= 128 || isalnum(p[0])))
+ if (!(p[0] == '_' || p[0] == '-' || p[0] >= 128 || isASCIIAlphanumeric(p[0])))
return false;
}
/**
- * This file is part of the DOM implementation for KDE.
- *
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#include "CSSPropertyNames.h"
#include "CSSRule.h"
#include "DeprecatedValueList.h"
-#include <ctype.h>
+#include <wtf/ASCIICType.h>
+
+using namespace WTF;
namespace WebCore {
UChar c = s[i];
if (c == 0 || c >= 0x7F)
return 0; // illegal character
- buffer[i] = tolower(c);
+ buffer[i] = toASCIILower(c);
}
return getPropertyID(buffer, len);
int i;
for (i = 0; i < length; ++i)
if (string[i] != noBreakSpace &&
- (string[i] <= 0x7F ? !isspace(string[i]) : (direction(string[i]) != WhiteSpaceNeutral)))
+ (string[i] <= 0x7F ? !isASCIISpace(string[i]) : (direction(string[i]) != WhiteSpaceNeutral)))
break;
return string.substring(i, length - i);
/*
- This file is part of the KDE libraries
-
Copyright (C) 1997 Martin Jones (mjones@kde.org)
(C) 1997 Torben Weis (weis@kde.org)
(C) 1998 Waldo Bastian (bastian@kde.org)
(C) 1999 Lars Knoll (knoll@kde.org)
(C) 1999 Antti Koivisto (koivisto@kde.org)
(C) 2001 Dirk Mueller (mueller@kde.org)
- Copyright (C) 2004, 2005, 2006, 2007 Apple Inc.
+ Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
Copyright (C) 2005, 2006 Alexey Proskuryakov (ap@nypop.com)
This library is free software; you can redistribute it and/or
#include "Settings.h"
#include "SystemTime.h"
#include "kjs_proxy.h"
+#include <wtf/ASCIICType.h>
#include "HTMLEntityNames.c"
#endif
using namespace std;
+using namespace WTF;
namespace WebCore {
{
for (unsigned i = 0; i != length; ++i) {
unsigned char c1 = s1[i];
- unsigned char uc1 = toupper(c1);
+ unsigned char uc1 = toASCIIUpper(static_cast<char>(c1));
UChar c2 = s2[i];
if (c1 != c2 && uc1 != c2)
return false;
#if ENABLE(FTPDIR)
#include "FTPDirectoryParser.h"
-#include "DeprecatedString.h"
+#include <wtf/ASCIICType.h>
+
+using namespace WTF;
namespace WebCore {
result.type = FTPFileEntry; /* its a file */
else if (*p == 'm')
{
- if (isdigit(line[pos]))
+ if (isASCIIDigit(line[pos]))
{
- while (pos < linelen && isdigit(line[pos]))
+ while (pos < linelen && isASCIIDigit(line[pos]))
pos++;
if (pos < linelen && line[pos] == ',')
{
}
else if (*p == 's')
{
- if (isdigit(line[pos]))
+ if (isASCIIDigit(line[pos]))
{
- while (pos < linelen && isdigit(line[pos]))
+ while (pos < linelen && isASCIIDigit(line[pos]))
pos++;
if (pos < linelen && line[pos] == ',')
result.fileSize = String(p + 1, &line[pos] - p + 1);
}
}
- else if (isalpha(*p)) /* 'i'/'up' or unknown "fact" (property) */
+ else if (isASCIIAlpha(*p)) /* 'i'/'up' or unknown "fact" (property) */
{
while (pos < linelen && *++p != ',')
pos++;
break;
}
else if (p[pos] != '.' && p[pos] != '~' &&
- !isdigit(p[pos]) && !isalpha(p[pos]))
+ !isASCIIDigit(p[pos]) && !isASCIIAlpha(p[pos]))
break;
- else if (isalpha(p[pos]) && p[pos] != toupper(p[pos]))
+ else if (isASCIIAlpha(p[pos]) && p[pos] != toASCIIUpper(p[pos]))
break;
}
if (pos > 0)
{
pos--;
if (p[pos] != '$' && p[pos] != '_' && p[pos] != '-' &&
- p[pos] != '~' && !isdigit(p[pos]) && !isalpha(p[pos]))
+ p[pos] != '~' && !isASCIIDigit(p[pos]) && !isASCIIAlpha(p[pos]))
break;
- else if (isalpha(p[pos]) && p[pos] != toupper(p[pos]))
+ else if (isASCIIAlpha(p[pos]) && p[pos] != toASCIIUpper(p[pos]))
break;
}
if (pos == 0)
((toklen[3]==10 || toklen[3]==11 ) &&
(tokens[3][toklen[3]-3]) == '.' )
) && /* time in [H]H:MM[:SS[.CC]] format */
- isdigit(*tokens[1]) && /* size */
- isdigit(*tokens[2]) && /* date */
- isdigit(*tokens[3]) /* time */
+ isASCIIDigit(*tokens[1]) && /* size */
+ isASCIIDigit(*tokens[2]) && /* date */
+ isASCIIDigit(*tokens[3]) /* time */
)
{
lstyle = 'V';
while (lstyle && pos < toklen[0] && *p != ']')
{
if (*p != '$' && *p != '.' && *p != '_' && *p != '-' &&
- *p != '~' && !isdigit(*p) && !isalpha(*p))
+ *p != '~' && !isASCIIDigit(*p) && !isASCIIAlpha(*p))
lstyle = 0;
pos++;
p++;
while (lstyle && pos < toklen[0] && *p != ';')
{
if (*p != '$' && *p != '.' && *p != '_' && *p != '-' &&
- *p != '~' && !isdigit(*p) && !isalpha(*p))
+ *p != '~' && !isASCIIDigit(*p) && !isASCIIAlpha(*p))
lstyle = 0;
- else if (isalpha(*p) && *p != toupper(*p))
+ else if (isASCIIAlpha(*p) && *p != toASCIIUpper(*p))
lstyle = 0;
p++;
pos++;
lstyle = 0;
for (pos++;lstyle && pos < toklen[0];pos++)
{
- if (!isdigit(tokens[0][pos]))
+ if (!isASCIIDigit(tokens[0][pos]))
lstyle = 0;
}
}
state.carryBufferLength = pos;
return FTPJunkEntry; /* tell caller to treat as junk */
}
- else if (isdigit(*tokens[1])) /* not no-privs message */
+ else if (isASCIIDigit(*tokens[1])) /* not no-privs message */
{
for (pos = 0; lstyle && pos < (toklen[1]); pos++)
{
- if (!isdigit((tokens[1][pos])) && (tokens[1][pos]) != '/')
+ if (!isASCIIDigit((tokens[1][pos])) && (tokens[1][pos]) != '/')
lstyle = 0;
}
if (lstyle && numtoks > 4) /* Multinet or UCX but not CMU */
state.parsedOne = true;
state.listStyle = lstyle;
- if (isdigit(*tokens[1])) /* not permission denied etc */
+ if (isASCIIDigit(*tokens[1])) /* not permission denied etc */
{
/* strip leading directory name */
if (*tokens[0] == '[') /* CMU server */
if (*p == '-')
p++;
tbuf[0] = p[0];
- tbuf[1] = tolower(p[1]);
- tbuf[2] = tolower(p[2]);
+ tbuf[1] = toASCIILower(p[1]);
+ tbuf[2] = toASCIILower(p[2]);
month_num = 0;
for (pos = 0; pos < (12*3); pos+=3)
{
return result.type;
- } /* if (isdigit(*tokens[1])) */
+ } /* if (isASCIIDigit(*tokens[1])) */
return FTPJunkEntry; /* junk */
if ( (*tokens[pos+1] == '-' &&
*tokens[pos+2] == '-' &&
*tokens[pos+3] == '-') ||
- (isdigit(*tokens[pos+1]) &&
- isdigit(*tokens[pos+2]) &&
- isdigit(*tokens[pos+3])) )
+ (isASCIIDigit(*tokens[pos+1]) &&
+ isASCIIDigit(*tokens[pos+2]) &&
+ isASCIIDigit(*tokens[pos+3])) )
{
lstyle = 'C';
tokmarker = pos;
{
for (pos = 0, p = tokens[0]; lstyle && pos < toklen[0]; pos++, p++)
{
- if (isalpha(*p) && toupper(*p) != *p)
+ if (isASCIIAlpha(*p) && toASCIIUpper(*p) != *p)
lstyle = 0;
}
for (pos = tokmarker+1; pos <= tokmarker+3; pos++)
{
for (p = tokens[pos]; lstyle && p<(tokens[pos]+toklen[pos]); p++)
{
- if (!isdigit(*p))
+ if (!isASCIIDigit(*p))
lstyle = 0;
}
}
else if (pos != 2 && pos != 5)
lstyle = 0;
}
- else if (*p != '-' && !isdigit(*p))
+ else if (*p != '-' && !isASCIIDigit(*p))
lstyle = 0;
else if (*p == '-' && pos != 4 && pos != 7)
lstyle = 0;
for (pos = 0, p = tokens[tokmarker+5];
lstyle && pos < toklen[tokmarker+5]; pos++, p++)
{
- if (*p != ':' && !isdigit(*p))
+ if (*p != ':' && !isASCIIDigit(*p))
lstyle = 0;
else if (*p == ':' && pos != (toklen[tokmarker+5]-3)
&& pos != (toklen[tokmarker+5]-6))
* "07-14-00 01:38PM 2250540 Valentineoffprank-HiRes.jpg"
*/
if ((numtoks >= 4) && toklen[0] == 8 && toklen[1] == 7 &&
- (*tokens[2] == '<' || isdigit(*tokens[2])) )
+ (*tokens[2] == '<' || isASCIIDigit(*tokens[2])) )
{
p = tokens[0];
- if ( isdigit(p[0]) && isdigit(p[1]) && p[2]=='-' &&
- isdigit(p[3]) && isdigit(p[4]) && p[5]=='-' &&
- isdigit(p[6]) && isdigit(p[7]) )
+ if ( isASCIIDigit(p[0]) && isASCIIDigit(p[1]) && p[2]=='-' &&
+ isASCIIDigit(p[3]) && isASCIIDigit(p[4]) && p[5]=='-' &&
+ isASCIIDigit(p[6]) && isASCIIDigit(p[7]) )
{
p = tokens[1];
- if ( isdigit(p[0]) && isdigit(p[1]) && p[2]==':' &&
- isdigit(p[3]) && isdigit(p[4]) &&
+ if ( isASCIIDigit(p[0]) && isASCIIDigit(p[1]) && p[2]==':' &&
+ isASCIIDigit(p[3]) && isASCIIDigit(p[4]) &&
(p[5]=='A' || p[5]=='P') && p[6]=='M')
{
lstyle = 'W';
{
for (pos = 1; (lstyle && pos < toklen[2]); pos++)
{
- if (!isdigit(*++p))
+ if (!isASCIIDigit(*++p))
lstyle = 0;
}
}
*/
p = &(line[toklen[0]]);
/* \s(\d\d-\d\d-\d\d)\s+(\d\d:\d\d)\s */
- if (numtoks >= 4 && toklen[0] <= 18 && isdigit(*tokens[0]) &&
+ if (numtoks >= 4 && toklen[0] <= 18 && isASCIIDigit(*tokens[0]) &&
(linelen - toklen[0]) >= (53-18) &&
p[18-18] == ' ' && p[34-18] == ' ' &&
p[37-18] == '-' && p[40-18] == '-' && p[43-18] == ' ' &&
p[45-18] == ' ' && p[48-18] == ':' && p[51-18] == ' ' &&
- isdigit(p[35-18]) && isdigit(p[36-18]) &&
- isdigit(p[38-18]) && isdigit(p[39-18]) &&
- isdigit(p[41-18]) && isdigit(p[42-18]) &&
- isdigit(p[46-18]) && isdigit(p[47-18]) &&
- isdigit(p[49-18]) && isdigit(p[50-18])
+ isASCIIDigit(p[35-18]) && isASCIIDigit(p[36-18]) &&
+ isASCIIDigit(p[38-18]) && isASCIIDigit(p[39-18]) &&
+ isASCIIDigit(p[41-18]) && isASCIIDigit(p[42-18]) &&
+ isASCIIDigit(p[46-18]) && isASCIIDigit(p[47-18]) &&
+ isASCIIDigit(p[49-18]) && isASCIIDigit(p[50-18])
)
{
lstyle = 'O'; /* OS/2 */
{
for (pos = 1; lstyle && pos < toklen[0]; pos++)
{
- if (!isdigit(tokens[0][pos]))
+ if (!isASCIIDigit(tokens[0][pos]))
lstyle = 0;
}
}
* (\d\d\d\d|\d\:\d\d|\d\d\:\d\d|\d\:\d\d\:\d\d|\d\d\:\d\d\:\d\d)
* \s+(.+)$
*/
- if (isdigit(*tokens[pos]) /* size */
+ if (isASCIIDigit(*tokens[pos]) /* size */
/* (\w\w\w) */
- && toklen[pos+1] == 3 && isalpha(*tokens[pos+1]) &&
- isalpha(tokens[pos+1][1]) && isalpha(tokens[pos+1][2])
+ && toklen[pos+1] == 3 && isASCIIAlpha(*tokens[pos+1]) &&
+ isASCIIAlpha(tokens[pos+1][1]) && isASCIIAlpha(tokens[pos+1][2])
/* (\d|\d\d) */
- && isdigit(*tokens[pos+2]) &&
+ && isASCIIDigit(*tokens[pos+2]) &&
(toklen[pos+2] == 1 ||
- (toklen[pos+2] == 2 && isdigit(tokens[pos+2][1])))
- && toklen[pos+3] >= 4 && isdigit(*tokens[pos+3])
+ (toklen[pos+2] == 2 && isASCIIDigit(tokens[pos+2][1])))
+ && toklen[pos+3] >= 4 && isASCIIDigit(*tokens[pos+3])
/* (\d\:\d\d\:\d\d|\d\d\:\d\d\:\d\d) */
&& (toklen[pos+3] <= 5 || (
(toklen[pos+3] == 7 || toklen[pos+3] == 8) &&
(tokens[pos+3][toklen[pos+3]-3]) == ':'))
- && isdigit(tokens[pos+3][toklen[pos+3]-2])
- && isdigit(tokens[pos+3][toklen[pos+3]-1])
+ && isASCIIDigit(tokens[pos+3][toklen[pos+3]-2])
+ && isASCIIDigit(tokens[pos+3][toklen[pos+3]-1])
&& (
/* (\d\d\d\d) */
((toklen[pos+3] == 4 || toklen[pos+3] == 5) &&
- isdigit(tokens[pos+3][1]) &&
- isdigit(tokens[pos+3][2]) )
+ isASCIIDigit(tokens[pos+3][1]) &&
+ isASCIIDigit(tokens[pos+3][2]) )
/* (\d\:\d\d|\d\:\d\d\:\d\d) */
|| ((toklen[pos+3] == 4 || toklen[pos+3] == 7) &&
(tokens[pos+3][1]) == ':' &&
- isdigit(tokens[pos+3][2]) && isdigit(tokens[pos+3][3]))
+ isASCIIDigit(tokens[pos+3][2]) && isASCIIDigit(tokens[pos+3][3]))
/* (\d\d\:\d\d|\d\d\:\d\d\:\d\d) */
|| ((toklen[pos+3] == 5 || toklen[pos+3] == 8) &&
- isdigit(tokens[pos+3][1]) && (tokens[pos+3][2]) == ':' &&
- isdigit(tokens[pos+3][3]) && isdigit(tokens[pos+3][4]))
+ isASCIIDigit(tokens[pos+3][1]) && (tokens[pos+3][2]) == ':' &&
+ isASCIIDigit(tokens[pos+3][3]) && isASCIIDigit(tokens[pos+3][4]))
)
)
{
p = tokens[tokmarker];
for (pos = 0; lstyle && pos < toklen[tokmarker]; pos++)
{
- if (!isdigit(*p++))
+ if (!isASCIIDigit(*p++))
lstyle = 0;
}
if (lstyle)
* CMT.CSV 0 Jul 06 1995 14:56 RHA
*/
if (numtoks >= 4 && toklen[0] < 13 &&
- ((toklen[1] == 5 && *tokens[1] == '<') || isdigit(*tokens[1])) )
+ ((toklen[1] == 5 && *tokens[1] == '<') || isASCIIDigit(*tokens[1])) )
{
if (numtoks == 4
&& (toklen[2] == 8 || toklen[2] == 9)
((tokens[2][2]) == '-' && (tokens[2][5]) == '-'))
&& (toklen[3] == 4 || toklen[3] == 5)
&& (tokens[3][toklen[3]-3]) == ':'
- && isdigit(tokens[2][0]) && isdigit(tokens[2][1])
- && isdigit(tokens[2][3]) && isdigit(tokens[2][4])
- && isdigit(tokens[2][6]) && isdigit(tokens[2][7])
- && (toklen[2] < 9 || isdigit(tokens[2][8]))
- && isdigit(tokens[3][toklen[3]-1]) && isdigit(tokens[3][toklen[3]-2])
- && isdigit(tokens[3][toklen[3]-4]) && isdigit(*tokens[3])
+ && isASCIIDigit(tokens[2][0]) && isASCIIDigit(tokens[2][1])
+ && isASCIIDigit(tokens[2][3]) && isASCIIDigit(tokens[2][4])
+ && isASCIIDigit(tokens[2][6]) && isASCIIDigit(tokens[2][7])
+ && (toklen[2] < 9 || isASCIIDigit(tokens[2][8]))
+ && isASCIIDigit(tokens[3][toklen[3]-1]) && isASCIIDigit(tokens[3][toklen[3]-2])
+ && isASCIIDigit(tokens[3][toklen[3]-4]) && isASCIIDigit(*tokens[3])
)
{
lstyle = 'w';
&& toklen[2] == 3 && toklen[3] == 2
&& toklen[4] == 4 && toklen[5] == 5
&& (tokens[5][2]) == ':'
- && isalpha(tokens[2][0]) && isalpha(tokens[2][1])
- && isalpha(tokens[2][2])
- && isdigit(tokens[3][0]) && isdigit(tokens[3][1])
- && isdigit(tokens[4][0]) && isdigit(tokens[4][1])
- && isdigit(tokens[4][2]) && isdigit(tokens[4][3])
- && isdigit(tokens[5][0]) && isdigit(tokens[5][1])
- && isdigit(tokens[5][3]) && isdigit(tokens[5][4])
+ && isASCIIAlpha(tokens[2][0]) && isASCIIAlpha(tokens[2][1])
+ && isASCIIAlpha(tokens[2][2])
+ && isASCIIDigit(tokens[3][0]) && isASCIIDigit(tokens[3][1])
+ && isASCIIDigit(tokens[4][0]) && isASCIIDigit(tokens[4][1])
+ && isASCIIDigit(tokens[4][2]) && isASCIIDigit(tokens[4][3])
+ && isASCIIDigit(tokens[5][0]) && isASCIIDigit(tokens[5][1])
+ && isASCIIDigit(tokens[5][3]) && isASCIIDigit(tokens[5][4])
/* could also check that (&(tokens[5][5]) - tokens[2]) == 17 */
)
{
{
for (pos = 0; lstyle && pos < toklen[1]; pos++)
{
- if (!isdigit(*p++))
+ if (!isASCIIDigit(*p++))
lstyle = 0;
}
} /* not <DIR> */
result.type = FTPDirectoryEntry;
p = tokens[1];
- if (isdigit(*p))
+ if (isASCIIDigit(*p))
{
result.type = FTPFileEntry;
pos = toklen[1];
p = tokens[2];
if (toklen[2] == 3) /* Chameleon */
{
- tbuf[0] = toupper(p[0]);
- tbuf[1] = tolower(p[1]);
- tbuf[2] = tolower(p[2]);
+ tbuf[0] = toASCIIUpper(p[0]);
+ tbuf[1] = toASCIILower(p[1]);
+ tbuf[2] = toASCIILower(p[2]);
for (pos = 0; pos < (12*3); pos+=3)
{
if (tbuf[0] == month_names[pos+0] &&
if (linelen > pos)
{
p = &line[pos];
- if ((*p == '-' || *p == '=' || isdigit(*p)) &&
+ if ((*p == '-' || *p == '=' || isASCIIDigit(*p)) &&
((linelen == (pos+1)) ||
(linelen >= (pos+3) && p[1] == ' ' && p[2] == ' ')) )
{
{
for (pos = 0; lstyle && pos < toklen[tokmarker]; pos++)
{
- if (!isdigit(tokens[tokmarker][pos]))
+ if (!isASCIIDigit(tokens[tokmarker][pos]))
lstyle = 0;
}
}
result.type = FTPDirectoryEntry;
}
}
- else if (isdigit(*tokens[tokmarker]))
+ else if (isASCIIDigit(*tokens[tokmarker]))
{
pos = toklen[tokmarker];
result.fileSize = String(tokens[tokmarker], pos);
pos = toklen[pos];
if ((pos == 4 || pos == 5)
- && isdigit(*p) && isdigit(p[pos-1]) && isdigit(p[pos-2])
+ && isASCIIDigit(*p) && isASCIIDigit(p[pos-1]) && isASCIIDigit(p[pos-2])
&& ((pos == 5 && p[2] == ':') ||
- (pos == 4 && (isdigit(p[1]) || p[1] == ':')))
+ (pos == 4 && (isASCIIDigit(p[1]) || p[1] == ':')))
)
{
month_num = tokmarker+1; /* assumed position of month field */
pos = tokmarker+2; /* assumed position of mday field */
- if (isdigit(*tokens[month_num])) /* positions are reversed */
+ if (isASCIIDigit(*tokens[month_num])) /* positions are reversed */
{
month_num++;
pos--;
}
p = tokens[month_num];
- if (isdigit(*tokens[pos])
+ if (isASCIIDigit(*tokens[pos])
&& (toklen[pos] == 1 ||
- (toklen[pos] == 2 && isdigit(tokens[pos][1])))
+ (toklen[pos] == 2 && isASCIIDigit(tokens[pos][1])))
&& toklen[month_num] == 3
- && isalpha(*p) && isalpha(p[1]) && isalpha(p[2]) )
+ && isASCIIAlpha(*p) && isASCIIAlpha(p[1]) && isASCIIAlpha(p[2]) )
{
pos = atoi(tokens[pos]);
if (pos > 0 && pos <= 31)
} // namespace WebCore
#endif // ENABLE(FTPDIR)
-
/*
- This file is part of the KDE libraries
-
Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de)
- Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
Copyright (C) 2005, 2006, 2007 Alexey Proskuryakov (ap@nypop.com)
This library is free software; you can redistribute it and/or
#include "DeprecatedString.h"
#include "HTMLNames.h"
#include "TextCodec.h"
+#include <wtf/ASCIICType.h>
+
+using namespace WTF;
namespace WebCore {
tag != linkTag && tag != metaTag && tag != objectTag &&
tag != titleTag && tag != baseTag &&
(end || tag != htmlTag) && !enclosingTagName &&
- (tag != headTag) && isalpha(tagBuffer[0])) {
+ (tag != headTag) && isASCIIAlpha(tagBuffer[0])) {
m_checkedForHeadCharset = true;
return true;
}
/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003, 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include "config.h"
#include "DeprecatedCString.h"
+#include <wtf/ASCIICType.h>
#include <wtf/Assertions.h>
-#include <ctype.h>
+
+using namespace WTF;
namespace WebCore {
{
while( *str != 0 )
{
- *str = tolower(*str);
+ *str = toASCIILower(*str);
str++;
}
}
{
while( *str != 0 )
{
- *str = toupper(*str);
+ *str = toASCIIUpper(*str);
str++;
}
}
while( (a=sub[pos]) && (b=str[index]) && a==b )
pos++, index++;
else
- while( (a=sub[pos]) && (b=str[index]) && tolower(a)==tolower(b) )
+ while( (a=sub[pos]) && (b=str[index]) && toASCIILower(a)==toASCIILower(b) )
pos++, index++;
// reached the end of our compare string without a mismatch?
found += str[i] == c;
}
} else {
- c = tolower(c);
+ c = toASCIILower(c);
for (unsigned i = 0; i != len; ++i) {
char chr = str[i];
- chr = tolower(chr);
+ chr = toASCIILower(chr);
found += chr == c;
}
}
/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
using namespace std;
using namespace KJS;
+using namespace WTF;
namespace WebCore {
return a->unicode() - b->unicode();
}
-
static bool equal(const DeprecatedChar *a, const char *b, int l)
{
ASSERT(l >= 0);
{
ASSERT(l >= 0);
while (l--) {
- if (tolower(*a) != tolower(*b))
+ if (toASCIILower(*a) != toASCIILower(*b))
return false;
a++; b++;
}
{
ASSERT(l >= 0);
while (l--) {
- if (tolower(a->unicode()) != tolower(*b))
+ if (toASCIILower(a->unicode()) != static_cast<unsigned char>(toASCIILower(*b)))
return false;
a++; b++;
}
{
ASSERT(l >= 0);
while (l--) {
- if (tolower(a->unicode()) != tolower(b->unicode()))
+ if (toASCIILower(a->unicode()) != toASCIILower(b->unicode()))
return false;
a++; b++;
}
static inline bool equalCaseInsensitive(char c1, char c2)
{
- return tolower(c1) == tolower(c2);
+ return toASCIILower(c1) == toASCIILower(c2);
}
static inline bool equalCaseInsensitive(DeprecatedChar c1, char c2)
{
- return tolower(c1.unicode()) == tolower(static_cast<unsigned char>(c2));
+ return toASCIILower(c1.unicode()) == static_cast<unsigned char>(toASCIILower(c2));
}
static bool isCharacterAllowedInBase(DeprecatedChar c, int base)
{
- int uc = c.unicode();
+ ::UChar uc = c.unicode();
if (uc > 0x7F)
return false;
- if (isdigit(uc))
+ if (isASCIIDigit(uc))
return uc - '0' < base;
- if (isalpha(uc)) {
+ if (isASCIIAlpha(uc)) {
if (base > 36)
base = 36;
return (uc >= 'a' && uc < 'a' + base - 10)
}
} else {
for ( i = 0; i < lstr; i++ ) {
- hthis += tolower(uthis[i].unicode());
- hstr += tolower(ustr[i].unicode());
+ hthis += toASCIILower(uthis[i].unicode());
+ hstr += toASCIILower(ustr[i].unicode());
}
i = 0;
while ( true ) {
return index + i;
if ( i == delta )
return -1;
- hthis += tolower(uthis[i + lstr].unicode());
- hthis -= tolower(uthis[i].unicode());
+ hthis += toASCIILower(uthis[i + lstr].unicode());
+ hthis -= toASCIILower(uthis[i].unicode());
i++;
}
}
}
} while (--n);
} else {
- int lc = tolower(*chs);
+ unsigned char lc = toASCIILower(*chs);
do {
- if (tolower(*++ptr) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne)) {
+ if (toASCIILower(*++ptr) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne)) {
return data->_length - chsLength - n + 1;
}
} while (--n);
}
} while (--n);
} else {
- int lc = tolower((unsigned char)*chs);
+ unsigned char lc = toASCIILower(*chs);
do {
- if (tolower((++ptr)->unicode()) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne)) {
+ if (toASCIILower((++ptr)->unicode()) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne)) {
return data->_length - chsLength - n + 1;
}
} while (--n);
while (n--)
count += *cPtr++ == ac;
} else { // case insensitive
- int lc = tolower(ac);
+ unsigned char lc = toASCIILower(ac);
while (n--) {
- count += tolower(*cPtr++) == lc;
+ count += toASCIILower(*cPtr++) == lc;
}
}
} else {
while ( n-- )
count += *uc++ == c;
} else { // case insensitive
- int lc = tolower(c.unicode());
+ ::UChar lc = toASCIILower(c.unicode());
while (n--) {
- count += tolower(uc->unicode()) == lc;
+ count += toASCIILower(uc->unicode()) == lc;
uc++;
}
}
p++;
} while (--n);
} else {
- int lc = tolower(c);
+ char lc = toASCIILower(c);
do {
- count += tolower(*p) == lc && equalCaseInsensitive(p + 1, str + 1, len - 1);
+ count += toASCIILower(*p) == lc && equalCaseInsensitive(p + 1, str + 1, len - 1);
p++;
} while (--n);
}
p++;
} while (--n);
} else {
- int lc = tolower(c);
+ unsigned char lc = toASCIILower(c);
do {
- count += tolower(p->unicode()) == lc && equalCaseInsensitive(p + 1, str + 1, len - 1);
+ count += toASCIILower(p->unicode()) == lc && equalCaseInsensitive(p + 1, str + 1, len - 1);
p++;
} while (--n);
}
while (length && isCharacterAllowedInBase(*p, base)) {
length--;
IntegralType digitValue;
- int c = p->unicode();
- if (isdigit(c))
+ ::UChar c = p->unicode();
+ if (isASCIIDigit(c))
digitValue = c - '0';
else if (c >= 'a')
digitValue = c - 'a' + 10;
/*
- * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#define DeprecatedString_h
#include "DeprecatedCString.h"
-
+#include <wtf/ASCIICType.h>
#include <wtf/unicode/Unicode.h>
-#include <ctype.h>
-
/* On some ARM platforms GCC won't pack structures by default so sizeof(DeprecatedChar)
will end up being != 2 which causes crashes since the code depends on that. */
#if COMPILER(GCC) && PLATFORM(FORCE_PACK)
#if USE(ICU_UNICODE)
// Use isspace() for basic Latin-1.
// This will include newlines, which aren't included in unicode DirWS.
- return c <= 0x7F ? isspace(c) : (u_charDirection(c) == U_WHITE_SPACE_NEUTRAL);
+ return c <= 0x7F ? WTF::isASCIISpace(c) : (u_charDirection(c) == U_WHITE_SPACE_NEUTRAL);
#elif USE(QT4_UNICODE)
return QChar(c).isSpace();
#endif
{
#if USE(ICU_UNICODE)
// FIXME: If fast enough, we should just call u_tolower directly.
- return c <= 0x7F ? tolower(c) : u_tolower(c);
+ return c <= 0x7F ? WTF::toASCIILower(c) : u_tolower(c);
#elif USE(QT4_UNICODE)
return QChar(c).toLower().unicode();
#endif
{
#if USE(ICU_UNICODE)
// FIXME: If fast enough, we should just call u_toupper directly.
- return c <= 0x7F ? toupper(c) : u_toupper(c);
+ return c <= 0x7F ? WTF::toASCIIUpper(c) : u_toupper(c);
#elif USE(QT4_UNICODE)
return QChar(c).toUpper().unicode();
#endif
#endif
using namespace std;
+using namespace WTF;
namespace WebCore {
// possible start of port
portEnd = portStart;
- while (isdigit(url[portEnd])) {
+ while (isASCIIDigit(url[portEnd])) {
portEnd++;
}
} else {
{
// Use isspace() for basic Latin-1.
// This will include newlines, which aren't included in unicode DirWS.
- return c <= 0x7F ? isspace(c) : direction(c) == WhiteSpaceNeutral;
+ return c <= 0x7F ? isASCIISpace(c) : direction(c) == WhiteSpaceNeutral;
}
static inline UChar* newUCharVector(unsigned n)
// the "len" parameter means are different here from what's done in RenderText.
// FIXME: No range checking here.
for (unsigned i = from; i < len; i++)
- if (m_data[i] > 0x7F || !isspace(m_data[i]))
+ if (m_data[i] > 0x7F || !isASCIISpace(m_data[i]))
return false;
return true;
}
UChar ored = 0;
for (unsigned i = 0; i < m_length; i++) {
UChar c = m_data[i];
- // The islower function is only guaranteed to work correctly and
- // in a locale-independent fashion for ASCII characters. We mask
- // to guarantee we don't pass any non-ASCII values in.
- allLower = allLower && islower(c & 0x7F);
+ allLower = allLower && isASCIILower(c);
ored |= c;
}
if (!(ored & ~0x7F))
for (int i = 0; i < length; i++) {
UChar c = m_data[i];
ored |= c;
- // The tolower function is only guaranteed to work correctly and
- // in a locale-independent fashion for ASCII characters. We mask
- // to guarantee we don't pass any non-ASCII values in.
- data[i] = tolower(c & 0x7F);
+ data[i] = toASCIILower(c);
}
if (!(ored & ~0x7F))
return c;
}
} else {
for (int i = 0; i < lstr; i++ ) {
- hthis += tolower(uthis[i]);
- hstr += tolower(ustr[i]);
+ hthis += toASCIILower(uthis[i]);
+ hstr += toASCIILower(ustr[i]);
}
int i = 0;
while (1) {
return index + i;
if (i == delta)
return -1;
- hthis += tolower(uthis[i + lstr]);
- hthis -= tolower(uthis[i]);
+ hthis += toASCIILower(uthis[i + lstr]);
+ hthis -= toASCIILower(uthis[i]);
i++;
}
}
}
} else {
for (i = 0; i < lstr; i++) {
- hthis += tolower(uthis[index + i]);
- hstr += tolower(ustr[i]);
+ hthis += toASCIILower(uthis[index + i]);
+ hstr += toASCIILower(ustr[i]);
}
i = index;
while (1) {
if (i == 0)
return -1;
i--;
- hthis -= tolower(uthis[i + lstr]);
- hthis += tolower(uthis[i]);
+ hthis -= toASCIILower(uthis[i + lstr]);
+ hthis += toASCIILower(uthis[i]);
}
}
UChar ored = 0;
bool equal = true;
for (unsigned i = 0; i != length; ++i) {
- unsigned char bc = b[i];
+ char bc = b[i];
if (!bc)
return false;
UChar ac = as[i];
ored |= ac;
- // The tolower function is only guaranteed to work correctly and
- // in a locale-independent fashion for ASCII characters. We mask
- // to guarantee we don't pass any non-ASCII values in.
- ASSERT(!(bc & ~0x7F));
- equal = equal && (tolower(ac & 0x7F) == tolower(bc));
+ equal = equal && (toASCIILower(ac) == toASCIILower(bc));
}
// Do a slower implementation for cases that include non-ASCII characters.
#include "PlatformString.h"
#include "TextCodecLatin1.h"
#include "TextCodecUTF16.h"
-#include <ctype.h>
+#include <wtf/ASCIICType.h>
#include <wtf/Assertions.h>
#include <wtf/HashMap.h>
#include "qt/TextCodecQt.h"
#endif
+using namespace WTF;
+
namespace WebCore {
const size_t maxEncodingNameLength = 63;
do {
do
c1 = *s1++;
- while (c1 && !isalnum(c1));
+ while (c1 && !isASCIIAlphanumeric(c1));
do
c2 = *s2++;
- while (c2 && !isalnum(c2));
- if (tolower(c1) != tolower(c2))
+ while (c2 && !isASCIIAlphanumeric(c2));
+ if (toASCIILower(c1) != toASCIILower(c2))
return false;
} while (c1 && c2);
return !c1 && !c2;
h += (h << 15);
return h;
}
- } while (!isalnum(c));
- h += tolower(c);
+ } while (!isASCIIAlphanumeric(c));
+ h += toASCIILower(c);
h += (h << 10);
h ^= (h >> 6);
}
size_t j = 0;
for (size_t i = 0; i < length; ++i) {
UChar c = characters[i];
- if (isalnum(c)) {
+ if (isASCIIAlphanumeric(c)) {
if (j == maxEncodingNameLength)
return 0;
buffer[j++] = c;
/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#import "PlatformKeyboardEvent.h"
#import "Logging.h"
+#import <wtf/ASCIICType.h>
+
+using namespace WTF;
namespace WebCore {
// FIXME: We should use something other than the vendor-area Unicode values for the above keys.
// For now, just fall through to the default.
default:
- return String::format("U+%04X", toupper(c));
+ return String::format("U+%04X", toASCIIUpper(c));
}
}
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include "config.h"
#include "PlatformKeyboardEvent.h"
-#include <windows.h>
-#define REPEAT_COUNT_MASK 0x0000FFFF
-#define NEW_RELEASE_STATE_MASK 0x80000000
-#define PREVIOUS_DOWN_STATE_MASK 0x40000000
+#include <windows.h>
+#include <wtf/ASCIICType.h>
-#define HIGH_BIT_MASK_SHORT 0x8000
+using namespace WTF;
namespace WebCore {
+static const unsigned REPEAT_COUNT_MASK = 0x0000FFFF;
+static const unsigned NEW_RELEASE_STATE_MASK = 0x80000000;
+static const unsigned PREVIOUS_DOWN_STATE_MASK = 0x40000000;
+
+static const unsigned short HIGH_BIT_MASK_SHORT = 0x8000;
+
// FIXME: This is incomplete. We could change this to mirror
// more like what Firefox does, and generate these switch statements
// at build time.
-static String keyIdentifierForWindowsKeyCode(short keyCode)
+static String keyIdentifierForWindowsKeyCode(unsigned short keyCode)
{
switch (keyCode) {
case VK_MENU:
case VK_DELETE:
return "U+007F";
default:
- return String::format("U+%04X", toupper(keyCode));
+ return String::format("U+%04X", toASCIIUpper(keyCode));
}
}
static ATOM registerPopup();
static LRESULT CALLBACK PopupWndProc(HWND, UINT, WPARAM, LPARAM);
+// FIXME: Remove this as soon as practical.
+static inline bool isASCIIPrintable(unsigned c)
+{
+ return c >= 0x20 && c <= 0x7E;
+}
+
PopupMenu::PopupMenu(PopupMenuClient* client)
: m_popupClient(client)
, m_scrollBar(0)
popup->client()->hidePopup();
break;
default:
- if (isprint(::MapVirtualKey(LOWORD(wParam), 2)))
+ if (isASCIIPrintable(::MapVirtualKey(LOWORD(wParam), 2)))
// Send the keydown to the WebView so it can be used for type-ahead find
::SendMessage(popup->client()->clientDocument()->view()->containingWindow(), message, wParam, lParam);
else
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include "Settings.h"
#include <kjs/JSLock.h>
#include <kjs/value.h>
+#include <wtf/ASCIICType.h>
using KJS::ExecState;
using KJS::Interpreter;
using std::min;
+using namespace WTF;
+
namespace WebCore {
using namespace EventNames;
UChar c;
if (capitalizeCharacter && name[i] >= 'a' && name[i] <= 'z')
- c = toupper(name[i]);
+ c = toASCIIUpper(name[i]);
else if (!capitalizeCharacter && name[i] >= 'A' && name[i] <= 'Z')
- c = tolower(name[i]);
+ c = toASCIILower(name[i]);
else
c = name[i];
w += tabWidth - ((xPos + w) % tabWidth);
else
w += monospaceCharacterWidth;
- if (isspace(c) && !isspace(previousChar))
+ if (isASCIISpace(c) && !isASCIISpace(previousChar))
w += f.wordSpacing();
}
previousChar = c;
+2007-10-16 Darin Adler <darin@apple.com>
+
+ Reviewed by Maciej and Geoff (and looked over by Eric).
+
+ - http://bugs.webkit.org/show_bug.cgi?id=15519
+ eliminate use of <ctype.h> for processing ASCII
+
+ * ForwardingHeaders/wtf/ASCIICType.h: Added.
+ * ForwardingHeaders/wtf/DisallowCType.h: Added.
+
+ * WebKitPrefix.h: Include DisallowCType.h.
+
+ * Misc/WebNSURLExtras.mm: (-[NSURL _web_URLWithLowercasedScheme]): Use toASCIILower.
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView callWebCoreCommand:]): Use toASCIIUpper.
+ (-[WebTextCompleteController filterKeyDown:]): Add a list of specific character codes,
+ instead of using ispunct.
+
2007-10-16 John Sullivan <sullivan@apple.com>
Reviewed by Adam Roben
--- /dev/null
+#include <JavaScriptCore/ASCIICType.h>
--- /dev/null
+#include <JavaScriptCore/DisallowCType.h>
/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2005, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
*
* Redistribution and use in source and binary forms, with or without
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import <WebKit/WebNSURLExtras.h>
+#import "WebNSURLExtras.h"
+#import "WebKitNSStringExtras.h"
+#import "WebLocalizableStrings.h"
+#import "WebNSDataExtras.h"
+#import "WebNSObjectExtras.h"
+#import "WebSystemInterface.h"
+#import <Foundation/NSURLRequest.h>
#import <JavaScriptCore/Assertions.h>
-#import <WebKit/WebKitNSStringExtras.h>
-#import <WebKit/WebNSDataExtras.h>
-#import <WebKit/WebNSObjectExtras.h>
-#import <WebKit/WebLocalizableStrings.h>
#import <WebCore/KURL.h>
#import <WebCore/LoaderNSURLExtras.h>
-
#import <WebKitSystemInterface.h>
-#import "WebSystemInterface.h"
-
-#import <Foundation/NSURLRequest.h>
-
#import <unicode/uchar.h>
#import <unicode/uidna.h>
#import <unicode/uscript.h>
using namespace WebCore;
+using namespace WTF;
typedef void (* StringRangeApplierFunction)(NSString *string, NSRange range, void *context);
int i;
BOOL changed = NO;
for (i = 0; i < range.length; ++i) {
- UInt8 c = buffer[range.location + i];
- UInt8 lower = tolower(c);
+ char c = buffer[range.location + i];
+ char lower = toASCIILower(c);
if (c != lower) {
buffer[range.location + i] = lower;
changed = YES;
#include <wtf/FastMalloc.h>
#endif
+#include <wtf/DisallowCType.h>
+
/* Work around bug with C++ library that screws up Objective-C++ when exception support is disabled. */
#undef try
#undef catch
using namespace WebCore;
using namespace HTMLNames;
+using namespace WTF;
@interface NSWindow (BorderViewAccess)
- (NSView*)_web_borderView;
ASSERT(selectorNameLength >= 2);
ASSERT(selectorName[selectorNameLength - 1] == ':');
Vector<char, 256> commandName(selectorNameLength - 1 + 1);
- commandName[0] = toupper(selectorName[0]);
+ commandName[0] = toASCIIUpper(selectorName[0]);
memcpy(&commandName[1], &selectorName[1], selectorNameLength - 2);
commandName[selectorNameLength - 1] = 0;
return _popupWindow != nil;
}
-// WebHTMLView gives us a crack at key events it sees. Return whether we consumed the event.
+// WebHTMLView gives us a crack at key events it sees. Return whether we consumed the event.
// The features for the various keys mimic NSTextView.
- (BOOL)filterKeyDown:(NSEvent *)event
{
- if (_popupWindow) {
- NSString *string = [event charactersIgnoringModifiers];
- unichar c = [string characterAtIndex:0];
- if (c == NSUpArrowFunctionKey) {
- int selectedRow = [_tableView selectedRow];
- if (0 < selectedRow) {
- [_tableView selectRow:selectedRow-1 byExtendingSelection:NO];
- [_tableView scrollRowToVisible:selectedRow-1];
- }
- return YES;
- } else if (c == NSDownArrowFunctionKey) {
- int selectedRow = [_tableView selectedRow];
- if (selectedRow < (int)[_completions count]-1) {
- [_tableView selectRow:selectedRow+1 byExtendingSelection:NO];
- [_tableView scrollRowToVisible:selectedRow+1];
- }
- return YES;
- } else if (c == NSRightArrowFunctionKey || c == '\n' || c == '\r' || c == '\t') {
- [self endRevertingChange:NO moveLeft:NO];
- return YES;
- } else if (c == NSLeftArrowFunctionKey) {
- [self endRevertingChange:NO moveLeft:YES];
- return YES;
- } else if (c == 0x1b || c == NSF5FunctionKey) {
- [self endRevertingChange:YES moveLeft:NO];
- return YES;
- } else if (c == ' ' || ispunct(c)) {
- [self endRevertingChange:NO moveLeft:NO];
- return NO; // let the char get inserted
+ if (!_popupWindow)
+ return NO;
+ NSString *string = [event charactersIgnoringModifiers];
+ if (![string length])
+ return NO;
+ unichar c = [string characterAtIndex:0];
+ if (c == NSUpArrowFunctionKey) {
+ int selectedRow = [_tableView selectedRow];
+ if (0 < selectedRow) {
+ [_tableView selectRow:selectedRow - 1 byExtendingSelection:NO];
+ [_tableView scrollRowToVisible:selectedRow - 1];
}
+ return YES;
+ }
+ if (c == NSDownArrowFunctionKey) {
+ int selectedRow = [_tableView selectedRow];
+ if (selectedRow < (int)[_completions count] - 1) {
+ [_tableView selectRow:selectedRow + 1 byExtendingSelection:NO];
+ [_tableView scrollRowToVisible:selectedRow + 1];
+ }
+ return YES;
+ }
+ if (c == NSRightArrowFunctionKey || c == '\n' || c == '\r' || c == '\t') {
+ // FIXME: What about backtab?
+ [self endRevertingChange:NO moveLeft:NO];
+ return YES;
+ }
+ if (c == NSLeftArrowFunctionKey) {
+ [self endRevertingChange:NO moveLeft:YES];
+ return YES;
+ }
+ if (c == 0x1B || c == NSF5FunctionKey) {
+ // FIXME: F5?
+ [self endRevertingChange:YES moveLeft:NO];
+ return YES;
+ }
+ if (c == ' ' || c >= 0x21 && c <= 0x2F || c >= 0x3A && c <= 0x40 || c >= 0x5B && c <= 0x60 || c >= 0x7B && c <= 0x7D) {
+ // FIXME: Is the above list of keys really definitive?
+ // Originally this code called ispunct; aren't there other punctuation keys on international keyboards?
+ [self endRevertingChange:NO moveLeft:NO];
+ return NO; // let the char get inserted
}
return NO;
}