* Emacs should no longer silently modify a binary file when instructed not to.
  Patch: detect-coding-iso2022.diff
  Provided-by: Kenichi Handa <handa@etl.go.jp> 
  Added-by: Rob Browning <rlb@defaultvalue.org>
  Status: backported from upstream fix of 2002-07-26

  Emacs should no longer modify a binary file when told to use a
  raw-text or no-conversion for the encoding during a save.

diff -urNad /home/rlb/deb/emacs21/trunk/src/coding.c trunk/src/coding.c
--- /home/rlb/deb/emacs21/trunk/src/coding.c	2003-09-09 17:28:48.000000000 -0500
+++ trunk/src/coding.c	2003-09-11 22:16:16.000000000 -0500
@@ -1359,6 +1359,7 @@
   while (mask && src < src_end)
     {
       ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep);
+    retry:
       switch (c)
 	{
 	case ISO_CODE_ESC:
@@ -1556,6 +1557,8 @@
 		  && mask & CODING_CATEGORY_MASK_ISO_8_2)
 		{
 		  int i = 1;
+
+		  c = -1;
 		  while (src < src_end)
 		    {
 		      ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep);
@@ -1568,6 +1571,9 @@
 		    mask &= ~CODING_CATEGORY_MASK_ISO_8_2;
 		  else
 		    mask_found |= CODING_CATEGORY_MASK_ISO_8_2;
+		  if (c >= 0)
+		    /* This means that we have read one extra byte.  */
+		    goto retry;
 		}
 	    }
 	  break;
