comparison src/quickfix.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 90c8ff9c19ee
children 98c35d312987
comparison
equal deleted inserted replaced
15469:bc9b5261ed01 15470:55ccc2d353bd
237 efmpat_to_regpat( 237 efmpat_to_regpat(
238 char_u *efmpat, 238 char_u *efmpat,
239 char_u *regpat, 239 char_u *regpat,
240 efm_T *efminfo, 240 efm_T *efminfo,
241 int idx, 241 int idx,
242 int round, 242 int round)
243 char_u *errmsg)
244 { 243 {
245 char_u *srcptr; 244 char_u *srcptr;
246 245
247 if (efminfo->addr[idx]) 246 if (efminfo->addr[idx])
248 { 247 {
249 // Each errorformat pattern can occur only once 248 // Each errorformat pattern can occur only once
250 sprintf((char *)errmsg, 249 semsg(_("E372: Too many %%%c in format string"), *efmpat);
251 _("E372: Too many %%%c in format string"), *efmpat);
252 EMSG(errmsg);
253 return NULL; 250 return NULL;
254 } 251 }
255 if ((idx && idx < 6 252 if ((idx && idx < 6
256 && vim_strchr((char_u *)"DXOPQ", efminfo->prefix) != NULL) 253 && vim_strchr((char_u *)"DXOPQ", efminfo->prefix) != NULL)
257 || (idx == 6 254 || (idx == 6
258 && vim_strchr((char_u *)"OPQ", efminfo->prefix) == NULL)) 255 && vim_strchr((char_u *)"OPQ", efminfo->prefix) == NULL))
259 { 256 {
260 sprintf((char *)errmsg, 257 semsg(_("E373: Unexpected %%%c in format string"), *efmpat);
261 _("E373: Unexpected %%%c in format string"), *efmpat);
262 EMSG(errmsg);
263 return NULL; 258 return NULL;
264 } 259 }
265 efminfo->addr[idx] = (char_u)++round; 260 efminfo->addr[idx] = (char_u)++round;
266 *regpat++ = '\\'; 261 *regpat++ = '\\';
267 *regpat++ = '('; 262 *regpat++ = '(';
314 static char_u * 309 static char_u *
315 scanf_fmt_to_regpat( 310 scanf_fmt_to_regpat(
316 char_u **pefmp, 311 char_u **pefmp,
317 char_u *efm, 312 char_u *efm,
318 int len, 313 int len,
319 char_u *regpat, 314 char_u *regpat)
320 char_u *errmsg)
321 { 315 {
322 char_u *efmp = *pefmp; 316 char_u *efmp = *pefmp;
323 317
324 if (*efmp == '[' || *efmp == '\\') 318 if (*efmp == '[' || *efmp == '\\')
325 { 319 {
333 while (efmp < efm + len 327 while (efmp < efm + len
334 && (*regpat++ = *++efmp) != ']') 328 && (*regpat++ = *++efmp) != ']')
335 // skip ; 329 // skip ;
336 if (efmp == efm + len) 330 if (efmp == efm + len)
337 { 331 {
338 EMSG(_("E374: Missing ] in format string")); 332 emsg(_("E374: Missing ] in format string"));
339 return NULL; 333 return NULL;
340 } 334 }
341 } 335 }
342 } 336 }
343 else if (efmp < efm + len) // %*\D, %*\s etc. 337 else if (efmp < efm + len) // %*\D, %*\s etc.
346 *regpat++ = '+'; 340 *regpat++ = '+';
347 } 341 }
348 else 342 else
349 { 343 {
350 // TODO: scanf()-like: %*ud, %*3c, %*f, ... ? 344 // TODO: scanf()-like: %*ud, %*3c, %*f, ... ?
351 sprintf((char *)errmsg, 345 semsg(_("E375: Unsupported %%%c in format string"), *efmp);
352 _("E375: Unsupported %%%c in format string"), *efmp);
353 EMSG(errmsg);
354 return NULL; 346 return NULL;
355 } 347 }
356 348
357 *pefmp = efmp; 349 *pefmp = efmp;
358 350
361 353
362 /* 354 /*
363 * Analyze/parse an errorformat prefix. 355 * Analyze/parse an errorformat prefix.
364 */ 356 */
365 static char_u * 357 static char_u *
366 efm_analyze_prefix(char_u *efmp, efm_T *efminfo, char_u *errmsg) 358 efm_analyze_prefix(char_u *efmp, efm_T *efminfo)
367 { 359 {
368 if (vim_strchr((char_u *)"+-", *efmp) != NULL) 360 if (vim_strchr((char_u *)"+-", *efmp) != NULL)
369 efminfo->flags = *efmp++; 361 efminfo->flags = *efmp++;
370 if (vim_strchr((char_u *)"DXAEWICZGOPQ", *efmp) != NULL) 362 if (vim_strchr((char_u *)"DXAEWICZGOPQ", *efmp) != NULL)
371 efminfo->prefix = *efmp; 363 efminfo->prefix = *efmp;
372 else 364 else
373 { 365 {
374 sprintf((char *)errmsg, 366 semsg(_("E376: Invalid %%%c in format string prefix"), *efmp);
375 _("E376: Invalid %%%c in format string prefix"), *efmp);
376 EMSG(errmsg);
377 return NULL; 367 return NULL;
378 } 368 }
379 369
380 return efmp; 370 return efmp;
381 } 371 }
389 static int 379 static int
390 efm_to_regpat( 380 efm_to_regpat(
391 char_u *efm, 381 char_u *efm,
392 int len, 382 int len,
393 efm_T *fmt_ptr, 383 efm_T *fmt_ptr,
394 char_u *regpat, 384 char_u *regpat)
395 char_u *errmsg)
396 { 385 {
397 char_u *ptr; 386 char_u *ptr;
398 char_u *efmp; 387 char_u *efmp;
399 int round; 388 int round;
400 int idx = 0; 389 int idx = 0;
411 for (idx = 0; idx < FMT_PATTERNS; ++idx) 400 for (idx = 0; idx < FMT_PATTERNS; ++idx)
412 if (fmt_pat[idx].convchar == *efmp) 401 if (fmt_pat[idx].convchar == *efmp)
413 break; 402 break;
414 if (idx < FMT_PATTERNS) 403 if (idx < FMT_PATTERNS)
415 { 404 {
416 ptr = efmpat_to_regpat(efmp, ptr, fmt_ptr, idx, round, 405 ptr = efmpat_to_regpat(efmp, ptr, fmt_ptr, idx, round);
417 errmsg);
418 if (ptr == NULL) 406 if (ptr == NULL)
419 return FAIL; 407 return FAIL;
420 round++; 408 round++;
421 } 409 }
422 else if (*efmp == '*') 410 else if (*efmp == '*')
423 { 411 {
424 ++efmp; 412 ++efmp;
425 ptr = scanf_fmt_to_regpat(&efmp, efm, len, ptr, errmsg); 413 ptr = scanf_fmt_to_regpat(&efmp, efm, len, ptr);
426 if (ptr == NULL) 414 if (ptr == NULL)
427 return FAIL; 415 return FAIL;
428 } 416 }
429 else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL) 417 else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL)
430 *ptr++ = *efmp; // regexp magic characters 418 *ptr++ = *efmp; // regexp magic characters
434 fmt_ptr->conthere = TRUE; 422 fmt_ptr->conthere = TRUE;
435 else if (efmp == efm + 1) // analyse prefix 423 else if (efmp == efm + 1) // analyse prefix
436 { 424 {
437 // prefix is allowed only at the beginning of the errorformat 425 // prefix is allowed only at the beginning of the errorformat
438 // option part 426 // option part
439 efmp = efm_analyze_prefix(efmp, fmt_ptr, errmsg); 427 efmp = efm_analyze_prefix(efmp, fmt_ptr);
440 if (efmp == NULL) 428 if (efmp == NULL)
441 return FAIL; 429 return FAIL;
442 } 430 }
443 else 431 else
444 { 432 {
445 sprintf((char *)errmsg, 433 semsg(_("E377: Invalid %%%c in format string"), *efmp);
446 _("E377: Invalid %%%c in format string"), *efmp);
447 EMSG(errmsg);
448 return FAIL; 434 return FAIL;
449 } 435 }
450 } 436 }
451 else // copy normal character 437 else // copy normal character
452 { 438 {
524 * the parsed 'errorformat' option. 510 * the parsed 'errorformat' option.
525 */ 511 */
526 static efm_T * 512 static efm_T *
527 parse_efm_option(char_u *efm) 513 parse_efm_option(char_u *efm)
528 { 514 {
529 char_u *errmsg = NULL;
530 int errmsglen;
531 efm_T *fmt_ptr = NULL; 515 efm_T *fmt_ptr = NULL;
532 efm_T *fmt_first = NULL; 516 efm_T *fmt_first = NULL;
533 efm_T *fmt_last = NULL; 517 efm_T *fmt_last = NULL;
534 char_u *fmtstr = NULL; 518 char_u *fmtstr = NULL;
535 int len; 519 int len;
536 int sz; 520 int sz;
537
538 errmsglen = CMDBUFFSIZE + 1;
539 errmsg = alloc_id(errmsglen, aid_qf_errmsg);
540 if (errmsg == NULL)
541 goto parse_efm_end;
542 521
543 // Each part of the format string is copied and modified from errorformat 522 // Each part of the format string is copied and modified from errorformat
544 // to regex prog. Only a few % characters are allowed. 523 // to regex prog. Only a few % characters are allowed.
545 524
546 // Get some space to modify the format string into. 525 // Get some space to modify the format string into.
561 fmt_last = fmt_ptr; 540 fmt_last = fmt_ptr;
562 541
563 // Isolate one part in the 'errorformat' option 542 // Isolate one part in the 'errorformat' option
564 len = efm_option_part_len(efm); 543 len = efm_option_part_len(efm);
565 544
566 if (efm_to_regpat(efm, len, fmt_ptr, fmtstr, errmsg) == FAIL) 545 if (efm_to_regpat(efm, len, fmt_ptr, fmtstr) == FAIL)
567 goto parse_efm_error; 546 goto parse_efm_error;
568 if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL) 547 if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL)
569 goto parse_efm_error; 548 goto parse_efm_error;
570 // Advance to next part 549 // Advance to next part
571 efm = skip_to_option_part(efm + len); // skip comma and spaces 550 efm = skip_to_option_part(efm + len); // skip comma and spaces
572 } 551 }
573 552
574 if (fmt_first == NULL) // nothing found 553 if (fmt_first == NULL) // nothing found
575 EMSG(_("E378: 'errorformat' contains no pattern")); 554 emsg(_("E378: 'errorformat' contains no pattern"));
576 555
577 goto parse_efm_end; 556 goto parse_efm_end;
578 557
579 parse_efm_error: 558 parse_efm_error:
580 free_efm_list(&fmt_first); 559 free_efm_list(&fmt_first);
581 560
582 parse_efm_end: 561 parse_efm_end:
583 vim_free(fmtstr); 562 vim_free(fmtstr);
584 vim_free(errmsg);
585 563
586 return fmt_first; 564 return fmt_first;
587 } 565 }
588 566
589 enum { 567 enum {
1269 { 1247 {
1270 if (idx == 'D') // enter directory 1248 if (idx == 'D') // enter directory
1271 { 1249 {
1272 if (*fields->namebuf == NUL) 1250 if (*fields->namebuf == NUL)
1273 { 1251 {
1274 EMSG(_("E379: Missing or empty directory name")); 1252 emsg(_("E379: Missing or empty directory name"));
1275 return QF_FAIL; 1253 return QF_FAIL;
1276 } 1254 }
1277 qfl->qf_directory = 1255 qfl->qf_directory =
1278 qf_push_dir(fields->namebuf, &qfl->qf_dir_stack, FALSE); 1256 qf_push_dir(fields->namebuf, &qfl->qf_dir_stack, FALSE);
1279 if (qfl->qf_directory == NULL) 1257 if (qfl->qf_directory == NULL)
1566 convert_setup(&pstate->vc, enc, p_enc); 1544 convert_setup(&pstate->vc, enc, p_enc);
1567 #endif 1545 #endif
1568 1546
1569 if (efile != NULL && (pstate->fd = mch_fopen((char *)efile, "r")) == NULL) 1547 if (efile != NULL && (pstate->fd = mch_fopen((char *)efile, "r")) == NULL)
1570 { 1548 {
1571 EMSG2(_(e_openerrf), efile); 1549 semsg(_(e_openerrf), efile);
1572 return FAIL; 1550 return FAIL;
1573 } 1551 }
1574 1552
1575 if (tv != NULL) 1553 if (tv != NULL)
1576 { 1554 {
1749 } 1727 }
1750 // return number of matches 1728 // return number of matches
1751 retval = qfl->qf_count; 1729 retval = qfl->qf_count;
1752 goto qf_init_end; 1730 goto qf_init_end;
1753 } 1731 }
1754 EMSG(_(e_readerrf)); 1732 emsg(_(e_readerrf));
1755 error2: 1733 error2:
1756 if (!adding) 1734 if (!adding)
1757 { 1735 {
1758 // Error when creating a new list. Free the new list 1736 // Error when creating a new list. Free the new list
1759 qf_free(qfl); 1737 qf_free(qfl);
1966 } 1944 }
1967 } 1945 }
1968 #ifdef ABORT_ON_INTERNAL_ERROR 1946 #ifdef ABORT_ON_INTERNAL_ERROR
1969 if (quickfix_busy < 0) 1947 if (quickfix_busy < 0)
1970 { 1948 {
1971 EMSG("quickfix_busy has become negative"); 1949 emsg("quickfix_busy has become negative");
1972 abort(); 1950 abort();
1973 } 1951 }
1974 #endif 1952 #endif
1975 } 1953 }
1976 1954
1978 void 1956 void
1979 check_quickfix_busy(void) 1957 check_quickfix_busy(void)
1980 { 1958 {
1981 if (quickfix_busy != 0) 1959 if (quickfix_busy != 0)
1982 { 1960 {
1983 EMSGN("quickfix_busy not zero on exit: %ld", (long)quickfix_busy); 1961 semsg("quickfix_busy not zero on exit: %ld", (long)quickfix_busy);
1984 # ifdef ABORT_ON_INTERNAL_ERROR 1962 # ifdef ABORT_ON_INTERNAL_ERROR
1985 abort(); 1963 abort();
1986 # endif 1964 # endif
1987 } 1965 }
1988 } 1966 }
2633 { 2611 {
2634 qf_ptr = prev_qf_ptr; 2612 qf_ptr = prev_qf_ptr;
2635 qf_idx = prev_index; 2613 qf_idx = prev_index;
2636 if (err != NULL) 2614 if (err != NULL)
2637 { 2615 {
2638 EMSG(_(err)); 2616 emsg(_(err));
2639 return NULL; 2617 return NULL;
2640 } 2618 }
2641 break; 2619 break;
2642 } 2620 }
2643 2621
3039 3017
3040 // If a location list, check whether the associated window is still 3018 // If a location list, check whether the associated window is still
3041 // present. 3019 // present.
3042 if (qfl_type == QFLT_LOCATION && !win_valid_any_tab(oldwin)) 3020 if (qfl_type == QFLT_LOCATION && !win_valid_any_tab(oldwin))
3043 { 3021 {
3044 EMSG(_("E924: Current window was closed")); 3022 emsg(_("E924: Current window was closed"));
3045 *opened_window = FALSE; 3023 *opened_window = FALSE;
3046 return NOTDONE; 3024 return NOTDONE;
3047 } 3025 }
3048 3026
3049 if (qfl_type == QFLT_QUICKFIX && !qflist_valid(NULL, save_qfid)) 3027 if (qfl_type == QFLT_QUICKFIX && !qflist_valid(NULL, save_qfid))
3050 { 3028 {
3051 EMSG(_("E925: Current quickfix was changed")); 3029 emsg(_("E925: Current quickfix was changed"));
3052 return NOTDONE; 3030 return NOTDONE;
3053 } 3031 }
3054 3032
3055 if (old_qf_curlist != qi->qf_curlist 3033 if (old_qf_curlist != qi->qf_curlist
3056 || !is_qf_entry_present(qfl, qf_ptr)) 3034 || !is_qf_entry_present(qfl, qf_ptr))
3057 { 3035 {
3058 if (qfl_type == QFLT_QUICKFIX) 3036 if (qfl_type == QFLT_QUICKFIX)
3059 EMSG(_("E925: Current quickfix was changed")); 3037 emsg(_("E925: Current quickfix was changed"));
3060 else 3038 else
3061 EMSG(_(e_loc_list_changed)); 3039 emsg(_(e_loc_list_changed));
3062 return NOTDONE; 3040 return NOTDONE;
3063 } 3041 }
3064 3042
3065 return retval; 3043 return retval;
3066 } 3044 }
3313 if (qi == NULL) 3291 if (qi == NULL)
3314 qi = &ql_info; 3292 qi = &ql_info;
3315 3293
3316 if (qf_stack_empty(qi) || qf_list_empty(qi, qi->qf_curlist)) 3294 if (qf_stack_empty(qi) || qf_list_empty(qi, qi->qf_curlist))
3317 { 3295 {
3318 EMSG(_(e_quickfix)); 3296 emsg(_(e_quickfix));
3319 return; 3297 return;
3320 } 3298 }
3321 3299
3322 qfl = &qi->qf_lists[qi->qf_curlist]; 3300 qfl = &qi->qf_lists[qi->qf_curlist];
3323 3301
3495 if (is_loclist_cmd(eap->cmdidx)) 3473 if (is_loclist_cmd(eap->cmdidx))
3496 { 3474 {
3497 qi = GET_LOC_LIST(curwin); 3475 qi = GET_LOC_LIST(curwin);
3498 if (qi == NULL) 3476 if (qi == NULL)
3499 { 3477 {
3500 EMSG(_(e_loclist)); 3478 emsg(_(e_loclist));
3501 return; 3479 return;
3502 } 3480 }
3503 } 3481 }
3504 3482
3505 if (qf_stack_empty(qi) || qf_list_empty(qi, qi->qf_curlist)) 3483 if (qf_stack_empty(qi) || qf_list_empty(qi, qi->qf_curlist))
3506 { 3484 {
3507 EMSG(_(e_quickfix)); 3485 emsg(_(e_quickfix));
3508 return; 3486 return;
3509 } 3487 }
3510 if (*arg == '+') 3488 if (*arg == '+')
3511 { 3489 {
3512 ++arg; 3490 ++arg;
3513 plus = TRUE; 3491 plus = TRUE;
3514 } 3492 }
3515 if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL) 3493 if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL)
3516 { 3494 {
3517 EMSG(_(e_trailing)); 3495 emsg(_(e_trailing));
3518 return; 3496 return;
3519 } 3497 }
3520 qfl = &qi->qf_lists[qi->qf_curlist]; 3498 qfl = &qi->qf_lists[qi->qf_curlist];
3521 if (plus) 3499 if (plus)
3522 { 3500 {
3641 if (is_loclist_cmd(eap->cmdidx)) 3619 if (is_loclist_cmd(eap->cmdidx))
3642 { 3620 {
3643 qi = GET_LOC_LIST(curwin); 3621 qi = GET_LOC_LIST(curwin);
3644 if (qi == NULL) 3622 if (qi == NULL)
3645 { 3623 {
3646 EMSG(_(e_loclist)); 3624 emsg(_(e_loclist));
3647 return; 3625 return;
3648 } 3626 }
3649 } 3627 }
3650 3628
3651 if (eap->addr_count != 0) 3629 if (eap->addr_count != 0)
3656 { 3634 {
3657 if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder) 3635 if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder)
3658 { 3636 {
3659 if (qi->qf_curlist == 0) 3637 if (qi->qf_curlist == 0)
3660 { 3638 {
3661 EMSG(_("E380: At bottom of quickfix stack")); 3639 emsg(_("E380: At bottom of quickfix stack"));
3662 break; 3640 break;
3663 } 3641 }
3664 --qi->qf_curlist; 3642 --qi->qf_curlist;
3665 } 3643 }
3666 else 3644 else
3667 { 3645 {
3668 if (qi->qf_curlist >= qi->qf_listcount - 1) 3646 if (qi->qf_curlist >= qi->qf_listcount - 1)
3669 { 3647 {
3670 EMSG(_("E381: At top of quickfix stack")); 3648 emsg(_("E381: At top of quickfix stack"));
3671 break; 3649 break;
3672 } 3650 }
3673 ++qi->qf_curlist; 3651 ++qi->qf_curlist;
3674 } 3652 }
3675 } 3653 }
3868 if (IS_LL_WINDOW(curwin)) 3846 if (IS_LL_WINDOW(curwin))
3869 qi = GET_LOC_LIST(curwin); 3847 qi = GET_LOC_LIST(curwin);
3870 3848
3871 if (qf_list_empty(qi, qi->qf_curlist)) 3849 if (qf_list_empty(qi, qi->qf_curlist))
3872 { 3850 {
3873 EMSG(_(e_quickfix)); 3851 emsg(_(e_quickfix));
3874 return; 3852 return;
3875 } 3853 }
3876 3854
3877 if (split) 3855 if (split)
3878 { 3856 {
4079 if (is_loclist_cmd(eap->cmdidx)) 4057 if (is_loclist_cmd(eap->cmdidx))
4080 { 4058 {
4081 qi = GET_LOC_LIST(curwin); 4059 qi = GET_LOC_LIST(curwin);
4082 if (qi == NULL) 4060 if (qi == NULL)
4083 { 4061 {
4084 EMSG(_(e_loclist)); 4062 emsg(_(e_loclist));
4085 return; 4063 return;
4086 } 4064 }
4087 } 4065 }
4088 4066
4089 incr_quickfix_busy(); 4067 incr_quickfix_busy();
4161 if (is_loclist_cmd(eap->cmdidx)) 4139 if (is_loclist_cmd(eap->cmdidx))
4162 { 4140 {
4163 qi = GET_LOC_LIST(curwin); 4141 qi = GET_LOC_LIST(curwin);
4164 if (qi == NULL) 4142 if (qi == NULL)
4165 { 4143 {
4166 EMSG(_(e_loclist)); 4144 emsg(_(e_loclist));
4167 return; 4145 return;
4168 } 4146 }
4169 } 4147 }
4170 4148
4171 win = qf_find_win(qi); 4149 win = qf_find_win(qi);
4607 4585
4608 if (*p_mef == NUL) 4586 if (*p_mef == NUL)
4609 { 4587 {
4610 name = vim_tempname('e', FALSE); 4588 name = vim_tempname('e', FALSE);
4611 if (name == NULL) 4589 if (name == NULL)
4612 EMSG(_(e_notmp)); 4590 emsg(_(e_notmp));
4613 return name; 4591 return name;
4614 } 4592 }
4615 4593
4616 for (p = p_mef; *p; ++p) 4594 for (p = p_mef; *p; ++p)
4617 if (p[0] == '#' && p[1] == '#') 4595 if (p[0] == '#' && p[1] == '#')
4939 if (is_loclist_cmd(eap->cmdidx)) 4917 if (is_loclist_cmd(eap->cmdidx))
4940 { 4918 {
4941 qi = GET_LOC_LIST(curwin); 4919 qi = GET_LOC_LIST(curwin);
4942 if (qi == NULL) 4920 if (qi == NULL)
4943 { 4921 {
4944 EMSG(_(e_loclist)); 4922 emsg(_(e_loclist));
4945 return; 4923 return;
4946 } 4924 }
4947 } 4925 }
4948 4926
4949 if (eap->addr_count > 0) 4927 if (eap->addr_count > 0)
4990 if (is_loclist_cmd(eap->cmdidx)) 4968 if (is_loclist_cmd(eap->cmdidx))
4991 { 4969 {
4992 qi = GET_LOC_LIST(curwin); 4970 qi = GET_LOC_LIST(curwin);
4993 if (qi == NULL) 4971 if (qi == NULL)
4994 { 4972 {
4995 EMSG(_(e_loclist)); 4973 emsg(_(e_loclist));
4996 return; 4974 return;
4997 } 4975 }
4998 } 4976 }
4999 4977
5000 if (eap->addr_count > 0 4978 if (eap->addr_count > 0
5146 if (s == NULL || *s == NUL) 5124 if (s == NULL || *s == NUL)
5147 { 5125 {
5148 // Pattern is empty, use last search pattern. 5126 // Pattern is empty, use last search pattern.
5149 if (last_search_pat() == NULL) 5127 if (last_search_pat() == NULL)
5150 { 5128 {
5151 EMSG(_(e_noprevre)); 5129 emsg(_(e_noprevre));
5152 return; 5130 return;
5153 } 5131 }
5154 regmatch->regprog = vim_regcomp(last_search_pat(), RE_MAGIC); 5132 regmatch->regprog = vim_regcomp(last_search_pat(), RE_MAGIC);
5155 } 5133 }
5156 else 5134 else
5236 if (!qflist_valid(wp, qfid)) 5214 if (!qflist_valid(wp, qfid))
5237 { 5215 {
5238 if (wp != NULL) 5216 if (wp != NULL)
5239 { 5217 {
5240 // An autocmd has freed the location list. 5218 // An autocmd has freed the location list.
5241 EMSG(_(e_loc_list_changed)); 5219 emsg(_(e_loc_list_changed));
5242 return FALSE; 5220 return FALSE;
5243 } 5221 }
5244 else 5222 else
5245 { 5223 {
5246 // Quickfix list is not found, create a new one. 5224 // Quickfix list is not found, create a new one.
5415 regmatch.regprog = NULL; 5393 regmatch.regprog = NULL;
5416 title = vim_strsave(qf_cmdtitle(*eap->cmdlinep)); 5394 title = vim_strsave(qf_cmdtitle(*eap->cmdlinep));
5417 p = skip_vimgrep_pat(eap->arg, &s, &flags); 5395 p = skip_vimgrep_pat(eap->arg, &s, &flags);
5418 if (p == NULL) 5396 if (p == NULL)
5419 { 5397 {
5420 EMSG(_(e_invalpat)); 5398 emsg(_(e_invalpat));
5421 goto theend; 5399 goto theend;
5422 } 5400 }
5423 5401
5424 vgr_init_regmatch(&regmatch, s); 5402 vgr_init_regmatch(&regmatch, s);
5425 if (regmatch.regprog == NULL) 5403 if (regmatch.regprog == NULL)
5426 goto theend; 5404 goto theend;
5427 5405
5428 p = skipwhite(p); 5406 p = skipwhite(p);
5429 if (*p == NUL) 5407 if (*p == NUL)
5430 { 5408 {
5431 EMSG(_("E683: File name missing or invalid pattern")); 5409 emsg(_("E683: File name missing or invalid pattern"));
5432 goto theend; 5410 goto theend;
5433 } 5411 }
5434 5412
5435 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd 5413 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd
5436 && eap->cmdidx != CMD_vimgrepadd 5414 && eap->cmdidx != CMD_vimgrepadd
5442 // parse the list of arguments 5420 // parse the list of arguments
5443 if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL) 5421 if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL)
5444 goto theend; 5422 goto theend;
5445 if (fcount == 0) 5423 if (fcount == 0)
5446 { 5424 {
5447 EMSG(_(e_nomatch)); 5425 emsg(_(e_nomatch));
5448 goto theend; 5426 goto theend;
5449 } 5427 }
5450 5428
5451 dirname_start = alloc_id(MAXPATHL, aid_qf_dirname_start); 5429 dirname_start = alloc_id(MAXPATHL, aid_qf_dirname_start);
5452 dirname_now = alloc_id(MAXPATHL, aid_qf_dirname_now); 5430 dirname_now = alloc_id(MAXPATHL, aid_qf_dirname_now);
5503 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; 5481 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id;
5504 5482
5505 if (buf == NULL) 5483 if (buf == NULL)
5506 { 5484 {
5507 if (!got_int) 5485 if (!got_int)
5508 smsg((char_u *)_("Cannot open file \"%s\""), fname); 5486 smsg(_("Cannot open file \"%s\""), fname);
5509 } 5487 }
5510 else 5488 else
5511 { 5489 {
5512 // Try for a match in all lines of the buffer. 5490 // Try for a match in all lines of the buffer.
5513 // For ":1vimgrep" look for first match only. 5491 // For ":1vimgrep" look for first match only.
5606 if ((flags & VGR_NOJUMP) == 0) 5584 if ((flags & VGR_NOJUMP) == 0)
5607 vgr_jump_to_match(qi, eap->forceit, &redraw_for_dummy, 5585 vgr_jump_to_match(qi, eap->forceit, &redraw_for_dummy,
5608 first_match_buf, target_dir); 5586 first_match_buf, target_dir);
5609 } 5587 }
5610 else 5588 else
5611 EMSG2(_(e_nomatch2), s); 5589 semsg(_(e_nomatch2), s);
5612 5590
5613 decr_quickfix_busy(); 5591 decr_quickfix_busy();
5614 5592
5615 // If we loaded a dummy buffer into the current window, the autocommands 5593 // If we loaded a dummy buffer into the current window, the autocommands
5616 // may have messed up things, need to redraw and recompute folds. 5594 // may have messed up things, need to redraw and recompute folds.
6283 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL)) 6261 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
6284 { 6262 {
6285 if (!did_bufnr_emsg) 6263 if (!did_bufnr_emsg)
6286 { 6264 {
6287 did_bufnr_emsg = TRUE; 6265 did_bufnr_emsg = TRUE;
6288 EMSGN(_("E92: Buffer %ld not found"), bufnum); 6266 semsg(_("E92: Buffer %ld not found"), bufnum);
6289 } 6267 }
6290 valid = FALSE; 6268 valid = FALSE;
6291 bufnum = 0; 6269 bufnum = 0;
6292 } 6270 }
6293 6271
6862 if (*eap->arg == NUL) 6840 if (*eap->arg == NUL)
6863 buf = curbuf; 6841 buf = curbuf;
6864 else if (*skipwhite(skipdigits(eap->arg)) == NUL) 6842 else if (*skipwhite(skipdigits(eap->arg)) == NUL)
6865 buf = buflist_findnr(atoi((char *)eap->arg)); 6843 buf = buflist_findnr(atoi((char *)eap->arg));
6866 if (buf == NULL) 6844 if (buf == NULL)
6867 EMSG(_(e_invarg)); 6845 emsg(_(e_invarg));
6868 else if (buf->b_ml.ml_mfp == NULL) 6846 else if (buf->b_ml.ml_mfp == NULL)
6869 EMSG(_("E681: Buffer is not loaded")); 6847 emsg(_("E681: Buffer is not loaded"));
6870 else 6848 else
6871 { 6849 {
6872 if (eap->addr_count == 0) 6850 if (eap->addr_count == 0)
6873 { 6851 {
6874 eap->line1 = 1; 6852 eap->line1 = 1;
6875 eap->line2 = buf->b_ml.ml_line_count; 6853 eap->line2 = buf->b_ml.ml_line_count;
6876 } 6854 }
6877 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count 6855 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count
6878 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count) 6856 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count)
6879 EMSG(_(e_invrange)); 6857 emsg(_(e_invrange));
6880 else 6858 else
6881 { 6859 {
6882 char_u *qf_title = qf_cmdtitle(*eap->cmdlinep); 6860 char_u *qf_title = qf_cmdtitle(*eap->cmdlinep);
6883 6861
6884 if (buf->b_sfname) 6862 if (buf->b_sfname)
7009 // display the first error 6987 // display the first error
7010 qf_jump_first(qi, save_qfid, eap->forceit); 6988 qf_jump_first(qi, save_qfid, eap->forceit);
7011 decr_quickfix_busy(); 6989 decr_quickfix_busy();
7012 } 6990 }
7013 else 6991 else
7014 EMSG(_("E777: String or List expected")); 6992 emsg(_("E777: String or List expected"));
7015 cleanup: 6993 cleanup:
7016 free_tv(tv); 6994 free_tv(tv);
7017 } 6995 }
7018 } 6996 }
7019 #endif 6997 #endif
7308 7286
7309 // Jump to first match. 7287 // Jump to first match.
7310 if (!qf_list_empty(qi, qi->qf_curlist)) 7288 if (!qf_list_empty(qi, qi->qf_curlist))
7311 qf_jump(qi, 0, 0, FALSE); 7289 qf_jump(qi, 0, 0, FALSE);
7312 else 7290 else
7313 EMSG2(_(e_nomatch2), eap->arg); 7291 semsg(_(e_nomatch2), eap->arg);
7314 7292
7315 decr_quickfix_busy(); 7293 decr_quickfix_busy();
7316 7294
7317 if (eap->cmdidx == CMD_lhelpgrep) 7295 if (eap->cmdidx == CMD_lhelpgrep)
7318 { 7296 {