Mailinglist Archive: yast-commit (213 mails)

< Previous Next >
[yast-commit] r62044 - in /branches/SuSE-Code-11-Branch/core: ./ libycp/src/ libycp/testsuite/tests/builtin/ package/
  • From: mvidner@xxxxxxxxxxxxxxxx
  • Date: Thu, 20 May 2010 14:16:11 -0000
  • Message-id: <E1OF6Xj-0001WN-E6@xxxxxxxxxxxxxxxx>
Author: mvidner
Date: Thu May 20 16:16:10 2010
New Revision: 62044

URL: http://svn.opensuse.org/viewcvs/yast?rev=62044&view=rev
Log:
Fixed the regexpsub algorithm not to loop endlessly
if the source string contains \1 (bnc#552914, bnc#606427).

Backport from:
svn merge -c 61272
http://svn.opensuse.org/svn/yast/branches/SuSE-Code-11-SP1-Branch/core

Modified:
branches/SuSE-Code-11-Branch/core/ (props changed)
branches/SuSE-Code-11-Branch/core/VERSION
branches/SuSE-Code-11-Branch/core/libycp/src/YCPBuiltinString.cc

branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.err

branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.out

branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.ycp
branches/SuSE-Code-11-Branch/core/package/yast2-core.changes

Modified: branches/SuSE-Code-11-Branch/core/VERSION
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/VERSION?rev=62044&r1=62043&r2=62044&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/VERSION (original)
+++ branches/SuSE-Code-11-Branch/core/VERSION Thu May 20 16:16:10 2010
@@ -1 +1 @@
-2.17.30.4
+2.17.30.5

Modified: branches/SuSE-Code-11-Branch/core/libycp/src/YCPBuiltinString.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/libycp/src/YCPBuiltinString.cc?rev=62044&r1=62043&r2=62044&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/libycp/src/YCPBuiltinString.cc (original)
+++ branches/SuSE-Code-11-Branch/core/libycp/src/YCPBuiltinString.cc Thu May 20
16:16:10 2010
@@ -872,10 +872,10 @@
/// (regexp builtins)
typedef struct REG_RET
{
- string result_str;
+ string result_str; // for regexpsub
string match_str[SUB_MAX]; // index 0 not used!!
int match_nb; // 0 - 9
- string error_str;
+ string error_str; // from regerror
bool error;
bool solved;
} Reg_Ret;
@@ -884,6 +884,7 @@
/*
* Universal regular expression solver.
* It is used by all regexp* ycp builtins.
+ * Replacement is done if result is not ""
*/
Reg_Ret solve_regular_expression (const char *input, const char *pattern,
const char *result)
@@ -925,27 +926,38 @@
return reg_ret;
}

- static const char *index[] = {
- NULL, /* not used */
- "\\1", "\\2", "\\3", "\\4",
- "\\5", "\\6", "\\7", "\\8", "\\9"
- };
-
string input_str (input);
- string result_str (result);

for (unsigned int i=0; (i <= compiled.re_nsub) && (i <= SUB_MAX); i++) {
reg_ret.match_str[i] = matchptr[i].rm_so >= 0 ?
input_str.substr(matchptr[i].rm_so, matchptr[i].rm_eo - matchptr[i].rm_so) : "";
reg_ret.match_nb = i;
-
- string::size_type col = string::npos;
- if(index[i] != NULL) col = result_str.find(index[i]);
- while( col != string::npos ) {
- result_str.replace( col, 2, reg_ret.match_str[i] );
- col = result_str.find(index[i], col + 1 );
- }
}

+
+ string result_str;
+ const char * done = result; // text before 'done' has been dealt
with
+ const char * bspos = result;
+
+
+ while (1) {
+ bspos = strchr (bspos, '\\');
+ if (bspos == NULL) // not found
+ break;
+
+ // STATE: \ seen
+ ++bspos;
+
+ if (*bspos >= '1' && *bspos <= '9') {
+ // copy non-backslash text
+ result_str.append (done, bspos - 1 - done);
+ // copy replacement string
+ result_str += reg_ret.match_str[*bspos - '0'];
+ done = bspos = bspos + 1;
+ }
+ }
+ // copy the rest
+ result_str += done;
+
reg_ret.result_str = result_str;
regfree (&compiled);
return reg_ret;

