View | Details | Raw Unified | Return to issue 73830
Collapse All | Expand All

(-)source/classes/sbxmod.cxx (-1 / +2 lines)
Lines 166-172 Link Here
166
	"integer",
166
	"integer",
167
	"is",
167
	"is",
168
	"let",
168
	"let",
169
	"lib"
169
	"lib",
170
	"like",
170
	"line",
171
	"line",
171
	"line input",
172
	"line input",
172
	"local",
173
	"local",
(-)source/comp/exprnode.cxx (-1 / +1 lines)
Lines 244-250 Link Here
244
244
245
void SbiExprNode::FoldConstants()
245
void SbiExprNode::FoldConstants()
246
{
246
{
247
	if( IsOperand() ) return;
247
	if( IsOperand() || eTok == LIKE ) return;
248
	pLeft->FoldConstants();
248
	pLeft->FoldConstants();
249
	if( pRight )
249
	if( pRight )
250
	{
250
	{
(-)source/comp/token.cxx (+1 lines)
Lines 130-135 Link Here
130
	{ IS,		"Is" },
130
	{ IS,		"Is" },
131
	{ LET,		"Let" },
131
	{ LET,		"Let" },
132
	{ LIB,		"Lib" },
132
	{ LIB,		"Lib" },
133
	{ LIKE,		"Like" },
133
	{ LINE,		"Line" },
134
	{ LINE,		"Line" },
134
	{ LINEINPUT,"Line Input" },
135
	{ LINEINPUT,"Line Input" },
135
	{ LOCAL,	"Local" },
136
	{ LOCAL,	"Local" },
(-)source/runtime/step0.cxx (-1 / +109 lines)
Lines 49-55 Link Here
49
#include <sb.hrc>
49
#include <sb.hrc>
50
#include <basrid.hxx>
50
#include <basrid.hxx>
51
#include "sbunoobj.hxx"
51
#include "sbunoobj.hxx"
52
#include "image.hxx"
52
#include <com/sun/star/uno/Any.hxx>
53
#include <com/sun/star/uno/Any.hxx>
54
#include <com/sun/star/util/SearchOptions.hdl>
55
#include <vcl/svapp.hxx>
56
#include <unotools/textsearch.hxx>
53
57
54
#include <algorithm>
58
#include <algorithm>
55
59
Lines 166-174 Link Here
166
void SbiRuntime::StepLE()		{ StepCompare( SbxLE );		}
170
void SbiRuntime::StepLE()		{ StepCompare( SbxLE );		}
167
void SbiRuntime::StepGE()		{ StepCompare( SbxGE );		}
171
void SbiRuntime::StepGE()		{ StepCompare( SbxGE );		}
168
172
173
namespace
174
{
175
	bool NeedEsc(sal_Unicode cCode)
176
	{
177
		String sEsc(RTL_CONSTASCII_USTRINGPARAM(".^$+\\|{}()"));
178
		return (STRING_NOTFOUND != sEsc.Search(cCode));
179
	}
180
181
	String VBALikeToRegexp(const String &rIn)
182
	{
183
		String sResult;
184
		const sal_Unicode *start = rIn.GetBuffer();
185
		const sal_Unicode *end = start + rIn.Len();
186
187
		int seenright = 0;
188
189
		sResult.Append('^');
190
191
		while (start < end) 
192
		{
193
			switch (*start)
194
			{
195
				case '?':
196
					sResult.Append('.');
197
					start++;
198
					break;
199
				case '*':
200
					sResult.Append(String(RTL_CONSTASCII_USTRINGPARAM(".*")));
201
					start++;
202
					break;
203
				case '#':
204
					sResult.Append(String(RTL_CONSTASCII_USTRINGPARAM("[0-9]")));
205
					start++;
206
					break;
207
				case ']':
208
					sResult.Append('\\');
209
					sResult.Append(*start++);
210
					break;
211
				case '[':
212
					sResult.Append(*start++);
213
					seenright = 0;
214
					while (start < end && !seenright)
215
					{
216
						switch (*start)
217
						{
218
							case '[':
219
							case '?':
220
							case '*':
221
							sResult.Append('\\');
222
							sResult.Append(*start);
223
								break;
224
							case ']':
225
							sResult.Append(*start);
226
								seenright = 1;
227
								break;
228
							default:
229
							if (NeedEsc(*start))
230
									sResult.Append('\\');
231
							sResult.Append(*start);
232
								break;
233
						}
234
						start++;
235
					}
236
					break;
237
				default:
238
					if (NeedEsc(*start))
239
						sResult.Append('\\');
240
					sResult.Append(*start++);
241
			}
242
		}
243
244
		sResult.Append('$');
245
246
		return sResult;
247
	}
248
}
249
169
void SbiRuntime::StepLIKE()
250
void SbiRuntime::StepLIKE()
170
{
251
{
171
	StarBASIC::FatalError( SbERR_NOT_IMPLEMENTED );
252
    SbxVariableRef refVar1 = PopVar();
253
    SbxVariableRef refVar2 = PopVar();
254
255
    String pattern = VBALikeToRegexp(refVar1->GetString());
256
    String value = refVar2->GetString();
257
258
    com::sun::star::util::SearchOptions aSearchOpt;
259
260
    aSearchOpt.algorithmType = com::sun::star::util::SearchAlgorithms_REGEXP;
261
262
    aSearchOpt.Locale = Application::GetSettings().GetLocale();
263
    aSearchOpt.searchString = pattern;
264
265
    int bTextMode(1);
266
    bool bCompatibility = ( pINST && pINST->IsCompatibility() );
267
    if( bCompatibility )
268
        bTextMode = GetImageFlag( SBIMG_COMPARETEXT );
269
270
    if( bTextMode )
271
        aSearchOpt.transliterateFlags |= com::sun::star::i18n::TransliterationModules_IGNORE_CASE;
272
273
    SbxVariable* pRes = new SbxVariable;
274
    utl::TextSearch aSearch(aSearchOpt);
275
    xub_StrLen nStart=0, nEnd=value.Len();
276
    int bRes = aSearch.SearchFrwrd(value, &nStart, &nEnd);
277
    pRes->PutBool( bRes );
278
279
    PushVar( pRes );
172
}
280
}
173
281
174
// TOS und TOS-1 sind beides Objektvariable und enthalten den selben Pointer
282
// TOS und TOS-1 sind beides Objektvariable und enthalten den selben Pointer

Return to issue 73830