|
1 |
| -/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
| 1 | +/* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. |
2 | 2 |
|
3 | 3 | This program is free software; you can redistribute it and/or modify
|
4 | 4 | it under the terms of the GNU General Public License, version 2.0,
|
@@ -55,15 +55,9 @@ String *EvalExprToCharset(Item *expr, String *out) {
|
55 | 55 | }
|
56 | 56 |
|
57 | 57 | bool Regexp_facade::SetPattern(Item *pattern_expr) {
|
58 |
| - /* |
59 |
| - The pattern is NULL, but that's fine. Since it's the facade's job to |
60 |
| - handle NULL values, we leverage the fact that any matching against NULL |
61 |
| - will have the result NULL and don't involve the Regexp_engine class at |
62 |
| - all. |
63 |
| - */ |
64 | 58 | if (pattern_expr == nullptr) {
|
65 | 59 | m_engine = nullptr;
|
66 |
| - return false; |
| 60 | + return true; |
67 | 61 | }
|
68 | 62 | if (!pattern_expr->const_item() || // Non-constant pattern, see above.
|
69 | 63 | m_engine == nullptr) { // Called for the first time.
|
@@ -117,7 +111,8 @@ String *Regexp_facade::Replace(Item *subject_expr, Item *replacement_expr,
|
117 | 111 |
|
118 | 112 | String *Regexp_facade::Substr(Item *subject_expr, int start, int occurrence,
|
119 | 113 | String *result) {
|
120 |
| - if (Reset(subject_expr) || !m_engine->Matches(start - 1, occurrence)) { |
| 114 | + if (Reset(subject_expr)) return nullptr; |
| 115 | + if (!m_engine->Matches(start - 1, occurrence)) { |
121 | 116 | m_engine->CheckError();
|
122 | 117 | return nullptr;
|
123 | 118 | }
|
|
0 commit comments