From 45447a4c916365940e60e26f576a0fa942cc005b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 8 Jun 2010 18:32:53 +0000 Subject: [PATCH] 2010-06-08 20:28 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/hbregexc.c + Restored RTE which is thrown when unsupported regex string is found in any .prg level regex API calls except HB_REGEXCOMP(). The only difference compared to previous solution is different error code (3015) to differenciate this case from wrong parameter _type_ error cases. ; TOFIX: IMO even current solution is not ideal, because it just forces developers to use HB_ISREGEX() to pre-evaluate regex strings before actually using them (causing performance hit), or it forces them to use HB_REGEXCOMP() to pre-compile and pre-evaluate the expressions before passing them to actual regex functions, in the valid case they want to avoid unexpected RTEs due to missing or unsupported regex (PCRE) subsystem. IOW it makes plain HB_ATX( , ... ) style calls prone to fail with RTE in certain, very hard to predict situations in officially supported Harbour builds. Comments are appreciated. * utils/hbmk2/hbmk2.prg * Deleted unused code. * Formatting. --- harbour/ChangeLog | 23 +++++++++++++++++++++++ harbour/src/rtl/hbregexc.c | 2 ++ harbour/utils/hbmk2/hbmk2.prg | 15 +-------------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3a4783679e..a980792257 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,12 +16,35 @@ The license applies to all entries newer than 2009-04-28. */ +2010-06-08 20:28 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * src/rtl/hbregexc.c + + Restored RTE which is thrown when unsupported regex string is + found in any .prg level regex API calls except HB_REGEXCOMP(). + The only difference compared to previous solution is different + error code (3015) to differenciate this case from wrong + parameter _type_ error cases. + ; TOFIX: IMO even current solution is not ideal, because it just + forces developers to use HB_ISREGEX() to pre-evaluate regex + strings before actually using them (causing performance hit), + or it forces them to use HB_REGEXCOMP() to pre-compile and + pre-evaluate the expressions before passing them to actual + regex functions, in the valid case they want to avoid unexpected + RTEs due to missing or unsupported regex (PCRE) subsystem. + IOW it makes plain HB_ATX( , ... ) style calls + prone to fail with RTE in certain, very hard to predict + situations in officially supported Harbour builds. + Comments are appreciated. + + * utils/hbmk2/hbmk2.prg + * Deleted unused code. + * Formatting. 2010-06-08 19:58 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/rtl/hbsocket.c ! added missing code to duplicate IP6 address passed explicitly to hb_socketResolveAddr() - thanks to Mindaugas for reporting the problem + 2010-06-08 09:21 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + contrib/hbide/resources/idepreferences.png + Icon for "hbIDE Setup" option. diff --git a/harbour/src/rtl/hbregexc.c b/harbour/src/rtl/hbregexc.c index d458e21b14..3a6bb15554 100644 --- a/harbour/src/rtl/hbregexc.c +++ b/harbour/src/rtl/hbregexc.c @@ -153,6 +153,8 @@ PHB_REGEX hb_regexGet( PHB_ITEM pRegExItm, int iFlags ) if( fArgError ) hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 1, pRegExItm ); + else if( ! pRegEx ) /* hb_regexCompile() failed */ + hb_errRT_BASE_SubstR( EG_ARG, 3015, NULL, HB_ERR_FUNCNAME, 1, pRegExItm ); return pRegEx; } diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index d552a51878..44581b3aa1 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -5828,7 +5828,7 @@ STATIC FUNCTION FindNewerHeaders( hbmk, cFileName, cParentDir, lSystemHeader, tT s_hRegexInclude := hb_regexComp( '^[ \t]*#[ \t]*include[ \t]*(\".+?\"|<.+?>)', .F. /* lCaseSensitive */, .T. /* lNewLine */ ) IF Empty( s_hRegexInclude ) hbmk_OutErr( hbmk, I_( "Internal Error: Regular expression engine missing or unsupported. Please check your Harbour build settings." ) ) - s_hRegexInclude := {} /* To show the error only once by setting to non-NIL empty value*/ + s_hRegexInclude := {} /* To show the error only once by setting to non-NIL empty value */ ENDIF ENDIF @@ -5853,19 +5853,6 @@ STATIC FUNCTION FindNewerHeaders( hbmk, cFileName, cParentDir, lSystemHeader, tT RETURN headstate[ _HEADSTATE_lAnyNewer ] -/* NOTE: Required for older versions of Harbour where hb_regexComp() - is throwing an RTE in case of an invalid regular expression. */ -STATIC FUNCTION hbmk_regexComp( ... ) - LOCAL hRegex - - BEGIN SEQUENCE WITH {| oError | Break( oError ) } - hRegex := hb_regexComp( ... ) - RECOVER - hRegex := NIL - END SEQUENCE - - RETURN hRegex - STATIC FUNCTION clpfile_read( cFileName ) LOCAL cFileBody := MemoRead( cFileName ) LOCAL aFiles