Skip to content

Instantly share code, notes, and snippets.

@lewang
Created September 14, 2012 02:46
Show Gist options
  • Save lewang/3719508 to your computer and use it in GitHub Desktop.
Save lewang/3719508 to your computer and use it in GitHub Desktop.
gettext continue after error (patch for 2.2.0, whitespace changes ignored
diff -b -B -u /Users/lewang/tmp/ruby.old.rb /Users/lewang/.rvm/gems/ree-1.8.7-2012.02\@agworld-3.2/gems/gettext-2.2.0/lib/gettext/tools/parser/ruby.rb
--- /Users/lewang/tmp/ruby.old.rb 2012-09-14 10:43:38.000000000 +0800
+++ /Users/lewang/.rvm/gems/[email protected]/gems/gettext-2.2.0/lib/gettext/tools/parser/ruby.rb 2012-09-13 15:49:30.000000000 +0800
@@ -18,7 +18,9 @@
module GetText
class RubyLexX < RubyLex # :nodoc: all
# Parser#parse resemlbes RubyLex#lex
- def parse
+ def parse(path = nil, lines = [])
+ tk = nil
+ begin
until ( (tk = token).kind_of?(RubyToken::TkEND_OF_SCRIPT) && !@continue or tk.nil? )
s = get_readed
if RubyToken::TkSTRING === tk
@@ -55,6 +57,10 @@
yield tk
end
+ rescue StandardError => err
+ $stderr.print "\n\ngot \"#{err.message}\" processing #{path}\n"
+ $stderr.print "line:#{tk.line_no}\n\t #{lines[tk.line_no - 1]}" if tk
+ end
return nil
end
@@ -136,7 +142,7 @@
line_no = nil
last_comment = ''
reset_comment = false
- rl.parse do |tk|
+ rl.parse(path, lines) do |tk|
begin
case tk
when RubyToken::TkIDENTIFIER, RubyToken::TkCONSTANT
Diff finished. Fri Sep 14 10:44:50 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment