comparison src/cmdhist.c @ 31531:6e24001000ed v9.0.1098

patch 9.0.1098: code uses too much indent Commit: https://github.com/vim/vim/commit/465de3a57b815f1188c707e7c083950c81652536 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Dec 26 12:50:04 2022 +0000 patch 9.0.1098: code uses too much indent Problem: Code uses too much indent. Solution: Use an early return. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/11747)
author Bram Moolenaar <Bram@vim.org>
date Mon, 26 Dec 2022 14:00:07 +0100
parents a220f176350a
children ca0229869b38
comparison
equal deleted inserted replaced
31530:4f57d68cd1c6 31531:6e24001000ed
458 int idx; 458 int idx;
459 int i; 459 int i;
460 int last; 460 int last;
461 int found = FALSE; 461 int found = FALSE;
462 462
463 regmatch.regprog = NULL; 463 if (hislen == 0 || histype < 0 || histype >= HIST_COUNT || *str == NUL
464 || hisidx[histype] < 0)
465 return FALSE;
466
467 idx = hisidx[histype];
468 regmatch.regprog = vim_regcomp(str, RE_MAGIC + RE_STRING);
469 if (regmatch.regprog == NULL)
470 return FALSE;
471
464 regmatch.rm_ic = FALSE; // always match case 472 regmatch.rm_ic = FALSE; // always match case
465 if (hislen != 0 473
466 && histype >= 0 474 i = last = idx;
467 && histype < HIST_COUNT 475 do
468 && *str != NUL 476 {
469 && (idx = hisidx[histype]) >= 0 477 hisptr = &history[histype][i];
470 && (regmatch.regprog = vim_regcomp(str, RE_MAGIC + RE_STRING)) 478 if (hisptr->hisstr == NULL)
471 != NULL) 479 break;
472 { 480 if (vim_regexec(&regmatch, hisptr->hisstr, (colnr_T)0))
473 i = last = idx; 481 {
474 do 482 found = TRUE;
475 { 483 vim_free(hisptr->hisstr);
476 hisptr = &history[histype][i]; 484 clear_hist_entry(hisptr);
477 if (hisptr->hisstr == NULL) 485 }
478 break; 486 else
479 if (vim_regexec(&regmatch, hisptr->hisstr, (colnr_T)0)) 487 {
488 if (i != last)
480 { 489 {
481 found = TRUE; 490 history[histype][last] = *hisptr;
482 vim_free(hisptr->hisstr);
483 clear_hist_entry(hisptr); 491 clear_hist_entry(hisptr);
484 } 492 }
485 else 493 if (--last < 0)
486 { 494 last += hislen;
487 if (i != last) 495 }
488 { 496 if (--i < 0)
489 history[histype][last] = *hisptr; 497 i += hislen;
490 clear_hist_entry(hisptr); 498 } while (i != idx);
491 } 499
492 if (--last < 0) 500 if (history[histype][idx].hisstr == NULL)
493 last += hislen; 501 hisidx[histype] = -1;
494 } 502
495 if (--i < 0)
496 i += hislen;
497 } while (i != idx);
498 if (history[histype][idx].hisstr == NULL)
499 hisidx[histype] = -1;
500 }
501 vim_regfree(regmatch.regprog); 503 vim_regfree(regmatch.regprog);
502 return found; 504 return found;
503 } 505 }
504 506
505 /* 507 /*