Skip to content

Commit ed690b0

Browse files
[[ libpcre833 ]] libpcre now updated to handle any unicode input
1 parent 455c85c commit ed690b0

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

Livecode.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@
1616
#define _HAS_VSNPRINTF
1717
#define _DEBUG
1818
#undef LEGACY_SYSTEM
19+
20+
// libpcre definitions
21+
#define SUPPORT_PCRE16
22+
#define SUPPORT_UCP
23+
#define SUPPORT_UTF

Livecode.files

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,29 @@ thirdparty/libpcre/src/pcreposix.c
25932593
thirdparty/libpcre/src/ucp.h
25942594
thirdparty/libpcre/src/ucpinternal.h
25952595
thirdparty/libpcre/src/ucptable.c
2596+
thirdparty/libpcre/src/pcre16_byte_order.c
2597+
thirdparty/libpcre/src/pcre16_chartables.c
2598+
thirdparty/libpcre/src/pcre16_compile.c
2599+
thirdparty/libpcre/src/pcre16_config.c
2600+
thirdparty/libpcre/src/pcre16_dfa_exec.c
2601+
thirdparty/libpcre/src/pcre16_exec.c
2602+
thirdparty/libpcre/src/pcre16_fullinfo.c
2603+
thirdparty/libpcre/src/pcre16_get.c
2604+
thirdparty/libpcre/src/pcre16_globals.c
2605+
thirdparty/libpcre/src/pcre16_jit_compile.c
2606+
thirdparty/libpcre/src/pcre16_maketables.c
2607+
thirdparty/libpcre/src/pcre16_newline.c
2608+
thirdparty/libpcre/src/pcre16_ord2utf16.c
2609+
thirdparty/libpcre/src/pcre16_printint.c
2610+
thirdparty/libpcre/src/pcre16_refcount.c
2611+
thirdparty/libpcre/src/pcre16_string_utils.c
2612+
thirdparty/libpcre/src/pcre16_study.c
2613+
thirdparty/libpcre/src/pcre16_tables.c
2614+
thirdparty/libpcre/src/pcre16_ucd.c
2615+
thirdparty/libpcre/src/pcre16_utf16_utils.c
2616+
thirdparty/libpcre/src/pcre16_valid_utf16.c
2617+
thirdparty/libpcre/src/pcre16_version.c
2618+
thirdparty/libpcre/src/pcre16_xclass.c
25962619
thirdparty/libpcre/score.txt
25972620
thirdparty/libpng/include/png.h
25982621
thirdparty/libpng/include/pngconf.h

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ server: libz libgif libjpeg libpcre libpng libopenssl libexternal libfoundation
7878
libcairopdf:
7979
$(MAKE) -C ./thirdparty/libcairo libcairopdf
8080

81-
revpdfprinter: libcairopdf libcore
81+
revpdfprinter: libcairopdf
8282
$(MAKE) -C ./revpdfprinter revpdfprinter
8383

8484
###############################################################################

engine/src/regex.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
2020
#include "parsedef.h"
2121
#include "regex.h"
2222

23-
#include <pcre.h>
23+
#include "pcre.h"
2424

25-
#define pcre_free free
25+
#define pcre16_free free
2626

2727

2828

@@ -189,7 +189,7 @@ regerror(int errcode, const regex_t *preg, MCStringRef &errbuf)
189189

190190
void regfree(regex_t *preg)
191191
{
192-
(pcre_free)(preg->re_pcre);
192+
(pcre16_free)(preg->re_pcre);
193193
}
194194

195195
/*************************************************
@@ -214,18 +214,18 @@ int regcomp(regex_t *preg, MCStringRef pattern, int cflags)
214214

215215
if ((cflags & REG_ICASE) != 0)
216216
options |= PCRE_CASELESS;
217-
if ((cflags & REG_NEWLINE) != 0)
217+
if ((cflags & REG_NEWLINE) != 0)
218218
options |= PCRE_MULTILINE;
219-
MCAutoPointer<char> t_pattern;
220-
/* UNCHECKED */ MCStringConvertToCString(pattern, &t_pattern);
221-
preg->re_pcre = pcre_compile(*t_pattern, options, &errorptr, &erroffset, NULL);
219+
220+
// SN-2014-01-14: [[ libpcre update ]]
221+
preg->re_pcre = pcre16_compile(MCStringGetCharPtr(pattern), options, &errorptr, &erroffset, NULL);
222222
preg->re_erroffset = erroffset;
223223

224224
if (preg->re_pcre == NULL)
225225
return eint[erroffset];
226226

227-
preg->re_nsub = pcre_info((const pcre *)preg->re_pcre, NULL, NULL);
228-
return 0;
227+
// [[ libpcre udpate ]] SN-2014-01-10: pcre_info() is deprecated, must be replaced with pcre_fullinfo()
228+
return pcre16_fullinfo((const pcre16 *)preg->re_pcre, NULL, PCRE_INFO_CAPTURECOUNT, &preg->re_nsub);
229229
}
230230

231231
/*************************************************
@@ -247,7 +247,7 @@ int regexec(regex_t *preg, MCStringRef string, int len, size_t nmatch,
247247
if ((eflags & REG_NOTBOL) != 0)
248248
options |= PCRE_NOTBOL;
249249
if ((eflags & REG_NOTEOL) != 0)
250-
options |= PCRE_NOTEOL;
250+
options |= PCRE_NOTEOL;
251251

252252
preg->re_erroffset = (size_t)(-1); /* Only has meaning after compile */
253253
if (nmatch > 0)
@@ -257,9 +257,8 @@ int regexec(regex_t *preg, MCStringRef string, int len, size_t nmatch,
257257
return REG_ESPACE;
258258
}
259259

260-
MCAutoPointer<char> t_string;
261-
/* UNCHECKED */ MCStringConvertToCString(string, &t_string);
262-
rc = pcre_exec((const pcre *)preg->re_pcre, NULL, *t_string, len, 0, options,
260+
// [[ libprce update ]] SN-2014-01-14: now handles unicode-encoded input
261+
rc = pcre16_exec((const pcre16 *)preg->re_pcre, NULL, MCStringGetCharPtr(string), len, 0, options,
263262
ovector, nmatch * 3);
264263

265264
if (rc == 0)

thirdparty

0 commit comments

Comments
 (0)