From bf082600c3f459b31dff6d29e11a23b70f3e3988 Mon Sep 17 00:00:00 2001 From: Maik Opitz Date: Tue, 1 Nov 2016 15:46:40 +0100 Subject: [PATCH 1/5] fixed RegEx with newer gcc versions --- AppKit/CPTextView/CPTextView.j | 6 +++--- AppKit/CPTextView/_CPRTFParser.j | 8 ++++---- Foundation/CPDate.j | 6 +++--- Foundation/CPDateFormatter.j | 4 ++-- Foundation/CPDecimal.j | 2 +- Foundation/_CPCollectionKVCOperators.j | 2 +- Tools/nib2cib/Converter.j | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 141bffa0b..9cb625db4 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -1848,18 +1848,18 @@ var kDelegateRespondsTo_textShouldBeginEditing + (JSObject)_wordBoundaryRegex { - return /(^[0-9][\.,])|(^.[^-\.,+#'"!§$%&/\(<\[\]>\)=?`´*\s{}\|¶])/m; + return new RegExp("/(^[0-9][\.,])|(^.[^-\.,+#'\"!§$%&/\(<\[\]>\)=?`´*\s{}\|¶])/m"); } + (JSObject)_paragraphBoundaryRegex { - return /^.[^\n\r]/m; + return new RegExp("/^.[^\n\r]/m"); } + (JSObject)_whitespaceRegex { // do not include \n here or we will get cross paragraph selections - return /^.[ \t]+/m; + return new RegExp("/^.[ \t]+/m"); } - (CPRange)_characterRangeForIndex:(unsigned)index asDefinedByRegex:(JSObject)regex diff --git a/AppKit/CPTextView/_CPRTFParser.j b/AppKit/CPTextView/_CPRTFParser.j index f1f94db99..a93e3081b 100644 --- a/AppKit/CPTextView/_CPRTFParser.j +++ b/AppKit/CPTextView/_CPRTFParser.j @@ -350,7 +350,7 @@ var kRgsymRtf = { var hex = ''; - while (/[a-fA-F0-9\']/.test(ch)) + while (new RegExp("/[a-fA-F0-9\']/").test(ch)) { if (ch == "'") { @@ -377,7 +377,7 @@ var kRgsymRtf = { var code = ''; - while (/[0-9]/.test(ch)) + while (new RegExp("/[0-9]/").test(ch)) { code += (ch + ''); ch = _rtf.charAt(++_currentParseIndex); @@ -621,7 +621,7 @@ var kRgsymRtf = { if (!/[a-zA-Z]/.test(ch)) return [self _translateKeyword:ch parameter:nil fParameter:fParam]; - while (/[a-zA-Z]/.test(ch)) + while (new RegExp("/[a-zA-Z]/").test(ch)) { keyword += ch; ch = rtf.charAt(++_currentParseIndex); @@ -635,7 +635,7 @@ var kRgsymRtf = { fParam = true; - while (/[0-9]/.test(ch)) + while (new RegExp("/[0-9]/").test(ch)) { param += (ch + ''); ch = rtf.charAt(++_currentParseIndex); diff --git a/Foundation/CPDate.j b/Foundation/CPDate.j index 574873ef6..55599f343 100644 --- a/Foundation/CPDate.j +++ b/Foundation/CPDate.j @@ -115,7 +115,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001, 0, 1, 0, 0, 0, 0)); */ - (id)initWithString:(CPString)description { - var format = /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}) ([-+])(\d{2})(\d{2})/, + var format = new RegExp("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}) ([-+])(\d{2})(\d{2})/"), d = description.match(new RegExp(format)); if (!d || d.length != 10) @@ -262,7 +262,7 @@ Date.parseISO8601 = function (date) // First, check for native parsing. timestamp = Date.parse(date); - if (isNaN(timestamp) && (struct = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(date))) + if (isNaN(timestamp) && (struct = new RegExp("/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/").exec(date))) { // avoid NaN timestamps caused by "undefined" values being passed to Date.UTC for (var i = 0, k; (k = numericKeys[i]); ++i) @@ -294,4 +294,4 @@ function _isNumberType(value) return YES; else return NO; -} \ No newline at end of file +} diff --git a/Foundation/CPDateFormatter.j b/Foundation/CPDateFormatter.j index f66179ba2..d7da96110 100644 --- a/Foundation/CPDateFormatter.j +++ b/Foundation/CPDateFormatter.j @@ -1931,7 +1931,7 @@ var defaultDateFormatterBehavior = CPDateFormatterBehavior10_4, */ - (int)_secondsFromTimeZoneDefaultFormatString:(CPString)aTimeZoneFormatString { - var format = /\w*([HPG-GMT])?([+-])(\d{1,2})([:])?(\d{2})\w*/, + var format = new RegExp("/\w*([HPG-GMT])?([+-])(\d{1,2})([:])?(\d{2})\w*/"), result = aTimeZoneFormatString.match(new RegExp(format)), seconds = 0; @@ -1969,7 +1969,7 @@ var defaultDateFormatterBehavior = CPDateFormatterBehavior10_4, var character = [aToken characterAtIndex:0], length = [aToken length], targetedArray, - format = /\w*([HPG-GMT])?([+-])(\d{1,2})([:])?(\d{2})\w*/, + format = new RegExp("/\w*([HPG-GMT])?([+-])(\d{1,2})([:])?(\d{2})\w*/"), result = aString.match(new RegExp(format)); switch (character) diff --git a/Foundation/CPDecimal.j b/Foundation/CPDecimal.j index 72fbe89cc..5946a8a7c 100644 --- a/Foundation/CPDecimal.j +++ b/Foundation/CPDecimal.j @@ -119,7 +119,7 @@ function CPDecimalMakeWithString(string, locale) // Note: this doesn't accept .01 for example, should it? // If yes simply add '?' after integer part group, i.e. ([+\-]?)((?:0|[1-9]\d*)?) // Note: now it accept .01 style. - var matches = string.match(/^([+\-]?)((?:0|[0-9]\d*)?)(?:\.(\d*))?(?:[eE]([+\-]?)(\d+))?$/); + var matches = string.match(new RegExp("/^([+\-]?)((?:0|[0-9]\d*)?)(?:\.(\d*))?(?:[eE]([+\-]?)(\d+))?$/")); if (!matches) return CPDecimalMakeNaN(); diff --git a/Foundation/_CPCollectionKVCOperators.j b/Foundation/_CPCollectionKVCOperators.j index 6180c29f7..3d320479c 100644 --- a/Foundation/_CPCollectionKVCOperators.j +++ b/Foundation/_CPCollectionKVCOperators.j @@ -22,7 +22,7 @@ @import "CPObject.j" -var _CPCollectionKVCOperatorSimpleRE = /^@(avg|count|m(ax|in)|sum|unionOfObjects|distinctUnionOfObjects|unionOfArrays|distinctUnionOfArrays|distinctUnionOfSets)(\.|$)/; +var _CPCollectionKVCOperatorSimpleRE = new RegExp("/^@(avg|count|m(ax|in)|sum|unionOfObjects|distinctUnionOfObjects|unionOfArrays|distinctUnionOfArrays|distinctUnionOfSets)(\.|$)/"); @implementation _CPCollectionKVCOperator : CPObject diff --git a/Tools/nib2cib/Converter.j b/Tools/nib2cib/Converter.j index 09407a086..251384a14 100644 --- a/Tools/nib2cib/Converter.j +++ b/Tools/nib2cib/Converter.j @@ -165,7 +165,7 @@ ConverterConversionException = @"ConverterConversionException"; if (system.engine === "rhino") plistContents = String(java.lang.String(plistContents).replaceAll("\\\\s*CF\\$UID\\s*\\<\/key\\>", "CP\\$UID")); else - plistContents = plistContents.replace(/\\s*CF\$UID\s*\<\/key\>/g, "CP$UID"); + plistContents = plistContents.replace("/\\s*CF\$UID\s*\<\/key\>/g", "CP$UID"); plistContents = plistContents.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]<\/string>/g, function(c) { From fb43f8bf1a1b5f750643f8471c0ff25690695bf8 Mon Sep 17 00:00:00 2001 From: Maik Opitz Date: Wed, 2 Nov 2016 16:45:01 +0100 Subject: [PATCH 2/5] Regex nochmals angepasst --- AppKit/CPTextView/CPTextView.j | 6 +++--- AppKit/CPTextView/_CPRTFParser.j | 8 ++++---- Foundation/CPDate.j | 4 ++-- Foundation/CPDateFormatter.j | 4 ++-- Foundation/CPDecimal.j | 2 +- Foundation/_CPCollectionKVCOperators.j | 2 +- Tools/nib2cib/Converter.j | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 9cb625db4..e5877e838 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -1848,18 +1848,18 @@ var kDelegateRespondsTo_textShouldBeginEditing + (JSObject)_wordBoundaryRegex { - return new RegExp("/(^[0-9][\.,])|(^.[^-\.,+#'\"!§$%&/\(<\[\]>\)=?`´*\s{}\|¶])/m"); + return new RegExp("(^[0-9][\\.,])|(^.[^-\\.,+#'\\\"!§$%&/\\(<\\[\\]>\\)=?`´*\\s{}\\|¶])", "m"); } + (JSObject)_paragraphBoundaryRegex { - return new RegExp("/^.[^\n\r]/m"); + return new RegExp(/^.[^\n\r]/m); } + (JSObject)_whitespaceRegex { // do not include \n here or we will get cross paragraph selections - return new RegExp("/^.[ \t]+/m"); + return new RegExp(/^.[ \t]+/m); } - (CPRange)_characterRangeForIndex:(unsigned)index asDefinedByRegex:(JSObject)regex diff --git a/AppKit/CPTextView/_CPRTFParser.j b/AppKit/CPTextView/_CPRTFParser.j index a93e3081b..c26d221db 100644 --- a/AppKit/CPTextView/_CPRTFParser.j +++ b/AppKit/CPTextView/_CPRTFParser.j @@ -350,7 +350,7 @@ var kRgsymRtf = { var hex = ''; - while (new RegExp("/[a-fA-F0-9\']/").test(ch)) + while (new RegExp("[a-fA-F0-9\\']").test(ch)) { if (ch == "'") { @@ -377,7 +377,7 @@ var kRgsymRtf = { var code = ''; - while (new RegExp("/[0-9]/").test(ch)) + while (new RegExp("[0-9]").test(ch)) { code += (ch + ''); ch = _rtf.charAt(++_currentParseIndex); @@ -621,7 +621,7 @@ var kRgsymRtf = { if (!/[a-zA-Z]/.test(ch)) return [self _translateKeyword:ch parameter:nil fParameter:fParam]; - while (new RegExp("/[a-zA-Z]/").test(ch)) + while (new RegExp("[a-zA-Z]").test(ch)) { keyword += ch; ch = rtf.charAt(++_currentParseIndex); @@ -635,7 +635,7 @@ var kRgsymRtf = { fParam = true; - while (new RegExp("/[0-9]/").test(ch)) + while (new RegExp("[0-9]").test(ch)) { param += (ch + ''); ch = rtf.charAt(++_currentParseIndex); diff --git a/Foundation/CPDate.j b/Foundation/CPDate.j index 55599f343..000a2c849 100644 --- a/Foundation/CPDate.j +++ b/Foundation/CPDate.j @@ -115,7 +115,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001, 0, 1, 0, 0, 0, 0)); */ - (id)initWithString:(CPString)description { - var format = new RegExp("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}) ([-+])(\d{2})(\d{2})/"), + var format = new RegExp("(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2}) ([-+])(\\d{2})(\\d{2})"), d = description.match(new RegExp(format)); if (!d || d.length != 10) @@ -262,7 +262,7 @@ Date.parseISO8601 = function (date) // First, check for native parsing. timestamp = Date.parse(date); - if (isNaN(timestamp) && (struct = new RegExp("/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/").exec(date))) + if (isNaN(timestamp) && (struct = new RegExp("^(\\d{4}|[+\\-]\\d{6})(?:-(\\d{2})(?:-(\\d{2}))?)?(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{3}))?)?(?:(Z)|([+\\-])(\\d{2})(?::(\\d{2}))?)?)?$").exec(date))) { // avoid NaN timestamps caused by "undefined" values being passed to Date.UTC for (var i = 0, k; (k = numericKeys[i]); ++i) diff --git a/Foundation/CPDateFormatter.j b/Foundation/CPDateFormatter.j index d7da96110..3624b7208 100644 --- a/Foundation/CPDateFormatter.j +++ b/Foundation/CPDateFormatter.j @@ -1931,7 +1931,7 @@ var defaultDateFormatterBehavior = CPDateFormatterBehavior10_4, */ - (int)_secondsFromTimeZoneDefaultFormatString:(CPString)aTimeZoneFormatString { - var format = new RegExp("/\w*([HPG-GMT])?([+-])(\d{1,2})([:])?(\d{2})\w*/"), + var format = new RegExp("\\w*([HPG-GMT])?([+-])(\\d{1,2})([:])?(\\d{2})\\w*"), result = aTimeZoneFormatString.match(new RegExp(format)), seconds = 0; @@ -1969,7 +1969,7 @@ var defaultDateFormatterBehavior = CPDateFormatterBehavior10_4, var character = [aToken characterAtIndex:0], length = [aToken length], targetedArray, - format = new RegExp("/\w*([HPG-GMT])?([+-])(\d{1,2})([:])?(\d{2})\w*/"), + format = new RegExp("\\w*([HPG-GMT])?([+-])(\\d{1,2})([:])?(\\d{2})\\w*"), result = aString.match(new RegExp(format)); switch (character) diff --git a/Foundation/CPDecimal.j b/Foundation/CPDecimal.j index 5946a8a7c..03e32124c 100644 --- a/Foundation/CPDecimal.j +++ b/Foundation/CPDecimal.j @@ -119,7 +119,7 @@ function CPDecimalMakeWithString(string, locale) // Note: this doesn't accept .01 for example, should it? // If yes simply add '?' after integer part group, i.e. ([+\-]?)((?:0|[1-9]\d*)?) // Note: now it accept .01 style. - var matches = string.match(new RegExp("/^([+\-]?)((?:0|[0-9]\d*)?)(?:\.(\d*))?(?:[eE]([+\-]?)(\d+))?$/")); + var matches = string.match(new RegExp("^([+\\-]?)((?:0|[0-9]\\d*)?)(?:\\.(\\d*))?(?:[eE]([+\\-]?)(\\d+))?$")); if (!matches) return CPDecimalMakeNaN(); diff --git a/Foundation/_CPCollectionKVCOperators.j b/Foundation/_CPCollectionKVCOperators.j index 3d320479c..36fe72145 100644 --- a/Foundation/_CPCollectionKVCOperators.j +++ b/Foundation/_CPCollectionKVCOperators.j @@ -22,7 +22,7 @@ @import "CPObject.j" -var _CPCollectionKVCOperatorSimpleRE = new RegExp("/^@(avg|count|m(ax|in)|sum|unionOfObjects|distinctUnionOfObjects|unionOfArrays|distinctUnionOfArrays|distinctUnionOfSets)(\.|$)/"); +var _CPCollectionKVCOperatorSimpleRE = new RegExp("^@(avg|count|m(ax|in)|sum|unionOfObjects|distinctUnionOfObjects|unionOfArrays|distinctUnionOfArrays|distinctUnionOfSets)(\\.|$)"); @implementation _CPCollectionKVCOperator : CPObject diff --git a/Tools/nib2cib/Converter.j b/Tools/nib2cib/Converter.j index 251384a14..dbf80ed49 100644 --- a/Tools/nib2cib/Converter.j +++ b/Tools/nib2cib/Converter.j @@ -165,7 +165,7 @@ ConverterConversionException = @"ConverterConversionException"; if (system.engine === "rhino") plistContents = String(java.lang.String(plistContents).replaceAll("\\\\s*CF\\$UID\\s*\\<\/key\\>", "CP\\$UID")); else - plistContents = plistContents.replace("/\\s*CF\$UID\s*\<\/key\>/g", "CP$UID"); + plistContents = plistContents.replace(new RegExp("\\\\s*CF\\$UID\\s*\\<\\/key\\>", "g"), "CP$UID"); plistContents = plistContents.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]<\/string>/g, function(c) { From 3a25c683b6fc3942095605a5a041355fd62e1bba Mon Sep 17 00:00:00 2001 From: Maik Opitz Date: Wed, 2 Nov 2016 16:48:10 +0100 Subject: [PATCH 3/5] Regex nochmals angepasst --- AppKit/CPTextView/CPTextView.j | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index e5877e838..a2c07711d 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -1853,13 +1853,13 @@ var kDelegateRespondsTo_textShouldBeginEditing + (JSObject)_paragraphBoundaryRegex { - return new RegExp(/^.[^\n\r]/m); + return new RegExp("^.[^\\n\\r]", "m"); } + (JSObject)_whitespaceRegex { // do not include \n here or we will get cross paragraph selections - return new RegExp(/^.[ \t]+/m); + return new RegExp("^.[ \\t]+", "m"); } - (CPRange)_characterRangeForIndex:(unsigned)index asDefinedByRegex:(JSObject)regex From 08f74201b68e0d92a81716668d4253ecd3240194 Mon Sep 17 00:00:00 2001 From: Maik Opitz Date: Wed, 2 Nov 2016 16:21:03 +0000 Subject: [PATCH 4/5] RegEx angepasst --- Tools/nib2cib/Converter.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/nib2cib/Converter.j b/Tools/nib2cib/Converter.j index dbf80ed49..19db97fee 100644 --- a/Tools/nib2cib/Converter.j +++ b/Tools/nib2cib/Converter.j @@ -167,7 +167,7 @@ ConverterConversionException = @"ConverterConversionException"; else plistContents = plistContents.replace(new RegExp("\\\\s*CF\\$UID\\s*\\<\\/key\\>", "g"), "CP$UID"); - plistContents = plistContents.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]<\/string>/g, function(c) + plistContents = plistContents.replace(new RegExp("[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F]<\\/string>", "g"), function(c) { CPLog.warn("Warning: converting character 0x" + c.charCodeAt(8).toString(16) + " to base64 representation"); return "" + CFData.encodeBase64String(c.charAt(8)) + ""; From a5c8e87e6d391e2c8946c79e4e704bf69079219b Mon Sep 17 00:00:00 2001 From: Maik Opitz Date: Thu, 3 Nov 2016 12:33:39 +0000 Subject: [PATCH 5/5] Removed mistaken triplequotes --- AppKit/CPTextView/CPTextView.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index a2c07711d..bbfbe3214 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -1848,7 +1848,7 @@ var kDelegateRespondsTo_textShouldBeginEditing + (JSObject)_wordBoundaryRegex { - return new RegExp("(^[0-9][\\.,])|(^.[^-\\.,+#'\\\"!§$%&/\\(<\\[\\]>\\)=?`´*\\s{}\\|¶])", "m"); + return new RegExp("(^[0-9][\\.,])|(^.[^-\\.,+#'\"!§$%&/\\(<\\[\\]>\\)=?`´*\\s{}\\|¶])", "m"); } + (JSObject)_paragraphBoundaryRegex