* bug#34769: Bug in emacs 26.1 gdb-send match-string applied after non-matching string-match
@ 2019-03-06 11:27 Tobias Zawada
2019-03-06 18:18 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Tobias Zawada @ 2019-03-06 11:27 UTC (permalink / raw)
To: 34769
Dear Emacs maintainers,
At the end of gdb-send one finds the following lines:
(let* ((control-command-p (string-match gdb-control-commands-regexp string))
(command-arg (match-string 3 string))
It is wrong to call (match-string 3 string) if (string-match gdb-control-commands-regexp string) returned nil.
The doc of match-string says:
"Return string of text matched by last search."
That means match-string only returns sensible results if the last match was successful.
Possible correction:
(let* ((control-command-p (string-match gdb-control-commands-regexp string))
(command-arg (and control-command-p (match-string 3 string)))
System info:
GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2018-05-29
Best regards,
Tobias
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#34769: Bug in emacs 26.1 gdb-send match-string applied after non-matching string-match
2019-03-06 11:27 bug#34769: Bug in emacs 26.1 gdb-send match-string applied after non-matching string-match Tobias Zawada
@ 2019-03-06 18:18 ` Eli Zaretskii
2019-03-06 20:10 ` Tobias Zawada
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2019-03-06 18:18 UTC (permalink / raw)
To: Tobias Zawada; +Cc: 34769
> Date: Wed, 6 Mar 2019 12:27:03 +0100 (CET)
> From: Tobias Zawada <i_inbox@tn-home.de>
>
> At the end of gdb-send one finds the following lines:
>
> (let* ((control-command-p (string-match gdb-control-commands-regexp string))
> (command-arg (match-string 3 string))
>
> It is wrong to call (match-string 3 string) if (string-match gdb-control-commands-regexp string) returned nil.
> The doc of match-string says:
> "Return string of text matched by last search."
> That means match-string only returns sensible results if the last match was successful.
That is true, and a cleanup is a good idea. But please note that the
undefined results are not used if control-command-p is nil, so the
issue is not that serious.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#34769: Bug in emacs 26.1 gdb-send match-string applied after non-matching string-match
2019-03-06 18:18 ` Eli Zaretskii
@ 2019-03-06 20:10 ` Tobias Zawada
2019-03-07 15:18 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Tobias Zawada @ 2019-03-06 20:10 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 34769
Dear Eli,
thanks for looking into this.
> > It is wrong to call (match-string 3 string) if (string-match gdb-control-commands-regexp string) returned nil.
> ...
> That is true, and a cleanup is a good idea. But please note that the
> undefined results are not used if control-command-p is nil, so the
> issue is not that serious.
The match data is that one of the previous successful matching operation.
One gets an args-out-of-range signal if the indexes in the match data are larger than the width of the string argument to match-string. That is how I discovered the error.
A reconstruction with gdb-send is too involved.
Instead I demonstrate the effect with the following orgmode source code block inclusive results:
#+BEGIN_SRC emacs-lisp
(string-match "\\(1\\) *\\(2\\)" "1 2")
(string-match "\\(3 \\(4\\)\\)" "1 2")
(append
(match-data)
(condition-case err
(match-string 2 "1 2")
(error (list err))))
#+END_SRC
#+RESULTS:
| 0 | 12 | 0 | 1 | 11 | 12 | (args-out-of-range 1 2 11 12) |
Best regards,
Tobias
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#34769: Bug in emacs 26.1 gdb-send match-string applied after non-matching string-match
2019-03-06 20:10 ` Tobias Zawada
@ 2019-03-07 15:18 ` Eli Zaretskii
0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2019-03-07 15:18 UTC (permalink / raw)
To: Tobias Zawada; +Cc: 34769-done
> Date: Wed, 6 Mar 2019 21:10:54 +0100 (CET)
> From: Tobias Zawada <i_inbox@tn-home.de>
> Cc: 34769@debbugs.gnu.org
>
> Dear Eli,
> thanks for looking into this.
>
> > > It is wrong to call (match-string 3 string) if (string-match gdb-control-commands-regexp string) returned nil.
> > ...
> > That is true, and a cleanup is a good idea. But please note that the
> > undefined results are not used if control-command-p is nil, so the
> > issue is not that serious.
>
> The match data is that one of the previous successful matching operation.
> One gets an args-out-of-range signal if the indexes in the match data are larger than the width of the string argument to match-string. That is how I discovered the error.
You are right; I've now fixed this on the emacs-26 branch.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-03-07 15:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-06 11:27 bug#34769: Bug in emacs 26.1 gdb-send match-string applied after non-matching string-match Tobias Zawada
2019-03-06 18:18 ` Eli Zaretskii
2019-03-06 20:10 ` Tobias Zawada
2019-03-07 15:18 ` Eli Zaretskii
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.