comparison src/if_ruby.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 1d2b5c016f17
children dd725a8ab112
comparison
equal deleted inserted replaced
15469:bc9b5261ed01 15470:55ccc2d353bd
743 return OK; 743 return OK;
744 hinstRuby = load_dll(libname); 744 hinstRuby = load_dll(libname);
745 if (!hinstRuby) 745 if (!hinstRuby)
746 { 746 {
747 if (verbose) 747 if (verbose)
748 EMSG2(_(e_loadlib), libname); 748 semsg(_(e_loadlib), libname);
749 return FAIL; 749 return FAIL;
750 } 750 }
751 751
752 for (i = 0; ruby_funcname_table[i].ptr; ++i) 752 for (i = 0; ruby_funcname_table[i].ptr; ++i)
753 { 753 {
755 ruby_funcname_table[i].name))) 755 ruby_funcname_table[i].name)))
756 { 756 {
757 close_dll(hinstRuby); 757 close_dll(hinstRuby);
758 hinstRuby = NULL; 758 hinstRuby = NULL;
759 if (verbose) 759 if (verbose)
760 EMSG2(_(e_loadfunc), ruby_funcname_table[i].name); 760 semsg(_(e_loadfunc), ruby_funcname_table[i].name);
761 return FAIL; 761 return FAIL;
762 } 762 }
763 } 763 }
764 return OK; 764 return OK;
765 } 765 }
883 line = rb_lastline_get(); 883 line = rb_lastline_get();
884 if (!NIL_P(line)) 884 if (!NIL_P(line))
885 { 885 {
886 if (TYPE(line) != T_STRING) 886 if (TYPE(line) != T_STRING)
887 { 887 {
888 EMSG(_("E265: $_ must be an instance of String")); 888 emsg(_("E265: $_ must be an instance of String"));
889 return; 889 return;
890 } 890 }
891 ml_replace(i, (char_u *) StringValuePtr(line), 1); 891 ml_replace(i, (char_u *) StringValuePtr(line), 1);
892 changed(); 892 changed();
893 #ifdef SYNTAX_HL 893 #ifdef SYNTAX_HL
977 ruby_initialized = 1; 977 ruby_initialized = 1;
978 #ifdef DYNAMIC_RUBY 978 #ifdef DYNAMIC_RUBY
979 } 979 }
980 else 980 else
981 { 981 {
982 EMSG(_("E266: Sorry, this command is disabled, the Ruby library could not be loaded.")); 982 emsg(_("E266: Sorry, this command is disabled, the Ruby library could not be loaded."));
983 return 0; 983 return 0;
984 } 984 }
985 #endif 985 #endif
986 } 986 }
987 return ruby_initialized; 987 return ruby_initialized;
1011 #define TAG_MASK 0xf 1011 #define TAG_MASK 0xf
1012 1012
1013 switch (state) 1013 switch (state)
1014 { 1014 {
1015 case TAG_RETURN: 1015 case TAG_RETURN:
1016 EMSG(_("E267: unexpected return")); 1016 emsg(_("E267: unexpected return"));
1017 break; 1017 break;
1018 case TAG_NEXT: 1018 case TAG_NEXT:
1019 EMSG(_("E268: unexpected next")); 1019 emsg(_("E268: unexpected next"));
1020 break; 1020 break;
1021 case TAG_BREAK: 1021 case TAG_BREAK:
1022 EMSG(_("E269: unexpected break")); 1022 emsg(_("E269: unexpected break"));
1023 break; 1023 break;
1024 case TAG_REDO: 1024 case TAG_REDO:
1025 EMSG(_("E270: unexpected redo")); 1025 emsg(_("E270: unexpected redo"));
1026 break; 1026 break;
1027 case TAG_RETRY: 1027 case TAG_RETRY:
1028 EMSG(_("E271: retry outside of rescue clause")); 1028 emsg(_("E271: retry outside of rescue clause"));
1029 break; 1029 break;
1030 case TAG_RAISE: 1030 case TAG_RAISE:
1031 case TAG_FATAL: 1031 case TAG_FATAL:
1032 #ifdef RUBY19_OR_LATER 1032 #ifdef RUBY19_OR_LATER
1033 error = rb_errinfo(); 1033 error = rb_errinfo();
1036 #endif 1036 #endif
1037 eclass = CLASS_OF(error); 1037 eclass = CLASS_OF(error);
1038 einfo = rb_obj_as_string(error); 1038 einfo = rb_obj_as_string(error);
1039 if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) 1039 if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0)
1040 { 1040 {
1041 EMSG(_("E272: unhandled exception")); 1041 emsg(_("E272: unhandled exception"));
1042 } 1042 }
1043 else 1043 else
1044 { 1044 {
1045 VALUE epath; 1045 VALUE epath;
1046 char *p; 1046 char *p;
1048 epath = rb_class_path(eclass); 1048 epath = rb_class_path(eclass);
1049 vim_snprintf(buff, BUFSIZ, "%s: %s", 1049 vim_snprintf(buff, BUFSIZ, "%s: %s",
1050 RSTRING_PTR(epath), RSTRING_PTR(einfo)); 1050 RSTRING_PTR(epath), RSTRING_PTR(einfo));
1051 p = strchr(buff, '\n'); 1051 p = strchr(buff, '\n');
1052 if (p) *p = '\0'; 1052 if (p) *p = '\0';
1053 EMSG(buff); 1053 emsg(buff);
1054 } 1054 }
1055 1055
1056 attr = syn_name2attr((char_u *)"Error"); 1056 attr = syn_name2attr((char_u *)"Error");
1057 # ifdef RUBY21_OR_LATER 1057 # ifdef RUBY21_OR_LATER
1058 bt = rb_funcallv(error, rb_intern("backtrace"), 0, 0); 1058 bt = rb_funcallv(error, rb_intern("backtrace"), 0, 0);
1064 msg_attr((char_u *)RSTRING_PTR(RARRAY_PTR(bt)[i]), attr); 1064 msg_attr((char_u *)RSTRING_PTR(RARRAY_PTR(bt)[i]), attr);
1065 # endif 1065 # endif
1066 break; 1066 break;
1067 default: 1067 default:
1068 vim_snprintf(buff, BUFSIZ, _("E273: unknown longjmp status %d"), state); 1068 vim_snprintf(buff, BUFSIZ, _("E273: unknown longjmp status %d"), state);
1069 EMSG(buff); 1069 emsg(buff);
1070 break; 1070 break;
1071 } 1071 }
1072 } 1072 }
1073 1073
1074 static VALUE vim_message(VALUE self UNUSED, VALUE str) 1074 static VALUE vim_message(VALUE self UNUSED, VALUE str)