Changeset 32609 in webkit for trunk/JavaScriptCore/kjs/ustring.cpp
- Timestamp:
- Apr 27, 2008, 10:59:07 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ustring.cpp
r32242 r32609 2 2 /* 3 3 * Copyright (C) 1999-2000 Harri Porten ([email protected]) 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 5 * Copyright (C) 2007 Cameron Zwarich ([email protected]) 6 6 * … … 862 862 } 863 863 864 CString UString::cstring() const 865 { 866 int length = size(); 867 int neededSize = length + 1; 868 char* buf = new char[neededSize]; 869 870 const UChar* p = data(); 871 char* q = buf; 872 const UChar* limit = p + length; 873 while (p != limit) { 874 *q = static_cast<char>(p[0]); 875 ++p; 876 ++q; 877 } 878 *q = '\0'; 879 880 return CString::adopt(buf, length); 864 bool UString::getCString(CStringBuffer& buffer) const 865 { 866 int length = size(); 867 int neededSize = length + 1; 868 buffer.resize(neededSize); 869 char* buf = buffer.data(); 870 871 UChar ored = 0; 872 const UChar* p = data(); 873 char* q = buf; 874 const UChar* limit = p + length; 875 while (p != limit) { 876 UChar c = p[0]; 877 ored |= c; 878 *q = static_cast<char>(c); 879 ++p; 880 ++q; 881 } 882 *q = '\0'; 883 884 return !(ored & 0xFF00); 881 885 } 882 886 … … 958 962 959 963 // FIXME: If tolerateTrailingJunk is true, then we want to tolerate non-8-bit junk 960 // after the number, so is8Bit is too strict a check. 961 if (!is8Bit()) 964 // after the number, so this is too strict a check. 965 CStringBuffer s; 966 if (!getCString(s)) 962 967 return NaN; 963 964 CString s = cstring(); 965 const char* c = s.c_str(); 968 const char* c = s.data(); 966 969 967 970 // skip leading white space
Note:
See TracChangeset
for help on using the changeset viewer.