Commit graph

40 commits

Author SHA1 Message Date
rfm
9b6267a491 Avoid using clang specific code 2025-01-05 16:42:19 +00:00
rfm
2882d8c812 Simplify by removng unnecessary argument in new callback 2025-01-04 16:50:13 +00:00
rfm
c722328e5c Regular expression improvements for classic environment 2025-01-04 15:05:14 +00:00
rfm
4c287f20b3 More regular expression leak fix changes ... use older code (plus fixes). 2024-11-21 21:05:34 +00:00
rfm
7b77a2074a Workaround to avoid memory leak in ICU functions if we set NULL as destination. 2024-11-20 17:46:35 +00:00
rfm
5b46efa8cd More leak fixes 2024-11-16 21:11:56 +00:00
rfm
6667842dd5 Update FSF address as requested by Gregory 2024-11-07 13:37:59 +00:00
rfm
35bb9f48ef regular expression range search 2024-05-12 10:03:15 +01:00
ethanc8
7862434d85 Implement +[NSRegularExpression escapedPatternForString:] 2023-12-29 22:43:35 -06:00
Riccardo Mottola
08858caf29 cleanup biolerplate comments, enable autogsdoc comments, cleanup some old RCS/CVS tags, fix emails 2023-12-23 02:44:50 +01:00
rfm
15ff083a9a Reformatting and compilation fixes. 2023-11-13 19:45:16 +00:00
Hugo Melder
ac38295f64
NSRegularExpression: Improved Error and Exception handling to match macOS behaviour (#343)
* NSRegularExpression: Match macOS error handling

* Add test cases for error handling

* NSRegularExpression: Raise an NSInvalidArgumentException instead of NSInternalInconsistencyException

* Check if NSRegularExpression throws an exception
2023-11-13 19:55:49 +01:00
Frederik Seiffert
b6740f0f6c Fix some checks when using ICU DLL from Windows 10 2022-02-18 19:06:54 +01:00
Frederik Seiffert
b41953d274 More robust check for Windows ICU
Also ensure that we don't include both unicode/*.h and icu.h.
2021-08-08 17:27:40 +02:00
Frederik Seiffert
dc32970502 Add support for using ICU DLL from Windows 10
Requires Windows 10 version 1903 (May 2019 Update):
https://docs.microsoft.com/en-us/windows/win32/intl/international-components-for-unicode--icu-

Also adds missing configure check for unicode/utext.h.
2021-08-03 16:52:38 +02:00
Gregory John Casamento
753c907938 Fix address for FSF and License name in all headers in base 2019-12-09 18:36:00 -05:00
Wolfgang Lux
e3caba204b Fix a serious misunderstanding of the icu string access API: The value
of nativeIndexingLimit must not exceed the length of the current chunk.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@40333 72102866-910b-0410-8b05-ffd578937521
2017-02-11 14:24:58 +00:00
Niels Grewe
6509aeb2de Fix handling of incorrect replacement patterns.
The error code from trying to apply a replacement pattern was not checked,
resulting in a crash inside libicu. This also fixes a few memory leaks
(replacement string objects not correctly autoreleased before returning them
 to the caller).


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@40142 72102866-910b-0410-8b05-ffd578937521
2016-10-12 13:43:32 +00:00
Wolfgang Lux
62b2fb95b8 Fix bug where a UText structure owned by the icu library is incorrectly
closed, which was causing a crash when -pattern is called more than once
for the same NSRegularExpression.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39960 72102866-910b-0410-8b05-ffd578937521
2016-07-06 08:08:51 +00:00
Niels Grewe
0d98f56eca Implement resource limits for regular expression evaluation. Tweaked
to roughly match the Cocoa behaviour, but can be changed through 
the GSRegularExpressionWorkLimit user default.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39872 72102866-910b-0410-8b05-ffd578937521
2016-06-17 09:04:04 +00:00
Niels Grewe
ac2d08d2a1 Implement -isEqual: and -hash on NSRegularExpression, so that copies are
actually equal


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39871 72102866-910b-0410-8b05-ffd578937521
2016-06-17 07:43:51 +00:00
Niels Grewe
8b8e32b080 Fix handling of capture groups not participating in the current match.
The Cocoa API specifies to return theses as (NSNotFound,0) ranges, but the
ICU API returns them as (-1,-1) pairs of start/end indices. The necessary
conversion was missing here.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38963 72102866-910b-0410-8b05-ffd578937521
2015-09-01 11:31:16 +00:00
Richard Frith-MacDonald
3df1043cea Mimic OSX handling of what appears to be an ICU bug
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37793 72102866-910b-0410-8b05-ffd578937521
2014-04-12 04:38:13 +00:00
Richard Frith-MacDonald
7ca6e56d39 prep for release
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36208 72102866-910b-0410-8b05-ffd578937521
2013-02-28 16:50:37 +00:00
Richard Frith-MacDonald
cd57095d65 get code to compile/link again
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35004 72102866-910b-0410-8b05-ffd578937521
2012-03-27 10:03:40 +00:00
Richard Frith-MacDonald
cd676ece36 moe consistent use of white space to match coding standard etc
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34809 72102866-910b-0410-8b05-ffd578937521
2012-02-23 17:57:50 +00:00
Wolfgang Lux
9ed632dcdb Correct result of NSRegularExpression -rangeOfFirstMatchInString:...
When no match is found location must be set to NSNotFound.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34348 72102866-910b-0410-8b05-ffd578937521
2011-12-23 14:59:14 +00:00
Wolfgang Lux
b1cb675199 Introduce NSRegularExpression support for libicu versions prior to 4.4,
which don't provide the UText interface to regular expressions.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34345 72102866-910b-0410-8b05-ffd578937521
2011-12-22 12:52:56 +00:00
David Chisnall
433554830d Fix the build with the pure non-fragile ABI by declaring macros before using them.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33724 72102866-910b-0410-8b05-ffd578937521
2011-08-13 15:28:22 +00:00
David Chisnall
fa6f119996 Clean up NSRegularExpression, so that it compiles without warnings with or without ICU, but we don't pretend that we support things that we don't and silently return nonsense results to make debugging difficult for GNUstep users.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33688 72102866-910b-0410-8b05-ffd578937521
2011-08-03 12:04:27 +00:00
Fred Kiefer
00c8832228 Remove some of the compiler warnings on system without clang or ICU.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33680 72102866-910b-0410-8b05-ffd578937521
2011-08-02 08:33:33 +00:00
David Chisnall
51446f39de I give up. No brain left.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33605 72102866-910b-0410-8b05-ffd578937521
2011-07-22 13:37:38 +00:00
David Chisnall
df82f8b96c Third try.
[NSException raise: GSNotEnoughCoffeeException];



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33604 72102866-910b-0410-8b05-ffd578937521
2011-07-22 13:34:08 +00:00
David Chisnall
eb32254242 Add missing #import.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33603 72102866-910b-0410-8b05-ffd578937521
2011-07-22 13:27:04 +00:00
David Chisnall
4b027a2106 Stub for NSRegularExpression when a compatible version of ICU is not present.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33602 72102866-910b-0410-8b05-ffd578937521
2011-07-22 13:23:11 +00:00
Richard Frith-MacDonald
47fdf3d48d get closer to coding standards
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31743 72102866-910b-0410-8b05-ffd578937521
2010-12-16 10:59:50 +00:00
Richard Frith-MacDonald
62de5b485f mostly fixups for ICU
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31742 72102866-910b-0410-8b05-ffd578937521
2010-12-16 10:09:43 +00:00
Eric Wasylishen
5dd47a135e Don't compile NSRegularExpression with ICU older than 4.4
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31702 72102866-910b-0410-8b05-ffd578937521
2010-12-02 19:12:24 +00:00
Niels Grewe
b69a2cfb91 Small rearrangements to make non-C99 compilers happy.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31637 72102866-910b-0410-8b05-ffd578937521
2010-11-19 22:29:04 +00:00
David Chisnall
a5335c34fb Added implementation of NSRegularExpression, from iOS 4 Foundation.
This class is a thin wrapper around libicu regular expressions, so if we don't
have libicu we simply don't compile it at all.  This will give people a linker
failure, rather than a nonfunctional class if they try to use GNUstep without
ICU with code that requires it.

The Apple documentation says that this class has a primitive method that takes
a block as an argument and that this method is called by others, so subclasses
can replace that block method without touching the convenience methods.  We
mimic this behaviour when compiling with block, but when compiling without them
it's a problem.  The current code contains some ugly hacks that will work in
normal usage but break with subclassing when not compiling with blocks.

This commit also includes a partial implementation of NSTextCheckingResult,
implementing the subset of its functionality required for NSRegularExpression
to work.

It also includes numerous fixes to GSICUString.  This is heavily used by
NSRegularExpression, to avoid copying strings when mapping between UText for
libicu and NSString for GNUstep.


Note: I don't have a copy of iOS anywhere to test this against, so it's
entirely possible that there are significant discrepancies between this
implementation of NSRegularExpression and the iOS version.  This version should
function exactly as the iOS one is described as functioning, but I think we've
all seen that Apple documentation refers more to hopes than facts.  Any testing
that someone who does have an ip{hone,od,ad} can do is very welcome.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31635 72102866-910b-0410-8b05-ffd578937521
2010-11-19 22:06:18 +00:00