Modified:
branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.err
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.err?rev=62044&r1=62043&r2=62044&view=diff
==============================================================================
---
branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.err
(original)
+++
branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.err
Thu May 20 16:16:10 2010
@@ -142,6 +142,34 @@
----------------------------------------------------------------------
Parsed:
----------------------------------------------------------------------
+(regexpsub ("aaabbb", "(a*b)(.*)", "\\1") == "aaab")
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+(regexpsub ("aaabbb", "(a*b)(.*)", "\\1\\1") == "aaabaaab")
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+(regexpsub ("aaabbb", "(a*b)(.*)", "\\") == "\\")
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+(regexpsub ("aaabbb", "(a*b)(.*)", "\\\\") == "\\\\")
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+(regexpsub ("aaabbb", "(a*b)(.*)", "A\\NZ") == "A\\NZ")
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+(regexpsub ("aaabbb", "(a*b)(.*)", "A\\\\1Z") == "A\\aaabZ")
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+(regexpsub ("machine=i386\\2ci486\\2ci586\\2ci686", "^([^=]*)=(.*)", "\\2") ==
"i386\\2ci486\\2ci586\\2ci686")
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
(regexptokenize ("aaabbBb", "(.*[[:upper:]]).*") == ["aaabbB"])
----------------------------------------------------------------------
Parsed:

Modified:
branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.out
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.out?rev=62044&r1=62043&r2=62044&view=diff
==============================================================================
---
branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.out
(original)
+++
branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.out
Thu May 20 16:16:10 2010
@@ -37,6 +37,13 @@
(true)
(true)
(true)
+(true)
+(true)
+(true)
+(true)
+(true)
+(true)
+(true)
("** sformat **")
("five is greater % than 3")
("** conversions **")

Modified:
branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.ycp?rev=62044&r1=62043&r2=62044&view=diff
==============================================================================
---
branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.ycp
(original)
+++
branches/SuSE-Code-11-Branch/core/libycp/testsuite/tests/builtin/Builtin-String1.ycp
Thu May 20 16:16:10 2010
@@ -65,6 +65,14 @@

(regexpsub ("aaabbb", "(.*ab).*", "s_\\1_e") == "s_aaab_e")
(regexpsub ("aaabbb", "(.*abb)(.*)", "s_\\1_e\\2") == "s_aaabb_eb")
+// bnc#552914
+(regexpsub ("aaabbb", "(a*b)(.*)", "\\1") == "aaab")
+(regexpsub ("aaabbb", "(a*b)(.*)", "\\1\\1") == "aaabaaab")
+(regexpsub ("aaabbb", "(a*b)(.*)", "\\") == "\\")
+(regexpsub ("aaabbb", "(a*b)(.*)", "\\\\") == "\\\\")
+(regexpsub ("aaabbb", "(a*b)(.*)", "A\\NZ") == "A\\NZ")
+(regexpsub ("aaabbb", "(a*b)(.*)", "A\\\\1Z") == "A\\aaabZ")
+(regexpsub ("machine=i386\\2ci486\\2ci586\\2ci686", "^([^=]*)=(.*)", "\\2") ==
"i386\\2ci486\\2ci586\\2ci686")

(regexptokenize ("aaabbBb", "(.*[[:upper:]]).*") == [ "aaabbB" ])
(regexptokenize ("aaabbb", "(.*ab)(.*)") == ["aaab", "bb"])

Modified: branches/SuSE-Code-11-Branch/core/package/yast2-core.changes
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/package/yast2-core.changes?rev=62044&r1=62043&r2=62044&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/package/yast2-core.changes (original)
+++ branches/SuSE-Code-11-Branch/core/package/yast2-core.changes Thu May 20
16:16:10 2010
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Thu May 20 15:19:37 CEST 2010 - mvidner@xxxxxxx
+
+- Fixed the regexpsub algorithm not to loop endlessly
+ if the source string contains \1 (bnc#552914, bnc#606427).
+- 2.17.30.5
+
+-------------------------------------------------------------------
Thu Nov 26 12:11:51 UTC 2009 - lslezak@xxxxxxx

- use 2.17.0 yast2-dbus-* Provides (instead of 2.16.99)

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages