Mercurial > vim
comparison src/ex_cmds2.c @ 18779:8f05b3cf8557 v8.1.2379
patch 8.1.2379: using old C style comments
Commit: https://github.com/vim/vim/commit/217e1b8359447f5550dcb0d1ee43380a90c253c5
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 1 21:41:28 2019 +0100
patch 8.1.2379: using old C style comments
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 01 Dec 2019 21:45:04 +0100 |
parents | d1e77015f60b |
children | 5c405689da3e |
comparison
equal
deleted
inserted
replaced
18778:2182f82b04e4 | 18779:8f05b3cf8557 |
---|---|
87 long prev_id = last_timer_id; | 87 long prev_id = last_timer_id; |
88 | 88 |
89 if (timer == NULL) | 89 if (timer == NULL) |
90 return NULL; | 90 return NULL; |
91 if (++last_timer_id <= prev_id) | 91 if (++last_timer_id <= prev_id) |
92 /* Overflow! Might cause duplicates... */ | 92 // Overflow! Might cause duplicates... |
93 last_timer_id = 0; | 93 last_timer_id = 0; |
94 timer->tr_id = last_timer_id; | 94 timer->tr_id = last_timer_id; |
95 insert_timer(timer); | 95 insert_timer(timer); |
96 if (repeat != 0) | 96 if (repeat != 0) |
97 timer->tr_repeat = repeat - 1; | 97 timer->tr_repeat = repeat - 1; |
133 proftime_T now; | 133 proftime_T now; |
134 int did_one = FALSE; | 134 int did_one = FALSE; |
135 int need_update_screen = FALSE; | 135 int need_update_screen = FALSE; |
136 long current_id = last_timer_id; | 136 long current_id = last_timer_id; |
137 | 137 |
138 /* Don't run any timers while exiting or dealing with an error. */ | 138 // Don't run any timers while exiting or dealing with an error. |
139 if (exiting || aborting()) | 139 if (exiting || aborting()) |
140 return next_due; | 140 return next_due; |
141 | 141 |
142 profile_start(&now); | 142 profile_start(&now); |
143 for (timer = first_timer; timer != NULL && !got_int; timer = timer_next) | 143 for (timer = first_timer; timer != NULL && !got_int; timer = timer_next) |
147 if (timer->tr_id == -1 || timer->tr_firing || timer->tr_paused) | 147 if (timer->tr_id == -1 || timer->tr_firing || timer->tr_paused) |
148 continue; | 148 continue; |
149 this_due = proftime_time_left(&timer->tr_due, &now); | 149 this_due = proftime_time_left(&timer->tr_due, &now); |
150 if (this_due <= 1) | 150 if (this_due <= 1) |
151 { | 151 { |
152 /* Save and restore a lot of flags, because the timer fires while | 152 // Save and restore a lot of flags, because the timer fires while |
153 * waiting for a character, which might be halfway a command. */ | 153 // waiting for a character, which might be halfway a command. |
154 int save_timer_busy = timer_busy; | 154 int save_timer_busy = timer_busy; |
155 int save_vgetc_busy = vgetc_busy; | 155 int save_vgetc_busy = vgetc_busy; |
156 int save_did_emsg = did_emsg; | 156 int save_did_emsg = did_emsg; |
157 int save_called_emsg = called_emsg; | 157 int save_called_emsg = called_emsg; |
158 int save_must_redraw = must_redraw; | 158 int save_must_redraw = must_redraw; |
161 int save_ex_pressedreturn = get_pressedreturn(); | 161 int save_ex_pressedreturn = get_pressedreturn(); |
162 int save_may_garbage_collect = may_garbage_collect; | 162 int save_may_garbage_collect = may_garbage_collect; |
163 except_T *save_current_exception = current_exception; | 163 except_T *save_current_exception = current_exception; |
164 vimvars_save_T vvsave; | 164 vimvars_save_T vvsave; |
165 | 165 |
166 /* Create a scope for running the timer callback, ignoring most of | 166 // Create a scope for running the timer callback, ignoring most of |
167 * the current scope, such as being inside a try/catch. */ | 167 // the current scope, such as being inside a try/catch. |
168 timer_busy = timer_busy > 0 || vgetc_busy > 0; | 168 timer_busy = timer_busy > 0 || vgetc_busy > 0; |
169 vgetc_busy = 0; | 169 vgetc_busy = 0; |
170 called_emsg = FALSE; | 170 called_emsg = FALSE; |
171 did_emsg = FALSE; | 171 did_emsg = FALSE; |
172 did_uncaught_emsg = FALSE; | 172 did_uncaught_emsg = FALSE; |
198 must_redraw = must_redraw > save_must_redraw | 198 must_redraw = must_redraw > save_must_redraw |
199 ? must_redraw : save_must_redraw; | 199 ? must_redraw : save_must_redraw; |
200 set_pressedreturn(save_ex_pressedreturn); | 200 set_pressedreturn(save_ex_pressedreturn); |
201 may_garbage_collect = save_may_garbage_collect; | 201 may_garbage_collect = save_may_garbage_collect; |
202 | 202 |
203 /* Only fire the timer again if it repeats and stop_timer() wasn't | 203 // Only fire the timer again if it repeats and stop_timer() wasn't |
204 * called while inside the callback (tr_id == -1). */ | 204 // called while inside the callback (tr_id == -1). |
205 if (timer->tr_repeat != 0 && timer->tr_id != -1 | 205 if (timer->tr_repeat != 0 && timer->tr_id != -1 |
206 && timer->tr_emsg_count < 3) | 206 && timer->tr_emsg_count < 3) |
207 { | 207 { |
208 profile_setlimit(timer->tr_interval, &timer->tr_due); | 208 profile_setlimit(timer->tr_interval, &timer->tr_due); |
209 this_due = proftime_time_left(&timer->tr_due, &now); | 209 this_due = proftime_time_left(&timer->tr_due, &now); |
248 else if (next_due == -1 || next_due > this_due) | 248 else if (next_due == -1 || next_due > this_due) |
249 next_due = this_due; | 249 next_due = this_due; |
250 } | 250 } |
251 #endif | 251 #endif |
252 #ifdef FEAT_TERMINAL | 252 #ifdef FEAT_TERMINAL |
253 /* Some terminal windows may need their buffer updated. */ | 253 // Some terminal windows may need their buffer updated. |
254 next_due = term_check_timers(next_due, &now); | 254 next_due = term_check_timers(next_due, &now); |
255 #endif | 255 #endif |
256 | 256 |
257 return current_id != last_timer_id ? 1 : next_due; | 257 return current_id != last_timer_id ? 1 : next_due; |
258 } | 258 } |
280 */ | 280 */ |
281 void | 281 void |
282 stop_timer(timer_T *timer) | 282 stop_timer(timer_T *timer) |
283 { | 283 { |
284 if (timer->tr_firing) | 284 if (timer->tr_firing) |
285 /* Free the timer after the callback returns. */ | 285 // Free the timer after the callback returns. |
286 timer->tr_id = -1; | 286 timer->tr_id = -1; |
287 else | 287 else |
288 { | 288 { |
289 remove_timer(timer); | 289 remove_timer(timer); |
290 free_timer(timer); | 290 free_timer(timer); |
518 int r; | 518 int r; |
519 bufref_T bufref; | 519 bufref_T bufref; |
520 | 520 |
521 if (!(p_aw || p_awa) || !p_write | 521 if (!(p_aw || p_awa) || !p_write |
522 #ifdef FEAT_QUICKFIX | 522 #ifdef FEAT_QUICKFIX |
523 /* never autowrite a "nofile" or "nowrite" buffer */ | 523 // never autowrite a "nofile" or "nowrite" buffer |
524 || bt_dontwrite(buf) | 524 || bt_dontwrite(buf) |
525 #endif | 525 #endif |
526 || (!forceit && buf->b_p_ro) || buf->b_ffname == NULL) | 526 || (!forceit && buf->b_p_ro) || buf->b_ffname == NULL) |
527 return FAIL; | 527 return FAIL; |
528 set_bufref(&bufref, buf); | 528 set_bufref(&bufref, buf); |
529 r = buf_write_all(buf, forceit); | 529 r = buf_write_all(buf, forceit); |
530 | 530 |
531 /* Writing may succeed but the buffer still changed, e.g., when there is a | 531 // Writing may succeed but the buffer still changed, e.g., when there is a |
532 * conversion error. We do want to return FAIL then. */ | 532 // conversion error. We do want to return FAIL then. |
533 if (bufref_valid(&bufref) && bufIsChanged(buf)) | 533 if (bufref_valid(&bufref) && bufIsChanged(buf)) |
534 r = FAIL; | 534 r = FAIL; |
535 return r; | 535 return r; |
536 } | 536 } |
537 | 537 |
552 | 552 |
553 set_bufref(&bufref, buf); | 553 set_bufref(&bufref, buf); |
554 | 554 |
555 (void)buf_write_all(buf, FALSE); | 555 (void)buf_write_all(buf, FALSE); |
556 | 556 |
557 /* an autocommand may have deleted the buffer */ | 557 // an autocommand may have deleted the buffer |
558 if (!bufref_valid(&bufref)) | 558 if (!bufref_valid(&bufref)) |
559 buf = firstbuf; | 559 buf = firstbuf; |
560 } | 560 } |
561 } | 561 } |
562 | 562 |
591 || cmdmod.browse | 591 || cmdmod.browse |
592 # endif | 592 # endif |
593 )) | 593 )) |
594 ++count; | 594 ++count; |
595 if (!bufref_valid(&bufref)) | 595 if (!bufref_valid(&bufref)) |
596 /* Autocommand deleted buffer, oops! It's not changed now. */ | 596 // Autocommand deleted buffer, oops! It's not changed now. |
597 return FALSE; | 597 return FALSE; |
598 | 598 |
599 dialog_changed(buf, count > 1); | 599 dialog_changed(buf, count > 1); |
600 | 600 |
601 if (!bufref_valid(&bufref)) | 601 if (!bufref_valid(&bufref)) |
602 /* Autocommand deleted buffer, oops! It's not changed now. */ | 602 // Autocommand deleted buffer, oops! It's not changed now. |
603 return FALSE; | 603 return FALSE; |
604 return bufIsChanged(buf); | 604 return bufIsChanged(buf); |
605 } | 605 } |
606 #endif | 606 #endif |
607 if (flags & CCGD_EXCMD) | 607 if (flags & CCGD_EXCMD) |
643 * Must check 'write' option first! | 643 * Must check 'write' option first! |
644 */ | 644 */ |
645 void | 645 void |
646 dialog_changed( | 646 dialog_changed( |
647 buf_T *buf, | 647 buf_T *buf, |
648 int checkall) /* may abandon all changed buffers */ | 648 int checkall) // may abandon all changed buffers |
649 { | 649 { |
650 char_u buff[DIALOG_MSG_SIZE]; | 650 char_u buff[DIALOG_MSG_SIZE]; |
651 int ret; | 651 int ret; |
652 buf_T *buf2; | 652 buf_T *buf2; |
653 exarg_T ea; | 653 exarg_T ea; |
663 vim_memset(&ea, 0, sizeof(ea)); | 663 vim_memset(&ea, 0, sizeof(ea)); |
664 | 664 |
665 if (ret == VIM_YES) | 665 if (ret == VIM_YES) |
666 { | 666 { |
667 #ifdef FEAT_BROWSE | 667 #ifdef FEAT_BROWSE |
668 /* May get file name, when there is none */ | 668 // May get file name, when there is none |
669 browse_save_fname(buf); | 669 browse_save_fname(buf); |
670 #endif | 670 #endif |
671 if (buf->b_fname != NULL && check_overwrite(&ea, buf, | 671 if (buf->b_fname != NULL && check_overwrite(&ea, buf, |
672 buf->b_fname, buf->b_ffname, FALSE) == OK) | 672 buf->b_fname, buf->b_ffname, FALSE) == OK) |
673 /* didn't hit Cancel */ | 673 // didn't hit Cancel |
674 (void)buf_write_all(buf, FALSE); | 674 (void)buf_write_all(buf, FALSE); |
675 } | 675 } |
676 else if (ret == VIM_NO) | 676 else if (ret == VIM_NO) |
677 { | 677 { |
678 unchanged(buf, TRUE, FALSE); | 678 unchanged(buf, TRUE, FALSE); |
696 { | 696 { |
697 bufref_T bufref; | 697 bufref_T bufref; |
698 | 698 |
699 set_bufref(&bufref, buf2); | 699 set_bufref(&bufref, buf2); |
700 #ifdef FEAT_BROWSE | 700 #ifdef FEAT_BROWSE |
701 /* May get file name, when there is none */ | 701 // May get file name, when there is none |
702 browse_save_fname(buf2); | 702 browse_save_fname(buf2); |
703 #endif | 703 #endif |
704 if (buf2->b_fname != NULL && check_overwrite(&ea, buf2, | 704 if (buf2->b_fname != NULL && check_overwrite(&ea, buf2, |
705 buf2->b_fname, buf2->b_ffname, FALSE) == OK) | 705 buf2->b_fname, buf2->b_ffname, FALSE) == OK) |
706 /* didn't hit Cancel */ | 706 // didn't hit Cancel |
707 (void)buf_write_all(buf2, FALSE); | 707 (void)buf_write_all(buf2, FALSE); |
708 | 708 |
709 /* an autocommand may have deleted the buffer */ | 709 // an autocommand may have deleted the buffer |
710 if (!bufref_valid(&bufref)) | 710 if (!bufref_valid(&bufref)) |
711 buf2 = firstbuf; | 711 buf2 = firstbuf; |
712 } | 712 } |
713 } | 713 } |
714 } | 714 } |
758 * When "unload" is TRUE the current buffer is unloaded instead of making it | 758 * When "unload" is TRUE the current buffer is unloaded instead of making it |
759 * hidden. This is used for ":q!". | 759 * hidden. This is used for ":q!". |
760 */ | 760 */ |
761 int | 761 int |
762 check_changed_any( | 762 check_changed_any( |
763 int hidden, /* Only check hidden buffers */ | 763 int hidden, // Only check hidden buffers |
764 int unload) | 764 int unload) |
765 { | 765 { |
766 int ret = FALSE; | 766 int ret = FALSE; |
767 buf_T *buf; | 767 buf_T *buf; |
768 int save; | 768 int save; |
771 int bufcount = 0; | 771 int bufcount = 0; |
772 int *bufnrs; | 772 int *bufnrs; |
773 tabpage_T *tp; | 773 tabpage_T *tp; |
774 win_T *wp; | 774 win_T *wp; |
775 | 775 |
776 /* Make a list of all buffers, with the most important ones first. */ | 776 // Make a list of all buffers, with the most important ones first. |
777 FOR_ALL_BUFFERS(buf) | 777 FOR_ALL_BUFFERS(buf) |
778 ++bufcount; | 778 ++bufcount; |
779 | 779 |
780 if (bufcount == 0) | 780 if (bufcount == 0) |
781 return FALSE; | 781 return FALSE; |
782 | 782 |
783 bufnrs = ALLOC_MULT(int, bufcount); | 783 bufnrs = ALLOC_MULT(int, bufcount); |
784 if (bufnrs == NULL) | 784 if (bufnrs == NULL) |
785 return FALSE; | 785 return FALSE; |
786 | 786 |
787 /* curbuf */ | 787 // curbuf |
788 bufnrs[bufnum++] = curbuf->b_fnum; | 788 bufnrs[bufnum++] = curbuf->b_fnum; |
789 | 789 |
790 /* buffers in current tab */ | 790 // buffers in current tab |
791 FOR_ALL_WINDOWS(wp) | 791 FOR_ALL_WINDOWS(wp) |
792 if (wp->w_buffer != curbuf) | 792 if (wp->w_buffer != curbuf) |
793 add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); | 793 add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); |
794 | 794 |
795 /* buffers in other tabs */ | 795 // buffers in other tabs |
796 FOR_ALL_TABPAGES(tp) | 796 FOR_ALL_TABPAGES(tp) |
797 if (tp != curtab) | 797 if (tp != curtab) |
798 for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) | 798 for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) |
799 add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); | 799 add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); |
800 | 800 |
801 /* any other buffer */ | 801 // any other buffer |
802 FOR_ALL_BUFFERS(buf) | 802 FOR_ALL_BUFFERS(buf) |
803 add_bufnum(bufnrs, &bufnum, buf->b_fnum); | 803 add_bufnum(bufnrs, &bufnum, buf->b_fnum); |
804 | 804 |
805 for (i = 0; i < bufnum; ++i) | 805 for (i = 0; i < bufnum; ++i) |
806 { | 806 { |
818 if (term_try_stop_job(buf) == FAIL) | 818 if (term_try_stop_job(buf) == FAIL) |
819 break; | 819 break; |
820 } | 820 } |
821 else | 821 else |
822 #endif | 822 #endif |
823 /* Try auto-writing the buffer. If this fails but the buffer no | 823 // Try auto-writing the buffer. If this fails but the buffer no |
824 * longer exists it's not changed, that's OK. */ | 824 // longer exists it's not changed, that's OK. |
825 if (check_changed(buf, (p_awa ? CCGD_AW : 0) | 825 if (check_changed(buf, (p_awa ? CCGD_AW : 0) |
826 | CCGD_MULTWIN | 826 | CCGD_MULTWIN |
827 | CCGD_ALLBUF) && bufref_valid(&bufref)) | 827 | CCGD_ALLBUF) && bufref_valid(&bufref)) |
828 break; /* didn't save - still changes */ | 828 break; // didn't save - still changes |
829 } | 829 } |
830 } | 830 } |
831 | 831 |
832 if (i >= bufnum) | 832 if (i >= bufnum) |
833 goto theend; | 833 goto theend; |
834 | 834 |
835 /* Get here if "buf" cannot be abandoned. */ | 835 // Get here if "buf" cannot be abandoned. |
836 ret = TRUE; | 836 ret = TRUE; |
837 exiting = FALSE; | 837 exiting = FALSE; |
838 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | 838 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
839 /* | 839 /* |
840 * When ":confirm" used, don't give an error message. | 840 * When ":confirm" used, don't give an error message. |
841 */ | 841 */ |
842 if (!(p_confirm || cmdmod.confirm)) | 842 if (!(p_confirm || cmdmod.confirm)) |
843 #endif | 843 #endif |
844 { | 844 { |
845 /* There must be a wait_return for this message, do_buffer() | 845 // There must be a wait_return for this message, do_buffer() |
846 * may cause a redraw. But wait_return() is a no-op when vgetc() | 846 // may cause a redraw. But wait_return() is a no-op when vgetc() |
847 * is busy (Quit used from window menu), then make sure we don't | 847 // is busy (Quit used from window menu), then make sure we don't |
848 * cause a scroll up. */ | 848 // cause a scroll up. |
849 if (vgetc_busy > 0) | 849 if (vgetc_busy > 0) |
850 { | 850 { |
851 msg_row = cmdline_row; | 851 msg_row = cmdline_row; |
852 msg_col = 0; | 852 msg_col = 0; |
853 msg_didout = FALSE; | 853 msg_didout = FALSE; |
867 wait_return(FALSE); | 867 wait_return(FALSE); |
868 no_wait_return = save; | 868 no_wait_return = save; |
869 } | 869 } |
870 } | 870 } |
871 | 871 |
872 /* Try to find a window that contains the buffer. */ | 872 // Try to find a window that contains the buffer. |
873 if (buf != curbuf) | 873 if (buf != curbuf) |
874 FOR_ALL_TAB_WINDOWS(tp, wp) | 874 FOR_ALL_TAB_WINDOWS(tp, wp) |
875 if (wp->w_buffer == buf) | 875 if (wp->w_buffer == buf) |
876 { | 876 { |
877 bufref_T bufref; | 877 bufref_T bufref; |
885 goto theend; | 885 goto theend; |
886 goto buf_found; | 886 goto buf_found; |
887 } | 887 } |
888 buf_found: | 888 buf_found: |
889 | 889 |
890 /* Open the changed buffer in the current window. */ | 890 // Open the changed buffer in the current window. |
891 if (buf != curbuf) | 891 if (buf != curbuf) |
892 set_curbuf(buf, unload ? DOBUF_UNLOAD : DOBUF_GOTO); | 892 set_curbuf(buf, unload ? DOBUF_UNLOAD : DOBUF_GOTO); |
893 | 893 |
894 theend: | 894 theend: |
895 vim_free(bufnrs); | 895 vim_free(bufnrs); |
963 #endif | 963 #endif |
964 | 964 |
965 #if defined(FEAT_SYN_HL) | 965 #if defined(FEAT_SYN_HL) |
966 if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo) | 966 if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo) |
967 { | 967 { |
968 /* Don't do syntax HL autocommands. Skipping the syntax file is a | 968 // Don't do syntax HL autocommands. Skipping the syntax file is a |
969 * great speed improvement. */ | 969 // great speed improvement. |
970 save_ei = au_event_disable(",Syntax"); | 970 save_ei = au_event_disable(",Syntax"); |
971 | 971 |
972 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | 972 for (buf = firstbuf; buf != NULL; buf = buf->b_next) |
973 buf->b_flags &= ~BF_SYN_SET; | 973 buf->b_flags &= ~BF_SYN_SET; |
974 buf = curbuf; | 974 buf = curbuf; |
984 || !check_changed(curbuf, CCGD_AW | 984 || !check_changed(curbuf, CCGD_AW |
985 | (eap->forceit ? CCGD_FORCEIT : 0) | 985 | (eap->forceit ? CCGD_FORCEIT : 0) |
986 | CCGD_EXCMD)) | 986 | CCGD_EXCMD)) |
987 { | 987 { |
988 i = 0; | 988 i = 0; |
989 /* start at the eap->line1 argument/window/buffer */ | 989 // start at the eap->line1 argument/window/buffer |
990 wp = firstwin; | 990 wp = firstwin; |
991 tp = first_tabpage; | 991 tp = first_tabpage; |
992 switch (eap->cmdidx) | 992 switch (eap->cmdidx) |
993 { | 993 { |
994 case CMD_windo: | 994 case CMD_windo: |
1003 i = eap->line1 - 1; | 1003 i = eap->line1 - 1; |
1004 break; | 1004 break; |
1005 default: | 1005 default: |
1006 break; | 1006 break; |
1007 } | 1007 } |
1008 /* set pcmark now */ | 1008 // set pcmark now |
1009 if (eap->cmdidx == CMD_bufdo) | 1009 if (eap->cmdidx == CMD_bufdo) |
1010 { | 1010 { |
1011 /* Advance to the first listed buffer after "eap->line1". */ | 1011 // Advance to the first listed buffer after "eap->line1". |
1012 for (buf = firstbuf; buf != NULL && (buf->b_fnum < eap->line1 | 1012 for (buf = firstbuf; buf != NULL && (buf->b_fnum < eap->line1 |
1013 || !buf->b_p_bl); buf = buf->b_next) | 1013 || !buf->b_p_bl); buf = buf->b_next) |
1014 if (buf->b_fnum > eap->line2) | 1014 if (buf->b_fnum > eap->line2) |
1015 { | 1015 { |
1016 buf = NULL; | 1016 buf = NULL; |
1031 ex_cc(eap); | 1031 ex_cc(eap); |
1032 | 1032 |
1033 buf = curbuf; | 1033 buf = curbuf; |
1034 i = eap->line1 - 1; | 1034 i = eap->line1 - 1; |
1035 if (eap->addr_count <= 0) | 1035 if (eap->addr_count <= 0) |
1036 /* default is all the quickfix/location list entries */ | 1036 // default is all the quickfix/location list entries |
1037 eap->line2 = qf_size; | 1037 eap->line2 = qf_size; |
1038 } | 1038 } |
1039 } | 1039 } |
1040 #endif | 1040 #endif |
1041 else | 1041 else |
1042 setpcmark(); | 1042 setpcmark(); |
1043 listcmd_busy = TRUE; /* avoids setting pcmark below */ | 1043 listcmd_busy = TRUE; // avoids setting pcmark below |
1044 | 1044 |
1045 while (!got_int && buf != NULL) | 1045 while (!got_int && buf != NULL) |
1046 { | 1046 { |
1047 if (eap->cmdidx == CMD_argdo) | 1047 if (eap->cmdidx == CMD_argdo) |
1048 { | 1048 { |
1049 /* go to argument "i" */ | 1049 // go to argument "i" |
1050 if (i == ARGCOUNT) | 1050 if (i == ARGCOUNT) |
1051 break; | 1051 break; |
1052 /* Don't call do_argfile() when already there, it will try | 1052 // Don't call do_argfile() when already there, it will try |
1053 * reloading the file. */ | 1053 // reloading the file. |
1054 if (curwin->w_arg_idx != i || !editing_arg_idx(curwin)) | 1054 if (curwin->w_arg_idx != i || !editing_arg_idx(curwin)) |
1055 { | 1055 { |
1056 /* Clear 'shm' to avoid that the file message overwrites | 1056 // Clear 'shm' to avoid that the file message overwrites |
1057 * any output from the command. */ | 1057 // any output from the command. |
1058 p_shm_save = vim_strsave(p_shm); | 1058 p_shm_save = vim_strsave(p_shm); |
1059 set_option_value((char_u *)"shm", 0L, (char_u *)"", 0); | 1059 set_option_value((char_u *)"shm", 0L, (char_u *)"", 0); |
1060 do_argfile(eap, i); | 1060 do_argfile(eap, i); |
1061 set_option_value((char_u *)"shm", 0L, p_shm_save, 0); | 1061 set_option_value((char_u *)"shm", 0L, p_shm_save, 0); |
1062 vim_free(p_shm_save); | 1062 vim_free(p_shm_save); |
1064 if (curwin->w_arg_idx != i) | 1064 if (curwin->w_arg_idx != i) |
1065 break; | 1065 break; |
1066 } | 1066 } |
1067 else if (eap->cmdidx == CMD_windo) | 1067 else if (eap->cmdidx == CMD_windo) |
1068 { | 1068 { |
1069 /* go to window "wp" */ | 1069 // go to window "wp" |
1070 if (!win_valid(wp)) | 1070 if (!win_valid(wp)) |
1071 break; | 1071 break; |
1072 win_goto(wp); | 1072 win_goto(wp); |
1073 if (curwin != wp) | 1073 if (curwin != wp) |
1074 break; /* something must be wrong */ | 1074 break; // something must be wrong |
1075 wp = curwin->w_next; | 1075 wp = curwin->w_next; |
1076 } | 1076 } |
1077 else if (eap->cmdidx == CMD_tabdo) | 1077 else if (eap->cmdidx == CMD_tabdo) |
1078 { | 1078 { |
1079 /* go to window "tp" */ | 1079 // go to window "tp" |
1080 if (!valid_tabpage(tp)) | 1080 if (!valid_tabpage(tp)) |
1081 break; | 1081 break; |
1082 goto_tabpage_tp(tp, TRUE, TRUE); | 1082 goto_tabpage_tp(tp, TRUE, TRUE); |
1083 tp = tp->tp_next; | 1083 tp = tp->tp_next; |
1084 } | 1084 } |
1085 else if (eap->cmdidx == CMD_bufdo) | 1085 else if (eap->cmdidx == CMD_bufdo) |
1086 { | 1086 { |
1087 /* Remember the number of the next listed buffer, in case | 1087 // Remember the number of the next listed buffer, in case |
1088 * ":bwipe" is used or autocommands do something strange. */ | 1088 // ":bwipe" is used or autocommands do something strange. |
1089 next_fnum = -1; | 1089 next_fnum = -1; |
1090 for (buf = curbuf->b_next; buf != NULL; buf = buf->b_next) | 1090 for (buf = curbuf->b_next; buf != NULL; buf = buf->b_next) |
1091 if (buf->b_p_bl) | 1091 if (buf->b_p_bl) |
1092 { | 1092 { |
1093 next_fnum = buf->b_fnum; | 1093 next_fnum = buf->b_fnum; |
1095 } | 1095 } |
1096 } | 1096 } |
1097 | 1097 |
1098 ++i; | 1098 ++i; |
1099 | 1099 |
1100 /* execute the command */ | 1100 // execute the command |
1101 do_cmdline(eap->arg, eap->getline, eap->cookie, | 1101 do_cmdline(eap->arg, eap->getline, eap->cookie, |
1102 DOCMD_VERBOSE + DOCMD_NOWAIT); | 1102 DOCMD_VERBOSE + DOCMD_NOWAIT); |
1103 | 1103 |
1104 if (eap->cmdidx == CMD_bufdo) | 1104 if (eap->cmdidx == CMD_bufdo) |
1105 { | 1105 { |
1106 /* Done? */ | 1106 // Done? |
1107 if (next_fnum < 0 || next_fnum > eap->line2) | 1107 if (next_fnum < 0 || next_fnum > eap->line2) |
1108 break; | 1108 break; |
1109 /* Check if the buffer still exists. */ | 1109 // Check if the buffer still exists. |
1110 FOR_ALL_BUFFERS(buf) | 1110 FOR_ALL_BUFFERS(buf) |
1111 if (buf->b_fnum == next_fnum) | 1111 if (buf->b_fnum == next_fnum) |
1112 break; | 1112 break; |
1113 if (buf == NULL) | 1113 if (buf == NULL) |
1114 break; | 1114 break; |
1115 | 1115 |
1116 /* Go to the next buffer. Clear 'shm' to avoid that the file | 1116 // Go to the next buffer. Clear 'shm' to avoid that the file |
1117 * message overwrites any output from the command. */ | 1117 // message overwrites any output from the command. |
1118 p_shm_save = vim_strsave(p_shm); | 1118 p_shm_save = vim_strsave(p_shm); |
1119 set_option_value((char_u *)"shm", 0L, (char_u *)"", 0); | 1119 set_option_value((char_u *)"shm", 0L, (char_u *)"", 0); |
1120 goto_buffer(eap, DOBUF_FIRST, FORWARD, next_fnum); | 1120 goto_buffer(eap, DOBUF_FIRST, FORWARD, next_fnum); |
1121 set_option_value((char_u *)"shm", 0L, p_shm_save, 0); | 1121 set_option_value((char_u *)"shm", 0L, p_shm_save, 0); |
1122 vim_free(p_shm_save); | 1122 vim_free(p_shm_save); |
1123 | 1123 |
1124 /* If autocommands took us elsewhere, quit here. */ | 1124 // If autocommands took us elsewhere, quit here. |
1125 if (curbuf->b_fnum != next_fnum) | 1125 if (curbuf->b_fnum != next_fnum) |
1126 break; | 1126 break; |
1127 } | 1127 } |
1128 | 1128 |
1129 #ifdef FEAT_QUICKFIX | 1129 #ifdef FEAT_QUICKFIX |
1135 | 1135 |
1136 qf_idx = qf_get_cur_idx(eap); | 1136 qf_idx = qf_get_cur_idx(eap); |
1137 | 1137 |
1138 ex_cnext(eap); | 1138 ex_cnext(eap); |
1139 | 1139 |
1140 /* If jumping to the next quickfix entry fails, quit here */ | 1140 // If jumping to the next quickfix entry fails, quit here |
1141 if (qf_get_cur_idx(eap) == qf_idx) | 1141 if (qf_get_cur_idx(eap) == qf_idx) |
1142 break; | 1142 break; |
1143 } | 1143 } |
1144 #endif | 1144 #endif |
1145 | 1145 |
1146 if (eap->cmdidx == CMD_windo) | 1146 if (eap->cmdidx == CMD_windo) |
1147 { | 1147 { |
1148 validate_cursor(); /* cursor may have moved */ | 1148 validate_cursor(); // cursor may have moved |
1149 | 1149 |
1150 /* required when 'scrollbind' has been set */ | 1150 // required when 'scrollbind' has been set |
1151 if (curwin->w_p_scb) | 1151 if (curwin->w_p_scb) |
1152 do_check_scrollbind(TRUE); | 1152 do_check_scrollbind(TRUE); |
1153 } | 1153 } |
1154 | 1154 |
1155 if (eap->cmdidx == CMD_windo || eap->cmdidx == CMD_tabdo) | 1155 if (eap->cmdidx == CMD_windo || eap->cmdidx == CMD_tabdo) |
1211 char_u *old_cur_comp = NULL; | 1211 char_u *old_cur_comp = NULL; |
1212 char_u *p; | 1212 char_u *p; |
1213 | 1213 |
1214 if (*eap->arg == NUL) | 1214 if (*eap->arg == NUL) |
1215 { | 1215 { |
1216 /* List all compiler scripts. */ | 1216 // List all compiler scripts. |
1217 do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')"); | 1217 do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')"); |
1218 /* ) keep the indenter happy... */ | 1218 // ) keep the indenter happy... |
1219 } | 1219 } |
1220 else | 1220 else |
1221 { | 1221 { |
1222 buf = alloc(STRLEN(eap->arg) + 14); | 1222 buf = alloc(STRLEN(eap->arg) + 14); |
1223 if (buf != NULL) | 1223 if (buf != NULL) |
1224 { | 1224 { |
1225 if (eap->forceit) | 1225 if (eap->forceit) |
1226 { | 1226 { |
1227 /* ":compiler! {name}" sets global options */ | 1227 // ":compiler! {name}" sets global options |
1228 do_cmdline_cmd((char_u *) | 1228 do_cmdline_cmd((char_u *) |
1229 "command -nargs=* CompilerSet set <args>"); | 1229 "command -nargs=* CompilerSet set <args>"); |
1230 } | 1230 } |
1231 else | 1231 else |
1232 { | 1232 { |
1233 /* ":compiler! {name}" sets local options. | 1233 // ":compiler! {name}" sets local options. |
1234 * To remain backwards compatible "current_compiler" is always | 1234 // To remain backwards compatible "current_compiler" is always |
1235 * used. A user's compiler plugin may set it, the distributed | 1235 // used. A user's compiler plugin may set it, the distributed |
1236 * plugin will then skip the settings. Afterwards set | 1236 // plugin will then skip the settings. Afterwards set |
1237 * "b:current_compiler" and restore "current_compiler". | 1237 // "b:current_compiler" and restore "current_compiler". |
1238 * Explicitly prepend "g:" to make it work in a function. */ | 1238 // Explicitly prepend "g:" to make it work in a function. |
1239 old_cur_comp = get_var_value((char_u *)"g:current_compiler"); | 1239 old_cur_comp = get_var_value((char_u *)"g:current_compiler"); |
1240 if (old_cur_comp != NULL) | 1240 if (old_cur_comp != NULL) |
1241 old_cur_comp = vim_strsave(old_cur_comp); | 1241 old_cur_comp = vim_strsave(old_cur_comp); |
1242 do_cmdline_cmd((char_u *) | 1242 do_cmdline_cmd((char_u *) |
1243 "command -nargs=* CompilerSet setlocal <args>"); | 1243 "command -nargs=* CompilerSet setlocal <args>"); |
1250 semsg(_("E666: compiler not supported: %s"), eap->arg); | 1250 semsg(_("E666: compiler not supported: %s"), eap->arg); |
1251 vim_free(buf); | 1251 vim_free(buf); |
1252 | 1252 |
1253 do_cmdline_cmd((char_u *)":delcommand CompilerSet"); | 1253 do_cmdline_cmd((char_u *)":delcommand CompilerSet"); |
1254 | 1254 |
1255 /* Set "b:current_compiler" from "current_compiler". */ | 1255 // Set "b:current_compiler" from "current_compiler". |
1256 p = get_var_value((char_u *)"g:current_compiler"); | 1256 p = get_var_value((char_u *)"g:current_compiler"); |
1257 if (p != NULL) | 1257 if (p != NULL) |
1258 set_internal_string_var((char_u *)"b:current_compiler", p); | 1258 set_internal_string_var((char_u *)"b:current_compiler", p); |
1259 | 1259 |
1260 /* Restore "current_compiler" for ":compiler {name}". */ | 1260 // Restore "current_compiler" for ":compiler {name}". |
1261 if (!eap->forceit) | 1261 if (!eap->forceit) |
1262 { | 1262 { |
1263 if (old_cur_comp != NULL) | 1263 if (old_cur_comp != NULL) |
1264 { | 1264 { |
1265 set_internal_string_var((char_u *)"g:current_compiler", | 1265 set_internal_string_var((char_u *)"g:current_compiler", |
1320 { | 1320 { |
1321 if (vim_fgets(IObuff, IOSIZE, file)) | 1321 if (vim_fgets(IObuff, IOSIZE, file)) |
1322 break; | 1322 break; |
1323 if (i == 0 && IObuff[0] == '#' && IObuff[1] == '!') | 1323 if (i == 0 && IObuff[0] == '#' && IObuff[1] == '!') |
1324 { | 1324 { |
1325 /* Check shebang. */ | 1325 // Check shebang. |
1326 if (strstr((char *)IObuff + 2, "python2") != NULL) | 1326 if (strstr((char *)IObuff + 2, "python2") != NULL) |
1327 { | 1327 { |
1328 requires_py_version = 2; | 1328 requires_py_version = 2; |
1329 break; | 1329 break; |
1330 } | 1330 } |
1365 init_pyxversion(); | 1365 init_pyxversion(); |
1366 # endif | 1366 # endif |
1367 if (v == 0) | 1367 if (v == 0) |
1368 { | 1368 { |
1369 # if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3) | 1369 # if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3) |
1370 /* user didn't choose a preference, 'pyx' is used */ | 1370 // user didn't choose a preference, 'pyx' is used |
1371 v = p_pyx; | 1371 v = p_pyx; |
1372 # elif defined(FEAT_PYTHON) | 1372 # elif defined(FEAT_PYTHON) |
1373 v = 2; | 1373 v = 2; |
1374 # elif defined(FEAT_PYTHON3) | 1374 # elif defined(FEAT_PYTHON3) |
1375 v = 3; | 1375 v = 3; |
1470 { | 1470 { |
1471 buf_T *buf; | 1471 buf_T *buf; |
1472 int save_no_check_timestamps = no_check_timestamps; | 1472 int save_no_check_timestamps = no_check_timestamps; |
1473 | 1473 |
1474 no_check_timestamps = 0; | 1474 no_check_timestamps = 0; |
1475 if (eap->addr_count == 0) /* default is all buffers */ | 1475 if (eap->addr_count == 0) // default is all buffers |
1476 check_timestamps(FALSE); | 1476 check_timestamps(FALSE); |
1477 else | 1477 else |
1478 { | 1478 { |
1479 buf = buflist_findnr((int)eap->line2); | 1479 buf = buflist_findnr((int)eap->line2); |
1480 if (buf != NULL) /* cannot happen? */ | 1480 if (buf != NULL) // cannot happen? |
1481 (void)buf_check_timestamp(buf, FALSE); | 1481 (void)buf_check_timestamp(buf, FALSE); |
1482 } | 1482 } |
1483 no_check_timestamps = save_no_check_timestamps; | 1483 no_check_timestamps = save_no_check_timestamps; |
1484 } | 1484 } |
1485 | 1485 |
1489 static char_u * | 1489 static char_u * |
1490 get_locale_val(int what) | 1490 get_locale_val(int what) |
1491 { | 1491 { |
1492 char_u *loc; | 1492 char_u *loc; |
1493 | 1493 |
1494 /* Obtain the locale value from the libraries. */ | 1494 // Obtain the locale value from the libraries. |
1495 loc = (char_u *)setlocale(what, NULL); | 1495 loc = (char_u *)setlocale(what, NULL); |
1496 | 1496 |
1497 # ifdef MSWIN | 1497 # ifdef MSWIN |
1498 if (loc != NULL) | 1498 if (loc != NULL) |
1499 { | 1499 { |
1500 char_u *p; | 1500 char_u *p; |
1501 | 1501 |
1502 /* setocale() returns something like "LC_COLLATE=<name>;LC_..." when | 1502 // setocale() returns something like "LC_COLLATE=<name>;LC_..." when |
1503 * one of the values (e.g., LC_CTYPE) differs. */ | 1503 // one of the values (e.g., LC_CTYPE) differs. |
1504 p = vim_strchr(loc, '='); | 1504 p = vim_strchr(loc, '='); |
1505 if (p != NULL) | 1505 if (p != NULL) |
1506 { | 1506 { |
1507 loc = ++p; | 1507 loc = ++p; |
1508 while (*p != NUL) /* remove trailing newline */ | 1508 while (*p != NUL) // remove trailing newline |
1509 { | 1509 { |
1510 if (*p < ' ' || *p == ';') | 1510 if (*p < ' ' || *p == ';') |
1511 { | 1511 { |
1512 *p = NUL; | 1512 *p = NUL; |
1513 break; | 1513 break; |
1583 | 1583 |
1584 # ifdef HAVE_GET_LOCALE_VAL | 1584 # ifdef HAVE_GET_LOCALE_VAL |
1585 # if defined(LC_MESSAGES) | 1585 # if defined(LC_MESSAGES) |
1586 p = get_locale_val(LC_MESSAGES); | 1586 p = get_locale_val(LC_MESSAGES); |
1587 # else | 1587 # else |
1588 /* This is necessary for Win32, where LC_MESSAGES is not defined and $LANG | 1588 // This is necessary for Win32, where LC_MESSAGES is not defined and $LANG |
1589 * may be set to the LCID number. LC_COLLATE is the best guess, LC_TIME | 1589 // may be set to the LCID number. LC_COLLATE is the best guess, LC_TIME |
1590 * and LC_MONETARY may be set differently for a Japanese working in the | 1590 // and LC_MONETARY may be set differently for a Japanese working in the |
1591 * US. */ | 1591 // US. |
1592 p = get_locale_val(LC_COLLATE); | 1592 p = get_locale_val(LC_COLLATE); |
1593 # endif | 1593 # endif |
1594 # else | 1594 # else |
1595 p = mch_getenv((char_u *)"LC_ALL"); | 1595 p = mch_getenv((char_u *)"LC_ALL"); |
1596 if (!is_valid_mess_lang(p)) | 1596 if (!is_valid_mess_lang(p)) |
1605 # endif | 1605 # endif |
1606 return is_valid_mess_lang(p) ? p : NULL; | 1606 return is_valid_mess_lang(p) ? p : NULL; |
1607 } | 1607 } |
1608 #endif | 1608 #endif |
1609 | 1609 |
1610 /* Complicated #if; matches with where get_mess_env() is used below. */ | 1610 // Complicated #if; matches with where get_mess_env() is used below. |
1611 #if (defined(FEAT_EVAL) && !((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ | 1611 #if (defined(FEAT_EVAL) && !((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ |
1612 && defined(LC_MESSAGES))) \ | 1612 && defined(LC_MESSAGES))) \ |
1613 || ((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ | 1613 || ((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ |
1614 && !defined(LC_MESSAGES)) | 1614 && !defined(LC_MESSAGES)) |
1615 /* | 1615 /* |
1626 p = mch_getenv((char_u *)"LC_MESSAGES"); | 1626 p = mch_getenv((char_u *)"LC_MESSAGES"); |
1627 if (p == NULL || *p == NUL) | 1627 if (p == NULL || *p == NUL) |
1628 { | 1628 { |
1629 p = mch_getenv((char_u *)"LANG"); | 1629 p = mch_getenv((char_u *)"LANG"); |
1630 if (p != NULL && VIM_ISDIGIT(*p)) | 1630 if (p != NULL && VIM_ISDIGIT(*p)) |
1631 p = NULL; /* ignore something like "1043" */ | 1631 p = NULL; // ignore something like "1043" |
1632 # ifdef HAVE_GET_LOCALE_VAL | 1632 # ifdef HAVE_GET_LOCALE_VAL |
1633 if (p == NULL || *p == NUL) | 1633 if (p == NULL || *p == NUL) |
1634 p = get_locale_val(LC_CTYPE); | 1634 p = get_locale_val(LC_CTYPE); |
1635 # endif | 1635 # endif |
1636 } | 1636 } |
1651 char_u *loc; | 1651 char_u *loc; |
1652 | 1652 |
1653 # ifdef HAVE_GET_LOCALE_VAL | 1653 # ifdef HAVE_GET_LOCALE_VAL |
1654 loc = get_locale_val(LC_CTYPE); | 1654 loc = get_locale_val(LC_CTYPE); |
1655 # else | 1655 # else |
1656 /* setlocale() not supported: use the default value */ | 1656 // setlocale() not supported: use the default value |
1657 loc = (char_u *)"C"; | 1657 loc = (char_u *)"C"; |
1658 # endif | 1658 # endif |
1659 set_vim_var_string(VV_CTYPE, loc, -1); | 1659 set_vim_var_string(VV_CTYPE, loc, -1); |
1660 | 1660 |
1661 /* When LC_MESSAGES isn't defined use the value from $LC_MESSAGES, fall | 1661 // When LC_MESSAGES isn't defined use the value from $LC_MESSAGES, fall |
1662 * back to LC_CTYPE if it's empty. */ | 1662 // back to LC_CTYPE if it's empty. |
1663 # if defined(HAVE_GET_LOCALE_VAL) && defined(LC_MESSAGES) | 1663 # if defined(HAVE_GET_LOCALE_VAL) && defined(LC_MESSAGES) |
1664 loc = get_locale_val(LC_MESSAGES); | 1664 loc = get_locale_val(LC_MESSAGES); |
1665 # else | 1665 # else |
1666 loc = get_mess_env(); | 1666 loc = get_mess_env(); |
1667 # endif | 1667 # endif |
1692 # define VIM_LC_MESSAGES 6789 | 1692 # define VIM_LC_MESSAGES 6789 |
1693 #endif | 1693 #endif |
1694 | 1694 |
1695 name = eap->arg; | 1695 name = eap->arg; |
1696 | 1696 |
1697 /* Check for "messages {name}", "ctype {name}" or "time {name}" argument. | 1697 // Check for "messages {name}", "ctype {name}" or "time {name}" argument. |
1698 * Allow abbreviation, but require at least 3 characters to avoid | 1698 // Allow abbreviation, but require at least 3 characters to avoid |
1699 * confusion with a two letter language name "me" or "ct". */ | 1699 // confusion with a two letter language name "me" or "ct". |
1700 p = skiptowhite(eap->arg); | 1700 p = skiptowhite(eap->arg); |
1701 if ((*p == NUL || VIM_ISWHITE(*p)) && p - eap->arg >= 3) | 1701 if ((*p == NUL || VIM_ISWHITE(*p)) && p - eap->arg >= 3) |
1702 { | 1702 { |
1703 if (STRNICMP(eap->arg, "messages", p - eap->arg) == 0) | 1703 if (STRNICMP(eap->arg, "messages", p - eap->arg) == 0) |
1704 { | 1704 { |
1740 else | 1740 else |
1741 #endif | 1741 #endif |
1742 { | 1742 { |
1743 loc = setlocale(what, (char *)name); | 1743 loc = setlocale(what, (char *)name); |
1744 #if defined(FEAT_FLOAT) && defined(LC_NUMERIC) | 1744 #if defined(FEAT_FLOAT) && defined(LC_NUMERIC) |
1745 /* Make sure strtod() uses a decimal point, not a comma. */ | 1745 // Make sure strtod() uses a decimal point, not a comma. |
1746 setlocale(LC_NUMERIC, "C"); | 1746 setlocale(LC_NUMERIC, "C"); |
1747 #endif | 1747 #endif |
1748 } | 1748 } |
1749 if (loc == NULL) | 1749 if (loc == NULL) |
1750 semsg(_("E197: Cannot set language to \"%s\""), name); | 1750 semsg(_("E197: Cannot set language to \"%s\""), name); |
1751 else | 1751 else |
1752 { | 1752 { |
1753 #ifdef HAVE_NL_MSG_CAT_CNTR | 1753 #ifdef HAVE_NL_MSG_CAT_CNTR |
1754 /* Need to do this for GNU gettext, otherwise cached translations | 1754 // Need to do this for GNU gettext, otherwise cached translations |
1755 * will be used again. */ | 1755 // will be used again. |
1756 extern int _nl_msg_cat_cntr; | 1756 extern int _nl_msg_cat_cntr; |
1757 | 1757 |
1758 ++_nl_msg_cat_cntr; | 1758 ++_nl_msg_cat_cntr; |
1759 #endif | 1759 #endif |
1760 /* Reset $LC_ALL, otherwise it would overrule everything. */ | 1760 // Reset $LC_ALL, otherwise it would overrule everything. |
1761 vim_setenv((char_u *)"LC_ALL", (char_u *)""); | 1761 vim_setenv((char_u *)"LC_ALL", (char_u *)""); |
1762 | 1762 |
1763 if (what != LC_TIME) | 1763 if (what != LC_TIME) |
1764 { | 1764 { |
1765 /* Tell gettext() what to translate to. It apparently doesn't | 1765 // Tell gettext() what to translate to. It apparently doesn't |
1766 * use the currently effective locale. Also do this when | 1766 // use the currently effective locale. Also do this when |
1767 * FEAT_GETTEXT isn't defined, so that shell commands use this | 1767 // FEAT_GETTEXT isn't defined, so that shell commands use this |
1768 * value. */ | 1768 // value. |
1769 if (what == LC_ALL) | 1769 if (what == LC_ALL) |
1770 { | 1770 { |
1771 vim_setenv((char_u *)"LANG", name); | 1771 vim_setenv((char_u *)"LANG", name); |
1772 | 1772 |
1773 /* Clear $LANGUAGE because GNU gettext uses it. */ | 1773 // Clear $LANGUAGE because GNU gettext uses it. |
1774 vim_setenv((char_u *)"LANGUAGE", (char_u *)""); | 1774 vim_setenv((char_u *)"LANGUAGE", (char_u *)""); |
1775 # ifdef MSWIN | 1775 # ifdef MSWIN |
1776 /* Apparently MS-Windows printf() may cause a crash when | 1776 // Apparently MS-Windows printf() may cause a crash when |
1777 * we give it 8-bit text while it's expecting text in the | 1777 // we give it 8-bit text while it's expecting text in the |
1778 * current locale. This call avoids that. */ | 1778 // current locale. This call avoids that. |
1779 setlocale(LC_CTYPE, "C"); | 1779 setlocale(LC_CTYPE, "C"); |
1780 # endif | 1780 # endif |
1781 } | 1781 } |
1782 if (what != LC_CTYPE) | 1782 if (what != LC_CTYPE) |
1783 { | 1783 { |
1793 #endif | 1793 #endif |
1794 } | 1794 } |
1795 } | 1795 } |
1796 | 1796 |
1797 # ifdef FEAT_EVAL | 1797 # ifdef FEAT_EVAL |
1798 /* Set v:lang, v:lc_time and v:ctype to the final result. */ | 1798 // Set v:lang, v:lc_time and v:ctype to the final result. |
1799 set_lang_var(); | 1799 set_lang_var(); |
1800 # endif | 1800 # endif |
1801 # ifdef FEAT_TITLE | 1801 # ifdef FEAT_TITLE |
1802 maketitle(); | 1802 maketitle(); |
1803 # endif | 1803 # endif |
1804 } | 1804 } |
1805 } | 1805 } |
1806 } | 1806 } |
1807 | 1807 |
1808 static char_u **locales = NULL; /* Array of all available locales */ | 1808 static char_u **locales = NULL; // Array of all available locales |
1809 | 1809 |
1810 # ifndef MSWIN | 1810 # ifndef MSWIN |
1811 static int did_init_locales = FALSE; | 1811 static int did_init_locales = FALSE; |
1812 | 1812 |
1813 /* | 1813 /* |
1818 find_locales(void) | 1818 find_locales(void) |
1819 { | 1819 { |
1820 garray_T locales_ga; | 1820 garray_T locales_ga; |
1821 char_u *loc; | 1821 char_u *loc; |
1822 | 1822 |
1823 /* Find all available locales by running command "locale -a". If this | 1823 // Find all available locales by running command "locale -a". If this |
1824 * doesn't work we won't have completion. */ | 1824 // doesn't work we won't have completion. |
1825 char_u *locale_a = get_cmd_output((char_u *)"locale -a", | 1825 char_u *locale_a = get_cmd_output((char_u *)"locale -a", |
1826 NULL, SHELL_SILENT, NULL); | 1826 NULL, SHELL_SILENT, NULL); |
1827 if (locale_a == NULL) | 1827 if (locale_a == NULL) |
1828 return NULL; | 1828 return NULL; |
1829 ga_init2(&locales_ga, sizeof(char_u *), 20); | 1829 ga_init2(&locales_ga, sizeof(char_u *), 20); |
1830 | 1830 |
1831 /* Transform locale_a string where each locale is separated by "\n" | 1831 // Transform locale_a string where each locale is separated by "\n" |
1832 * into an array of locale strings. */ | 1832 // into an array of locale strings. |
1833 loc = (char_u *)strtok((char *)locale_a, "\n"); | 1833 loc = (char_u *)strtok((char *)locale_a, "\n"); |
1834 | 1834 |
1835 while (loc != NULL) | 1835 while (loc != NULL) |
1836 { | 1836 { |
1837 if (ga_grow(&locales_ga, 1) == FAIL) | 1837 if (ga_grow(&locales_ga, 1) == FAIL) |