------- Start of forwarded message ------- To: [EMAIL PROTECTED] Subject: Re: What was this? From: Stefan Monnier <[EMAIL PROTECTED]> Date: Fri, 21 Jul 2006 16:30:21 -0400 In-Reply-To: <[EMAIL PROTECTED]> (Richard Stallman's message of "Fri, 21 Jul 2006 15:36:50 -0400") MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=failed version=3.0.4
> What did you check in at this time? There is no other check-in recorded > in emacs-diffs, so I cannot tell. Was this in a branch? > Date: Thu, 20 Jul 2006 21:23:49 +0000 > From: Stefan Monnier <[EMAIL PROTECTED]> > Subject: [Emacs-diffs] (no subject) > To: emacs-diffs@gnu.org > Message-ID: <[EMAIL PROTECTED]> > CVSROOT: /sources/emacs > Module name: emacs > Changes by: Stefan Monnier <monnier> 06/07/20 21:23:49 I believe this is the attached patch which I committed on the trunk. No branch in sight. Looking at http://lists.gnu.org/archive/html/emacs-diffs/2006-07/index.html I see that the `ChangeLog' part of my commit is properly recorded in the emacs-diffs archive, but the lisp/progmodes/sh-script.el part isn't. Also I see that this problem is endemic. Stefan Index: lisp/progmodes/sh-script.el =================================================================== RCS file: /sources/emacs/emacs/lisp/progmodes/sh-script.el,v retrieving revision 1.184 retrieving revision 1.185 diff -u -r1.184 -r1.185 - --- lisp/progmodes/sh-script.el 19 Jul 2006 04:31:40 -0000 1.184 +++ lisp/progmodes/sh-script.el 20 Jul 2006 21:23:48 -0000 1.185 @@ -980,54 +980,55 @@ (re-search-forward sh-here-doc-re limit t)) (defun sh-quoted-subshell (limit) - - "Search for a subshell embedded in a string. Find all the unescaped - -\" characters within said subshell, remembering that subshells can nest." + "Search for a subshell embedded in a string. +Find all the unescaped \" characters within said subshell, remembering that +subshells can nest." ;; FIXME: This can (and often does) match multiple lines, yet it makes no ;; effort to handle multiline cases correctly, so it ends up being ;; rather flakey. - - (if (re-search-forward "\"\\(?:\\(?:.\\|\n\\)*?[^\\]\\(\\\\\\\\\\)*\\)??\\(\\$(\\|`\\)" limit t) - - ;; bingo we have a $( or a ` inside a "" - - (let ((char (char-after (point))) - - (continue t) - - (pos (point)) - - (data nil) ;; value to put into match-data (and return) - - (last nil) ;; last char seen - - (bq (equal (match-string 1) "`")) ;; ` state flip-flop - - (seen nil) ;; list of important positions - - (nest 1)) ;; subshell nesting level - - (while (and continue char (<= pos limit)) - - ;; unescaped " inside a $( ... ) construct. - - ;; state machine time... - - ;; \ => ignore next char; - - ;; ` => increase or decrease nesting level based on bq flag - - ;; ) [where nesting > 0] => decrease nesting - - ;; ( [where nesting > 0] => increase nesting - - ;; ( [preceeded by $ ] => increase nesting - - ;; " [nesting <= 0 ] => terminate, we're done. - - ;; " [nesting > 0 ] => remember this, it's not a proper " - - ;; FIXME: don't count parens that appear within quotes. - - (cond - - ((eq ?\\ last) nil) - - ((eq ?\` char) (setq nest (+ nest (if bq -1 1)) bq (not bq))) - - ((and (> nest 0) (eq ?\) char)) (setq nest (1- nest))) - - ((and (eq ?$ last) (eq ?\( char)) (setq nest (1+ nest))) - - ((and (> nest 0) (eq ?\( char)) (setq nest (1+ nest))) - - ((eq char ?\") - - (if (>= 0 nest) (setq continue nil) (push pos seen)))) - - ;;(message "POS: %d [%d]" pos nest) - - (setq last char - - pos (1+ pos) - - char (char-after pos)) ) - - ;; FIXME: why construct a costly match data to pass to - - ;; sh-apply-quoted-subshell rather than apply the highlight - - ;; directly here? -- Stef - - (when seen - - ;;(message "SEEN: %S" seen) - - (setq data (list (current-buffer))) - - (dolist(P seen) - - (setq data (cons P (cons (1+ P) data)))) - - (store-match-data data)) - - data) )) + (when (re-search-forward "\"\\(?:\\(?:.\\|\n\\)*?[^\\]\\(?:\\\\\\\\\\)*\\)??\\(\\$(\\|`\\)" limit t) + ;; bingo we have a $( or a ` inside a "" + (let ((char (char-after (point))) + (continue t) + (pos (point)) + (data nil) ;; value to put into match-data (and return) + (last nil) ;; last char seen + (bq (equal (match-string 1) "`")) ;; ` state flip-flop + (seen nil) ;; list of important positions + (nest 1)) ;; subshell nesting level + (while (and continue char (<= pos limit)) + ;; unescaped " inside a $( ... ) construct. + ;; state machine time... + ;; \ => ignore next char; + ;; ` => increase or decrease nesting level based on bq flag + ;; ) [where nesting > 0] => decrease nesting + ;; ( [where nesting > 0] => increase nesting + ;; ( [preceeded by $ ] => increase nesting + ;; " [nesting <= 0 ] => terminate, we're done. + ;; " [nesting > 0 ] => remember this, it's not a proper " + ;; FIXME: don't count parens that appear within quotes. + (cond + ((eq ?\\ last) nil) + ((eq ?\` char) (setq nest (+ nest (if bq -1 1)) bq (not bq))) + ((and (> nest 0) (eq ?\) char)) (setq nest (1- nest))) + ((and (eq ?$ last) (eq ?\( char)) (setq nest (1+ nest))) + ((and (> nest 0) (eq ?\( char)) (setq nest (1+ nest))) + ((eq char ?\") + (if (>= 0 nest) (setq continue nil) (push pos seen)))) + ;;(message "POS: %d [%d]" pos nest) + (setq last char + pos (1+ pos) + char (char-after pos)) ) + ;; FIXME: why construct a costly match data to pass to + ;; sh-apply-quoted-subshell rather than apply the highlight + ;; directly here? -- Stef + (when seen + ;;(message "SEEN: %S" seen) + (setq data (list (current-buffer))) + (dolist(P seen) + (setq data (cons P (cons (1+ P) data)))) + (store-match-data data)) + data) )) (defun sh-is-quoted-p (pos) (and (eq (char-before pos) ?\\) ------- End of forwarded message ------- _______________________________________________ Savannah-help-public mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/savannah-hackers