Mercurial > vim
comparison src/spellfile.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 | 6e4e0d43b20b |
children | 98c35d312987 |
comparison
equal
deleted
inserted
replaced
15469:bc9b5261ed01 | 15470:55ccc2d353bd |
---|---|
357 | 357 |
358 fd = mch_fopen((char *)fname, "r"); | 358 fd = mch_fopen((char *)fname, "r"); |
359 if (fd == NULL) | 359 if (fd == NULL) |
360 { | 360 { |
361 if (!silent) | 361 if (!silent) |
362 EMSG2(_(e_notopen), fname); | 362 semsg(_(e_notopen), fname); |
363 else if (p_verbose > 2) | 363 else if (p_verbose > 2) |
364 { | 364 { |
365 verbose_enter(); | 365 verbose_enter(); |
366 smsg((char_u *)e_notopen, fname); | 366 smsg((const char *)e_notopen, fname); |
367 verbose_leave(); | 367 verbose_leave(); |
368 } | 368 } |
369 goto endFAIL; | 369 goto endFAIL; |
370 } | 370 } |
371 if (p_verbose > 2) | 371 if (p_verbose > 2) |
372 { | 372 { |
373 verbose_enter(); | 373 verbose_enter(); |
374 smsg((char_u *)_("Reading spell file \"%s\""), fname); | 374 smsg(_("Reading spell file \"%s\""), fname); |
375 verbose_leave(); | 375 verbose_leave(); |
376 } | 376 } |
377 | 377 |
378 if (old_lp == NULL) | 378 if (old_lp == NULL) |
379 { | 379 { |
401 */ | 401 */ |
402 for (i = 0; i < VIMSPELLMAGICL; ++i) | 402 for (i = 0; i < VIMSPELLMAGICL; ++i) |
403 buf[i] = getc(fd); /* <fileID> */ | 403 buf[i] = getc(fd); /* <fileID> */ |
404 if (STRNCMP(buf, VIMSPELLMAGIC, VIMSPELLMAGICL) != 0) | 404 if (STRNCMP(buf, VIMSPELLMAGIC, VIMSPELLMAGICL) != 0) |
405 { | 405 { |
406 EMSG(_("E757: This does not look like a spell file")); | 406 emsg(_("E757: This does not look like a spell file")); |
407 goto endFAIL; | 407 goto endFAIL; |
408 } | 408 } |
409 c = getc(fd); /* <versionnr> */ | 409 c = getc(fd); /* <versionnr> */ |
410 if (c < VIMSPELLVERSION) | 410 if (c < VIMSPELLVERSION) |
411 { | 411 { |
412 EMSG(_("E771: Old spell file, needs to be updated")); | 412 emsg(_("E771: Old spell file, needs to be updated")); |
413 goto endFAIL; | 413 goto endFAIL; |
414 } | 414 } |
415 else if (c > VIMSPELLVERSION) | 415 else if (c > VIMSPELLVERSION) |
416 { | 416 { |
417 EMSG(_("E772: Spell file is for newer version of Vim")); | 417 emsg(_("E772: Spell file is for newer version of Vim")); |
418 goto endFAIL; | 418 goto endFAIL; |
419 } | 419 } |
420 | 420 |
421 | 421 |
422 /* | 422 /* |
519 default: | 519 default: |
520 /* Unsupported section. When it's required give an error | 520 /* Unsupported section. When it's required give an error |
521 * message. When it's not required skip the contents. */ | 521 * message. When it's not required skip the contents. */ |
522 if (c & SNF_REQUIRED) | 522 if (c & SNF_REQUIRED) |
523 { | 523 { |
524 EMSG(_("E770: Unsupported section in spell file")); | 524 emsg(_("E770: Unsupported section in spell file")); |
525 goto endFAIL; | 525 goto endFAIL; |
526 } | 526 } |
527 while (--len >= 0) | 527 while (--len >= 0) |
528 if (getc(fd) < 0) | 528 if (getc(fd) < 0) |
529 goto truncerr; | 529 goto truncerr; |
530 break; | 530 break; |
531 } | 531 } |
532 someerror: | 532 someerror: |
533 if (res == SP_FORMERROR) | 533 if (res == SP_FORMERROR) |
534 { | 534 { |
535 EMSG(_(e_format)); | 535 emsg(_(e_format)); |
536 goto endFAIL; | 536 goto endFAIL; |
537 } | 537 } |
538 if (res == SP_TRUNCERROR) | 538 if (res == SP_TRUNCERROR) |
539 { | 539 { |
540 truncerr: | 540 truncerr: |
541 EMSG(_(e_spell_trunc)); | 541 emsg(_(e_spell_trunc)); |
542 goto endFAIL; | 542 goto endFAIL; |
543 } | 543 } |
544 if (res == SP_OTHERERROR) | 544 if (res == SP_OTHERERROR) |
545 goto endFAIL; | 545 goto endFAIL; |
546 } | 546 } |
693 */ | 693 */ |
694 for (i = 0; i < VIMSUGMAGICL; ++i) | 694 for (i = 0; i < VIMSUGMAGICL; ++i) |
695 buf[i] = getc(fd); /* <fileID> */ | 695 buf[i] = getc(fd); /* <fileID> */ |
696 if (STRNCMP(buf, VIMSUGMAGIC, VIMSUGMAGICL) != 0) | 696 if (STRNCMP(buf, VIMSUGMAGIC, VIMSUGMAGICL) != 0) |
697 { | 697 { |
698 EMSG2(_("E778: This does not look like a .sug file: %s"), | 698 semsg(_("E778: This does not look like a .sug file: %s"), |
699 slang->sl_fname); | 699 slang->sl_fname); |
700 goto nextone; | 700 goto nextone; |
701 } | 701 } |
702 c = getc(fd); /* <versionnr> */ | 702 c = getc(fd); /* <versionnr> */ |
703 if (c < VIMSUGVERSION) | 703 if (c < VIMSUGVERSION) |
704 { | 704 { |
705 EMSG2(_("E779: Old .sug file, needs to be updated: %s"), | 705 semsg(_("E779: Old .sug file, needs to be updated: %s"), |
706 slang->sl_fname); | 706 slang->sl_fname); |
707 goto nextone; | 707 goto nextone; |
708 } | 708 } |
709 else if (c > VIMSUGVERSION) | 709 else if (c > VIMSUGVERSION) |
710 { | 710 { |
711 EMSG2(_("E780: .sug file is for newer version of Vim: %s"), | 711 semsg(_("E780: .sug file is for newer version of Vim: %s"), |
712 slang->sl_fname); | 712 slang->sl_fname); |
713 goto nextone; | 713 goto nextone; |
714 } | 714 } |
715 | 715 |
716 /* Check the timestamp, it must be exactly the same as the one in | 716 /* Check the timestamp, it must be exactly the same as the one in |
717 * the .spl file. Otherwise the word numbers won't match. */ | 717 * the .spl file. Otherwise the word numbers won't match. */ |
718 timestamp = get8ctime(fd); /* <timestamp> */ | 718 timestamp = get8ctime(fd); /* <timestamp> */ |
719 if (timestamp != slang->sl_sugtime) | 719 if (timestamp != slang->sl_sugtime) |
720 { | 720 { |
721 EMSG2(_("E781: .sug file doesn't match .spl file: %s"), | 721 semsg(_("E781: .sug file doesn't match .spl file: %s"), |
722 slang->sl_fname); | 722 slang->sl_fname); |
723 goto nextone; | 723 goto nextone; |
724 } | 724 } |
725 | 725 |
726 /* | 726 /* |
729 */ | 729 */ |
730 if (spell_read_tree(fd, &slang->sl_sbyts, &slang->sl_sidxs, | 730 if (spell_read_tree(fd, &slang->sl_sbyts, &slang->sl_sidxs, |
731 FALSE, 0) != 0) | 731 FALSE, 0) != 0) |
732 { | 732 { |
733 someerror: | 733 someerror: |
734 EMSG2(_("E782: error while reading .sug file: %s"), | 734 semsg(_("E782: error while reading .sug file: %s"), |
735 slang->sl_fname); | 735 slang->sl_fname); |
736 slang_clear_sug(slang); | 736 slang_clear_sug(slang); |
737 goto nextone; | 737 goto nextone; |
738 } | 738 } |
739 | 739 |
2223 * Open the file. | 2223 * Open the file. |
2224 */ | 2224 */ |
2225 fd = mch_fopen((char *)fname, "r"); | 2225 fd = mch_fopen((char *)fname, "r"); |
2226 if (fd == NULL) | 2226 if (fd == NULL) |
2227 { | 2227 { |
2228 EMSG2(_(e_notopen), fname); | 2228 semsg(_(e_notopen), fname); |
2229 return NULL; | 2229 return NULL; |
2230 } | 2230 } |
2231 | 2231 |
2232 vim_snprintf((char *)IObuff, IOSIZE, _("Reading affix file %s..."), fname); | 2232 vim_snprintf((char *)IObuff, IOSIZE, _("Reading affix file %s..."), fname); |
2233 spell_message(spin, IObuff); | 2233 spell_message(spin, IObuff); |
2275 if (spin->si_conv.vc_type != CONV_NONE) | 2275 if (spin->si_conv.vc_type != CONV_NONE) |
2276 { | 2276 { |
2277 pc = string_convert(&spin->si_conv, rline, NULL); | 2277 pc = string_convert(&spin->si_conv, rline, NULL); |
2278 if (pc == NULL) | 2278 if (pc == NULL) |
2279 { | 2279 { |
2280 smsg((char_u *)_("Conversion failure for word in %s line %d: %s"), | 2280 smsg(_("Conversion failure for word in %s line %d: %s"), |
2281 fname, lnum, rline); | 2281 fname, lnum, rline); |
2282 continue; | 2282 continue; |
2283 } | 2283 } |
2284 line = pc; | 2284 line = pc; |
2285 } | 2285 } |
2323 /* Setup for conversion from "ENC" to 'encoding'. */ | 2323 /* Setup for conversion from "ENC" to 'encoding'. */ |
2324 aff->af_enc = enc_canonize(items[1]); | 2324 aff->af_enc = enc_canonize(items[1]); |
2325 if (aff->af_enc != NULL && !spin->si_ascii | 2325 if (aff->af_enc != NULL && !spin->si_ascii |
2326 && convert_setup(&spin->si_conv, aff->af_enc, | 2326 && convert_setup(&spin->si_conv, aff->af_enc, |
2327 p_enc) == FAIL) | 2327 p_enc) == FAIL) |
2328 smsg((char_u *)_("Conversion in %s not supported: from %s to %s"), | 2328 smsg(_("Conversion in %s not supported: from %s to %s"), |
2329 fname, aff->af_enc, p_enc); | 2329 fname, aff->af_enc, p_enc); |
2330 spin->si_conv.vc_fail = TRUE; | 2330 spin->si_conv.vc_fail = TRUE; |
2331 #else | 2331 #else |
2332 smsg((char_u *)_("Conversion in %s not supported"), fname); | 2332 smsg(_("Conversion in %s not supported"), fname); |
2333 #endif | 2333 #endif |
2334 } | 2334 } |
2335 else if (is_aff_rule(items, itemcnt, "FLAG", 2) | 2335 else if (is_aff_rule(items, itemcnt, "FLAG", 2) |
2336 && aff->af_flagtype == AFT_CHAR) | 2336 && aff->af_flagtype == AFT_CHAR) |
2337 { | 2337 { |
2340 else if (STRCMP(items[1], "num") == 0) | 2340 else if (STRCMP(items[1], "num") == 0) |
2341 aff->af_flagtype = AFT_NUM; | 2341 aff->af_flagtype = AFT_NUM; |
2342 else if (STRCMP(items[1], "caplong") == 0) | 2342 else if (STRCMP(items[1], "caplong") == 0) |
2343 aff->af_flagtype = AFT_CAPLONG; | 2343 aff->af_flagtype = AFT_CAPLONG; |
2344 else | 2344 else |
2345 smsg((char_u *)_("Invalid value for FLAG in %s line %d: %s"), | 2345 smsg(_("Invalid value for FLAG in %s line %d: %s"), |
2346 fname, lnum, items[1]); | 2346 fname, lnum, items[1]); |
2347 if (aff->af_rare != 0 | 2347 if (aff->af_rare != 0 |
2348 || aff->af_keepcase != 0 | 2348 || aff->af_keepcase != 0 |
2349 || aff->af_bad != 0 | 2349 || aff->af_bad != 0 |
2350 || aff->af_needaffix != 0 | 2350 || aff->af_needaffix != 0 |
2353 || aff->af_comproot != 0 | 2353 || aff->af_comproot != 0 |
2354 || aff->af_nosuggest != 0 | 2354 || aff->af_nosuggest != 0 |
2355 || compflags != NULL | 2355 || compflags != NULL |
2356 || aff->af_suff.ht_used > 0 | 2356 || aff->af_suff.ht_used > 0 |
2357 || aff->af_pref.ht_used > 0) | 2357 || aff->af_pref.ht_used > 0) |
2358 smsg((char_u *)_("FLAG after using flags in %s line %d: %s"), | 2358 smsg(_("FLAG after using flags in %s line %d: %s"), |
2359 fname, lnum, items[1]); | 2359 fname, lnum, items[1]); |
2360 } | 2360 } |
2361 else if (spell_info_item(items[0])) | 2361 else if (spell_info_item(items[0])) |
2362 { | 2362 { |
2363 p = (char_u *)getroom(spin, | 2363 p = (char_u *)getroom(spin, |
2444 && aff->af_compforbid == 0) | 2444 && aff->af_compforbid == 0) |
2445 { | 2445 { |
2446 aff->af_compforbid = affitem2flag(aff->af_flagtype, items[1], | 2446 aff->af_compforbid = affitem2flag(aff->af_flagtype, items[1], |
2447 fname, lnum); | 2447 fname, lnum); |
2448 if (aff->af_pref.ht_used > 0) | 2448 if (aff->af_pref.ht_used > 0) |
2449 smsg((char_u *)_("Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in %s line %d"), | 2449 smsg(_("Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in %s line %d"), |
2450 fname, lnum); | 2450 fname, lnum); |
2451 } | 2451 } |
2452 else if (is_aff_rule(items, itemcnt, "COMPOUNDPERMITFLAG", 2) | 2452 else if (is_aff_rule(items, itemcnt, "COMPOUNDPERMITFLAG", 2) |
2453 && aff->af_comppermit == 0) | 2453 && aff->af_comppermit == 0) |
2454 { | 2454 { |
2455 aff->af_comppermit = affitem2flag(aff->af_flagtype, items[1], | 2455 aff->af_comppermit = affitem2flag(aff->af_flagtype, items[1], |
2456 fname, lnum); | 2456 fname, lnum); |
2457 if (aff->af_pref.ht_used > 0) | 2457 if (aff->af_pref.ht_used > 0) |
2458 smsg((char_u *)_("Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in %s line %d"), | 2458 smsg(_("Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in %s line %d"), |
2459 fname, lnum); | 2459 fname, lnum); |
2460 } | 2460 } |
2461 else if (is_aff_rule(items, itemcnt, "COMPOUNDFLAG", 2) | 2461 else if (is_aff_rule(items, itemcnt, "COMPOUNDFLAG", 2) |
2462 && compflags == NULL) | 2462 && compflags == NULL) |
2463 { | 2463 { |
2474 else if (is_aff_rule(items, itemcnt, "COMPOUNDRULES", 2)) | 2474 else if (is_aff_rule(items, itemcnt, "COMPOUNDRULES", 2)) |
2475 { | 2475 { |
2476 /* We don't use the count, but do check that it's a number and | 2476 /* We don't use the count, but do check that it's a number and |
2477 * not COMPOUNDRULE mistyped. */ | 2477 * not COMPOUNDRULE mistyped. */ |
2478 if (atoi((char *)items[1]) == 0) | 2478 if (atoi((char *)items[1]) == 0) |
2479 smsg((char_u *)_("Wrong COMPOUNDRULES value in %s line %d: %s"), | 2479 smsg(_("Wrong COMPOUNDRULES value in %s line %d: %s"), |
2480 fname, lnum, items[1]); | 2480 fname, lnum, items[1]); |
2481 } | 2481 } |
2482 else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2)) | 2482 else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2)) |
2483 { | 2483 { |
2484 /* Don't use the first rule if it is a number. */ | 2484 /* Don't use the first rule if it is a number. */ |
2505 else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2) | 2505 else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2) |
2506 && compmax == 0) | 2506 && compmax == 0) |
2507 { | 2507 { |
2508 compmax = atoi((char *)items[1]); | 2508 compmax = atoi((char *)items[1]); |
2509 if (compmax == 0) | 2509 if (compmax == 0) |
2510 smsg((char_u *)_("Wrong COMPOUNDWORDMAX value in %s line %d: %s"), | 2510 smsg(_("Wrong COMPOUNDWORDMAX value in %s line %d: %s"), |
2511 fname, lnum, items[1]); | 2511 fname, lnum, items[1]); |
2512 } | 2512 } |
2513 else if (is_aff_rule(items, itemcnt, "COMPOUNDMIN", 2) | 2513 else if (is_aff_rule(items, itemcnt, "COMPOUNDMIN", 2) |
2514 && compminlen == 0) | 2514 && compminlen == 0) |
2515 { | 2515 { |
2516 compminlen = atoi((char *)items[1]); | 2516 compminlen = atoi((char *)items[1]); |
2517 if (compminlen == 0) | 2517 if (compminlen == 0) |
2518 smsg((char_u *)_("Wrong COMPOUNDMIN value in %s line %d: %s"), | 2518 smsg(_("Wrong COMPOUNDMIN value in %s line %d: %s"), |
2519 fname, lnum, items[1]); | 2519 fname, lnum, items[1]); |
2520 } | 2520 } |
2521 else if (is_aff_rule(items, itemcnt, "COMPOUNDSYLMAX", 2) | 2521 else if (is_aff_rule(items, itemcnt, "COMPOUNDSYLMAX", 2) |
2522 && compsylmax == 0) | 2522 && compsylmax == 0) |
2523 { | 2523 { |
2524 compsylmax = atoi((char *)items[1]); | 2524 compsylmax = atoi((char *)items[1]); |
2525 if (compsylmax == 0) | 2525 if (compsylmax == 0) |
2526 smsg((char_u *)_("Wrong COMPOUNDSYLMAX value in %s line %d: %s"), | 2526 smsg(_("Wrong COMPOUNDSYLMAX value in %s line %d: %s"), |
2527 fname, lnum, items[1]); | 2527 fname, lnum, items[1]); |
2528 } | 2528 } |
2529 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDDUP", 1)) | 2529 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDDUP", 1)) |
2530 { | 2530 { |
2531 compoptions |= COMP_CHECKDUP; | 2531 compoptions |= COMP_CHECKDUP; |
2543 compoptions |= COMP_CHECKTRIPLE; | 2543 compoptions |= COMP_CHECKTRIPLE; |
2544 } | 2544 } |
2545 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 2)) | 2545 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 2)) |
2546 { | 2546 { |
2547 if (atoi((char *)items[1]) == 0) | 2547 if (atoi((char *)items[1]) == 0) |
2548 smsg((char_u *)_("Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s"), | 2548 smsg(_("Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s"), |
2549 fname, lnum, items[1]); | 2549 fname, lnum, items[1]); |
2550 } | 2550 } |
2551 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 3)) | 2551 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 3)) |
2552 { | 2552 { |
2553 garray_T *gap = &spin->si_comppat; | 2553 garray_T *gap = &spin->si_comppat; |
2617 hi = hash_find(tp, key); | 2617 hi = hash_find(tp, key); |
2618 if (!HASHITEM_EMPTY(hi)) | 2618 if (!HASHITEM_EMPTY(hi)) |
2619 { | 2619 { |
2620 cur_aff = HI2AH(hi); | 2620 cur_aff = HI2AH(hi); |
2621 if (cur_aff->ah_combine != (*items[2] == 'Y')) | 2621 if (cur_aff->ah_combine != (*items[2] == 'Y')) |
2622 smsg((char_u *)_("Different combining flag in continued affix block in %s line %d: %s"), | 2622 smsg(_("Different combining flag in continued affix block in %s line %d: %s"), |
2623 fname, lnum, items[1]); | 2623 fname, lnum, items[1]); |
2624 if (!cur_aff->ah_follows) | 2624 if (!cur_aff->ah_follows) |
2625 smsg((char_u *)_("Duplicate affix in %s line %d: %s"), | 2625 smsg(_("Duplicate affix in %s line %d: %s"), |
2626 fname, lnum, items[1]); | 2626 fname, lnum, items[1]); |
2627 } | 2627 } |
2628 else | 2628 else |
2629 { | 2629 { |
2630 /* New affix letter. */ | 2630 /* New affix letter. */ |
2642 || cur_aff->ah_flag == aff->af_needaffix | 2642 || cur_aff->ah_flag == aff->af_needaffix |
2643 || cur_aff->ah_flag == aff->af_circumfix | 2643 || cur_aff->ah_flag == aff->af_circumfix |
2644 || cur_aff->ah_flag == aff->af_nosuggest | 2644 || cur_aff->ah_flag == aff->af_nosuggest |
2645 || cur_aff->ah_flag == aff->af_needcomp | 2645 || cur_aff->ah_flag == aff->af_needcomp |
2646 || cur_aff->ah_flag == aff->af_comproot) | 2646 || cur_aff->ah_flag == aff->af_comproot) |
2647 smsg((char_u *)_("Affix also used for BAD/RARE/KEEPCASE/NEEDAFFIX/NEEDCOMPOUND/NOSUGGEST in %s line %d: %s"), | 2647 smsg(_("Affix also used for BAD/RARE/KEEPCASE/NEEDAFFIX/NEEDCOMPOUND/NOSUGGEST in %s line %d: %s"), |
2648 fname, lnum, items[1]); | 2648 fname, lnum, items[1]); |
2649 STRCPY(cur_aff->ah_key, items[1]); | 2649 STRCPY(cur_aff->ah_key, items[1]); |
2650 hash_add(tp, cur_aff->ah_key); | 2650 hash_add(tp, cur_aff->ah_key); |
2651 | 2651 |
2652 cur_aff->ah_combine = (*items[2] == 'Y'); | 2652 cur_aff->ah_combine = (*items[2] == 'Y'); |
2663 cur_aff->ah_follows = FALSE; | 2663 cur_aff->ah_follows = FALSE; |
2664 | 2664 |
2665 /* Myspell allows extra text after the item, but that might | 2665 /* Myspell allows extra text after the item, but that might |
2666 * mean mistakes go unnoticed. Require a comment-starter. */ | 2666 * mean mistakes go unnoticed. Require a comment-starter. */ |
2667 if (itemcnt > lasti && *items[lasti] != '#') | 2667 if (itemcnt > lasti && *items[lasti] != '#') |
2668 smsg((char_u *)_(e_afftrailing), fname, lnum, items[lasti]); | 2668 smsg(_(e_afftrailing), fname, lnum, items[lasti]); |
2669 | 2669 |
2670 if (STRCMP(items[2], "Y") != 0 && STRCMP(items[2], "N") != 0) | 2670 if (STRCMP(items[2], "Y") != 0 && STRCMP(items[2], "N") != 0) |
2671 smsg((char_u *)_("Expected Y or N in %s line %d: %s"), | 2671 smsg(_("Expected Y or N in %s line %d: %s"), |
2672 fname, lnum, items[2]); | 2672 fname, lnum, items[2]); |
2673 | 2673 |
2674 if (*items[0] == 'P' && aff->af_pfxpostpone) | 2674 if (*items[0] == 'P' && aff->af_pfxpostpone) |
2675 { | 2675 { |
2676 if (cur_aff->ah_newID == 0) | 2676 if (cur_aff->ah_newID == 0) |
2708 if (itemcnt > lasti | 2708 if (itemcnt > lasti |
2709 && !aff->af_ignoreextra | 2709 && !aff->af_ignoreextra |
2710 && *items[lasti] != '#' | 2710 && *items[lasti] != '#' |
2711 && (STRCMP(items[lasti], "-") != 0 | 2711 && (STRCMP(items[lasti], "-") != 0 |
2712 || itemcnt != lasti + 1)) | 2712 || itemcnt != lasti + 1)) |
2713 smsg((char_u *)_(e_afftrailing), fname, lnum, items[lasti]); | 2713 smsg(_(e_afftrailing), fname, lnum, items[lasti]); |
2714 | 2714 |
2715 /* New item for an affix letter. */ | 2715 /* New item for an affix letter. */ |
2716 --aff_todo; | 2716 --aff_todo; |
2717 aff_entry = (affentry_T *)getroom(spin, | 2717 aff_entry = (affentry_T *)getroom(spin, |
2718 sizeof(affentry_T), TRUE); | 2718 sizeof(affentry_T), TRUE); |
2752 else | 2752 else |
2753 sprintf((char *)buf, "%s$", items[4]); | 2753 sprintf((char *)buf, "%s$", items[4]); |
2754 aff_entry->ae_prog = vim_regcomp(buf, | 2754 aff_entry->ae_prog = vim_regcomp(buf, |
2755 RE_MAGIC + RE_STRING + RE_STRICT); | 2755 RE_MAGIC + RE_STRING + RE_STRICT); |
2756 if (aff_entry->ae_prog == NULL) | 2756 if (aff_entry->ae_prog == NULL) |
2757 smsg((char_u *)_("Broken condition in %s line %d: %s"), | 2757 smsg(_("Broken condition in %s line %d: %s"), |
2758 fname, lnum, items[4]); | 2758 fname, lnum, items[4]); |
2759 } | 2759 } |
2760 | 2760 |
2761 /* For postponed prefixes we need an entry in si_prefcond | 2761 /* For postponed prefixes we need an entry in si_prefcond |
2762 * for the condition. Use an existing one if possible. | 2762 * for the condition. Use an existing one if possible. |
2900 else if (is_aff_rule(items, itemcnt, "REP", 2) | 2900 else if (is_aff_rule(items, itemcnt, "REP", 2) |
2901 || is_aff_rule(items, itemcnt, "REPSAL", 2)) | 2901 || is_aff_rule(items, itemcnt, "REPSAL", 2)) |
2902 { | 2902 { |
2903 /* Ignore REP/REPSAL count */; | 2903 /* Ignore REP/REPSAL count */; |
2904 if (!isdigit(*items[1])) | 2904 if (!isdigit(*items[1])) |
2905 smsg((char_u *)_("Expected REP(SAL) count in %s line %d"), | 2905 smsg(_("Expected REP(SAL) count in %s line %d"), |
2906 fname, lnum); | 2906 fname, lnum); |
2907 } | 2907 } |
2908 else if ((STRCMP(items[0], "REP") == 0 | 2908 else if ((STRCMP(items[0], "REP") == 0 |
2909 || STRCMP(items[0], "REPSAL") == 0) | 2909 || STRCMP(items[0], "REPSAL") == 0) |
2910 && itemcnt >= 3) | 2910 && itemcnt >= 3) |
2911 { | 2911 { |
2912 /* REP/REPSAL item */ | 2912 /* REP/REPSAL item */ |
2913 /* Myspell ignores extra arguments, we require it starts with | 2913 /* Myspell ignores extra arguments, we require it starts with |
2914 * # to detect mistakes. */ | 2914 * # to detect mistakes. */ |
2915 if (itemcnt > 3 && items[3][0] != '#') | 2915 if (itemcnt > 3 && items[3][0] != '#') |
2916 smsg((char_u *)_(e_afftrailing), fname, lnum, items[3]); | 2916 smsg(_(e_afftrailing), fname, lnum, items[3]); |
2917 if (items[0][3] == 'S' ? do_repsal : do_rep) | 2917 if (items[0][3] == 'S' ? do_repsal : do_rep) |
2918 { | 2918 { |
2919 /* Replace underscore with space (can't include a space | 2919 /* Replace underscore with space (can't include a space |
2920 * directly). */ | 2920 * directly). */ |
2921 for (p = items[1]; *p != NUL; MB_PTR_ADV(p)) | 2921 for (p = items[1]; *p != NUL; MB_PTR_ADV(p)) |
2935 if (!found_map) | 2935 if (!found_map) |
2936 { | 2936 { |
2937 /* First line contains the count. */ | 2937 /* First line contains the count. */ |
2938 found_map = TRUE; | 2938 found_map = TRUE; |
2939 if (!isdigit(*items[1])) | 2939 if (!isdigit(*items[1])) |
2940 smsg((char_u *)_("Expected MAP count in %s line %d"), | 2940 smsg(_("Expected MAP count in %s line %d"), |
2941 fname, lnum); | 2941 fname, lnum); |
2942 } | 2942 } |
2943 else if (do_mapline) | 2943 else if (do_mapline) |
2944 { | 2944 { |
2945 int c; | 2945 int c; |
2954 #endif | 2954 #endif |
2955 if ((spin->si_map.ga_len > 0 | 2955 if ((spin->si_map.ga_len > 0 |
2956 && vim_strchr(spin->si_map.ga_data, c) | 2956 && vim_strchr(spin->si_map.ga_data, c) |
2957 != NULL) | 2957 != NULL) |
2958 || vim_strchr(p, c) != NULL) | 2958 || vim_strchr(p, c) != NULL) |
2959 smsg((char_u *)_("Duplicate character in MAP in %s line %d"), | 2959 smsg(_("Duplicate character in MAP in %s line %d"), |
2960 fname, lnum); | 2960 fname, lnum); |
2961 } | 2961 } |
2962 | 2962 |
2963 /* We simply concatenate all the MAP strings, separated by | 2963 /* We simply concatenate all the MAP strings, separated by |
2964 * slashes. */ | 2964 * slashes. */ |
3011 hash_add(&spin->si_commonwords, p); | 3011 hash_add(&spin->si_commonwords, p); |
3012 } | 3012 } |
3013 } | 3013 } |
3014 } | 3014 } |
3015 else | 3015 else |
3016 smsg((char_u *)_("Unrecognized or duplicate item in %s line %d: %s"), | 3016 smsg(_("Unrecognized or duplicate item in %s line %d: %s"), |
3017 fname, lnum, items[0]); | 3017 fname, lnum, items[0]); |
3018 } | 3018 } |
3019 } | 3019 } |
3020 | 3020 |
3021 if (fol != NULL || low != NULL || upp != NULL) | 3021 if (fol != NULL || low != NULL || upp != NULL) |
3039 && !enc_utf8 | 3039 && !enc_utf8 |
3040 #endif | 3040 #endif |
3041 ) | 3041 ) |
3042 { | 3042 { |
3043 if (fol == NULL || low == NULL || upp == NULL) | 3043 if (fol == NULL || low == NULL || upp == NULL) |
3044 smsg((char_u *)_("Missing FOL/LOW/UPP line in %s"), fname); | 3044 smsg(_("Missing FOL/LOW/UPP line in %s"), fname); |
3045 else | 3045 else |
3046 (void)set_spell_chartab(fol, low, upp); | 3046 (void)set_spell_chartab(fol, low, upp); |
3047 } | 3047 } |
3048 | 3048 |
3049 vim_free(fol); | 3049 vim_free(fol); |
3065 } | 3065 } |
3066 | 3066 |
3067 if (compsylmax != 0) | 3067 if (compsylmax != 0) |
3068 { | 3068 { |
3069 if (syllable == NULL) | 3069 if (syllable == NULL) |
3070 smsg((char_u *)_("COMPOUNDSYLMAX used without SYLLABLE")); | 3070 smsg(_("COMPOUNDSYLMAX used without SYLLABLE")); |
3071 aff_check_number(spin->si_compsylmax, compsylmax, "COMPOUNDSYLMAX"); | 3071 aff_check_number(spin->si_compsylmax, compsylmax, "COMPOUNDSYLMAX"); |
3072 spin->si_compsylmax = compsylmax; | 3072 spin->si_compsylmax = compsylmax; |
3073 } | 3073 } |
3074 | 3074 |
3075 if (compoptions != 0) | 3075 if (compoptions != 0) |
3099 } | 3099 } |
3100 | 3100 |
3101 if (sofofrom != NULL || sofoto != NULL) | 3101 if (sofofrom != NULL || sofoto != NULL) |
3102 { | 3102 { |
3103 if (sofofrom == NULL || sofoto == NULL) | 3103 if (sofofrom == NULL || sofoto == NULL) |
3104 smsg((char_u *)_("Missing SOFO%s line in %s"), | 3104 smsg(_("Missing SOFO%s line in %s"), |
3105 sofofrom == NULL ? "FROM" : "TO", fname); | 3105 sofofrom == NULL ? "FROM" : "TO", fname); |
3106 else if (spin->si_sal.ga_len > 0) | 3106 else if (spin->si_sal.ga_len > 0) |
3107 smsg((char_u *)_("Both SAL and SOFO lines in %s"), fname); | 3107 smsg(_("Both SAL and SOFO lines in %s"), fname); |
3108 else | 3108 else |
3109 { | 3109 { |
3110 aff_check_string(spin->si_sofofr, sofofrom, "SOFOFROM"); | 3110 aff_check_string(spin->si_sofofr, sofofrom, "SOFOFROM"); |
3111 aff_check_string(spin->si_sofoto, sofoto, "SOFOTO"); | 3111 aff_check_string(spin->si_sofoto, sofoto, "SOFOTO"); |
3112 spin->si_sofofr = sofofrom; | 3112 spin->si_sofofr = sofofrom; |
3206 | 3206 |
3207 res = get_affitem(flagtype, &p); | 3207 res = get_affitem(flagtype, &p); |
3208 if (res == 0) | 3208 if (res == 0) |
3209 { | 3209 { |
3210 if (flagtype == AFT_NUM) | 3210 if (flagtype == AFT_NUM) |
3211 smsg((char_u *)_("Flag is not a number in %s line %d: %s"), | 3211 smsg(_("Flag is not a number in %s line %d: %s"), |
3212 fname, lnum, item); | 3212 fname, lnum, item); |
3213 else | 3213 else |
3214 smsg((char_u *)_("Illegal flag in %s line %d: %s"), | 3214 smsg(_("Illegal flag in %s line %d: %s"), |
3215 fname, lnum, item); | 3215 fname, lnum, item); |
3216 } | 3216 } |
3217 if (*p != NUL) | 3217 if (*p != NUL) |
3218 { | 3218 { |
3219 smsg((char_u *)_(e_affname), fname, lnum, item); | 3219 smsg(_(e_affname), fname, lnum, item); |
3220 return 0; | 3220 return 0; |
3221 } | 3221 } |
3222 | 3222 |
3223 return res; | 3223 return res; |
3224 } | 3224 } |
3417 */ | 3417 */ |
3418 static void | 3418 static void |
3419 aff_check_number(int spinval, int affval, char *name) | 3419 aff_check_number(int spinval, int affval, char *name) |
3420 { | 3420 { |
3421 if (spinval != 0 && spinval != affval) | 3421 if (spinval != 0 && spinval != affval) |
3422 smsg((char_u *)_("%s value differs from what is used in another .aff file"), name); | 3422 smsg(_("%s value differs from what is used in another .aff file"), name); |
3423 } | 3423 } |
3424 | 3424 |
3425 /* | 3425 /* |
3426 * Give a warning when "spinval" and "affval" strings are set and not the same. | 3426 * Give a warning when "spinval" and "affval" strings are set and not the same. |
3427 */ | 3427 */ |
3428 static void | 3428 static void |
3429 aff_check_string(char_u *spinval, char_u *affval, char *name) | 3429 aff_check_string(char_u *spinval, char_u *affval, char *name) |
3430 { | 3430 { |
3431 if (spinval != NULL && STRCMP(spinval, affval) != 0) | 3431 if (spinval != NULL && STRCMP(spinval, affval) != 0) |
3432 smsg((char_u *)_("%s value differs from what is used in another .aff file"), name); | 3432 smsg(_("%s value differs from what is used in another .aff file"), name); |
3433 } | 3433 } |
3434 | 3434 |
3435 /* | 3435 /* |
3436 * Return TRUE if strings "s1" and "s2" are equal. Also consider both being | 3436 * Return TRUE if strings "s1" and "s2" are equal. Also consider both being |
3437 * NULL as equal. | 3437 * NULL as equal. |
3547 * Open the file. | 3547 * Open the file. |
3548 */ | 3548 */ |
3549 fd = mch_fopen((char *)fname, "r"); | 3549 fd = mch_fopen((char *)fname, "r"); |
3550 if (fd == NULL) | 3550 if (fd == NULL) |
3551 { | 3551 { |
3552 EMSG2(_(e_notopen), fname); | 3552 semsg(_(e_notopen), fname); |
3553 return FAIL; | 3553 return FAIL; |
3554 } | 3554 } |
3555 | 3555 |
3556 /* The hashtable is only used to detect duplicated words. */ | 3556 /* The hashtable is only used to detect duplicated words. */ |
3557 hash_init(&ht); | 3557 hash_init(&ht); |
3564 spin->si_msg_count = 999999; | 3564 spin->si_msg_count = 999999; |
3565 | 3565 |
3566 /* Read and ignore the first line: word count. */ | 3566 /* Read and ignore the first line: word count. */ |
3567 (void)vim_fgets(line, MAXLINELEN, fd); | 3567 (void)vim_fgets(line, MAXLINELEN, fd); |
3568 if (!vim_isdigit(*skipwhite(line))) | 3568 if (!vim_isdigit(*skipwhite(line))) |
3569 EMSG2(_("E760: No word count in %s"), fname); | 3569 semsg(_("E760: No word count in %s"), fname); |
3570 | 3570 |
3571 /* | 3571 /* |
3572 * Read all the lines in the file one by one. | 3572 * Read all the lines in the file one by one. |
3573 * The words are converted to 'encoding' here, before being added to | 3573 * The words are converted to 'encoding' here, before being added to |
3574 * the hashtable. | 3574 * the hashtable. |
3594 if (spin->si_conv.vc_type != CONV_NONE) | 3594 if (spin->si_conv.vc_type != CONV_NONE) |
3595 { | 3595 { |
3596 pc = string_convert(&spin->si_conv, line, NULL); | 3596 pc = string_convert(&spin->si_conv, line, NULL); |
3597 if (pc == NULL) | 3597 if (pc == NULL) |
3598 { | 3598 { |
3599 smsg((char_u *)_("Conversion failure for word in %s line %d: %s"), | 3599 smsg(_("Conversion failure for word in %s line %d: %s"), |
3600 fname, lnum, line); | 3600 fname, lnum, line); |
3601 continue; | 3601 continue; |
3602 } | 3602 } |
3603 w = pc; | 3603 w = pc; |
3604 } | 3604 } |
3659 hash = hash_hash(dw); | 3659 hash = hash_hash(dw); |
3660 hi = hash_lookup(&ht, dw, hash); | 3660 hi = hash_lookup(&ht, dw, hash); |
3661 if (!HASHITEM_EMPTY(hi)) | 3661 if (!HASHITEM_EMPTY(hi)) |
3662 { | 3662 { |
3663 if (p_verbose > 0) | 3663 if (p_verbose > 0) |
3664 smsg((char_u *)_("Duplicate word in %s line %d: %s"), | 3664 smsg(_("Duplicate word in %s line %d: %s"), |
3665 fname, lnum, dw); | 3665 fname, lnum, dw); |
3666 else if (duplicate == 0) | 3666 else if (duplicate == 0) |
3667 smsg((char_u *)_("First duplicate word in %s line %d: %s"), | 3667 smsg(_("First duplicate word in %s line %d: %s"), |
3668 fname, lnum, dw); | 3668 fname, lnum, dw); |
3669 ++duplicate; | 3669 ++duplicate; |
3670 } | 3670 } |
3671 else | 3671 else |
3672 hash_add_item(&ht, hi, dw, hash); | 3672 hash_add_item(&ht, hi, dw, hash); |
3717 | 3717 |
3718 vim_free(pc); | 3718 vim_free(pc); |
3719 } | 3719 } |
3720 | 3720 |
3721 if (duplicate > 0) | 3721 if (duplicate > 0) |
3722 smsg((char_u *)_("%d duplicate word(s) in %s"), duplicate, fname); | 3722 smsg(_("%d duplicate word(s) in %s"), duplicate, fname); |
3723 if (spin->si_ascii && non_ascii > 0) | 3723 if (spin->si_ascii && non_ascii > 0) |
3724 smsg((char_u *)_("Ignored %d word(s) with non-ASCII characters in %s"), | 3724 smsg(_("Ignored %d word(s) with non-ASCII characters in %s"), |
3725 non_ascii, fname); | 3725 non_ascii, fname); |
3726 hash_clear(&ht); | 3726 hash_clear(&ht); |
3727 | 3727 |
3728 fclose(fd); | 3728 fclose(fd); |
3729 return retval; | 3729 return retval; |
4131 * Open the file. | 4131 * Open the file. |
4132 */ | 4132 */ |
4133 fd = mch_fopen((char *)fname, "r"); | 4133 fd = mch_fopen((char *)fname, "r"); |
4134 if (fd == NULL) | 4134 if (fd == NULL) |
4135 { | 4135 { |
4136 EMSG2(_(e_notopen), fname); | 4136 semsg(_(e_notopen), fname); |
4137 return FAIL; | 4137 return FAIL; |
4138 } | 4138 } |
4139 | 4139 |
4140 vim_snprintf((char *)IObuff, IOSIZE, _("Reading word file %s..."), fname); | 4140 vim_snprintf((char *)IObuff, IOSIZE, _("Reading word file %s..."), fname); |
4141 spell_message(spin, IObuff); | 4141 spell_message(spin, IObuff); |
4166 if (spin->si_conv.vc_type != CONV_NONE) | 4166 if (spin->si_conv.vc_type != CONV_NONE) |
4167 { | 4167 { |
4168 pc = string_convert(&spin->si_conv, rline, NULL); | 4168 pc = string_convert(&spin->si_conv, rline, NULL); |
4169 if (pc == NULL) | 4169 if (pc == NULL) |
4170 { | 4170 { |
4171 smsg((char_u *)_("Conversion failure for word in %s line %d: %s"), | 4171 smsg(_("Conversion failure for word in %s line %d: %s"), |
4172 fname, lnum, rline); | 4172 fname, lnum, rline); |
4173 continue; | 4173 continue; |
4174 } | 4174 } |
4175 line = pc; | 4175 line = pc; |
4176 } | 4176 } |
4185 { | 4185 { |
4186 ++line; | 4186 ++line; |
4187 if (STRNCMP(line, "encoding=", 9) == 0) | 4187 if (STRNCMP(line, "encoding=", 9) == 0) |
4188 { | 4188 { |
4189 if (spin->si_conv.vc_type != CONV_NONE) | 4189 if (spin->si_conv.vc_type != CONV_NONE) |
4190 smsg((char_u *)_("Duplicate /encoding= line ignored in %s line %d: %s"), | 4190 smsg(_("Duplicate /encoding= line ignored in %s line %d: %s"), |
4191 fname, lnum, line - 1); | 4191 fname, lnum, line - 1); |
4192 else if (did_word) | 4192 else if (did_word) |
4193 smsg((char_u *)_("/encoding= line after word ignored in %s line %d: %s"), | 4193 smsg(_("/encoding= line after word ignored in %s line %d: %s"), |
4194 fname, lnum, line - 1); | 4194 fname, lnum, line - 1); |
4195 else | 4195 else |
4196 { | 4196 { |
4197 #ifdef FEAT_MBYTE | 4197 #ifdef FEAT_MBYTE |
4198 char_u *enc; | 4198 char_u *enc; |
4201 line += 9; | 4201 line += 9; |
4202 enc = enc_canonize(line); | 4202 enc = enc_canonize(line); |
4203 if (enc != NULL && !spin->si_ascii | 4203 if (enc != NULL && !spin->si_ascii |
4204 && convert_setup(&spin->si_conv, enc, | 4204 && convert_setup(&spin->si_conv, enc, |
4205 p_enc) == FAIL) | 4205 p_enc) == FAIL) |
4206 smsg((char_u *)_("Conversion in %s not supported: from %s to %s"), | 4206 smsg(_("Conversion in %s not supported: from %s to %s"), |
4207 fname, line, p_enc); | 4207 fname, line, p_enc); |
4208 vim_free(enc); | 4208 vim_free(enc); |
4209 spin->si_conv.vc_fail = TRUE; | 4209 spin->si_conv.vc_fail = TRUE; |
4210 #else | 4210 #else |
4211 smsg((char_u *)_("Conversion in %s not supported"), fname); | 4211 smsg(_("Conversion in %s not supported"), fname); |
4212 #endif | 4212 #endif |
4213 } | 4213 } |
4214 continue; | 4214 continue; |
4215 } | 4215 } |
4216 | 4216 |
4217 if (STRNCMP(line, "regions=", 8) == 0) | 4217 if (STRNCMP(line, "regions=", 8) == 0) |
4218 { | 4218 { |
4219 if (spin->si_region_count > 1) | 4219 if (spin->si_region_count > 1) |
4220 smsg((char_u *)_("Duplicate /regions= line ignored in %s line %d: %s"), | 4220 smsg(_("Duplicate /regions= line ignored in %s line %d: %s"), |
4221 fname, lnum, line); | 4221 fname, lnum, line); |
4222 else | 4222 else |
4223 { | 4223 { |
4224 line += 8; | 4224 line += 8; |
4225 if (STRLEN(line) > MAXREGIONS * 2) | 4225 if (STRLEN(line) > MAXREGIONS * 2) |
4226 smsg((char_u *)_("Too many regions in %s line %d: %s"), | 4226 smsg(_("Too many regions in %s line %d: %s"), |
4227 fname, lnum, line); | 4227 fname, lnum, line); |
4228 else | 4228 else |
4229 { | 4229 { |
4230 spin->si_region_count = (int)STRLEN(line) / 2; | 4230 spin->si_region_count = (int)STRLEN(line) / 2; |
4231 STRCPY(spin->si_region_name, line); | 4231 STRCPY(spin->si_region_name, line); |
4235 } | 4235 } |
4236 } | 4236 } |
4237 continue; | 4237 continue; |
4238 } | 4238 } |
4239 | 4239 |
4240 smsg((char_u *)_("/ line ignored in %s line %d: %s"), | 4240 smsg(_("/ line ignored in %s line %d: %s"), |
4241 fname, lnum, line - 1); | 4241 fname, lnum, line - 1); |
4242 continue; | 4242 continue; |
4243 } | 4243 } |
4244 | 4244 |
4245 flags = 0; | 4245 flags = 0; |
4265 flags |= WF_REGION; | 4265 flags |= WF_REGION; |
4266 | 4266 |
4267 l = *p - '0'; | 4267 l = *p - '0'; |
4268 if (l == 0 || l > spin->si_region_count) | 4268 if (l == 0 || l > spin->si_region_count) |
4269 { | 4269 { |
4270 smsg((char_u *)_("Invalid region nr in %s line %d: %s"), | 4270 smsg(_("Invalid region nr in %s line %d: %s"), |
4271 fname, lnum, p); | 4271 fname, lnum, p); |
4272 break; | 4272 break; |
4273 } | 4273 } |
4274 regionmask |= 1 << (l - 1); | 4274 regionmask |= 1 << (l - 1); |
4275 } | 4275 } |
4276 else | 4276 else |
4277 { | 4277 { |
4278 smsg((char_u *)_("Unrecognized flags in %s line %d: %s"), | 4278 smsg(_("Unrecognized flags in %s line %d: %s"), |
4279 fname, lnum, p); | 4279 fname, lnum, p); |
4280 break; | 4280 break; |
4281 } | 4281 } |
4282 ++p; | 4282 ++p; |
4283 } | 4283 } |
4344 (unsigned)(sizeof(sblock_T) + SBLOCKSIZE)); | 4344 (unsigned)(sizeof(sblock_T) + SBLOCKSIZE)); |
4345 if (bl == NULL) | 4345 if (bl == NULL) |
4346 { | 4346 { |
4347 if (!spin->si_did_emsg) | 4347 if (!spin->si_did_emsg) |
4348 { | 4348 { |
4349 EMSG(_("E845: Insufficient memory, word list will be incomplete")); | 4349 emsg(_("E845: Insufficient memory, word list will be incomplete")); |
4350 spin->si_did_emsg = TRUE; | 4350 spin->si_did_emsg = TRUE; |
4351 } | 4351 } |
4352 return NULL; | 4352 return NULL; |
4353 } | 4353 } |
4354 bl->sb_next = spin->si_blocks; | 4354 bl->sb_next = spin->si_blocks; |
4574 } | 4574 } |
4575 prev = &node->wn_child; | 4575 prev = &node->wn_child; |
4576 node = *prev; | 4576 node = *prev; |
4577 } | 4577 } |
4578 #ifdef SPELL_PRINTTREE | 4578 #ifdef SPELL_PRINTTREE |
4579 smsg((char_u *)"Added \"%s\"", word); | 4579 smsg("Added \"%s\"", word); |
4580 spell_print_tree(root->wn_sibling); | 4580 spell_print_tree(root->wn_sibling); |
4581 #endif | 4581 #endif |
4582 | 4582 |
4583 /* count nr of words added since last message */ | 4583 /* count nr of words added since last message */ |
4584 ++spin->si_msg_count; | 4584 ++spin->si_msg_count; |
4914 warnings from picky compiler */ | 4914 warnings from picky compiler */ |
4915 | 4915 |
4916 fd = mch_fopen((char *)fname, "w"); | 4916 fd = mch_fopen((char *)fname, "w"); |
4917 if (fd == NULL) | 4917 if (fd == NULL) |
4918 { | 4918 { |
4919 EMSG2(_(e_notopen), fname); | 4919 semsg(_(e_notopen), fname); |
4920 return FAIL; | 4920 return FAIL; |
4921 } | 4921 } |
4922 | 4922 |
4923 /* <HEADER>: <fileID> <versionnr> */ | 4923 /* <HEADER>: <fileID> <versionnr> */ |
4924 /* <fileID> */ | 4924 /* <fileID> */ |
5303 retval = FAIL; | 5303 retval = FAIL; |
5304 | 5304 |
5305 if (fwv != (size_t)1) | 5305 if (fwv != (size_t)1) |
5306 retval = FAIL; | 5306 retval = FAIL; |
5307 if (retval == FAIL) | 5307 if (retval == FAIL) |
5308 EMSG(_(e_write)); | 5308 emsg(_(e_write)); |
5309 | 5309 |
5310 return retval; | 5310 return retval; |
5311 } | 5311 } |
5312 | 5312 |
5313 /* | 5313 /* |
5448 np->wn_child->wn_u2.wnode = node; | 5448 np->wn_child->wn_u2.wnode = node; |
5449 | 5449 |
5450 if (fd != NULL) | 5450 if (fd != NULL) |
5451 if (putc(np->wn_byte, fd) == EOF) /* <byte> or <xbyte> */ | 5451 if (putc(np->wn_byte, fd) == EOF) /* <byte> or <xbyte> */ |
5452 { | 5452 { |
5453 EMSG(_(e_write)); | 5453 emsg(_(e_write)); |
5454 return 0; | 5454 return 0; |
5455 } | 5455 } |
5456 } | 5456 } |
5457 } | 5457 } |
5458 | 5458 |
5553 * compression possible. | 5553 * compression possible. |
5554 */ | 5554 */ |
5555 if (sug_maketable(spin) == FAIL) | 5555 if (sug_maketable(spin) == FAIL) |
5556 goto theend; | 5556 goto theend; |
5557 | 5557 |
5558 smsg((char_u *)_("Number of words after soundfolding: %ld"), | 5558 smsg(_("Number of words after soundfolding: %ld"), |
5559 (long)spin->si_spellbuf->b_ml.ml_line_count); | 5559 (long)spin->si_spellbuf->b_ml.ml_line_count); |
5560 | 5560 |
5561 /* | 5561 /* |
5562 * Compress the soundfold trie. | 5562 * Compress the soundfold trie. |
5563 */ | 5563 */ |
5680 wordcount[depth] = 0; | 5680 wordcount[depth] = 0; |
5681 } | 5681 } |
5682 } | 5682 } |
5683 } | 5683 } |
5684 | 5684 |
5685 smsg((char_u *)_("Total number of words: %d"), words_done); | 5685 smsg(_("Total number of words: %d"), words_done); |
5686 | 5686 |
5687 return OK; | 5687 return OK; |
5688 } | 5688 } |
5689 | 5689 |
5690 /* | 5690 /* |
5846 | 5846 |
5847 /* Create the file. Note that an existing file is silently overwritten! */ | 5847 /* Create the file. Note that an existing file is silently overwritten! */ |
5848 fd = mch_fopen((char *)fname, "w"); | 5848 fd = mch_fopen((char *)fname, "w"); |
5849 if (fd == NULL) | 5849 if (fd == NULL) |
5850 { | 5850 { |
5851 EMSG2(_(e_notopen), fname); | 5851 semsg(_(e_notopen), fname); |
5852 return; | 5852 return; |
5853 } | 5853 } |
5854 | 5854 |
5855 vim_snprintf((char *)IObuff, IOSIZE, | 5855 vim_snprintf((char *)IObuff, IOSIZE, |
5856 _("Writing suggestion file %s..."), fname); | 5856 _("Writing suggestion file %s..."), fname); |
5859 /* | 5859 /* |
5860 * <SUGHEADER>: <fileID> <versionnr> <timestamp> | 5860 * <SUGHEADER>: <fileID> <versionnr> <timestamp> |
5861 */ | 5861 */ |
5862 if (fwrite(VIMSUGMAGIC, VIMSUGMAGICL, (size_t)1, fd) != 1) /* <fileID> */ | 5862 if (fwrite(VIMSUGMAGIC, VIMSUGMAGICL, (size_t)1, fd) != 1) /* <fileID> */ |
5863 { | 5863 { |
5864 EMSG(_(e_write)); | 5864 emsg(_(e_write)); |
5865 goto theend; | 5865 goto theend; |
5866 } | 5866 } |
5867 putc(VIMSUGVERSION, fd); /* <versionnr> */ | 5867 putc(VIMSUGVERSION, fd); /* <versionnr> */ |
5868 | 5868 |
5869 /* Write si_sugtime to the file. */ | 5869 /* Write si_sugtime to the file. */ |
5901 /* <sugline>: <sugnr> ... NUL */ | 5901 /* <sugline>: <sugnr> ... NUL */ |
5902 line = ml_get_buf(spin->si_spellbuf, lnum, FALSE); | 5902 line = ml_get_buf(spin->si_spellbuf, lnum, FALSE); |
5903 len = (int)STRLEN(line) + 1; | 5903 len = (int)STRLEN(line) + 1; |
5904 if (fwrite(line, (size_t)len, (size_t)1, fd) == 0) | 5904 if (fwrite(line, (size_t)len, (size_t)1, fd) == 0) |
5905 { | 5905 { |
5906 EMSG(_(e_write)); | 5906 emsg(_(e_write)); |
5907 goto theend; | 5907 goto theend; |
5908 } | 5908 } |
5909 spin->si_memtot += len; | 5909 spin->si_memtot += len; |
5910 } | 5910 } |
5911 | 5911 |
5912 /* Write another byte to check for errors. */ | 5912 /* Write another byte to check for errors. */ |
5913 if (putc(0, fd) == EOF) | 5913 if (putc(0, fd) == EOF) |
5914 EMSG(_(e_write)); | 5914 emsg(_(e_write)); |
5915 | 5915 |
5916 vim_snprintf((char *)IObuff, IOSIZE, | 5916 vim_snprintf((char *)IObuff, IOSIZE, |
5917 _("Estimated runtime memory use: %d bytes"), spin->si_memtot); | 5917 _("Estimated runtime memory use: %d bytes"), spin->si_memtot); |
5918 spell_message(spin, IObuff); | 5918 spell_message(spin, IObuff); |
5919 | 5919 |
6008 if (strstr((char *)gettail(wfname), SPL_FNAME_ADD) != NULL) | 6008 if (strstr((char *)gettail(wfname), SPL_FNAME_ADD) != NULL) |
6009 spin.si_add = TRUE; | 6009 spin.si_add = TRUE; |
6010 } | 6010 } |
6011 | 6011 |
6012 if (incount <= 0) | 6012 if (incount <= 0) |
6013 EMSG(_(e_invarg)); /* need at least output and input names */ | 6013 emsg(_(e_invarg)); /* need at least output and input names */ |
6014 else if (vim_strchr(gettail(wfname), '_') != NULL) | 6014 else if (vim_strchr(gettail(wfname), '_') != NULL) |
6015 EMSG(_("E751: Output file name must not have region name")); | 6015 emsg(_("E751: Output file name must not have region name")); |
6016 else if (incount > MAXREGIONS) | 6016 else if (incount > MAXREGIONS) |
6017 EMSGN(_("E754: Only up to %ld regions supported"), MAXREGIONS); | 6017 semsg(_("E754: Only up to %ld regions supported"), MAXREGIONS); |
6018 else | 6018 else |
6019 { | 6019 { |
6020 /* Check for overwriting before doing things that may take a lot of | 6020 /* Check for overwriting before doing things that may take a lot of |
6021 * time. */ | 6021 * time. */ |
6022 if (!over_write && mch_stat((char *)wfname, &st) >= 0) | 6022 if (!over_write && mch_stat((char *)wfname, &st) >= 0) |
6023 { | 6023 { |
6024 EMSG(_(e_exists)); | 6024 emsg(_(e_exists)); |
6025 goto theend; | 6025 goto theend; |
6026 } | 6026 } |
6027 if (mch_isdir(wfname)) | 6027 if (mch_isdir(wfname)) |
6028 { | 6028 { |
6029 EMSG2(_(e_isadir2), wfname); | 6029 semsg(_(e_isadir2), wfname); |
6030 goto theend; | 6030 goto theend; |
6031 } | 6031 } |
6032 | 6032 |
6033 fname = alloc(MAXPATHL); | 6033 fname = alloc(MAXPATHL); |
6034 if (fname == NULL) | 6034 if (fname == NULL) |
6046 { | 6046 { |
6047 len = (int)STRLEN(innames[i]); | 6047 len = (int)STRLEN(innames[i]); |
6048 if (STRLEN(gettail(innames[i])) < 5 | 6048 if (STRLEN(gettail(innames[i])) < 5 |
6049 || innames[i][len - 3] != '_') | 6049 || innames[i][len - 3] != '_') |
6050 { | 6050 { |
6051 EMSG2(_("E755: Invalid region in %s"), innames[i]); | 6051 semsg(_("E755: Invalid region in %s"), innames[i]); |
6052 goto theend; | 6052 goto theend; |
6053 } | 6053 } |
6054 spin.si_region_name[i * 2] = TOLOWER_ASC(innames[i][len - 2]); | 6054 spin.si_region_name[i * 2] = TOLOWER_ASC(innames[i][len - 2]); |
6055 spin.si_region_name[i * 2 + 1] = | 6055 spin.si_region_name[i * 2 + 1] = |
6056 TOLOWER_ASC(innames[i][len - 1]); | 6056 TOLOWER_ASC(innames[i][len - 1]); |
6258 new_spf = TRUE; | 6258 new_spf = TRUE; |
6259 } | 6259 } |
6260 | 6260 |
6261 if (*curwin->w_s->b_p_spf == NUL) | 6261 if (*curwin->w_s->b_p_spf == NUL) |
6262 { | 6262 { |
6263 EMSG2(_(e_notset), "spellfile"); | 6263 semsg(_(e_notset), "spellfile"); |
6264 return; | 6264 return; |
6265 } | 6265 } |
6266 fnamebuf = alloc(MAXPATHL); | 6266 fnamebuf = alloc(MAXPATHL); |
6267 if (fnamebuf == NULL) | 6267 if (fnamebuf == NULL) |
6268 return; | 6268 return; |
6272 copy_option_part(&spf, fnamebuf, MAXPATHL, ","); | 6272 copy_option_part(&spf, fnamebuf, MAXPATHL, ","); |
6273 if (i == idx) | 6273 if (i == idx) |
6274 break; | 6274 break; |
6275 if (*spf == NUL) | 6275 if (*spf == NUL) |
6276 { | 6276 { |
6277 EMSGN(_("E765: 'spellfile' does not have %ld entries"), idx); | 6277 semsg(_("E765: 'spellfile' does not have %ld entries"), idx); |
6278 vim_free(fnamebuf); | 6278 vim_free(fnamebuf); |
6279 return; | 6279 return; |
6280 } | 6280 } |
6281 } | 6281 } |
6282 | 6282 |
6284 buf = buflist_findname_exp(fnamebuf); | 6284 buf = buflist_findname_exp(fnamebuf); |
6285 if (buf != NULL && buf->b_ml.ml_mfp == NULL) | 6285 if (buf != NULL && buf->b_ml.ml_mfp == NULL) |
6286 buf = NULL; | 6286 buf = NULL; |
6287 if (buf != NULL && bufIsChanged(buf)) | 6287 if (buf != NULL && bufIsChanged(buf)) |
6288 { | 6288 { |
6289 EMSG(_(e_bufloaded)); | 6289 emsg(_(e_bufloaded)); |
6290 vim_free(fnamebuf); | 6290 vim_free(fnamebuf); |
6291 return; | 6291 return; |
6292 } | 6292 } |
6293 | 6293 |
6294 fname = fnamebuf; | 6294 fname = fnamebuf; |
6319 { | 6319 { |
6320 fputc('#', fd); | 6320 fputc('#', fd); |
6321 if (undo) | 6321 if (undo) |
6322 { | 6322 { |
6323 home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE); | 6323 home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE); |
6324 smsg((char_u *)_("Word '%.*s' removed from %s"), | 6324 smsg(_("Word '%.*s' removed from %s"), |
6325 len, word, NameBuff); | 6325 len, word, NameBuff); |
6326 } | 6326 } |
6327 } | 6327 } |
6328 fseek(fd, fpos_next, SEEK_SET); | 6328 fseek(fd, fpos_next, SEEK_SET); |
6329 } | 6329 } |
6356 fd = mch_fopen((char *)fname, "a"); | 6356 fd = mch_fopen((char *)fname, "a"); |
6357 } | 6357 } |
6358 } | 6358 } |
6359 | 6359 |
6360 if (fd == NULL) | 6360 if (fd == NULL) |
6361 EMSG2(_(e_notopen), fname); | 6361 semsg(_(e_notopen), fname); |
6362 else | 6362 else |
6363 { | 6363 { |
6364 if (bad) | 6364 if (bad) |
6365 fprintf(fd, "%.*s/!\n", len, word); | 6365 fprintf(fd, "%.*s/!\n", len, word); |
6366 else | 6366 else |
6367 fprintf(fd, "%.*s\n", len, word); | 6367 fprintf(fd, "%.*s\n", len, word); |
6368 fclose(fd); | 6368 fclose(fd); |
6369 | 6369 |
6370 home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE); | 6370 home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE); |
6371 smsg((char_u *)_("Word '%.*s' added to %s"), len, word, NameBuff); | 6371 smsg(_("Word '%.*s' added to %s"), len, word, NameBuff); |
6372 } | 6372 } |
6373 } | 6373 } |
6374 | 6374 |
6375 if (fd != NULL) | 6375 if (fd != NULL) |
6376 { | 6376 { |
6483 | 6483 |
6484 while (*pf != NUL) | 6484 while (*pf != NUL) |
6485 { | 6485 { |
6486 if (*pl == NUL || *pu == NUL) | 6486 if (*pl == NUL || *pu == NUL) |
6487 { | 6487 { |
6488 EMSG(_(e_affform)); | 6488 emsg(_(e_affform)); |
6489 return FAIL; | 6489 return FAIL; |
6490 } | 6490 } |
6491 #ifdef FEAT_MBYTE | 6491 #ifdef FEAT_MBYTE |
6492 f = mb_ptr2char_adv(&pf); | 6492 f = mb_ptr2char_adv(&pf); |
6493 l = mb_ptr2char_adv(&pl); | 6493 l = mb_ptr2char_adv(&pl); |
6509 * case-folding */ | 6509 * case-folding */ |
6510 if (l < 256 && l != f) | 6510 if (l < 256 && l != f) |
6511 { | 6511 { |
6512 if (f >= 256) | 6512 if (f >= 256) |
6513 { | 6513 { |
6514 EMSG(_(e_affrange)); | 6514 emsg(_(e_affrange)); |
6515 return FAIL; | 6515 return FAIL; |
6516 } | 6516 } |
6517 new_st.st_fold[l] = f; | 6517 new_st.st_fold[l] = f; |
6518 } | 6518 } |
6519 | 6519 |
6522 * "FOL" . */ | 6522 * "FOL" . */ |
6523 if (u < 256 && u != f) | 6523 if (u < 256 && u != f) |
6524 { | 6524 { |
6525 if (f >= 256) | 6525 if (f >= 256) |
6526 { | 6526 { |
6527 EMSG(_(e_affrange)); | 6527 emsg(_(e_affrange)); |
6528 return FAIL; | 6528 return FAIL; |
6529 } | 6529 } |
6530 new_st.st_fold[u] = f; | 6530 new_st.st_fold[u] = f; |
6531 new_st.st_isu[u] = TRUE; | 6531 new_st.st_isu[u] = TRUE; |
6532 new_st.st_upper[f] = u; | 6532 new_st.st_upper[f] = u; |
6533 } | 6533 } |
6534 } | 6534 } |
6535 | 6535 |
6536 if (*pl != NUL || *pu != NUL) | 6536 if (*pl != NUL || *pu != NUL) |
6537 { | 6537 { |
6538 EMSG(_(e_affform)); | 6538 emsg(_(e_affform)); |
6539 return FAIL; | 6539 return FAIL; |
6540 } | 6540 } |
6541 | 6541 |
6542 return set_spell_finish(&new_st); | 6542 return set_spell_finish(&new_st); |
6543 } | 6543 } |
6597 if (spelltab.st_isw[i] != new_st->st_isw[i] | 6597 if (spelltab.st_isw[i] != new_st->st_isw[i] |
6598 || spelltab.st_isu[i] != new_st->st_isu[i] | 6598 || spelltab.st_isu[i] != new_st->st_isu[i] |
6599 || spelltab.st_fold[i] != new_st->st_fold[i] | 6599 || spelltab.st_fold[i] != new_st->st_fold[i] |
6600 || spelltab.st_upper[i] != new_st->st_upper[i]) | 6600 || spelltab.st_upper[i] != new_st->st_upper[i]) |
6601 { | 6601 { |
6602 EMSG(_("E763: Word characters differ between spell files")); | 6602 emsg(_("E763: Word characters differ between spell files")); |
6603 return FAIL; | 6603 return FAIL; |
6604 } | 6604 } |
6605 } | 6605 } |
6606 } | 6606 } |
6607 else | 6607 else |
6723 hash_add_item(&lp->sl_map_hash, hi, b, hash); | 6723 hash_add_item(&lp->sl_map_hash, hi, b, hash); |
6724 else | 6724 else |
6725 { | 6725 { |
6726 /* This should have been checked when generating the .spl | 6726 /* This should have been checked when generating the .spl |
6727 * file. */ | 6727 * file. */ |
6728 EMSG(_("E783: duplicate char in MAP entry")); | 6728 emsg(_("E783: duplicate char in MAP entry")); |
6729 vim_free(b); | 6729 vim_free(b); |
6730 } | 6730 } |
6731 } | 6731 } |
6732 else | 6732 else |
6733 #endif | 6733 #endif |