all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@m17n.org>
Cc: monnier@cs.yale.edu
Subject: Re: Bug in regexp matching in data readed in binary mode
Date: Thu, 16 Jan 2003 09:31:41 +0900 (JST)	[thread overview]
Message-ID: <200301160031.JAA10750@etlken.m17n.org> (raw)
In-Reply-To: <2nvg0qqomo.fsf@zsh.cs.rochester.edu> (message from ShengHuo ZHU on Wed, 15 Jan 2003 13:00:47 -0500)

In article <2nvg0qqomo.fsf@zsh.cs.rochester.edu>, ShengHuo ZHU <zsh@cs.rochester.edu> writes:
> I can reproduce the bug, however I think the bug is probably related
> to the decoding part of the read_process_output function, which I am
> not familiar with.

> I hope that the following code (based on Alex's code) may illustrate
> the bug in a better way.  The first piece of code returns t, which is
> obviously wrong. But if we insert a space and delete it, it returns
> nil in the second piece.

Thank you for the test case.  The bug was in regex.c.  The
attached patch will fix it.  Please try it.  It also fixes
the bug of backward searching of eight-bit-graphic char.

Stefan, it seems that you are maintaining regex.c.  What
should I do for this change?  Can I directly install it in
HEAD (and perhaps in RC)?

---
Ken'ichi HANDA
handa@m17n.org

2003-01-16  Kenichi Handa  <handa@m17n.org>

	* regex.c (GET_CHAR_BEFORE_2): Fix for the case that the previous
	char is eight-bit-graphic.
	(re_search_2): Likewise.

*** regex.c.~1.183.~	Wed Dec  4 17:26:49 2002
--- regex.c	Thu Jan 16 09:27:28 2003
***************
*** 157,164 ****
         {						    		\
  	 re_char *dtemp = (p) == (str2) ? (end1) : (p);		    	\
  	 re_char *dlimit = ((p) > (str2) && (p) <= (end2)) ? (str2) : (str1); \
  	 while (dtemp-- > dlimit && !CHAR_HEAD_P (*dtemp));		\
! 	 c = STRING_CHAR (dtemp, (p) - dtemp);				\
         }						    		\
       else						    		\
         (c = ((p) == (str2) ? (end1) : (p))[-1]);			\
--- 157,168 ----
         {						    		\
  	 re_char *dtemp = (p) == (str2) ? (end1) : (p);		    	\
  	 re_char *dlimit = ((p) > (str2) && (p) <= (end2)) ? (str2) : (str1); \
+ 	 re_char *d0 = dtemp;						\
  	 while (dtemp-- > dlimit && !CHAR_HEAD_P (*dtemp));		\
! 	 if (MULTIBYTE_FORM_LENGTH (dtemp, d0 - dtemp) == d0 - dtemp)	\
! 	   c = STRING_CHAR (dtemp, d0 - dtemp);				\
! 	 else								\
! 	   c = d0[-1];							\
         }						    		\
       else						    		\
         (c = ((p) == (str2) ? (end1) : (p))[-1]);			\
***************
*** 4307,4324 ****
  		p--, len++;
  
  	      /* Adjust it. */
- #if 0				/* XXX */
  	      if (MULTIBYTE_FORM_LENGTH (p, len + 1) != (len + 1))
! 		;
! 	      else
! #endif
! 		{
! 		  range += len;
! 		  if (range > 0)
! 		    break;
  
! 		  startpos -= len;
! 		}
  	    }
  	}
      }
--- 4311,4326 ----
  		p--, len++;
  
  	      /* Adjust it. */
  	      if (MULTIBYTE_FORM_LENGTH (p, len + 1) != (len + 1))
! 		/* The previous character is eight-bit-graphic which
! 		   is represented by one byte even in a multibyte
! 		   buffer/string.  */
! 		len = 0;
! 	      range += len;
! 	      if (range > 0)
! 		break;
  
! 	      startpos -= len;
  	    }
  	}
      }

  reply	other threads:[~2003-01-16  0:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.261.1042555834.21513.bug-gnu-emacs@gnu.org>
2003-01-15 18:00 ` Bug in regexp matching in data readed in binary mode ShengHuo ZHU
2003-01-16  0:31   ` Kenichi Handa [this message]
2003-01-14 14:42 Alex Ott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200301160031.JAA10750@etlken.m17n.org \
    --to=handa@m17n.org \
    --cc=monnier@cs.yale.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.