comparison src/debugger.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 c0be6563fa39
children b89cfd86e18e
comparison
equal deleted inserted replaced
31530:4f57d68cd1c6 31531:6e24001000ed
680 #ifdef FEAT_PROFILE 680 #ifdef FEAT_PROFILE
681 if (eap->cmdidx == CMD_profile) 681 if (eap->cmdidx == CMD_profile)
682 gap = &prof_ga; 682 gap = &prof_ga;
683 #endif 683 #endif
684 684
685 if (dbg_parsearg(eap->arg, gap) == OK) 685 if (dbg_parsearg(eap->arg, gap) != OK)
686 { 686 return;
687 bp = &DEBUGGY(gap, gap->ga_len); 687
688 bp->dbg_forceit = eap->forceit; 688 bp = &DEBUGGY(gap, gap->ga_len);
689 689 bp->dbg_forceit = eap->forceit;
690 if (bp->dbg_type != DBG_EXPR) 690
691 { 691 if (bp->dbg_type != DBG_EXPR)
692 pat = file_pat_to_reg_pat(bp->dbg_name, NULL, NULL, FALSE); 692 {
693 if (pat != NULL) 693 pat = file_pat_to_reg_pat(bp->dbg_name, NULL, NULL, FALSE);
694 if (pat != NULL)
695 {
696 bp->dbg_prog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
697 vim_free(pat);
698 }
699 if (pat == NULL || bp->dbg_prog == NULL)
700 vim_free(bp->dbg_name);
701 else
702 {
703 if (bp->dbg_lnum == 0) // default line number is 1
704 bp->dbg_lnum = 1;
705 #ifdef FEAT_PROFILE
706 if (eap->cmdidx != CMD_profile)
707 #endif
694 { 708 {
695 bp->dbg_prog = vim_regcomp(pat, RE_MAGIC + RE_STRING); 709 DEBUGGY(gap, gap->ga_len).dbg_nr = ++last_breakp;
696 vim_free(pat); 710 ++debug_tick;
697 } 711 }
698 if (pat == NULL || bp->dbg_prog == NULL) 712 ++gap->ga_len;
699 vim_free(bp->dbg_name); 713 }
700 else 714 }
701 { 715 else
702 if (bp->dbg_lnum == 0) // default line number is 1 716 {
703 bp->dbg_lnum = 1; 717 // DBG_EXPR
704 #ifdef FEAT_PROFILE 718 DEBUGGY(gap, gap->ga_len++).dbg_nr = ++last_breakp;
705 if (eap->cmdidx != CMD_profile) 719 ++debug_tick;
706 #endif 720 if (gap == &dbg_breakp)
707 { 721 has_expr_breakpoint = TRUE;
708 DEBUGGY(gap, gap->ga_len).dbg_nr = ++last_breakp;
709 ++debug_tick;
710 }
711 ++gap->ga_len;
712 }
713 }
714 else
715 {
716 // DBG_EXPR
717 DEBUGGY(gap, gap->ga_len++).dbg_nr = ++last_breakp;
718 ++debug_tick;
719 if (gap == &dbg_breakp)
720 has_expr_breakpoint = TRUE;
721 }
722 } 722 }
723 } 723 }
724 724
725 /* 725 /*
726 * ":debuggreedy". 726 * ":debuggreedy".
820 } 820 }
821 vim_free(bp->dbg_name); 821 vim_free(bp->dbg_name);
822 } 822 }
823 823
824 if (todel < 0) 824 if (todel < 0)
825 {
825 semsg(_(e_breakpoint_not_found_str), eap->arg); 826 semsg(_(e_breakpoint_not_found_str), eap->arg);
826 else 827 return;
827 { 828 }
828 while (gap->ga_len > 0) 829
829 { 830 while (gap->ga_len > 0)
830 vim_free(DEBUGGY(gap, todel).dbg_name); 831 {
832 vim_free(DEBUGGY(gap, todel).dbg_name);
831 #ifdef FEAT_EVAL 833 #ifdef FEAT_EVAL
832 if (DEBUGGY(gap, todel).dbg_type == DBG_EXPR 834 if (DEBUGGY(gap, todel).dbg_type == DBG_EXPR
833 && DEBUGGY(gap, todel).dbg_val != NULL) 835 && DEBUGGY(gap, todel).dbg_val != NULL)
834 free_tv(DEBUGGY(gap, todel).dbg_val); 836 free_tv(DEBUGGY(gap, todel).dbg_val);
835 #endif 837 #endif
836 vim_regfree(DEBUGGY(gap, todel).dbg_prog); 838 vim_regfree(DEBUGGY(gap, todel).dbg_prog);
837 --gap->ga_len; 839 --gap->ga_len;
838 if (todel < gap->ga_len) 840 if (todel < gap->ga_len)
839 mch_memmove(&DEBUGGY(gap, todel), &DEBUGGY(gap, todel + 1), 841 mch_memmove(&DEBUGGY(gap, todel), &DEBUGGY(gap, todel + 1),
840 (gap->ga_len - todel) * sizeof(struct debuggy)); 842 (gap->ga_len - todel) * sizeof(struct debuggy));
841 #ifdef FEAT_PROFILE 843 #ifdef FEAT_PROFILE
842 if (eap->cmdidx == CMD_breakdel) 844 if (eap->cmdidx == CMD_breakdel)
843 #endif 845 #endif
844 ++debug_tick; 846 ++debug_tick;
845 if (!del_all) 847 if (!del_all)
846 break; 848 break;
847 } 849 }
848 850
849 // If all breakpoints were removed clear the array. 851 // If all breakpoints were removed clear the array.
850 if (gap->ga_len == 0) 852 if (gap->ga_len == 0)
851 ga_clear(gap); 853 ga_clear(gap);
852 if (gap == &dbg_breakp) 854 if (gap == &dbg_breakp)
853 update_has_expr_breakpoint(); 855 update_has_expr_breakpoint();
854 }
855 } 856 }
856 857
857 /* 858 /*
858 * ":breaklist". 859 * ":breaklist".
859 */ 860 */
862 { 863 {
863 struct debuggy *bp; 864 struct debuggy *bp;
864 int i; 865 int i;
865 866
866 if (dbg_breakp.ga_len == 0) 867 if (dbg_breakp.ga_len == 0)
868 {
867 msg(_("No breakpoints defined")); 869 msg(_("No breakpoints defined"));
868 else 870 return;
869 for (i = 0; i < dbg_breakp.ga_len; ++i) 871 }
870 { 872
871 bp = &BREAKP(i); 873 for (i = 0; i < dbg_breakp.ga_len; ++i)
872 if (bp->dbg_type == DBG_FILE) 874 {
873 home_replace(NULL, bp->dbg_name, NameBuff, MAXPATHL, TRUE); 875 bp = &BREAKP(i);
874 if (bp->dbg_type != DBG_EXPR) 876 if (bp->dbg_type == DBG_FILE)
875 smsg(_("%3d %s %s line %ld"), 877 home_replace(NULL, bp->dbg_name, NameBuff, MAXPATHL, TRUE);
878 if (bp->dbg_type != DBG_EXPR)
879 smsg(_("%3d %s %s line %ld"),
876 bp->dbg_nr, 880 bp->dbg_nr,
877 bp->dbg_type == DBG_FUNC ? "func" : "file", 881 bp->dbg_type == DBG_FUNC ? "func" : "file",
878 bp->dbg_type == DBG_FUNC ? bp->dbg_name : NameBuff, 882 bp->dbg_type == DBG_FUNC ? bp->dbg_name : NameBuff,
879 (long)bp->dbg_lnum); 883 (long)bp->dbg_lnum);
880 else 884 else
881 smsg(_("%3d expr %s"), 885 smsg(_("%3d expr %s"),
882 bp->dbg_nr, bp->dbg_name); 886 bp->dbg_nr, bp->dbg_name);
883 } 887 }
884 } 888 }
885 889
886 /* 890 /*
887 * Find a breakpoint for a function or sourced file. 891 * Find a breakpoint for a function or sourced file.
888 * Returns line number at which to break; zero when no matching breakpoint. 892 * Returns line number at which to break; zero when no matching breakpoint.