unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* regex bug with pattern "\\*/" matching end of buffer */
@ 2005-04-26 18:07 Geoff Odhner
  0 siblings, 0 replies; 2+ messages in thread
From: Geoff Odhner @ 2005-04-26 18:07 UTC (permalink / raw)


This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

In GNU Emacs 21.3.1 (i686-pc-linux-gnu, X toolkit)
 of 2005-03-24 on monster
configured using `configure  --prefix=/home/geoff/i686 --with-toolkit-scroll-bars'
Important settings:
  value of $LC_ALL: C
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  locale-coding-system: nil
  default-enable-multibyte-characters: t

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

If I have a file with the following line (no trailing space):

	char	ch;	/* sample comment */

then I put the cursor on it and execute the following elisp code:

	(save-restriction
	  (narrow-to-region (progn (beginning-of-line) (point))
			    (progn (end-of-line) (point)))
	  (goto-char (point-min))
	  (while (and (re-search-forward "/\\*"  nil t) (not (eobp)))
	    (replace-match "/-*" nil nil))
	  (goto-char (point-min))
	  (while (and (re-search-forward "\\*/"  nil t) (not (eobp)))
	    (replace-match "*-/" nil nil)))

it will give me the following line as the result:

	char	ch;	/-* sample comment */

In contrast, what I expect is this:

	char	ch;	/-* sample comment *-/

If I add a trailing space, then I get appropriate behavior.


Regards,

Geoff Odhner



Recent input:
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> r e p l <tab> s t <tab> <return> C-x 0 
<help-echo> <switch-frame> <down-mouse-1> <mouse-movement> 
<mouse-1> <kp-subtract> <up> <kp-add> A-s <f2> <up> 
<up> <up> <return> <up> <up> <return> <f10> <f2> w 
i d <tab> e <tab> <return> <C-kp-add> A-z <f2> k <return> 
<f2> r e l SPC <return> <f3> <S-kp-add> A-z C-x C-v 
<return> <next> <next> <next> <down-mouse-1> <mouse-1> 
<C-kp-add> A-z <down-mouse-1> <mouse-1> <kp-subtract> 
<down> <kp-add> A-z <up> A-z A-s <down-mouse-1> <mouse-1> 
<down-mouse-1> <mouse-1> <down-mouse-1> <mouse-1> SPC 
<S-kp-add> A-z A-z <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <menu-bar> <help-menu> 
<report-emacs-bug>

Recent messages:

Undo!
Mark set [2 times]
Line eaten
Mark set [2 times]
Line inserted
Undo! [2 times]
Wrote /home/geoff/ggoo/elisp/el/lines-G.el
Undo! [2 times]
Loading emacsbug...done

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: regex bug with pattern "\\*/" matching end of buffer */
       [not found] <20050430231850.495369F50E@mirror.positive-internet.com>
@ 2005-05-02 12:54 ` Geoff Odhner
  0 siblings, 0 replies; 2+ messages in thread
From: Geoff Odhner @ 2005-05-02 12:54 UTC (permalink / raw)
  Cc: bug-gnu-emacs, Geoff Odhner

Thank you.  I am relieved to find the bug is in my code.  Indeed, it works 
correctly when I recode it thus:
         (while (and (re-search-forward "\\*/"  nil t) (replace-match 
"*-/" nil nil)) (not (eobp))))

Geoff Odhner


Richard Stallman <rms@gnu.org> wrote on 04/30/2005 07:18:50 PM:

>          (while (and (re-search-forward "\\*/"  nil t) (not (eobp)))
>       (replace-match "*-/" nil nil)))
> 
>     it will give me the following line as the result:
> 
>        char   ch;   /-* sample comment */
> 
> That's because (eobp) returns t when you're at the end of the
> accessible portion of the buffer.  So the bug is in your code,
> I think.
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-05-02 12:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20050430231850.495369F50E@mirror.positive-internet.com>
2005-05-02 12:54 ` regex bug with pattern "\\*/" matching end of buffer */ Geoff Odhner
2005-04-26 18:07 Geoff Odhner

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).