@@ -24,7 +24,7 @@ class GetText::POParser
2424 msgctxt
2525 : MSGCTXT string_list
2626 {
27- @msgctxt = unescape ( val [ 1 ] )
27+ @msgctxt = val [ 1 ]
2828 }
2929 ;
3030
@@ -36,9 +36,8 @@ class GetText::POParser
3636 single_message
3737 : MSGID string_list MSGSTR string_list
3838 {
39- msgid_raw = val [ 1 ]
40- msgid = unescape ( msgid_raw )
41- msgstr = unescape ( val [ 3 ] )
39+ msgid = val [ 1 ]
40+ msgstr = val [ 3 ]
4241 use_message_p = true
4342 if @fuzzy and not msgid . empty?
4443 use_message_p = ( not ignore_fuzzy? )
@@ -48,7 +47,7 @@ class GetText::POParser
4847 else
4948 $stderr. print _ ( "Warning: fuzzy message was used.\n " )
5049 end
51- $stderr. print " #{ @po_file } : msgid '#{ msgid_raw } '\n "
50+ $stderr. print " #{ @po_file } : msgid '#{ msgid } '\n "
5251 end
5352 end
5453 @fuzzy = false
@@ -144,20 +143,23 @@ require "gettext/po"
144143 @report_warning
145144 end
146145
147- def unescape ( orig )
148- ret = orig . gsub ( /\\ n/ , "\n " )
149- ret . gsub! ( /\\ t/ , "\t " )
150- ret . gsub! ( /\\ r/ , "\r " )
151- ret . gsub! ( /\\ "/ , "\" " )
152- ret
146+ def unescape ( string )
147+ string . gsub ( /\\ (.)/ ) do
148+ escaped_character = $1
149+ case escaped_character
150+ when "t"
151+ "\t "
152+ when "r"
153+ "\r "
154+ when "n"
155+ "\n "
156+ else
157+ escaped_character
158+ end
159+ end
153160 end
154161 private :unescape
155162
156- def unescape_string ( string )
157- string . gsub ( /\\ \\ / , "\\ " )
158- end
159- private :unescape_string
160-
161163 def parse ( str , data )
162164 @translator_comments = [ ]
163165 @extracted_comments = [ ]
@@ -202,7 +204,7 @@ require "gettext/po"
202204 @q . push [ :COMMENT , $&]
203205 str = $'
204206 when /\A \" (.*)\" /
205- @q . push [ :STRING , unescape_string ( $1) ]
207+ @q . push [ :STRING , unescape ( $1) ]
206208 str = $'
207209 else
208210 #c = str[0,1]
0 commit comments