Mercurial > vim
comparison src/ex_cmds2.c @ 41:f529edb9bab3 v7.0025
updated for version 7.0025
author | vimboss |
---|---|
date | Mon, 27 Dec 2004 21:59:20 +0000 |
parents | f1d2a58883b9 |
children | e474bae3795f |
comparison
equal
deleted
inserted
replaced
40:f1d2a58883b9 | 41:f529edb9bab3 |
---|---|
489 else | 489 else |
490 { | 490 { |
491 if (bp->dbg_lnum == 0) /* default line number is 1 */ | 491 if (bp->dbg_lnum == 0) /* default line number is 1 */ |
492 bp->dbg_lnum = 1; | 492 bp->dbg_lnum = 1; |
493 BREAKP(dbg_breakp.ga_len++).dbg_nr = ++last_breakp; | 493 BREAKP(dbg_breakp.ga_len++).dbg_nr = ++last_breakp; |
494 --dbg_breakp.ga_room; | |
495 ++debug_tick; | 494 ++debug_tick; |
496 } | 495 } |
497 } | 496 } |
498 } | 497 } |
499 | 498 |
562 else | 561 else |
563 { | 562 { |
564 vim_free(BREAKP(todel).dbg_name); | 563 vim_free(BREAKP(todel).dbg_name); |
565 vim_free(BREAKP(todel).dbg_prog); | 564 vim_free(BREAKP(todel).dbg_prog); |
566 --dbg_breakp.ga_len; | 565 --dbg_breakp.ga_len; |
567 ++dbg_breakp.ga_room; | |
568 if (todel < dbg_breakp.ga_len) | 566 if (todel < dbg_breakp.ga_len) |
569 mch_memmove(&BREAKP(todel), &BREAKP(todel + 1), | 567 mch_memmove(&BREAKP(todel), &BREAKP(todel + 1), |
570 (dbg_breakp.ga_len - todel) * sizeof(struct debuggy)); | 568 (dbg_breakp.ga_len - todel) * sizeof(struct debuggy)); |
571 ++debug_tick; | 569 ++debug_tick; |
572 } | 570 } |
1061 *p = NUL; | 1059 *p = NUL; |
1062 | 1060 |
1063 return str; | 1061 return str; |
1064 } | 1062 } |
1065 | 1063 |
1064 /* | |
1065 * Separate the arguments in "str" and return a list of pointers in the | |
1066 * growarray "gap". | |
1067 */ | |
1068 int | |
1069 get_arglist(gap, str) | |
1070 garray_T *gap; | |
1071 char_u *str; | |
1072 { | |
1073 ga_init2(gap, (int)sizeof(char_u *), 20); | |
1074 while (*str != NUL) | |
1075 { | |
1076 if (ga_grow(gap, 1) == FAIL) | |
1077 { | |
1078 ga_clear(gap); | |
1079 return FAIL; | |
1080 } | |
1081 ((char_u **)gap->ga_data)[gap->ga_len++] = str; | |
1082 | |
1083 /* Isolate one argument, change it in-place, put a NUL after it. */ | |
1084 str = do_one_arg(str); | |
1085 } | |
1086 return OK; | |
1087 } | |
1088 | |
1066 #if defined(FEAT_GUI) || defined(FEAT_CLIENTSERVER) || defined(PROTO) | 1089 #if defined(FEAT_GUI) || defined(FEAT_CLIENTSERVER) || defined(PROTO) |
1067 /* | 1090 /* |
1068 * Redefine the argument list. | 1091 * Redefine the argument list. |
1069 */ | 1092 */ |
1070 void | 1093 void |
1099 #endif | 1122 #endif |
1100 | 1123 |
1101 /* | 1124 /* |
1102 * Collect all file name arguments in "new_ga". | 1125 * Collect all file name arguments in "new_ga". |
1103 */ | 1126 */ |
1104 ga_init2(&new_ga, (int)sizeof(char_u *), 20); | 1127 if (get_arglist(&new_ga, str) == FAIL) |
1105 while (*str) | 1128 return FAIL; |
1106 { | |
1107 if (ga_grow(&new_ga, 1) == FAIL) | |
1108 { | |
1109 ga_clear(&new_ga); | |
1110 return FAIL; | |
1111 } | |
1112 ((char_u **)new_ga.ga_data)[new_ga.ga_len++] = str; | |
1113 --new_ga.ga_room; | |
1114 | |
1115 /* Isolate one argument, change it in-place, put a NUL after it. */ | |
1116 str = do_one_arg(str); | |
1117 } | |
1118 | 1129 |
1119 #ifdef FEAT_LISTCMDS | 1130 #ifdef FEAT_LISTCMDS |
1120 if (what == AL_DEL) | 1131 if (what == AL_DEL) |
1121 { | 1132 { |
1122 regmatch_T regmatch; | 1133 regmatch_T regmatch; |
1152 didone = TRUE; | 1163 didone = TRUE; |
1153 vim_free(ARGLIST[match].ae_fname); | 1164 vim_free(ARGLIST[match].ae_fname); |
1154 mch_memmove(ARGLIST + match, ARGLIST + match + 1, | 1165 mch_memmove(ARGLIST + match, ARGLIST + match + 1, |
1155 (ARGCOUNT - match - 1) * sizeof(aentry_T)); | 1166 (ARGCOUNT - match - 1) * sizeof(aentry_T)); |
1156 --ALIST(curwin)->al_ga.ga_len; | 1167 --ALIST(curwin)->al_ga.ga_len; |
1157 ++ALIST(curwin)->al_ga.ga_room; | |
1158 if (curwin->w_arg_idx > match) | 1168 if (curwin->w_arg_idx > match) |
1159 --curwin->w_arg_idx; | 1169 --curwin->w_arg_idx; |
1160 --match; | 1170 --match; |
1161 } | 1171 } |
1162 | 1172 |
1187 (void)alist_add_list(exp_count, exp_files, after); | 1197 (void)alist_add_list(exp_count, exp_files, after); |
1188 vim_free(exp_files); | 1198 vim_free(exp_files); |
1189 } | 1199 } |
1190 else /* what == AL_SET */ | 1200 else /* what == AL_SET */ |
1191 #endif | 1201 #endif |
1192 alist_set(ALIST(curwin), exp_count, exp_files, FALSE); | 1202 alist_set(ALIST(curwin), exp_count, exp_files, FALSE, NULL, 0); |
1193 } | 1203 } |
1194 | 1204 |
1195 alist_check_arg_idx(); | 1205 alist_check_arg_idx(); |
1196 | 1206 |
1197 return OK; | 1207 return OK; |
1340 AARGLIST(curwin->w_alist)[gap->ga_len].ae_fname = | 1350 AARGLIST(curwin->w_alist)[gap->ga_len].ae_fname = |
1341 vim_strsave(GARGLIST[i].ae_fname); | 1351 vim_strsave(GARGLIST[i].ae_fname); |
1342 AARGLIST(curwin->w_alist)[gap->ga_len].ae_fnum = | 1352 AARGLIST(curwin->w_alist)[gap->ga_len].ae_fnum = |
1343 GARGLIST[i].ae_fnum; | 1353 GARGLIST[i].ae_fnum; |
1344 ++gap->ga_len; | 1354 ++gap->ga_len; |
1345 --gap->ga_room; | |
1346 } | 1355 } |
1347 } | 1356 } |
1348 #endif | 1357 #endif |
1349 } | 1358 } |
1350 | 1359 |
1577 for (i = eap->line1; i <= eap->line2; ++i) | 1586 for (i = eap->line1; i <= eap->line2; ++i) |
1578 vim_free(ARGLIST[i - 1].ae_fname); | 1587 vim_free(ARGLIST[i - 1].ae_fname); |
1579 mch_memmove(ARGLIST + eap->line1 - 1, ARGLIST + eap->line2, | 1588 mch_memmove(ARGLIST + eap->line1 - 1, ARGLIST + eap->line2, |
1580 (size_t)((ARGCOUNT - eap->line2) * sizeof(aentry_T))); | 1589 (size_t)((ARGCOUNT - eap->line2) * sizeof(aentry_T))); |
1581 ALIST(curwin)->al_ga.ga_len -= n; | 1590 ALIST(curwin)->al_ga.ga_len -= n; |
1582 ALIST(curwin)->al_ga.ga_room += n; | |
1583 if (curwin->w_arg_idx >= eap->line2) | 1591 if (curwin->w_arg_idx >= eap->line2) |
1584 curwin->w_arg_idx -= n; | 1592 curwin->w_arg_idx -= n; |
1585 else if (curwin->w_arg_idx > eap->line1) | 1593 else if (curwin->w_arg_idx > eap->line1) |
1586 curwin->w_arg_idx = eap->line1; | 1594 curwin->w_arg_idx = eap->line1; |
1587 } | 1595 } |
1784 { | 1792 { |
1785 ARGLIST[after + i].ae_fname = files[i]; | 1793 ARGLIST[after + i].ae_fname = files[i]; |
1786 ARGLIST[after + i].ae_fnum = buflist_add(files[i], BLN_LISTED); | 1794 ARGLIST[after + i].ae_fnum = buflist_add(files[i], BLN_LISTED); |
1787 } | 1795 } |
1788 ALIST(curwin)->al_ga.ga_len += count; | 1796 ALIST(curwin)->al_ga.ga_len += count; |
1789 ALIST(curwin)->al_ga.ga_room -= count; | |
1790 if (curwin->w_arg_idx >= after) | 1797 if (curwin->w_arg_idx >= after) |
1791 ++curwin->w_arg_idx; | 1798 ++curwin->w_arg_idx; |
1792 return after; | 1799 return after; |
1793 } | 1800 } |
1794 | 1801 |
2363 { | 2370 { |
2364 while (script_names.ga_len < current_SID) | 2371 while (script_names.ga_len < current_SID) |
2365 { | 2372 { |
2366 SCRIPT_NAME(script_names.ga_len + 1) = NULL; | 2373 SCRIPT_NAME(script_names.ga_len + 1) = NULL; |
2367 ++script_names.ga_len; | 2374 ++script_names.ga_len; |
2368 --script_names.ga_room; | |
2369 } | 2375 } |
2370 SCRIPT_NAME(current_SID) = fname_exp; | 2376 SCRIPT_NAME(current_SID) = fname_exp; |
2371 # ifdef UNIX | 2377 # ifdef UNIX |
2372 if (stat_ok) | 2378 if (stat_ok) |
2373 { | 2379 { |
2672 buf = (char_u *)ga.ga_data; | 2678 buf = (char_u *)ga.ga_data; |
2673 | 2679 |
2674 #ifdef USE_CR | 2680 #ifdef USE_CR |
2675 if (sp->fileformat == EOL_MAC) | 2681 if (sp->fileformat == EOL_MAC) |
2676 { | 2682 { |
2677 if (fgets_cr((char *)buf + ga.ga_len, ga.ga_room, sp->fp) == NULL) | 2683 if (fgets_cr((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len, |
2684 sp->fp) == NULL) | |
2678 break; | 2685 break; |
2679 } | 2686 } |
2680 else | 2687 else |
2681 #endif | 2688 #endif |
2682 if (fgets((char *)buf + ga.ga_len, ga.ga_room, sp->fp) == NULL) | 2689 if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len, |
2690 sp->fp) == NULL) | |
2683 break; | 2691 break; |
2684 len = (int)STRLEN(buf); | 2692 len = (int)STRLEN(buf); |
2685 #ifdef USE_CRNL | 2693 #ifdef USE_CRNL |
2686 /* Ignore a trailing CTRL-Z, when in Dos mode. Only recognize the | 2694 /* Ignore a trailing CTRL-Z, when in Dos mode. Only recognize the |
2687 * CTRL-Z by its own, or after a NL. */ | 2695 * CTRL-Z by its own, or after a NL. */ |
2721 len = STRLEN(buf); | 2729 len = STRLEN(buf); |
2722 } | 2730 } |
2723 #endif | 2731 #endif |
2724 | 2732 |
2725 have_read = TRUE; | 2733 have_read = TRUE; |
2726 ga.ga_room -= len - ga.ga_len; | |
2727 ga.ga_len = len; | 2734 ga.ga_len = len; |
2728 | 2735 |
2729 /* If the line was longer than the buffer, read more. */ | 2736 /* If the line was longer than the buffer, read more. */ |
2730 if (ga.ga_room == 1 && buf[len - 1] != '\n') | 2737 if (ga.ga_maxlen - ga.ga_len == 1 && buf[len - 1] != '\n') |
2731 continue; | 2738 continue; |
2732 | 2739 |
2733 if (len >= 1 && buf[len - 1] == '\n') /* remove trailing NL */ | 2740 if (len >= 1 && buf[len - 1] == '\n') /* remove trailing NL */ |
2734 { | 2741 { |
2735 #ifdef USE_CRNL | 2742 #ifdef USE_CRNL |
2747 if (has_cr) /* replace trailing CR */ | 2754 if (has_cr) /* replace trailing CR */ |
2748 { | 2755 { |
2749 buf[len - 2] = '\n'; | 2756 buf[len - 2] = '\n'; |
2750 --len; | 2757 --len; |
2751 --ga.ga_len; | 2758 --ga.ga_len; |
2752 ++ga.ga_room; | |
2753 } | 2759 } |
2754 else /* lines like ":map xx yy^M" will have failed */ | 2760 else /* lines like ":map xx yy^M" will have failed */ |
2755 { | 2761 { |
2756 if (!sp->error) | 2762 if (!sp->error) |
2757 { | 2763 { |