Diffstat (limited to 'noncore/apps/tinykate/libkate/document/katehighlight.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katehighlight.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp index 539d356..89024f7 100644 --- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp +++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp | |||
@@ -344,103 +344,108 @@ const QChar *HlCHex::checkHgl(const QChar *str, int len, bool) { | |||
344 | #if 0 | 344 | #if 0 |
345 | int i; | 345 | int i; |
346 | for (i=0;(*s)!='\0';s++,i++); | 346 | for (i=0;(*s)!='\0';s++,i++); |
347 | QString line(str,i); | 347 | QString line(str,i); |
348 | QRegExp3 rx("0[xX][a-fA-F\\d]+[UuLl]?"); // this matches but is also matching parenthesis | 348 | QRegExp3 rx("0[xX][a-fA-F\\d]+[UuLl]?"); // this matches but is also matching parenthesis |
349 | int pos=rx.search(line,0); | 349 | int pos=rx.search(line,0); |
350 | if(pos > -1) return str+rx.matchedLength(); | 350 | if(pos > -1) return str+rx.matchedLength(); |
351 | else | 351 | else |
352 | return 0L; | 352 | return 0L; |
353 | 353 | ||
354 | #else | 354 | #else |
355 | if (str[0] == '0' && ((str[1]&0xdf) == 'X' )) { | 355 | if (str[0] == '0' && ((str[1]&0xdf) == 'X' )) { |
356 | str += 2; | 356 | str += 2; |
357 | s = str; | 357 | s = str; |
358 | while (s->isDigit() || ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') /*|| (*s >= 'a' && *s <= 'f')*/) s++; | 358 | while (s->isDigit() || ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') /*|| (*s >= 'a' && *s <= 'f')*/) s++; |
359 | if (s > str) { | 359 | if (s > str) { |
360 | if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++; | 360 | if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++; |
361 | return s; | 361 | return s; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | return 0L; | 364 | return 0L; |
365 | #endif | 365 | #endif |
366 | } | 366 | } |
367 | 367 | ||
368 | HlCFloat::HlCFloat(int attribute, int context) | 368 | HlCFloat::HlCFloat(int attribute, int context) |
369 | : HlFloat(attribute,context) { | 369 | : HlFloat(attribute,context) { |
370 | } | 370 | } |
371 | 371 | ||
372 | const QChar *HlCFloat::checkHgl(const QChar *s, int len, bool lineStart) { | 372 | const QChar *HlCFloat::checkHgl(const QChar *s, int len, bool lineStart) { |
373 | 373 | ||
374 | s = HlFloat::checkHgl(s, len, lineStart); | 374 | s = HlFloat::checkHgl(s, len, lineStart); |
375 | if (s && ((*s&0xdf) == 'F' )) s++; | 375 | if (s && ((*s&0xdf) == 'F' )) s++; |
376 | return s; | 376 | return s; |
377 | } | 377 | } |
378 | 378 | ||
379 | HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len) | 379 | HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len) |
380 | : HlItem(attribute, context) { | 380 | : HlItem(attribute, context) { |
381 | _charList=charList; | 381 | _charList=charList; |
382 | _charListLen=len; | 382 | _charListLen=len; |
383 | } | 383 | } |
384 | 384 | ||
385 | const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool) | 385 | const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool) |
386 | { | 386 | { |
387 | if (ustrchr(_charList, _charListLen, *s)) return s +1; | 387 | if (ustrchr(_charList, _charListLen, *s)) return s +1; |
388 | return 0L; | 388 | return 0L; |
389 | } | 389 | } |
390 | 390 | ||
391 | HlRegExpr::HlRegExpr(int attribute, int context,QString regexp) | 391 | HlRegExpr::HlRegExpr(int attribute, int context,QString regexp) |
392 | : HlItem(attribute, context) { | 392 | : HlItem(attribute, context), Expr(0) { |
393 | 393 | ||
394 | handlesLinestart=regexp.startsWith("^"); | 394 | handlesLinestart=regexp.startsWith("^"); |
395 | if(!handlesLinestart) regexp.prepend("^"); | 395 | if(!handlesLinestart) regexp.prepend("^"); |
396 | Expr=new QRegExp3(regexp); | 396 | Expr=new QRegExp3(regexp); |
397 | } | 397 | } |
398 | 398 | ||
399 | HlRegExpr::~HlRegExpr() | ||
400 | { | ||
401 | delete Expr; | ||
402 | } | ||
403 | |||
399 | const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart) | 404 | const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart) |
400 | { | 405 | { |
401 | if ((!lineStart) && handlesLinestart) return 0; | 406 | if ((!lineStart) && handlesLinestart) return 0; |
402 | 407 | ||
403 | QString line(s,len); | 408 | QString line(s,len); |
404 | int pos = Expr->search( line, 0 ); | 409 | int pos = Expr->search( line, 0 ); |
405 | if (pos==-1) return 0L; | 410 | if (pos==-1) return 0L; |
406 | else | 411 | else |
407 | return (s+Expr->matchedLength()); | 412 | return (s+Expr->matchedLength()); |
408 | }; | 413 | }; |
409 | 414 | ||
410 | 415 | ||
411 | HlLineContinue::HlLineContinue(int attribute, int context) | 416 | HlLineContinue::HlLineContinue(int attribute, int context) |
412 | : HlItem(attribute,context) { | 417 | : HlItem(attribute,context) { |
413 | } | 418 | } |
414 | 419 | ||
415 | const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) { | 420 | const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) { |
416 | 421 | ||
417 | if ((s[0].latin1() == '\\') && (len == 1)) | 422 | if ((s[0].latin1() == '\\') && (len == 1)) |
418 | { | 423 | { |
419 | return s + 1; | 424 | return s + 1; |
420 | } | 425 | } |
421 | return 0L; | 426 | return 0L; |
422 | } | 427 | } |
423 | 428 | ||
424 | 429 | ||
425 | HlCStringChar::HlCStringChar(int attribute, int context) | 430 | HlCStringChar::HlCStringChar(int attribute, int context) |
426 | : HlItem(attribute,context) { | 431 | : HlItem(attribute,context) { |
427 | } | 432 | } |
428 | 433 | ||
429 | //checks for hex and oct (for example \x1b or \033) | 434 | //checks for hex and oct (for example \x1b or \033) |
430 | const QChar *checkCharHexOct(const QChar *str) { | 435 | const QChar *checkCharHexOct(const QChar *str) { |
431 | const QChar *s; | 436 | const QChar *s; |
432 | s=str; | 437 | s=str; |
433 | int n; | 438 | int n; |
434 | if (*s == 'x') { | 439 | if (*s == 'x') { |
435 | n = 0; | 440 | n = 0; |
436 | do { | 441 | do { |
437 | s++; | 442 | s++; |
438 | n *= 16; | 443 | n *= 16; |
439 | if (s->isDigit()) n += *s - '0'; | 444 | if (s->isDigit()) n += *s - '0'; |
440 | else if ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') n += (*s&0xdf) - 'A' + 10; | 445 | else if ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') n += (*s&0xdf) - 'A' + 10; |
441 | // else if (*s >= 'a' && *s <= 'f') n += *s - 'a' + 10; | 446 | // else if (*s >= 'a' && *s <= 'f') n += *s - 'a' + 10; |
442 | else break; | 447 | else break; |
443 | if (n >= 256) return 0L; | 448 | if (n >= 256) return 0L; |
444 | } while (true); | 449 | } while (true); |
445 | if (s - str == 1) return 0L; | 450 | if (s - str == 1) return 0L; |
446 | } else { | 451 | } else { |