From: Matt Armstrong Date: 2001-12-01T15:26:22+09:00 Subject: [ruby-talk:27159] Bug fix for ruby-mode.el --=-=-= The current CVS version of ruby-mode.el breaks fontification for strings like this one: "foo\\" Emacs does not recognize the second " as the end of the string. I am seeing this with Emacs 21. The problem is that a recent change used a regexp of "[\\?\\$]" instead of "[?$]" -- the ? and $ have no special meaning within a character class, and it seems that the current regexp matches the characters '\\', '?' and '$' when it really only wants to match '?' and '$'. Attached is a patch that fixes the problem, as well as a script that can be used to test for the bug. -- matt --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=ruby-mode.el.patch Content-Description: Bug fix for ruby-mode.el Index: ruby-mode.el =================================================================== RCS file: /src/ruby/misc/ruby-mode.el,v retrieving revision 1.36 diff -u -r1.36 ruby-mode.el --- ruby-mode.el 2001/10/30 08:43:28 1.36 +++ ruby-mode.el 2001/12/01 06:20:49 @@ -673,22 +673,22 @@ ("\\(#\\)[{$@]" 1 (1 . nil)) ;; the last $' in the string ,'...$' is not variable ;; the last ?' in the string ,'...?' is not ascii code - ("\\(^\\|[[\\s <+(,=]\\)\\('\\)[^'\n\\\\]*\\(\\\\.[^'\n\\\\]*\\)*[\\?\\$]\\('\\)" + ("\\(^\\|[[\\s <+(,=]\\)\\('\\)[^'\n\\\\]*\\(\\\\.[^'\n\\\\]*\\)*[?$]\\('\\)" (2 (7 . nil)) (4 (7 . nil))) ;; the last $` in the string ,`...$` is not variable ;; the last ?` in the string ,`...?` is not ascii code - ("\\(^\\|[[\\s <+(,=]\\)\\(`\\)[^`\n\\\\]*\\(\\\\.[^`\n\\\\]*\\)*[\\?\\$]\\(`\\)" + ("\\(^\\|[[\\s <+(,=]\\)\\(`\\)[^`\n\\\\]*\\(\\\\.[^`\n\\\\]*\\)*[?$]\\(`\\)" (2 (7 . nil)) (4 (7 . nil))) ;; the last $" in the string ,"...$" is not variable ;; the last ?" in the string ,"...?" is not ascii code - ("\\(^\\|[[\\s <+(,=]\\)\\(\"\\)[^\"\n\\\\]*\\(\\\\.[^\"\n\\\\]*\\)*[\\?\\$]\\(\"\\)" + ("\\(^\\|[[\\s <+(,=]\\)\\(\"\\)[^\"\n\\\\]*\\(\\\\.[^\"\n\\\\]*\\)*[?$]\\(\"\\)" (2 (7 . nil)) (4 (7 . nil))) ;; $' $" $` .... are variables ;; ?' ?" ?` are ascii codes - ("[\\?\\$][#\"'`]" 0 (1 . nil)) + ("[?$][#\"'`]" 0 (1 . nil)) ;; regexps ("\\(^\\|[=(,~?:;]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)" (4 (7 . ?/)) --=-=-= Content-Disposition: attachment; filename=ruby-mode-string-bug.rb Content-Description: Test case for bug s = "test \" + string # string " s = "test $\\" + variable # comment --> " s = "test \\" + variable # comment --> " s = "test $#" + variable # comment -> " s = "test $\"" + variable # comment -> " s = "test $'" + variable # comment -> " s = "test $`" + variable # comment -> " s = "test ?#" + variable # comment -> " s = "test ?'" + variable # comment -> " s = "test ?\"" + variable # comment -> " s = "test ?`" + variable # comment -> " s = $# + yo s = $' + yo s = $" + yo s = $` + yo s = ?# + yo s = ?' + yo s = ?" + yo s = ?` + yo --=-=-=--