Subversion Repositories JSX

Compare Revisions

Last modification

Ignore whitespace Rev 474 → Rev 475

/trunk/regexp.js
98,9 → 98,20
var _RegExp2 = jsx.object.extend(
(/** @constructor */function () {
var
_UCDfields = ["codePoint",, "propertyClass"],
_destructure = jsx.array.destructure,
_WideString = _jsx_object.getFeature(
jsx, "string", "unicode", "WideString"),
_fromCharCode = function (codePoint) {
if (codePoint > 0xFFFF)
{
return _WideString.fromCharCode(codePoint);
}
 
return String.fromCharCode(codePoint);
},
 
propertyClasses,
ucdFields = ["codePoint",, "propertyClass"],
 
_parseUCDText = function () {
(new jsx.net.http.Request(
108,17 → 119,33
function (xhr) {
var lines = xhr.responseText.split(/\r?\n|\r/).map(
function (e) {
return _destructure(e.split(";"), _UCDfields);
var entry = _destructure(e.split(";"), ucdFields);
entry.codePoint = parseInt(entry.codePoint, 16);
return entry;
});
 
lines.sort(function (a, b) {
return (a.propertyClass < b.propertyClass
|| (a.propertyClass === b.propertyClass
&& a.codePoint < b.codePoint))
? -1
: ((a.propertyClass === b.propertyClass
&& a.codePoint === b.codePoint)
? 0 : 1);
if (a.propertyClass < b.propertyClass)
{
return -1;
}
 
if (a.propertyClass > b.propertyClass)
{
return 1;
}
 
if (a.codePoint < b.codePoint)
{
return -1;
}
 
if (a.codePoint > b.codePoint)
{
return 1;
}
 
return 0;
});
 
propertyClasses = _RegExp2.propertyClasses = {};
129,10 → 156,10
line = lines[i],
propertyClass = line.propertyClass,
prevClass,
codePoint = parseInt(line.codePoint, 16),
codePoint = line.codePoint,
prevCodePoint;
 
if (isNaN(codePoint) || codePoint > 0xFFFF)
if (isNaN(codePoint) || (codePoint > 0xFFFF && !_WideString))
{
continue;
}
143,11 → 170,13
{
if (startRange)
{
propertyClasses[prevClass] += "-" + String.fromCharCode(prevCodePoint);
propertyClasses[prevClass] +=
"-" + _fromCharCode(prevCodePoint);
}
}
 
propertyClasses[propertyClass] = String.fromCharCode(codePoint);
propertyClasses[propertyClass] =
_fromCharCode(codePoint);
 
var startRange = false;
}
157,12 → 186,14
{
if (startRange)
{
propertyClasses[prevClass] += "-" + String.fromCharCode(prevCodePoint);
propertyClasses[prevClass] +=
"-" + _fromCharCode(prevCodePoint);
 
startRange = false;
}
 
propertyClasses[propertyClass] += String.fromCharCode(codePoint);
propertyClasses[propertyClass] +=
_fromCharCode(codePoint);
}
else
{
176,7 → 207,8
 
if (startRange)
{
propertyClasses[prevClass] += "-" + String.fromCharCode(prevCodePoint);
propertyClasses[prevClass] +=
"-" + _fromCharCode(prevCodePoint);
}
}
)).send();
/trunk/test/regexp.php
14,7 → 14,7
-->
</style>
<script type="text/javascript"
src="../builder?src=object,dom,dom/timeout,test/test,http&amp;verbose=1"></script>
src="../builder?src=object,string/unicode,dom,dom/timeout,test/test,http&amp;verbose=1"></script>
<script type="text/javascript" src="../regexp.js"></script>
<script type="text/javascript" src="../UnicodeData.js"></script>
<script type="text/javascript" src="regexp-test.js"></script>
/trunk/test/regexp-test.js
599,6 → 599,7
name: 'Load UCD dynamically with'
+ ' <acronym title="XMLHttpRequest">XHR</acronym> (text)',
code: function () {
var propertyClasses = RegExp2.propertyClasses;
delete RegExp2.propertyClasses;
assert(typeof RegExp2.propertyClasses == "undefined");
 
607,10 → 608,19
assert(typeof RegExp2.ucdScriptPath == "undefined");
assert(typeof RegExp2.ucdTextPath == "string");
 
var rx = new RegExp2("\\p{Zp}");
var rx;
jsx.tryThis(
function () {
rx = new RegExp2("\\p{Ll}");
},
function (e) {
jsx.error(e);
});
 
var classLl = "[" + RegExp2.propertyClasses["Ll"] + "]";
RegExp2.ucdScriptPath = ucdScriptPath;
assert(rx.source == "[\u2029]");
RegExp2.propertyClasses = propertyClasses;
assert(rx && (rx.source == classLl));
 
if (!jsx.info(rx))
{