[patch] fix for ++enc= always causes E474

19 views
Skip to first unread message

Charles Cooper

unread,
Dec 9, 2011, 8:24:54 PM12/9/11
to vim...@googlegroups.com
This problem occurs in vim with +multi_byte.
:edit ++encoding=xyz always causes error E474, while ++enc=xyz succeeds.

"encoding" is the only ++option where the short form of the option is a
substring of the long form.  The check for these options does not account
for this.

Here is one way to fix this (same as attached patch).

--- vim/src/ex_docmd.c  2011-10-22 21:32:57.000000000 -0400
+++ vim2/src/ex_docmd.c 2011-11-06 20:46:26.000000000 -0500
@@ -4838,14 +4838,14 @@
        pp = &eap->force_ff;
     }
 #ifdef FEAT_MBYTE
-    else if (STRNCMP(arg, "enc", 3) == 0)
+    else if (STRNCMP(arg, "encoding", 8) == 0)
     {
-       arg += 3;
+       arg += 8;
        pp = &eap->force_enc;
     }
-    else if (STRNCMP(arg, "encoding", 8) == 0)
+    else if (STRNCMP(arg, "enc", 3) == 0)
     {
-       arg += 8;
+       arg += 3;
        pp = &eap->force_enc;
     }
     else if (STRNCMP(arg, "bad", 3) == 0)




ex_docmd.c.patch

Bram Moolenaar

unread,
Dec 10, 2011, 8:10:11 AM12/10/11
to Charles Cooper, vim...@googlegroups.com

Charles Cooper wrote:

> This problem occurs in vim with +multi_byte.
> :edit ++encoding=xyz always causes error E474, while ++enc=xyz succeeds.
>
> "encoding" is the only ++option where the short form of the option is a
> substring of the long form. The check for these options does not account
> for this.
>
> Here is one way to fix this (same as attached patch).

Thanks for the patch, I'll look into it soon.

--
ARTHUR: This new learning amazes me, Sir Bedevere. Explain again how sheep's
bladders may be employed to prevent earthquakes.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Ben Fritz

unread,
Dec 11, 2011, 1:10:55 AM12/11/11
to vim_dev

On Dec 9, 7:24 pm, Charles Cooper <sabl...@gmail.com> wrote:
> This problem occurs in vim with +multi_byte.
> :edit ++encoding=xyz always causes error E474, while ++enc=xyz succeeds.
>
> "encoding" is the only ++option where the short form of the option is a
> substring of the long form.  The check for these options does not account
> for this.
>

This is confusing, because ++enc actually modifies 'fileencoding', not
'encoding'. I think this potentially makes it even more confusing.

Tony Mechelynck

unread,
Dec 11, 2011, 9:29:33 AM12/11/11
to vim...@googlegroups.com, Ben Fritz

++enc and ++encoding are already both foreseen, but the current code
tests for ++enc first, and for ++encoding only if ++enc was not found,
which is wrong. The patch just reverses the order of the already
existing tests.

The case of ++bin / ++binary / ++nobin / ++nobinary is already handled
by the existing code.


Best regards,
Tony.
--
Ten years of rejection slips is nature's way of telling you to stop
writing.
-- R. Geis

Reply all
Reply to author
Forward
0 new messages