Mercurial > emacs
comparison lisp/gud.el @ 4357:5731da0436e8
* gud.el (gud-gdb-marker-filter): Preserve the match data across
the filter's execution.
* gud.el (gud-gdb-marker-filter): If we received some text after
the position marker, append it to any text before the marker,
instead of throwing away the text before the marker.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Fri, 30 Jul 1993 22:43:39 +0000 |
parents | 3011390123ed |
children | 820df40f1e8c |
comparison
equal
deleted
inserted
replaced
4356:3f0d5006a2c4 | 4357:5731da0436e8 |
---|---|
163 ;; beginning of a marker, we save it here between calls to the | 163 ;; beginning of a marker, we save it here between calls to the |
164 ;; filter. | 164 ;; filter. |
165 (defvar gud-gdb-marker-acc "") | 165 (defvar gud-gdb-marker-acc "") |
166 | 166 |
167 (defun gud-gdb-marker-filter (string) | 167 (defun gud-gdb-marker-filter (string) |
168 (setq gud-gdb-marker-acc (concat gud-gdb-marker-acc string)) | 168 (save-match-data |
169 (let ((output "")) | 169 (setq gud-gdb-marker-acc (concat gud-gdb-marker-acc string)) |
170 | 170 (let ((output "")) |
171 ;; Process all the complete markers in this chunk. | 171 |
172 (while (string-match "^\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n" | 172 ;; Process all the complete markers in this chunk. |
173 gud-gdb-marker-acc) | 173 (while (string-match "^\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n" |
174 (setq | 174 gud-gdb-marker-acc) |
175 | 175 (setq |
176 ;; Extract the frame position from the marker. | 176 |
177 gud-last-frame | 177 ;; Extract the frame position from the marker. |
178 (cons (substring gud-gdb-marker-acc (match-beginning 1) (match-end 1)) | 178 gud-last-frame |
179 (string-to-int (substring gud-gdb-marker-acc | 179 (cons (substring gud-gdb-marker-acc (match-beginning 1) (match-end 1)) |
180 (match-beginning 2) | 180 (string-to-int (substring gud-gdb-marker-acc |
181 (match-end 2)))) | 181 (match-beginning 2) |
182 | 182 (match-end 2)))) |
183 ;; Append any text before the marker to the output we're going | 183 |
184 ;; to return - we don't include the marker in this text. | 184 ;; Append any text before the marker to the output we're going |
185 output (concat output | 185 ;; to return - we don't include the marker in this text. |
186 (substring gud-gdb-marker-acc 0 (match-beginning 0))) | 186 output (concat output |
187 | 187 (substring gud-gdb-marker-acc 0 (match-beginning 0))) |
188 ;; Set the accumulator to the remaining text. | 188 |
189 gud-gdb-marker-acc (substring gud-gdb-marker-acc (match-end 0)))) | 189 ;; Set the accumulator to the remaining text. |
190 | 190 gud-gdb-marker-acc (substring gud-gdb-marker-acc (match-end 0)))) |
191 ;; Does the remaining text look like it might end with the | 191 |
192 ;; beginning of another marker? If it does, then keep it in | 192 ;; Does the remaining text look like it might end with the |
193 ;; gud-gdb-marker-acc until we receive the rest of it. Since we | 193 ;; beginning of another marker? If it does, then keep it in |
194 ;; know the full marker regexp above failed, it's pretty simple to | 194 ;; gud-gdb-marker-acc until we receive the rest of it. Since we |
195 ;; test for marker starts. | 195 ;; know the full marker regexp above failed, it's pretty simple to |
196 (if (string-match "^\032.*\\'" gud-gdb-marker-acc) | 196 ;; test for marker starts. |
197 (progn | 197 (if (string-match "^\032.*\\'" gud-gdb-marker-acc) |
198 ;; Everything before the potential marker start can be output. | 198 (progn |
199 (setq output (concat output (substring gud-gdb-marker-acc | 199 ;; Everything before the potential marker start can be output. |
200 0 (match-beginning 0)))) | 200 (setq output (concat output (substring gud-gdb-marker-acc |
201 | 201 0 (match-beginning 0)))) |
202 ;; Everything after, we save, to combine with later input. | 202 |
203 (setq gud-gdb-marker-acc | 203 ;; Everything after, we save, to combine with later input. |
204 (substring gud-gdb-marker-acc (match-beginning 0)))) | 204 (setq gud-gdb-marker-acc |
205 | 205 (substring gud-gdb-marker-acc (match-beginning 0)))) |
206 (setq output gud-gdb-marker-acc | 206 |
207 gud-gdb-marker-acc "")) | 207 (setq output (concat output gud-gdb-marker-acc) |
208 | 208 gud-gdb-marker-acc "")) |
209 output)) | 209 |
210 output))) | |
210 | 211 |
211 (defun gud-gdb-find-file (f) | 212 (defun gud-gdb-find-file (f) |
212 (find-file-noselect f)) | 213 (find-file-noselect f)) |
213 | 214 |
214 ;;;###autoload | 215 ;;;###autoload |