Changeset 26676 in webkit


Ignore:
Timestamp:
Oct 16, 2007, 1:13:24 PM (18 years ago)
Author:
darin
Message:

JavaScriptCore:

Reviewed by Maciej and Geoff (and looked over by Eric).

  • 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.

WebCore:

Reviewed by Maciej and Geoff (and looked over by Eric).

  • 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.

WebKit:

Reviewed by Maciej and Geoff (and looked over by Eric).

  • 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.
Location:
trunk
Files:
6 added
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r26639 r26676  
     12007-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
    1232007-10-14  Maciej Stachowiak  <[email protected]>
    224
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r25786 r26676  
    218218                935AF46E09E9D9DB00ACD1D8 /* UnusedParam.h in Headers */ = {isa = PBXBuildFile; fileRef = 935AF46B09E9D9DB00ACD1D8 /* UnusedParam.h */; };
    219219                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, ); }; };
    220222                93AA4F780957251F0084B3A7 /* AlwaysInline.h in Headers */ = {isa = PBXBuildFile; fileRef = 93AA4F770957251F0084B3A7 /* AlwaysInline.h */; settings = {ATTRIBUTES = (Private, ); }; };
    221223                93B6A0DF0AA64DA40076DE27 /* GetPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B6A0DE0AA64DA40076DE27 /* GetPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    570572                937B63CC09E766D200A671DD /* DerivedSources.make */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = DerivedSources.make; sourceTree = "<group>"; usesTabs = 1; };
    571573                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>"; };
    572576                93AA4F770957251F0084B3A7 /* AlwaysInline.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = AlwaysInline.h; sourceTree = "<group>"; tabWidth = 8; };
    573577                93B6A0DE0AA64DA40076DE27 /* GetPtr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GetPtr.h; sourceTree = "<group>"; };
     
    897901                        isa = PBXGroup;
    898902                        children = (
    899                                 652246A40C8D7A0E007BDAF7 /* HashIterators.h */,
    900903                                E195678D09E7CF1200B89D13 /* unicode */,
    901904                                93AA4F770957251F0084B3A7 /* AlwaysInline.h */,
     905                                938C4F690CA06BC700D9310A /* ASCIICType.h */,
    902906                                65E217B808E7EECC0023E5F6 /* Assertions.cpp */,
    903907                                65E217B708E7EECC0023E5F6 /* Assertions.h */,
     908                                938C4F6B0CA06BCE00D9310A /* DisallowCType.h */,
    904909                                65E217B908E7EECC0023E5F6 /* FastMalloc.cpp */,
    905910                                65E217BA08E7EECC0023E5F6 /* FastMalloc.h */,
     
    909914                                657EEBBF094E445E008C9C7B /* HashCountedSet.h */,
    910915                                65DFC92A08EA173A00F7300B /* HashFunctions.h */,
     916                                652246A40C8D7A0E007BDAF7 /* HashIterators.h */,
    911917                                65DFC92B08EA173A00F7300B /* HashMap.h */,
    912918                                65DFC92C08EA173A00F7300B /* HashSet.h */,
     
    12541260                                652246A50C8D7A0E007BDAF7 /* HashIterators.h in Headers */,
    12551261                                95C18D490C90E82600E72F73 /* JSRetainPtr.h in Headers */,
     1262                                938C4F6A0CA06BC700D9310A /* ASCIICType.h in Headers */,
     1263                                938C4F6C0CA06BCE00D9310A /* DisallowCType.h in Headers */,
    12561264                        );
    12571265                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/JavaScriptCore/kjs/config.h

    r26513 r26676  
    11/*
    2  * Copyright (C) 2006 Apple Computer, Inc.
     2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <[email protected]>
    44 *
     
    8686#include <wtf/FastMalloc.h>
    8787#endif
     88
     89#include <wtf/DisallowCType.h>
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r26454 r26676  
    11/*
    2  *  This file is part of the KDE libraries
    32 *  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.
    54 *
    65 *  This library is free software; you can redistribute it and/or
     
    4140#endif
    4241
    43 #include <ctype.h>
    4442#include <float.h>
    4543#include <limits.h>
     
    5553#include "DateMath.h"
    5654
     55#include <wtf/ASCIICType.h>
    5756#include <wtf/MathExtras.h>
    5857#include <wtf/StringExtras.h>
     
    6160    #include <CoreFoundation/CoreFoundation.h>
    6261#endif
     62
     63using namespace WTF;
    6364
    6465namespace KJS {
     
    743744};
    744745
    745 inline static void skipSpacesAndComments(const char *&s)
     746inline static void skipSpacesAndComments(const char*& s)
    746747{
    747748    int nesting = 0;
    748749    char ch;
    749750    while ((ch = *s)) {
    750         if (!isspace(ch)) {
     751        if (!isASCIISpace(ch)) {
    751752            if (ch == '(')
    752753                nesting++;
     
    761762
    762763// returns 0-11 (Jan-Dec); -1 on failure
    763 static int findMonth(const char *monthStr)
     764static int findMonth(const char* monthStr)
    764765{
    765766    assert(monthStr);
     
    768769        if (!*monthStr)
    769770            return -1;
    770         needle[i] = static_cast<char>(tolower(*monthStr++));
     771        needle[i] = static_cast<char>(toASCIILower(*monthStr++));
    771772    }
    772773    needle[3] = '\0';
     
    806807    const char *wordStart = dateString;
    807808    // Check contents of first words if not number
    808     while (*dateString && !isdigit(*dateString)) {
    809         if (isspace(*dateString) || *dateString == '(') {
     809    while (*dateString && !isASCIIDigit(*dateString)) {
     810        if (isASCIISpace(*dateString) || *dateString == '(') {
    810811            if (dateString - wordStart >= 3)
    811812                month = findMonth(wordStart);
     
    956957
    957958            // ':40 GMT'
    958             if (*dateString && *dateString != ':' && !isspace(*dateString))
     959            if (*dateString && *dateString != ':' && !isASCIISpace(*dateString))
    959960                return NaN;
    960961
  • trunk/JavaScriptCore/kjs/function.cpp

    r26619 r26676  
    11// -*- c-basic-offset: 2 -*-
    22/*
    3  *  This file is part of the KDE libraries
    43 *  Copyright (C) 1999-2002 Harri Porten ([email protected])
    54 *  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.
    76 *  Copyright (C) 2007 Cameron Zwarich ([email protected])
    87 *
     
    4140#include <assert.h>
    4241#include <string.h>
    43 #include <ctype.h>
    44 
     42
     43#include <wtf/ASCIICType.h>
    4544#include <wtf/unicode/Unicode.h>
    4645
     
    583582    if (c == '%') {
    584583      int charLen = 0;
    585       if (k <= len - 3 && isxdigit(p[1].uc) && isxdigit(p[2].uc)) {
     584      if (k <= len - 3 && isASCIIHexDigit(p[1].uc) && isASCIIHexDigit(p[2].uc)) {
    586585        const char b0 = Lexer::convertHex(p[1].uc, p[2].uc);
    587586        const int sequenceLen = UTF8SequenceLength(b0);
     
    592591          for (int i = 1; i < sequenceLen; ++i) {
    593592            const UChar* q = p + i * 3;
    594             if (q[0] == '%' && isxdigit(q[1].uc) && isxdigit(q[2].uc))
     593            if (q[0] == '%' && isASCIIHexDigit(q[1].uc) && isASCIIHexDigit(q[2].uc))
    595594              sequence[i] = Lexer::convertHex(q[1].uc, q[2].uc);
    596595            else {
     
    620619        // For that, it's good to support the wonky "%u" syntax for compatibility with WinIE.
    621620        if (k <= len - 6 && p[1] == 'u'
    622             && isxdigit(p[2].uc) && isxdigit(p[3].uc)
    623             && isxdigit(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)) {
    624623          charLen = 6;
    625624          u = Lexer::convertUnicode(p[2].uc, p[3].uc, p[4].uc, p[5].uc);
  • trunk/JavaScriptCore/kjs/ustring.cpp

    r26182 r26676  
    11// -*- c-basic-offset: 2 -*-
    22/*
    3  *  This file is part of the KDE libraries
    43 *  Copyright (C) 1999-2000 Harri Porten ([email protected])
    54 *  Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
     
    4847#endif
    4948
    50 using std::max;
    51 using std::min;
     49using namespace WTF;
     50using namespace std;
    5251
    5352namespace KJS {
     
    955954
    956955  // skip leading white space
    957   while (isspace(*c))
     956  while (isASCIISpace(*c))
    958957    c++;
    959958
     
    10101009
    10111010  // allow trailing white space
    1012   while (isspace(*c))
     1011  while (isASCIISpace(*c))
    10131012    c++;
    10141013  // don't allow anything after - unless tolerant=true
  • trunk/WebCore/ChangeLog

    r26674 r26676  
     12007-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
    1702007-10-16  Mitz Pettel  <[email protected]>
    271
  • trunk/WebCore/WebCorePrefix.h

    r25754 r26676  
    6060#endif // defined(WIN32) || defined(_WIN32)
    6161
    62 #include <ctype.h>
    6362#include <sys/types.h>
    6463#include <fcntl.h>
     
    8483#include <cstddef>
    8584#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 #endif
    10485
    10586#endif
  • trunk/WebCore/config.h

    r25754 r26676  
    2626#define HAVE_FUNC_USLEEP 1
    2727#endif /* __APPLE__ */
    28 
    2928
    3029#if PLATFORM(WIN_OS)
     
    6766
    6867#endif
     68
     69#include <wtf/DisallowCType.h>
    6970
    7071#if !COMPILER(MSVC) // can't get this to compile on Visual C++ yet
  • trunk/WebCore/css/CSSParser.cpp

    r26663 r26676  
    163163    else
    164164        for (int i = 0; i < length; i++)
    165             characters[i] = tolower(characters[i]);
     165            characters[i] = toASCIILower(characters[i]);
    166166}
    167167
  • trunk/WebCore/css/CSSPrimitiveValue.cpp

    r25754 r26676  
    1 /**
    2  * This file is part of the DOM implementation for KDE.
    3  *
     1/*
    42 * (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.
    64 *
    75 * This library is free software; you can redistribute it and/or
     
    3230#include "Pair.h"
    3331#include "RenderStyle.h"
    34 #include <ctype.h>
     32#include <wtf/ASCIICType.h>
     33
     34using namespace WTF;
    3535
    3636namespace WebCore {
     
    4747
    4848    // {nmstart}
    49     if (p == end || !(p[0] == '_' || p[0] >= 128 || isalpha(p[0])))
     49    if (p == end || !(p[0] == '_' || p[0] >= 128 || isASCIIAlpha(p[0])))
    5050        return false;
    5151    ++p;
     
    5353    // {nmchar}*
    5454    for (; p != end; ++p) {
    55         if (!(p[0] == '_' || p[0] == '-' || p[0] >= 128 || isalnum(p[0])))
     55        if (!(p[0] == '_' || p[0] == '-' || p[0] >= 128 || isASCIIAlphanumeric(p[0])))
    5656            return false;
    5757    }
  • trunk/WebCore/css/CSSStyleDeclaration.cpp

    r26522 r26676  
    11/**
    2  * This file is part of the DOM implementation for KDE.
    3  *
    42 * (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.
    64 *
    75 * This library is free software; you can redistribute it and/or
     
    2927#include "CSSRule.h"
    3028#include "DeprecatedValueList.h"
    31 #include <ctype.h>
     29#include <wtf/ASCIICType.h>
     30
     31using namespace WTF;
    3232
    3333namespace WebCore {
     
    4848        if (c == 0 || c >= 0x7F)
    4949            return 0; // illegal character
    50         buffer[i] = tolower(c);
     50        buffer[i] = toASCIILower(c);
    5151    }
    5252
  • trunk/WebCore/html/HTMLSelectElement.cpp

    r26665 r26676  
    908908    for (i = 0; i < length; ++i)
    909909        if (string[i] != noBreakSpace &&
    910             (string[i] <= 0x7F ? !isspace(string[i]) : (direction(string[i]) != WhiteSpaceNeutral)))
     910            (string[i] <= 0x7F ? !isASCIISpace(string[i]) : (direction(string[i]) != WhiteSpaceNeutral)))
    911911            break;
    912912
  • trunk/WebCore/html/HTMLTokenizer.cpp

    r25754 r26676  
    11/*
    2     This file is part of the KDE libraries
    3 
    42    Copyright (C) 1997 Martin Jones ([email protected])
    53              (C) 1997 Torben Weis ([email protected])
     
    86              (C) 1999 Antti Koivisto ([email protected])
    97              (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.
    119    Copyright (C) 2005, 2006 Alexey Proskuryakov ([email protected])
    1210
     
    4745#include "SystemTime.h"
    4846#include "kjs_proxy.h"
     47#include <wtf/ASCIICType.h>
    4948
    5049#include "HTMLEntityNames.c"
     
    6261
    6362using namespace std;
     63using namespace WTF;
    6464
    6565namespace WebCore {
     
    120120    for (unsigned i = 0; i != length; ++i) {
    121121        unsigned char c1 = s1[i];
    122         unsigned char uc1 = toupper(c1);
     122        unsigned char uc1 = toASCIIUpper(static_cast<char>(c1));
    123123        UChar c2 = s2[i];
    124124        if (c1 != c2 && uc1 != c2)
  • trunk/WebCore/loader/FTPDirectoryParser.cpp

    r26185 r26676  
    2525#include "FTPDirectoryParser.h"
    2626
    27 #include "DeprecatedString.h"
     27#include <wtf/ASCIICType.h>
     28
     29using namespace WTF;
    2830
    2931namespace WebCore {
     
    128130          else if (*p == 'm')
    129131          {
    130             if (isdigit(line[pos]))
    131             {
    132               while (pos < linelen && isdigit(line[pos]))
     132            if (isASCIIDigit(line[pos]))
     133            {
     134              while (pos < linelen && isASCIIDigit(line[pos]))
    133135                pos++;
    134136              if (pos < linelen && line[pos] == ',')
     
    146148          else if (*p == 's')
    147149          {
    148             if (isdigit(line[pos]))
    149             {
    150               while (pos < linelen && isdigit(line[pos]))
     150            if (isASCIIDigit(line[pos]))
     151            {
     152              while (pos < linelen && isASCIIDigit(line[pos]))
    151153                pos++;
    152154              if (pos < linelen && line[pos] == ',')
     
    154156            }
    155157          }
    156           else if (isalpha(*p)) /* 'i'/'up' or unknown "fact" (property) */
     158          else if (isASCIIAlpha(*p)) /* 'i'/'up' or unknown "fact" (property) */
    157159          {
    158160            while (pos < linelen && *++p != ',')
     
    232234            }
    233235            else if (p[pos] != '.' && p[pos] != '~' &&
    234                      !isdigit(p[pos]) && !isalpha(p[pos]))
     236                     !isASCIIDigit(p[pos]) && !isASCIIAlpha(p[pos]))
    235237              break;
    236             else if (isalpha(p[pos]) && p[pos] != toupper(p[pos]))
     238            else if (isASCIIAlpha(p[pos]) && p[pos] != toASCIIUpper(p[pos]))
    237239              break;
    238240          }
     
    250252            pos--;
    251253            if (p[pos] != '$' && p[pos] != '_' && p[pos] != '-' &&
    252                 p[pos] != '~' && !isdigit(p[pos]) && !isalpha(p[pos]))
     254                p[pos] != '~' && !isASCIIDigit(p[pos]) && !isASCIIAlpha(p[pos]))
    253255              break;
    254             else if (isalpha(p[pos]) && p[pos] != toupper(p[pos]))
     256            else if (isASCIIAlpha(p[pos]) && p[pos] != toASCIIUpper(p[pos]))
    255257              break;
    256258          }
     
    288290                        (tokens[3][toklen[3]-3]) == '.' )
    289291        ) &&  /* time in [H]H:MM[:SS[.CC]] format */
    290                                     isdigit(*tokens[1]) && /* size */
    291                                     isdigit(*tokens[2]) && /* date */
    292                                     isdigit(*tokens[3])    /* time */
     292                                    isASCIIDigit(*tokens[1]) && /* size */
     293                                    isASCIIDigit(*tokens[2]) && /* date */
     294                                    isASCIIDigit(*tokens[3])    /* time */
    293295                )
    294296        {
     
    327329            {
    328330              if (*p != '$' && *p != '.' && *p != '_' && *p != '-' &&
    329                   *p != '~' && !isdigit(*p) && !isalpha(*p))             
     331                  *p != '~' && !isASCIIDigit(*p) && !isASCIIAlpha(*p))             
    330332                lstyle = 0;
    331333              pos++;
     
    342344          {
    343345            if (*p != '$' && *p != '.' && *p != '_' && *p != '-' &&
    344                 *p != '~' && !isdigit(*p) && !isalpha(*p))
     346                *p != '~' && !isASCIIDigit(*p) && !isASCIIAlpha(*p))
    345347              lstyle = 0;
    346             else if (isalpha(*p) && *p != toupper(*p))
     348            else if (isASCIIAlpha(*p) && *p != toASCIIUpper(*p))
    347349              lstyle = 0;
    348350            p++;
     
    355357            for (pos++;lstyle && pos < toklen[0];pos++)
    356358            {
    357               if (!isdigit(tokens[0][pos]))
     359              if (!isASCIIDigit(tokens[0][pos]))
    358360                lstyle = 0;
    359361            }
     
    378380            return FTPJunkEntry; /* tell caller to treat as junk */
    379381          }
    380           else if (isdigit(*tokens[1])) /* not no-privs message */
     382          else if (isASCIIDigit(*tokens[1])) /* not no-privs message */
    381383          {
    382384            for (pos = 0; lstyle && pos < (toklen[1]); pos++)
    383385            {
    384               if (!isdigit((tokens[1][pos])) && (tokens[1][pos]) != '/')
     386              if (!isASCIIDigit((tokens[1][pos])) && (tokens[1][pos]) != '/')
    385387                lstyle = 0;
    386388            }
     
    403405        state.listStyle = lstyle;
    404406
    405         if (isdigit(*tokens[1]))  /* not permission denied etc */
     407        if (isASCIIDigit(*tokens[1]))  /* not permission denied etc */
    406408        {
    407409          /* strip leading directory name */
     
    494496            p++;
    495497          tbuf[0] = p[0];
    496           tbuf[1] = tolower(p[1]);
    497           tbuf[2] = tolower(p[2]);
     498          tbuf[1] = toASCIILower(p[1]);
     499          tbuf[2] = toASCIILower(p[2]);
    498500          month_num = 0;
    499501          for (pos = 0; pos < (12*3); pos+=3)
     
    521523          return result.type;
    522524
    523         } /* if (isdigit(*tokens[1])) */
     525        } /* if (isASCIIDigit(*tokens[1])) */
    524526
    525527        return FTPJunkEntry; /* junk */
     
    578580                      *tokens[pos+2] == '-' &&
    579581                      *tokens[pos+3] == '-')  ||
    580                       (isdigit(*tokens[pos+1]) &&
    581                        isdigit(*tokens[pos+2]) &&
    582                        isdigit(*tokens[pos+3])) )
     582                      (isASCIIDigit(*tokens[pos+1]) &&
     583                       isASCIIDigit(*tokens[pos+2]) &&
     584                       isASCIIDigit(*tokens[pos+3])) )
    583585                {
    584586                  lstyle = 'C';
     
    596598        for (pos = 0, p = tokens[0]; lstyle && pos < toklen[0]; pos++, p++)
    597599        { 
    598           if (isalpha(*p) && toupper(*p) != *p)
     600          if (isASCIIAlpha(*p) && toASCIIUpper(*p) != *p)
    599601            lstyle = 0;
    600602        }
     
    605607            for (p = tokens[pos]; lstyle && p<(tokens[pos]+toklen[pos]); p++)
    606608            {
    607               if (!isdigit(*p))
     609              if (!isASCIIDigit(*p))
    608610                lstyle = 0;
    609611            }
     
    626628              lstyle = 0;
    627629          }
    628           else if (*p != '-' && !isdigit(*p))
     630          else if (*p != '-' && !isASCIIDigit(*p))
    629631            lstyle = 0;
    630632          else if (*p == '-' && pos != 4 && pos != 7)
     
    634636             lstyle && pos < toklen[tokmarker+5]; pos++, p++)
    635637        {
    636           if (*p != ':' && !isdigit(*p))
     638          if (*p != ':' && !isASCIIDigit(*p))
    637639            lstyle = 0;
    638640          else if (*p == ':' && pos != (toklen[tokmarker+5]-3)
     
    721723      */
    722724      if ((numtoks >= 4) && toklen[0] == 8 && toklen[1] == 7 &&
    723           (*tokens[2] == '<' || isdigit(*tokens[2])) )
     725          (*tokens[2] == '<' || isASCIIDigit(*tokens[2])) )
    724726      {
    725727        p = tokens[0];
    726         if ( isdigit(p[0]) && isdigit(p[1]) && p[2]=='-' &&
    727              isdigit(p[3]) && isdigit(p[4]) && p[5]=='-' &&
    728              isdigit(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]) )
    729731        {
    730732          p = tokens[1];
    731           if ( isdigit(p[0]) && isdigit(p[1]) && p[2]==':' &&
    732                isdigit(p[3]) && isdigit(p[4]) &&
     733          if ( isASCIIDigit(p[0]) && isASCIIDigit(p[1]) && p[2]==':' &&
     734               isASCIIDigit(p[3]) && isASCIIDigit(p[4]) &&
    733735               (p[5]=='A' || p[5]=='P') && p[6]=='M')
    734736          {
     
    742744                for (pos = 1; (lstyle && pos < toklen[2]); pos++)
    743745                {
    744                   if (!isdigit(*++p))
     746                  if (!isASCIIDigit(*++p))
    745747                    lstyle = 0;
    746748                }
     
    846848      p = &(line[toklen[0]]);
    847849      /* \s(\d\d-\d\d-\d\d)\s+(\d\d:\d\d)\s */
    848       if (numtoks >= 4 && toklen[0] <= 18 && isdigit(*tokens[0]) &&
     850      if (numtoks >= 4 && toklen[0] <= 18 && isASCIIDigit(*tokens[0]) &&
    849851         (linelen - toklen[0]) >= (53-18)                        &&
    850852         p[18-18] == ' ' && p[34-18] == ' '                      &&
    851853         p[37-18] == '-' && p[40-18] == '-' && p[43-18] == ' '   &&
    852854         p[45-18] == ' ' && p[48-18] == ':' && p[51-18] == ' '   &&
    853          isdigit(p[35-18]) && isdigit(p[36-18])                  &&
    854          isdigit(p[38-18]) && isdigit(p[39-18])                  &&
    855          isdigit(p[41-18]) && isdigit(p[42-18])                  &&
    856          isdigit(p[46-18]) && isdigit(p[47-18])                  &&
    857          isdigit(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])
    858860      )
    859861      {
     
    863865          for (pos = 1; lstyle && pos < toklen[0]; pos++)
    864866          {
    865             if (!isdigit(tokens[0][pos]))
     867            if (!isASCIIDigit(tokens[0][pos]))
    866868              lstyle = 0;
    867869          }
     
    10031005           *  \s+(.+)$
    10041006          */
    1005           if (isdigit(*tokens[pos]) /* size */
     1007          if (isASCIIDigit(*tokens[pos]) /* size */
    10061008              /* (\w\w\w) */
    1007            && toklen[pos+1] == 3 && isalpha(*tokens[pos+1]) &&
    1008               isalpha(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])
    10091011              /* (\d|\d\d) */
    1010            && isdigit(*tokens[pos+2]) &&
     1012           && isASCIIDigit(*tokens[pos+2]) &&
    10111013                (toklen[pos+2] == 1 ||
    1012                   (toklen[pos+2] == 2 && isdigit(tokens[pos+2][1])))
    1013            && toklen[pos+3] >= 4 && isdigit(*tokens[pos+3])
     1014                  (toklen[pos+2] == 2 && isASCIIDigit(tokens[pos+2][1])))
     1015           && toklen[pos+3] >= 4 && isASCIIDigit(*tokens[pos+3])
    10141016              /* (\d\:\d\d\:\d\d|\d\d\:\d\d\:\d\d) */
    10151017           && (toklen[pos+3] <= 5 || (
    10161018               (toklen[pos+3] == 7 || toklen[pos+3] == 8) &&
    10171019               (tokens[pos+3][toklen[pos+3]-3]) == ':'))
    1018            && isdigit(tokens[pos+3][toklen[pos+3]-2])
    1019            && isdigit(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])
    10201022           && (
    10211023              /* (\d\d\d\d) */
    10221024                 ((toklen[pos+3] == 4 || toklen[pos+3] == 5) &&
    1023                   isdigit(tokens[pos+3][1]) &&
    1024                   isdigit(tokens[pos+3][2])  )
     1025                  isASCIIDigit(tokens[pos+3][1]) &&
     1026                  isASCIIDigit(tokens[pos+3][2])  )
    10251027              /* (\d\:\d\d|\d\:\d\d\:\d\d) */
    10261028              || ((toklen[pos+3] == 4 || toklen[pos+3] == 7) &&
    10271029                  (tokens[pos+3][1]) == ':' &&
    1028                   isdigit(tokens[pos+3][2]) && isdigit(tokens[pos+3][3]))
     1030                  isASCIIDigit(tokens[pos+3][2]) && isASCIIDigit(tokens[pos+3][3]))
    10291031              /* (\d\d\:\d\d|\d\d\:\d\d\:\d\d) */
    10301032              || ((toklen[pos+3] == 5 || toklen[pos+3] == 8) &&
    1031                   isdigit(tokens[pos+3][1]) && (tokens[pos+3][2]) == ':' &&
    1032                   isdigit(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]))
    10331035              )
    10341036           )
     
    10411043            for (pos = 0; lstyle && pos < toklen[tokmarker]; pos++)
    10421044            {
    1043               if (!isdigit(*p++))
     1045              if (!isASCIIDigit(*p++))
    10441046                lstyle = 0;
    10451047            }
     
    12011203      */
    12021204      if (numtoks >= 4 && toklen[0] < 13 &&
    1203           ((toklen[1] == 5 && *tokens[1] == '<') || isdigit(*tokens[1])) )
     1205          ((toklen[1] == 5 && *tokens[1] == '<') || isASCIIDigit(*tokens[1])) )
    12041206      {
    12051207        if (numtoks == 4
     
    12091211         && (toklen[3] == 4 || toklen[3] == 5)
    12101212         && (tokens[3][toklen[3]-3]) == ':'
    1211          && isdigit(tokens[2][0]) && isdigit(tokens[2][1])
    1212          && isdigit(tokens[2][3]) && isdigit(tokens[2][4])
    1213          && isdigit(tokens[2][6]) && isdigit(tokens[2][7])
    1214          && (toklen[2] < 9 || isdigit(tokens[2][8]))
    1215          && isdigit(tokens[3][toklen[3]-1]) && isdigit(tokens[3][toklen[3]-2])
    1216          && isdigit(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])
    12171219         )
    12181220        {
     
    12231225         && toklen[4] == 4 && toklen[5] == 5
    12241226         && (tokens[5][2]) == ':'
    1225          && isalpha(tokens[2][0]) && isalpha(tokens[2][1])
    1226          &&                          isalpha(tokens[2][2])
    1227          && isdigit(tokens[3][0]) && isdigit(tokens[3][1])
    1228          && isdigit(tokens[4][0]) && isdigit(tokens[4][1])
    1229          && isdigit(tokens[4][2]) && isdigit(tokens[4][3])
    1230          && isdigit(tokens[5][0]) && isdigit(tokens[5][1])
    1231          && isdigit(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])
    12321234         /* could also check that (&(tokens[5][5]) - tokens[2]) == 17 */
    12331235        )
     
    12431245            for (pos = 0; lstyle && pos < toklen[1]; pos++)
    12441246            {
    1245               if (!isdigit(*p++))
     1247              if (!isASCIIDigit(*p++))
    12461248                lstyle = 0;
    12471249            }
     
    12611263
    12621264        p = tokens[1];
    1263         if (isdigit(*p))
     1265        if (isASCIIDigit(*p))
    12641266        {
    12651267          result.type = FTPFileEntry;
     
    12711273        if (toklen[2] == 3) /* Chameleon */
    12721274        {
    1273           tbuf[0] = toupper(p[0]);
    1274           tbuf[1] = tolower(p[1]);
    1275           tbuf[2] = tolower(p[2]);
     1275          tbuf[0] = toASCIIUpper(p[0]);
     1276          tbuf[1] = toASCIILower(p[1]);
     1277          tbuf[2] = toASCIILower(p[2]);
    12761278          for (pos = 0; pos < (12*3); pos+=3)
    12771279          {
     
    13921394        {
    13931395          p = &line[pos];
    1394           if ((*p == '-' || *p == '=' || isdigit(*p)) &&
     1396          if ((*p == '-' || *p == '=' || isASCIIDigit(*p)) &&
    13951397              ((linelen == (pos+1)) ||
    13961398               (linelen >= (pos+3) && p[1] == ' ' && p[2] == ' ')) )
     
    14191421                for (pos = 0; lstyle && pos < toklen[tokmarker]; pos++)
    14201422                {
    1421                   if (!isdigit(tokens[tokmarker][pos]))
     1423                  if (!isASCIIDigit(tokens[tokmarker][pos]))
    14221424                    lstyle = 0;
    14231425                }
     
    14761478          }
    14771479        }
    1478         else if (isdigit(*tokens[tokmarker]))
     1480        else if (isASCIIDigit(*tokens[tokmarker]))
    14791481        {
    14801482          pos = toklen[tokmarker];
     
    14911493
    14921494          if ((pos == 4 || pos == 5)
    1493           &&  isdigit(*p) && isdigit(p[pos-1]) && isdigit(p[pos-2])
     1495          &&  isASCIIDigit(*p) && isASCIIDigit(p[pos-1]) && isASCIIDigit(p[pos-2])
    14941496          &&  ((pos == 5 && p[2] == ':') || 
    1495                (pos == 4 && (isdigit(p[1]) || p[1] == ':')))
     1497               (pos == 4 && (isASCIIDigit(p[1]) || p[1] == ':')))
    14961498             )
    14971499          {
    14981500            month_num = tokmarker+1; /* assumed position of month field */
    14991501            pos = tokmarker+2;       /* assumed position of mday field */
    1500             if (isdigit(*tokens[month_num])) /* positions are reversed */
     1502            if (isASCIIDigit(*tokens[month_num])) /* positions are reversed */
    15011503            {
    15021504              month_num++;
     
    15041506            }
    15051507            p = tokens[month_num];
    1506             if (isdigit(*tokens[pos])
     1508            if (isASCIIDigit(*tokens[pos])
    15071509            && (toklen[pos] == 1 ||
    1508                   (toklen[pos] == 2 && isdigit(tokens[pos][1])))
     1510                  (toklen[pos] == 2 && isASCIIDigit(tokens[pos][1])))
    15091511            && toklen[month_num] == 3
    1510             && isalpha(*p) && isalpha(p[1]) && isalpha(p[2])  )
     1512            && isASCIIAlpha(*p) && isASCIIAlpha(p[1]) && isASCIIAlpha(p[2])  )
    15111513            {
    15121514              pos = atoi(tokens[pos]);
     
    16021604
    16031605#endif // ENABLE(FTPDIR)
    1604 
  • trunk/WebCore/loader/TextResourceDecoder.cpp

    r25754 r26676  
    11/*
    2     This file is part of the KDE libraries
    3 
    42    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.
    64    Copyright (C) 2005, 2006, 2007 Alexey Proskuryakov ([email protected])
    75
     
    3230#include "HTMLNames.h"
    3331#include "TextCodec.h"
     32#include <wtf/ASCIICType.h>
     33
     34using namespace WTF;
    3435
    3536namespace WebCore {
     
    650651                       tag != titleTag && tag != baseTag &&
    651652                       (end || tag != htmlTag) && !enclosingTagName &&
    652                        (tag != headTag) && isalpha(tagBuffer[0])) {
     653                       (tag != headTag) && isASCIIAlpha(tagBuffer[0])) {
    653654                m_checkedForHeadCharset = true;
    654655                return true;
  • trunk/WebCore/platform/DeprecatedCString.cpp

    r15286 r26676  
    11/*
    2  * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
     2 * Copyright (C) 2003, 2007 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727#include "DeprecatedCString.h"
    2828
     29#include <wtf/ASCIICType.h>
    2930#include <wtf/Assertions.h>
    30 #include <ctype.h>
     31
     32using namespace WTF;
    3133
    3234namespace WebCore {
     
    112114        while( *str != 0 )
    113115        {
    114             *str = tolower(*str);
     116            *str = toASCIILower(*str);
    115117            str++;
    116118        }
     
    129131        while( *str != 0 )
    130132        {
    131             *str = toupper(*str);
     133            *str = toASCIIUpper(*str);
    132134            str++;
    133135        }
     
    185187                    pos++, index++;
    186188            else
    187                 while( (a=sub[pos]) && (b=str[index]) && tolower(a)==tolower(b) )
     189                while( (a=sub[pos]) && (b=str[index]) && toASCIILower(a)==toASCIILower(b) )
    188190                    pos++, index++;
    189191           
     
    212214            }
    213215        } else {
    214             c = tolower(c);
     216            c = toASCIILower(c);
    215217
    216218            for (unsigned i = 0; i != len; ++i) {
    217219                char chr = str[i];
    218                 chr = tolower(chr);
     220                chr = toASCIILower(chr);
    219221                found += chr == c;
    220222            }
  • trunk/WebCore/platform/DeprecatedString.cpp

    r25643 r26676  
    11/*
    2  * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
     2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5050using namespace std;
    5151using namespace KJS;
     52using namespace WTF;
    5253
    5354namespace WebCore {
     
    136137}
    137138
    138 
    139139static bool equal(const DeprecatedChar *a, const char *b, int l)
    140140{
     
    154154    ASSERT(l >= 0);
    155155    while (l--) {
    156         if (tolower(*a) != tolower(*b))
     156        if (toASCIILower(*a) != toASCIILower(*b))
    157157            return false;
    158158        a++; b++;
     
    165165    ASSERT(l >= 0);
    166166    while (l--) {
    167         if (tolower(a->unicode()) != tolower(*b))
     167        if (toASCIILower(a->unicode()) != static_cast<unsigned char>(toASCIILower(*b)))
    168168            return false;
    169169        a++; b++;
     
    176176    ASSERT(l >= 0);
    177177    while (l--) {
    178         if (tolower(a->unicode()) != tolower(b->unicode()))
     178        if (toASCIILower(a->unicode()) != toASCIILower(b->unicode()))
    179179            return false;
    180180        a++; b++;
     
    185185static inline bool equalCaseInsensitive(char c1, char c2)
    186186{
    187     return tolower(c1) == tolower(c2);
     187    return toASCIILower(c1) == toASCIILower(c2);
    188188}
    189189
    190190static inline bool equalCaseInsensitive(DeprecatedChar c1, char c2)
    191191{
    192     return tolower(c1.unicode()) == tolower(static_cast<unsigned char>(c2));
     192    return toASCIILower(c1.unicode()) == static_cast<unsigned char>(toASCIILower(c2));
    193193}
    194194
    195195static bool isCharacterAllowedInBase(DeprecatedChar c, int base)
    196196{
    197     int uc = c.unicode();
     197    ::UChar uc = c.unicode();
    198198    if (uc > 0x7F)
    199199        return false;
    200     if (isdigit(uc))
     200    if (isASCIIDigit(uc))
    201201        return uc - '0' < base;
    202     if (isalpha(uc)) {
     202    if (isASCIIAlpha(uc)) {
    203203        if (base > 36)
    204204            base = 36;
     
    974974    } else {
    975975        for ( i = 0; i < lstr; i++ ) {
    976             hthis += tolower(uthis[i].unicode());
    977             hstr += tolower(ustr[i].unicode());
     976            hthis += toASCIILower(uthis[i].unicode());
     977            hstr += toASCIILower(ustr[i].unicode());
    978978        }
    979979        i = 0;
     
    983983            if ( i == delta )
    984984                return -1;
    985             hthis += tolower(uthis[i + lstr].unicode());
    986             hthis -= tolower(uthis[i].unicode());
     985            hthis += toASCIILower(uthis[i + lstr].unicode());
     986            hthis -= toASCIILower(uthis[i].unicode());
    987987            i++;
    988988        }
     
    10221022            } while (--n);
    10231023        } else {
    1024             int lc = tolower(*chs);
     1024            unsigned char lc = toASCIILower(*chs);
    10251025            do {
    1026                 if (tolower(*++ptr) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne)) {
     1026                if (toASCIILower(*++ptr) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne)) {
    10271027                    return data->_length - chsLength - n + 1;
    10281028                }
     
    10411041            } while (--n);
    10421042        } else {
    1043             int lc = tolower((unsigned char)*chs);
     1043            unsigned char lc = toASCIILower(*chs);
    10441044            do {
    1045                 if (tolower((++ptr)->unicode()) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne)) {
     1045                if (toASCIILower((++ptr)->unicode()) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne)) {
    10461046                    return data->_length - chsLength - n + 1;
    10471047                }
     
    11631163                count += *cPtr++ == ac;
    11641164        } else {                                        // case insensitive
    1165             int lc = tolower(ac);
     1165            unsigned char lc = toASCIILower(ac);
    11661166            while (n--) {
    1167                 count += tolower(*cPtr++) == lc;
     1167                count += toASCIILower(*cPtr++) == lc;
    11681168            }
    11691169        }
     
    11761176                count += *uc++ == c;
    11771177        } else {                                        // case insensitive
    1178             int lc = tolower(c.unicode());
     1178            ::UChar lc = toASCIILower(c.unicode());
    11791179            while (n--) {
    1180                 count += tolower(uc->unicode()) == lc;
     1180                count += toASCIILower(uc->unicode()) == lc;
    11811181                uc++;
    11821182            }
     
    12171217            } while (--n);
    12181218        } else {
    1219             int lc = tolower(c);
     1219            char lc = toASCIILower(c);
    12201220            do {
    1221                 count += tolower(*p) == lc && equalCaseInsensitive(p + 1, str + 1, len - 1);
     1221                count += toASCIILower(*p) == lc && equalCaseInsensitive(p + 1, str + 1, len - 1);
    12221222                p++;
    12231223            } while (--n);
     
    12321232            } while (--n);
    12331233        } else {
    1234             int lc = tolower(c);
     1234            unsigned char lc = toASCIILower(c);
    12351235            do {
    1236                 count += tolower(p->unicode()) == lc && equalCaseInsensitive(p + 1, str + 1, len - 1);
     1236                count += toASCIILower(p->unicode()) == lc && equalCaseInsensitive(p + 1, str + 1, len - 1);
    12371237                p++;
    12381238            } while (--n);
     
    14151415        length--;
    14161416        IntegralType digitValue;
    1417         int c = p->unicode();
    1418         if (isdigit(c))
     1417        ::UChar c = p->unicode();
     1418        if (isASCIIDigit(c))
    14191419            digitValue = c - '0';
    14201420        else if (c >= 'a')
  • trunk/WebCore/platform/DeprecatedString.h

    r25321 r26676  
    11/*
    2  * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
     2 * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828
    2929#include "DeprecatedCString.h"
    30 
     30#include <wtf/ASCIICType.h>
    3131#include <wtf/unicode/Unicode.h>
    32 
    33 #include <ctype.h>
    3432
    3533/* On some ARM platforms GCC won't pack structures by default so sizeof(DeprecatedChar)
     
    124122    // Use isspace() for basic Latin-1.
    125123    // 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);
    127125#elif USE(QT4_UNICODE)
    128126    return QChar(c).isSpace();
     
    134132#if USE(ICU_UNICODE)
    135133    // 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);
    137135#elif USE(QT4_UNICODE)
    138136    return QChar(c).toLower().unicode();
     
    144142#if USE(ICU_UNICODE)
    145143    // 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);
    147145#elif USE(QT4_UNICODE)
    148146    return QChar(c).toUpper().unicode();
  • trunk/WebCore/platform/KURL.cpp

    r25085 r26676  
    3939
    4040using namespace std;
     41using namespace WTF;
    4142
    4243namespace WebCore {
     
    10311032            // possible start of port
    10321033            portEnd = portStart;
    1033             while (isdigit(url[portEnd])) {
     1034            while (isASCIIDigit(url[portEnd])) {
    10341035                portEnd++;
    10351036            }
  • trunk/WebCore/platform/StringImpl.cpp

    r25754 r26676  
    5252    // Use isspace() for basic Latin-1.
    5353    // This will include newlines, which aren't included in unicode DirWS.
    54     return c <= 0x7F ? isspace(c) : direction(c) == WhiteSpaceNeutral;
     54    return c <= 0x7F ? isASCIISpace(c) : direction(c) == WhiteSpaceNeutral;
    5555}   
    5656   
     
    258258    // FIXME: No range checking here.
    259259    for (unsigned i = from; i < len; i++)
    260         if (m_data[i] > 0x7F || !isspace(m_data[i]))
     260        if (m_data[i] > 0x7F || !isASCIISpace(m_data[i]))
    261261            return false;
    262262    return true;
     
    390390    for (unsigned i = 0; i < m_length; i++) {
    391391        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);
    396393        ored |= c;
    397394    }
     
    427424        UChar c = m_data[i];
    428425        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);
    433427    }
    434428    if (!(ored & ~0x7F))
     
    814808    } else {
    815809        for (int i = 0; i < lstr; i++ ) {
    816             hthis += tolower(uthis[i]);
    817             hstr += tolower(ustr[i]);
     810            hthis += toASCIILower(uthis[i]);
     811            hstr += toASCIILower(ustr[i]);
    818812        }
    819813        int i = 0;
     
    823817            if (i == delta)
    824818                return -1;
    825             hthis += tolower(uthis[i + lstr]);
    826             hthis -= tolower(uthis[i]);
     819            hthis += toASCIILower(uthis[i + lstr]);
     820            hthis -= toASCIILower(uthis[i]);
    827821            i++;
    828822        }
     
    886880    } else {
    887881        for (i = 0; i < lstr; i++) {
    888             hthis += tolower(uthis[index + i]);
    889             hstr += tolower(ustr[i]);
     882            hthis += toASCIILower(uthis[index + i]);
     883            hstr += toASCIILower(ustr[i]);
    890884        }
    891885        i = index;
     
    896890                return -1;
    897891            i--;
    898             hthis -= tolower(uthis[i + lstr]);
    899             hthis += tolower(uthis[i]);
     892            hthis -= toASCIILower(uthis[i + lstr]);
     893            hthis += toASCIILower(uthis[i]);
    900894        }
    901895    }
     
    10861080    bool equal = true;
    10871081    for (unsigned i = 0; i != length; ++i) {
    1088         unsigned char bc = b[i];
     1082        char bc = b[i];
    10891083        if (!bc)
    10901084            return false;
    10911085        UChar ac = as[i];
    10921086        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));
    10981088    }
    10991089
  • trunk/WebCore/platform/TextEncodingRegistry.cpp

    r24203 r26676  
    3030#include "TextCodecLatin1.h"
    3131#include "TextCodecUTF16.h"
    32 #include <ctype.h>
     32#include <wtf/ASCIICType.h>
    3333#include <wtf/Assertions.h>
    3434#include <wtf/HashMap.h>
     
    4343#include "qt/TextCodecQt.h"
    4444#endif
     45
     46using namespace WTF;
    4547
    4648namespace WebCore {
     
    6567            do
    6668                c1 = *s1++;
    67             while (c1 && !isalnum(c1));
     69            while (c1 && !isASCIIAlphanumeric(c1));
    6870            do
    6971                c2 = *s2++;
    70             while (c2 && !isalnum(c2));
    71             if (tolower(c1) != tolower(c2))
     72            while (c2 && !isASCIIAlphanumeric(c2));
     73            if (toASCIILower(c1) != toASCIILower(c2))
    7274                return false;
    7375        } while (c1 && c2);
     
    9193                    return h;
    9294                }
    93             } while (!isalnum(c));
    94             h += tolower(c);
     95            } while (!isASCIIAlphanumeric(c));
     96            h += toASCIILower(c);
    9597            h += (h << 10);
    9698            h ^= (h >> 6);
     
    219221    for (size_t i = 0; i < length; ++i) {
    220222        UChar c = characters[i];
    221         if (isalnum(c)) {
     223        if (isASCIIAlphanumeric(c)) {
    222224            if (j == maxEncodingNameLength)
    223225                return 0;
  • trunk/WebCore/platform/mac/KeyEventMac.mm

    r21445 r26676  
    11/*
    2  * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
     2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828
    2929#import "Logging.h"
     30#import <wtf/ASCIICType.h>
     31
     32using namespace WTF;
    3033
    3134namespace WebCore {
     
    323326            // For now, just fall through to the default.
    324327        default:
    325             return String::format("U+%04X", toupper(c));
     328            return String::format("U+%04X", toASCIIUpper(c));
    326329    }
    327330}
  • trunk/WebCore/platform/win/KeyEventWin.cpp

    r25520 r26676  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#include "config.h"
    2727#include "PlatformKeyboardEvent.h"
     28
    2829#include <windows.h>
     30#include <wtf/ASCIICType.h>
    2931
    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
     32using namespace WTF;
    3533
    3634namespace WebCore {
     35
     36static const unsigned REPEAT_COUNT_MASK = 0x0000FFFF;
     37static const unsigned NEW_RELEASE_STATE_MASK = 0x80000000;
     38static const unsigned PREVIOUS_DOWN_STATE_MASK = 0x40000000;
     39
     40static const unsigned short HIGH_BIT_MASK_SHORT = 0x8000;
    3741
    3842// FIXME: This is incomplete. We could change this to mirror
    3943// more like what Firefox does, and generate these switch statements
    4044// at build time.
    41 static String keyIdentifierForWindowsKeyCode(short keyCode)
     45static String keyIdentifierForWindowsKeyCode(unsigned short keyCode)
    4246{
    4347    switch (keyCode) {
     
    130134            return "U+007F";
    131135        default:
    132             return String::format("U+%04X", toupper(keyCode));
     136            return String::format("U+%04X", toASCIIUpper(keyCode));
    133137    }
    134138}
  • trunk/WebCore/platform/win/PopupMenuWin.cpp

    r26484 r26676  
    6060static LRESULT CALLBACK PopupWndProc(HWND, UINT, WPARAM, LPARAM);
    6161
     62// FIXME: Remove this as soon as practical.
     63static inline bool isASCIIPrintable(unsigned c)
     64{
     65    return c >= 0x20 && c <= 0x7E;
     66}
     67
    6268PopupMenu::PopupMenu(PopupMenuClient* client)
    6369    : m_popupClient(client)
     
    674680                        break;
    675681                    default:
    676                         if (isprint(::MapVirtualKey(LOWORD(wParam), 2)))
     682                        if (isASCIIPrintable(::MapVirtualKey(LOWORD(wParam), 2)))
    677683                            // Send the keydown to the WebView so it can be used for type-ahead find
    678684                            ::SendMessage(popup->client()->clientDocument()->view()->containingWindow(), message, wParam, lParam);
  • trunk/WebCore/plugins/win/PluginViewWin.cpp

    r26632 r26676  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5757#include <kjs/JSLock.h>
    5858#include <kjs/value.h>
     59#include <wtf/ASCIICType.h>
    5960
    6061using KJS::ExecState;
     
    6768
    6869using std::min;
     70
     71using namespace WTF;
    6972
    7073namespace WebCore {
     
    943946
    944947        if (capitalizeCharacter && name[i] >= 'a' && name[i] <= 'z')
    945             c = toupper(name[i]);
     948            c = toASCIIUpper(name[i]);
    946949        else if (!capitalizeCharacter && name[i] >= 'A' && name[i] <= 'Z')
    947             c = tolower(name[i]);
     950            c = toASCIILower(name[i]);
    948951        else
    949952            c = name[i];
  • trunk/WebCore/rendering/RenderText.cpp

    r26384 r26676  
    405405                else
    406406                    w += monospaceCharacterWidth;
    407                 if (isspace(c) && !isspace(previousChar))
     407                if (isASCIISpace(c) && !isASCIISpace(previousChar))
    408408                    w += f.wordSpacing();
    409409            }
  • trunk/WebKit/ChangeLog

    r26661 r26676  
     12007-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
    1192007-10-16  John Sullivan  <[email protected]>
    220
  • trunk/WebKit/Misc/WebNSURLExtras.mm

    r24818 r26676  
    11/*
    2  * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
     2 * Copyright (C) 2005, 2007 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Alexey Proskuryakov ([email protected])
    44 *
     
    2828 */
    2929
    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>
    3238#import <JavaScriptCore/Assertions.h>
    33 #import <WebKit/WebKitNSStringExtras.h>
    34 #import <WebKit/WebNSDataExtras.h>
    35 #import <WebKit/WebNSObjectExtras.h>
    36 #import <WebKit/WebLocalizableStrings.h>
    3739#import <WebCore/KURL.h>
    3840#import <WebCore/LoaderNSURLExtras.h>
    39 
    4041#import <WebKitSystemInterface.h>
    41 #import "WebSystemInterface.h"
    42 
    43 #import <Foundation/NSURLRequest.h>
    44 
    4542#import <unicode/uchar.h>
    4643#import <unicode/uidna.h>
     
    4845
    4946using namespace WebCore;
     47using namespace WTF;
    5048
    5149typedef void (* StringRangeApplierFunction)(NSString *string, NSRange range, void *context);
     
    605603    BOOL changed = NO;
    606604    for (i = 0; i < range.length; ++i) {
    607         UInt8 c = buffer[range.location + i];
    608         UInt8 lower = tolower(c);
     605        char c = buffer[range.location + i];
     606        char lower = toASCIILower(c);
    609607        if (c != lower) {
    610608            buffer[range.location + i] = lower;
  • trunk/WebKit/WebKitPrefix.h

    r25000 r26676  
    7777#endif
    7878
     79#include <wtf/DisallowCType.h>
     80
    7981/* Work around bug with C++ library that screws up Objective-C++ when exception support is disabled. */
    8082#undef try
  • trunk/WebKit/WebView/WebHTMLView.mm

    r26629 r26676  
    113113using namespace WebCore;
    114114using namespace HTMLNames;
     115using namespace WTF;
    115116
    116117@interface NSWindow (BorderViewAccess)
     
    20712072    ASSERT(selectorName[selectorNameLength - 1] == ':');
    20722073    Vector<char, 256> commandName(selectorNameLength - 1 + 1);
    2073     commandName[0] = toupper(selectorName[0]);
     2074    commandName[0] = toASCIIUpper(selectorName[0]);
    20742075    memcpy(&commandName[1], &selectorName[1], selectorNameLength - 2);
    20752076    commandName[selectorNameLength - 1] = 0;
     
    59165917}
    59175918
    5918 // WebHTMLView gives us a crack at key events it sees.  Return whether we consumed the event.
     5919// WebHTMLView gives us a crack at key events it sees. Return whether we consumed the event.
    59195920// The features for the various keys mimic NSTextView.
    59205921- (BOOL)filterKeyDown:(NSEvent *)event
    59215922{
    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];
    59515934        }
     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
    59525964    }
    59535965    return NO;
Note: See TracChangeset for help on using the changeset viewer.