Mercurial > vim
comparison src/misc2.c @ 15470:55ccc2d353bd v8.1.0743
patch 8.1.0743: giving error messages is not flexible
commit https://github.com/vim/vim/commit/f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 13 23:38:42 2019 +0100
patch 8.1.0743: giving error messages is not flexible
Problem: Giving error messages is not flexible.
Solution: Add semsg(). Change argument from "char_u *" to "char *", also
for msg() and get rid of most MSG macros. (Ozaki Kiichi, closes
#3302) Also make emsg() accept a "char *" argument. Get rid of
an enormous number of type casts.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 13 Jan 2019 23:45:08 +0100 |
parents | eae582bfb293 |
children | 41fbbcea0f1b |
comparison
equal
deleted
inserted
replaced
15469:bc9b5261ed01 | 15470:55ccc2d353bd |
---|---|
918 #if !defined(UNIX) | 918 #if !defined(UNIX) |
919 if (sizeof(int) == 2 && size > 0x7fff) | 919 if (sizeof(int) == 2 && size > 0x7fff) |
920 { | 920 { |
921 /* Don't hide this message */ | 921 /* Don't hide this message */ |
922 emsg_silent = 0; | 922 emsg_silent = 0; |
923 EMSG(_("E340: Line is becoming too long")); | 923 emsg(_("E340: Line is becoming too long")); |
924 return NULL; | 924 return NULL; |
925 } | 925 } |
926 #endif | 926 #endif |
927 return (lalloc((long_u)size, TRUE)); | 927 return (lalloc((long_u)size, TRUE)); |
928 } | 928 } |
958 /* Safety check for allocating zero bytes */ | 958 /* Safety check for allocating zero bytes */ |
959 if (size == 0) | 959 if (size == 0) |
960 { | 960 { |
961 /* Don't hide this message */ | 961 /* Don't hide this message */ |
962 emsg_silent = 0; | 962 emsg_silent = 0; |
963 IEMSGN(_("E341: Internal error: lalloc(%ld, )"), size); | 963 siemsg(_("E341: Internal error: lalloc(%ld, )"), size); |
964 return NULL; | 964 return NULL; |
965 } | 965 } |
966 | 966 |
967 #ifdef MEM_PROFILE | 967 #ifdef MEM_PROFILE |
968 mem_pre_alloc_l(&size); | 968 mem_pre_alloc_l(&size); |
1077 | 1077 |
1078 /* Must come first to avoid coming back here when printing the error | 1078 /* Must come first to avoid coming back here when printing the error |
1079 * message fails, e.g. when setting v:errmsg. */ | 1079 * message fails, e.g. when setting v:errmsg. */ |
1080 did_outofmem_msg = TRUE; | 1080 did_outofmem_msg = TRUE; |
1081 | 1081 |
1082 EMSGN(_("E342: Out of memory! (allocating %lu bytes)"), size); | 1082 semsg(_("E342: Out of memory! (allocating %lu bytes)"), size); |
1083 } | 1083 } |
1084 } | 1084 } |
1085 | 1085 |
1086 #if defined(EXITFREE) || defined(PROTO) | 1086 #if defined(EXITFREE) || defined(PROTO) |
1087 | 1087 |
3270 #endif | 3270 #endif |
3271 | 3271 |
3272 if (p_verbose > 3) | 3272 if (p_verbose > 3) |
3273 { | 3273 { |
3274 verbose_enter(); | 3274 verbose_enter(); |
3275 smsg((char_u *)_("Calling shell to execute: \"%s\""), | 3275 smsg(_("Calling shell to execute: \"%s\""), |
3276 cmd == NULL ? p_sh : cmd); | 3276 cmd == NULL ? p_sh : cmd); |
3277 out_char('\n'); | 3277 out_char('\n'); |
3278 cursor_on(); | 3278 cursor_on(); |
3279 verbose_leave(); | 3279 verbose_leave(); |
3280 } | 3280 } |
3284 prof_child_enter(&wait_time); | 3284 prof_child_enter(&wait_time); |
3285 #endif | 3285 #endif |
3286 | 3286 |
3287 if (*p_sh == NUL) | 3287 if (*p_sh == NUL) |
3288 { | 3288 { |
3289 EMSG(_(e_shellempty)); | 3289 emsg(_(e_shellempty)); |
3290 retval = -1; | 3290 retval = -1; |
3291 } | 3291 } |
3292 else | 3292 else |
3293 { | 3293 { |
3294 #ifdef FEAT_GUI_MSWIN | 3294 #ifdef FEAT_GUI_MSWIN |
3536 /* | 3536 /* |
3537 * Parse the 'guicursor' option ("what" is SHAPE_CURSOR) or 'mouseshape' | 3537 * Parse the 'guicursor' option ("what" is SHAPE_CURSOR) or 'mouseshape' |
3538 * ("what" is SHAPE_MOUSE). | 3538 * ("what" is SHAPE_MOUSE). |
3539 * Returns error message for an illegal option, NULL otherwise. | 3539 * Returns error message for an illegal option, NULL otherwise. |
3540 */ | 3540 */ |
3541 char_u * | 3541 char * |
3542 parse_shape_opt(int what) | 3542 parse_shape_opt(int what) |
3543 { | 3543 { |
3544 char_u *modep; | 3544 char_u *modep; |
3545 char_u *colonp; | 3545 char_u *colonp; |
3546 char_u *commap; | 3546 char_u *commap; |
3572 { | 3572 { |
3573 colonp = vim_strchr(modep, ':'); | 3573 colonp = vim_strchr(modep, ':'); |
3574 commap = vim_strchr(modep, ','); | 3574 commap = vim_strchr(modep, ','); |
3575 | 3575 |
3576 if (colonp == NULL || (commap != NULL && commap < colonp)) | 3576 if (colonp == NULL || (commap != NULL && commap < colonp)) |
3577 return (char_u *)N_("E545: Missing colon"); | 3577 return N_("E545: Missing colon"); |
3578 if (colonp == modep) | 3578 if (colonp == modep) |
3579 return (char_u *)N_("E546: Illegal mode"); | 3579 return N_("E546: Illegal mode"); |
3580 | 3580 |
3581 /* | 3581 /* |
3582 * Repeat for all mode's before the colon. | 3582 * Repeat for all mode's before the colon. |
3583 * For the 'a' mode, we loop to handle all the modes. | 3583 * For the 'a' mode, we loop to handle all the modes. |
3584 */ | 3584 */ |
3600 if (STRNICMP(modep, shape_table[idx].name, len) | 3600 if (STRNICMP(modep, shape_table[idx].name, len) |
3601 == 0) | 3601 == 0) |
3602 break; | 3602 break; |
3603 if (idx == SHAPE_IDX_COUNT | 3603 if (idx == SHAPE_IDX_COUNT |
3604 || (shape_table[idx].used_for & what) == 0) | 3604 || (shape_table[idx].used_for & what) == 0) |
3605 return (char_u *)N_("E546: Illegal mode"); | 3605 return N_("E546: Illegal mode"); |
3606 if (len == 2 && modep[0] == 'v' && modep[1] == 'e') | 3606 if (len == 2 && modep[0] == 'v' && modep[1] == 'e') |
3607 found_ve = TRUE; | 3607 found_ve = TRUE; |
3608 } | 3608 } |
3609 modep += len + 1; | 3609 modep += len + 1; |
3610 } | 3610 } |
3639 for (i = 0; ; ++i) | 3639 for (i = 0; ; ++i) |
3640 { | 3640 { |
3641 if (mshape_names[i] == NULL) | 3641 if (mshape_names[i] == NULL) |
3642 { | 3642 { |
3643 if (!VIM_ISDIGIT(*p)) | 3643 if (!VIM_ISDIGIT(*p)) |
3644 return (char_u *)N_("E547: Illegal mouseshape"); | 3644 return N_("E547: Illegal mouseshape"); |
3645 if (round == 2) | 3645 if (round == 2) |
3646 shape_table[idx].mshape = | 3646 shape_table[idx].mshape = |
3647 getdigits(&p) + MSHAPE_NUMBERED; | 3647 getdigits(&p) + MSHAPE_NUMBERED; |
3648 else | 3648 else |
3649 (void)getdigits(&p); | 3649 (void)getdigits(&p); |
3679 len = 8; | 3679 len = 8; |
3680 if (len != 0) | 3680 if (len != 0) |
3681 { | 3681 { |
3682 p += len; | 3682 p += len; |
3683 if (!VIM_ISDIGIT(*p)) | 3683 if (!VIM_ISDIGIT(*p)) |
3684 return (char_u *)N_("E548: digit expected"); | 3684 return N_("E548: digit expected"); |
3685 n = getdigits(&p); | 3685 n = getdigits(&p); |
3686 if (len == 3) /* "ver" or "hor" */ | 3686 if (len == 3) /* "ver" or "hor" */ |
3687 { | 3687 { |
3688 if (n == 0) | 3688 if (n == 0) |
3689 return (char_u *)N_("E549: Illegal percentage"); | 3689 return N_("E549: Illegal percentage"); |
3690 if (round == 2) | 3690 if (round == 2) |
3691 { | 3691 { |
3692 if (TOLOWER_ASC(i) == 'v') | 3692 if (TOLOWER_ASC(i) == 'v') |
3693 shape_table[idx].shape = SHAPE_VER; | 3693 shape_table[idx].shape = SHAPE_VER; |
3694 else | 3694 else |
4383 len = 0; | 4383 len = 0; |
4384 while (*wc_part != NUL) | 4384 while (*wc_part != NUL) |
4385 { | 4385 { |
4386 if (len + 5 >= MAXPATHL) | 4386 if (len + 5 >= MAXPATHL) |
4387 { | 4387 { |
4388 EMSG(_(e_pathtoolong)); | 4388 emsg(_(e_pathtoolong)); |
4389 break; | 4389 break; |
4390 } | 4390 } |
4391 if (STRNCMP(wc_part, "**", 2) == 0) | 4391 if (STRNCMP(wc_part, "**", 2) == 0) |
4392 { | 4392 { |
4393 ff_expand_buffer[len++] = *wc_part++; | 4393 ff_expand_buffer[len++] = *wc_part++; |
4402 else | 4402 else |
4403 ff_expand_buffer[len++] = FF_MAX_STAR_STAR_EXPAND; | 4403 ff_expand_buffer[len++] = FF_MAX_STAR_STAR_EXPAND; |
4404 wc_part = (char_u *)errpt; | 4404 wc_part = (char_u *)errpt; |
4405 if (*wc_part != NUL && !vim_ispathsep(*wc_part)) | 4405 if (*wc_part != NUL && !vim_ispathsep(*wc_part)) |
4406 { | 4406 { |
4407 EMSG2(_("E343: Invalid path: '**[number]' must be at the end of the path or be followed by '%s'."), PATHSEPSTR); | 4407 semsg(_("E343: Invalid path: '**[number]' must be at the end of the path or be followed by '%s'."), PATHSEPSTR); |
4408 goto error_return; | 4408 goto error_return; |
4409 } | 4409 } |
4410 } | 4410 } |
4411 else | 4411 else |
4412 ff_expand_buffer[len++] = *wc_part++; | 4412 ff_expand_buffer[len++] = *wc_part++; |
4434 | 4434 |
4435 /* create an absolute path */ | 4435 /* create an absolute path */ |
4436 if (STRLEN(search_ctx->ffsc_start_dir) | 4436 if (STRLEN(search_ctx->ffsc_start_dir) |
4437 + STRLEN(search_ctx->ffsc_fix_path) + 3 >= MAXPATHL) | 4437 + STRLEN(search_ctx->ffsc_fix_path) + 3 >= MAXPATHL) |
4438 { | 4438 { |
4439 EMSG(_(e_pathtoolong)); | 4439 emsg(_(e_pathtoolong)); |
4440 goto error_return; | 4440 goto error_return; |
4441 } | 4441 } |
4442 STRCPY(ff_expand_buffer, search_ctx->ffsc_start_dir); | 4442 STRCPY(ff_expand_buffer, search_ctx->ffsc_start_dir); |
4443 add_pathsep(ff_expand_buffer); | 4443 add_pathsep(ff_expand_buffer); |
4444 { | 4444 { |
4665 { | 4665 { |
4666 #ifdef FF_VERBOSE | 4666 #ifdef FF_VERBOSE |
4667 if (p_verbose >= 5) | 4667 if (p_verbose >= 5) |
4668 { | 4668 { |
4669 verbose_enter_scroll(); | 4669 verbose_enter_scroll(); |
4670 smsg((char_u *)"Already Searched: %s (%s)", | 4670 smsg("Already Searched: %s (%s)", |
4671 stackp->ffs_fix_path, stackp->ffs_wc_path); | 4671 stackp->ffs_fix_path, stackp->ffs_wc_path); |
4672 /* don't overwrite this either */ | 4672 /* don't overwrite this either */ |
4673 msg_puts((char_u *)"\n"); | 4673 msg_puts((char_u *)"\n"); |
4674 verbose_leave_scroll(); | 4674 verbose_leave_scroll(); |
4675 } | 4675 } |
4679 } | 4679 } |
4680 #ifdef FF_VERBOSE | 4680 #ifdef FF_VERBOSE |
4681 else if (p_verbose >= 5) | 4681 else if (p_verbose >= 5) |
4682 { | 4682 { |
4683 verbose_enter_scroll(); | 4683 verbose_enter_scroll(); |
4684 smsg((char_u *)"Searching: %s (%s)", | 4684 smsg("Searching: %s (%s)", |
4685 stackp->ffs_fix_path, stackp->ffs_wc_path); | 4685 stackp->ffs_fix_path, stackp->ffs_wc_path); |
4686 /* don't overwrite this either */ | 4686 /* don't overwrite this either */ |
4687 msg_puts((char_u *)"\n"); | 4687 msg_puts((char_u *)"\n"); |
4688 verbose_leave_scroll(); | 4688 verbose_leave_scroll(); |
4689 } | 4689 } |
4898 ) == FAIL) | 4898 ) == FAIL) |
4899 { | 4899 { |
4900 if (p_verbose >= 5) | 4900 if (p_verbose >= 5) |
4901 { | 4901 { |
4902 verbose_enter_scroll(); | 4902 verbose_enter_scroll(); |
4903 smsg((char_u *)"Already: %s", | 4903 smsg("Already: %s", |
4904 file_path); | 4904 file_path); |
4905 /* don't overwrite this either */ | 4905 /* don't overwrite this either */ |
4906 msg_puts((char_u *)"\n"); | 4906 msg_puts((char_u *)"\n"); |
4907 verbose_leave_scroll(); | 4907 verbose_leave_scroll(); |
4908 } | 4908 } |
4926 } | 4926 } |
4927 #ifdef FF_VERBOSE | 4927 #ifdef FF_VERBOSE |
4928 if (p_verbose >= 5) | 4928 if (p_verbose >= 5) |
4929 { | 4929 { |
4930 verbose_enter_scroll(); | 4930 verbose_enter_scroll(); |
4931 smsg((char_u *)"HIT: %s", file_path); | 4931 smsg("HIT: %s", file_path); |
4932 /* don't overwrite this either */ | 4932 /* don't overwrite this either */ |
4933 msg_puts((char_u *)"\n"); | 4933 msg_puts((char_u *)"\n"); |
4934 verbose_leave_scroll(); | 4934 verbose_leave_scroll(); |
4935 } | 4935 } |
4936 #endif | 4936 #endif |
5126 { | 5126 { |
5127 #ifdef FF_VERBOSE | 5127 #ifdef FF_VERBOSE |
5128 if (p_verbose >= 5) | 5128 if (p_verbose >= 5) |
5129 { | 5129 { |
5130 verbose_enter_scroll(); | 5130 verbose_enter_scroll(); |
5131 smsg((char_u *)"ff_get_visited_list: FOUND list for %s", | 5131 smsg("ff_get_visited_list: FOUND list for %s", |
5132 filename); | 5132 filename); |
5133 /* don't overwrite this either */ | 5133 /* don't overwrite this either */ |
5134 msg_puts((char_u *)"\n"); | 5134 msg_puts((char_u *)"\n"); |
5135 verbose_leave_scroll(); | 5135 verbose_leave_scroll(); |
5136 } | 5136 } |
5143 | 5143 |
5144 #ifdef FF_VERBOSE | 5144 #ifdef FF_VERBOSE |
5145 if (p_verbose >= 5) | 5145 if (p_verbose >= 5) |
5146 { | 5146 { |
5147 verbose_enter_scroll(); | 5147 verbose_enter_scroll(); |
5148 smsg((char_u *)"ff_get_visited_list: new list for %s", filename); | 5148 smsg("ff_get_visited_list: new list for %s", filename); |
5149 /* don't overwrite this either */ | 5149 /* don't overwrite this either */ |
5150 msg_puts((char_u *)"\n"); | 5150 msg_puts((char_u *)"\n"); |
5151 verbose_leave_scroll(); | 5151 verbose_leave_scroll(); |
5152 } | 5152 } |
5153 #endif | 5153 #endif |
5764 if (file_name == NULL && (options & FNAME_MESS)) | 5764 if (file_name == NULL && (options & FNAME_MESS)) |
5765 { | 5765 { |
5766 if (first == TRUE) | 5766 if (first == TRUE) |
5767 { | 5767 { |
5768 if (find_what == FINDFILE_DIR) | 5768 if (find_what == FINDFILE_DIR) |
5769 EMSG2(_("E344: Can't find directory \"%s\" in cdpath"), | 5769 semsg(_("E344: Can't find directory \"%s\" in cdpath"), |
5770 ff_file_to_find); | 5770 ff_file_to_find); |
5771 else | 5771 else |
5772 EMSG2(_("E345: Can't find file \"%s\" in path"), | 5772 semsg(_("E345: Can't find file \"%s\" in path"), |
5773 ff_file_to_find); | 5773 ff_file_to_find); |
5774 } | 5774 } |
5775 else | 5775 else |
5776 { | 5776 { |
5777 if (find_what == FINDFILE_DIR) | 5777 if (find_what == FINDFILE_DIR) |
5778 EMSG2(_("E346: No more directory \"%s\" found in cdpath"), | 5778 semsg(_("E346: No more directory \"%s\" found in cdpath"), |
5779 ff_file_to_find); | 5779 ff_file_to_find); |
5780 else | 5780 else |
5781 EMSG2(_("E347: No more file \"%s\" found in path"), | 5781 semsg(_("E347: No more file \"%s\" found in path"), |
5782 ff_file_to_find); | 5782 ff_file_to_find); |
5783 } | 5783 } |
5784 } | 5784 } |
5785 | 5785 |
5786 theend: | 5786 theend: |