Hi

When pressing  g8  in normal mode on the NUL character <00>,
Vim-7.3 (and older) displays 0a. It should display 00.  The ":ascii"
Ex command correctly displays <<00>>.

Steps to reproduce:

1) Create a file with NUL char in it:

  $ perl -e 'print chr(0)' > test.txt

2) Run:

  $ vim -u NONE -c ":set display=uhex" -c ":norm g8" test.txt

3) Observe that Vim displays 0a at the bottom of the screen instead
of the expected 00.

Attached patch fixes it.
-- Dominique

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r 74c8bba1d9e8 src/mbyte.c
--- a/src/mbyte.c	Mon May 17 22:07:47 2010 +0200
+++ b/src/mbyte.c	Tue May 18 20:23:55 2010 +0200
@@ -3150,6 +3150,7 @@
     int		len;
     int		rlen = 0;
     char_u	*line;
+    char_u	c;
     int		clen;
     int		i;
 
@@ -3176,7 +3177,8 @@
 	    }
 	    clen = utf_ptr2len(line + i);
 	}
-	sprintf((char *)IObuff + rlen, "%02x ", line[i]);
+	c = (line[i] == NL) ? NUL : line[i];	/* NUL is stored as NL */
+	sprintf((char *)IObuff + rlen, "%02x ", c);
 	--clen;
 	rlen += (int)STRLEN(IObuff + rlen);
 	if (rlen > IOSIZE - 20)
@@ -4871,7 +4873,7 @@
 	 *
 	 * An alternative approach would be to destroy the IM context and
 	 * recreate it.  But that means loading/unloading the IM module on
-	 * every mode switch, which causes a quite noticable delay even on
+	 * every mode switch, which causes a quite noticeable delay even on
 	 * my rather fast box...
 	 * *
 	 * Moreover, there are some XIM which cannot respond to
@@ -5179,7 +5181,7 @@
     static void
 im_xim_send_event_imactivate()
 {
-    /* Force turn on preedit state by symulate keypress event.
+    /* Force turn on preedit state by simulating keypress event.
      * Keycode and state is specified by 'imactivatekey'.
      */
     XKeyEvent ev;
@@ -5256,7 +5258,7 @@
 	    {
 		/* Force turn off preedit state.  With some IM
 		 * implementations, we cannot turn off preedit state by
-		 * symulate keypress event.  It is why using such a method
+		 * simulating keypress event.  It is why using such a method
 		 * that destroy old IC (input context), and create new one.
 		 * When create new IC, its preedit state is usually off.
 		 */
@@ -5272,14 +5274,14 @@
 	else
 	{
 	    /* First, force destroy old IC, and create new one.  It
-	     * symulates "turning off preedit state".
+	     * simulates "turning off preedit state".
 	     */
 	    xim_set_focus(FALSE);
 	    gdk_ic_destroy(xic);
 	    xim_init();
 	    xim_can_preediting = FALSE;
 
-	    /* 2nd, when requested to activate IM, symulate this by sending
+	    /* 2nd, when requested to activate IM, simulate this by sending
 	     * the event.
 	     */
 	    if (active)
@@ -5334,7 +5336,7 @@
 	 * couldn't switch state of XIM preediting.  This is reason why these
 	 * codes are commented out.
 	 */
-	/* First, force destroy old IC, and create new one.  It symulates
+	/* First, force destroy old IC, and create new one.  It simulates
 	 * "turning off preedit state".
 	 */
 	xim_set_focus(FALSE);
@@ -5342,7 +5344,7 @@
 	xic = NULL;
 	xim_init();
 
-	/* 2nd, when requested to activate IM, symulate this by sending the
+	/* 2nd, when requested to activate IM, simulate this by sending the
 	 * event.
 	 */
 	if (active)

Raspunde prin e-mail lui