Mercurial > octave-nkf
comparison src/DLD-FUNCTIONS/regexp.cc @ 10550:c48b7048e720
style fixes
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 23 Apr 2010 14:43:41 -0400 |
parents | f5b8b28917a2 |
children | fb14397f73cb |
comparison
equal
deleted
inserted
replaced
10549:95c3e38098bf | 10550:c48b7048e720 |
---|---|
349 (dotexceptnewline ? 0 : PCRE_DOTALL) | | 349 (dotexceptnewline ? 0 : PCRE_DOTALL) | |
350 (lineanchors ? PCRE_MULTILINE : 0) | | 350 (lineanchors ? PCRE_MULTILINE : 0) | |
351 (freespacing ? PCRE_EXTENDED : 0), | 351 (freespacing ? PCRE_EXTENDED : 0), |
352 &err, &erroffset, 0); | 352 &err, &erroffset, 0); |
353 | 353 |
354 if (re == 0) { | 354 if (re == 0) |
355 error("%s: %s at position %d of expression", nm.c_str(), | 355 { |
356 err, erroffset); | 356 error("%s: %s at position %d of expression", nm.c_str(), |
357 return 0; | 357 err, erroffset); |
358 } | 358 return 0; |
359 } | |
359 | 360 |
360 int subpatterns; | 361 int subpatterns; |
361 int namecount; | 362 int namecount; |
362 int nameentrysize; | 363 int nameentrysize; |
363 char *nametable; | 364 char *nametable; |
445 | 446 |
446 const char **listptr; | 447 const char **listptr; |
447 int status = pcre_get_substring_list(buffer.c_str(), ovector, | 448 int status = pcre_get_substring_list(buffer.c_str(), ovector, |
448 matches, &listptr); | 449 matches, &listptr); |
449 | 450 |
450 if (status == PCRE_ERROR_NOMEMORY) { | 451 if (status == PCRE_ERROR_NOMEMORY) |
451 error("%s: cannot allocate memory in pcre_get_substring_list", | 452 { |
452 nm.c_str()); | 453 error("%s: cannot allocate memory in pcre_get_substring_list", |
453 pcre_free(re); | 454 nm.c_str()); |
454 return 0; | 455 pcre_free(re); |
455 } | 456 return 0; |
457 } | |
456 | 458 |
457 Cell cell_t (dim_vector(1,pos_match)); | 459 Cell cell_t (dim_vector(1,pos_match)); |
458 string_vector named_tokens(nnames); | 460 string_vector named_tokens(nnames); |
459 int pos_offset = 0; | 461 int pos_offset = 0; |
460 pos_match = 0; | 462 pos_match = 0; |
461 for (int i = 1; i < matches; i++) | 463 for (int i = 1; i < matches; i++) |
462 if (ovector[2*i] >= 0 && ovector[2*i+1] > 0) { | 464 if (ovector[2*i] >= 0 && ovector[2*i+1] > 0) |
463 if (i == 1 || ovector[2*i] != ovector[2*i-2] | 465 { |
464 || ovector[2*i-1] != ovector[2*i+1]) | 466 if (i == 1 || ovector[2*i] != ovector[2*i-2] |
465 { | 467 || ovector[2*i-1] != ovector[2*i+1]) |
466 if (namecount > 0) | 468 { |
467 named_tokens(named_idx(i-pos_offset-1)) = | 469 if (namecount > 0) |
468 std::string(*(listptr+nidx[i-pos_offset-1])); | 470 named_tokens(named_idx(i-pos_offset-1)) = |
469 cell_t(pos_match++) = | 471 std::string(*(listptr+nidx[i-pos_offset-1])); |
470 std::string(*(listptr+i)); | 472 cell_t(pos_match++) = |
471 } | 473 std::string(*(listptr+i)); |
472 else | 474 } |
473 pos_offset++; | 475 else |
476 pos_offset++; | |
474 } | 477 } |
475 | 478 |
476 m = std::string(*listptr); | 479 m = std::string(*listptr); |
477 t = cell_t; | 480 t = cell_t; |
478 | 481 |