Mercurial > vim
comparison src/ex_docmd.c @ 3097:738ea87c1964 v7.3.320
updated for version 7.3.320
Problem: When a 0xa0 character is in a sourced file the error message for
unrecognized command does not show the problem.
Solution: Display 0xa0 as <a0>.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 21 Sep 2011 19:10:46 +0200 |
parents | 1fad9c73d77a |
children | ec901ddc84d5 |
comparison
equal
deleted
inserted
replaced
3096:57585ff9888f | 3097:738ea87c1964 |
---|---|
59 static char_u *do_one_cmd __ARGS((char_u **, int, struct condstack *, char_u *(*fgetline)(int, void *, int), void *cookie)); | 59 static char_u *do_one_cmd __ARGS((char_u **, int, struct condstack *, char_u *(*fgetline)(int, void *, int), void *cookie)); |
60 #else | 60 #else |
61 static char_u *do_one_cmd __ARGS((char_u **, int, char_u *(*fgetline)(int, void *, int), void *cookie)); | 61 static char_u *do_one_cmd __ARGS((char_u **, int, char_u *(*fgetline)(int, void *, int), void *cookie)); |
62 static int if_level = 0; /* depth in :if */ | 62 static int if_level = 0; /* depth in :if */ |
63 #endif | 63 #endif |
64 static void append_command __ARGS((char_u *cmd)); | |
64 static char_u *find_command __ARGS((exarg_T *eap, int *full)); | 65 static char_u *find_command __ARGS((exarg_T *eap, int *full)); |
65 | 66 |
66 static void ex_abbreviate __ARGS((exarg_T *eap)); | 67 static void ex_abbreviate __ARGS((exarg_T *eap)); |
67 static void ex_map __ARGS((exarg_T *eap)); | 68 static void ex_map __ARGS((exarg_T *eap)); |
68 static void ex_unmap __ARGS((exarg_T *eap)); | 69 static void ex_unmap __ARGS((exarg_T *eap)); |
2134 { | 2135 { |
2135 if (!ea.skip) | 2136 if (!ea.skip) |
2136 { | 2137 { |
2137 STRCPY(IObuff, _("E492: Not an editor command")); | 2138 STRCPY(IObuff, _("E492: Not an editor command")); |
2138 if (!sourcing) | 2139 if (!sourcing) |
2139 { | 2140 append_command(*cmdlinep); |
2140 STRCAT(IObuff, ": "); | |
2141 STRNCAT(IObuff, *cmdlinep, 40); | |
2142 } | |
2143 errormsg = IObuff; | 2141 errormsg = IObuff; |
2144 } | 2142 } |
2145 goto doend; | 2143 goto doend; |
2146 } | 2144 } |
2147 | 2145 |
2706 if (errormsg != IObuff) | 2704 if (errormsg != IObuff) |
2707 { | 2705 { |
2708 STRCPY(IObuff, errormsg); | 2706 STRCPY(IObuff, errormsg); |
2709 errormsg = IObuff; | 2707 errormsg = IObuff; |
2710 } | 2708 } |
2711 STRCAT(errormsg, ": "); | 2709 append_command(*cmdlinep); |
2712 STRNCAT(errormsg, *cmdlinep, IOSIZE - STRLEN(IObuff) - 1); | |
2713 } | 2710 } |
2714 emsg(errormsg); | 2711 emsg(errormsg); |
2715 } | 2712 } |
2716 #ifdef FEAT_EVAL | 2713 #ifdef FEAT_EVAL |
2717 do_errthrow(cstack, | 2714 do_errthrow(cstack, |
2792 { | 2789 { |
2793 *pp = skipwhite(*pp + i); | 2790 *pp = skipwhite(*pp + i); |
2794 return TRUE; | 2791 return TRUE; |
2795 } | 2792 } |
2796 return FALSE; | 2793 return FALSE; |
2794 } | |
2795 | |
2796 /* | |
2797 * Append "cmd" to the error message in IObuff. | |
2798 * Takes care of limiting the length and handling 0xa0, which would be | |
2799 * invisible otherwise. | |
2800 */ | |
2801 static void | |
2802 append_command(cmd) | |
2803 char_u *cmd; | |
2804 { | |
2805 char_u *s = cmd; | |
2806 char_u *d; | |
2807 | |
2808 STRCAT(IObuff, ": "); | |
2809 d = IObuff + STRLEN(IObuff); | |
2810 while (*s != NUL && d - IObuff < IOSIZE - 7) | |
2811 { | |
2812 if ( | |
2813 #ifdef FEAT_MBYTE | |
2814 enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : | |
2815 #endif | |
2816 *s == 0xa0) | |
2817 { | |
2818 s += | |
2819 #ifdef FEAT_MBYTE | |
2820 enc_utf8 ? 2 : | |
2821 #endif | |
2822 1; | |
2823 STRCPY(d, "<a0>"); | |
2824 d += 4; | |
2825 } | |
2826 else | |
2827 MB_COPY_CHAR(s, d); | |
2828 } | |
2829 *d = NUL; | |
2797 } | 2830 } |
2798 | 2831 |
2799 /* | 2832 /* |
2800 * Find an Ex command by its name, either built-in or user. | 2833 * Find an Ex command by its name, either built-in or user. |
2801 * Start of the name can be found at eap->cmd. | 2834 * Start of the name can be found at eap->cmd. |