- Timestamp:
- May 22, 2019, 10:03:37 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/core/bnf.tab.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 95 95 } 96 96 97 # æå®å '[]' å 98 ã§ã®ã¿ä½¿ç¨ã§ãããã¼ã¯ã¼ã 97 # 指定子 '[]' 内でのみ使用できるキーワード 99 98 RESERVED2 = { 100 99 # specifier … … 113 112 # port (entry) 114 113 'inline' => :INLINE, 115 'ref_desc' => :REF_DESC, # call ãå¯114 'ref_desc' => :REF_DESC, # call も可 116 115 117 116 # port (call) … … 157 156 } 158 157 159 # å帰çãªãã¼ãµã®ããã®ã¹ã¿ãã¯158 # 再帰的なパーサのためのスタック 160 159 @@generator_nest = -1 161 160 @@generator_stack = [] 162 161 @@current_locale = [] 163 162 164 # import_C ä¸ã§ãã163 # import_C 中である 165 164 @@import_C = false 166 165 167 # ãã¹ã¦ã®æ§æ解æãå®äºãã166 # すべての構文解析が完了した 168 167 @@b_end_all_parse = false 169 168 170 # tag ãªãstruct169 # tag なし struct 171 170 @@no_struct_tag_num = 0 172 171 173 172 def self.parse( file_name, plugin = nil, b_reuse = false ) 174 # ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ(å¥ãã¼ãµã§èªã¿è¾¼ã)173 # パーサインスタンスを生成(別パーサで読み込む) 175 174 parser = Generator.new 176 175 177 # plugin ãã import ããã¦ããå ´åã® plugin è¨å®176 # plugin から import されている場合の plugin 設定 178 177 parser.set_plugin plugin 179 178 180 # reuse ãã©ã°ãè¨å®179 # reuse フラグを設定 181 180 parser.set_reuse b_reuse 182 181 183 # cdl ããã¼ã¹182 # cdl をパース 184 183 parser.parse( [file_name] ) 185 184 186 # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã185 # 終期化 パーサスタックを戻す 187 186 parser.finalize 188 187 end … … 204 203 def self.get_plugin 205 204 if @@generator_stack[@@generator_nest] then 206 # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯nil205 # tecsgen 引数の cdl が import される場合は nil 207 206 return @@generator_stack[@@generator_nest].get_plugin 208 207 else … … 221 220 def self.is_reuse? 222 221 if @@generator_stack[@@generator_nest] then 223 # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯nil222 # tecsgen 引数の cdl が import される場合は nil 224 223 return @@generator_stack[@@generator_nest].is_reuse? 225 224 else … … 251 250 b_in_string = false 252 251 253 # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµããã誤ãåé¡ã®å¯¾ç252 # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策 254 253 TECS_LANG::set_kcode_binary 255 254 … … 261 260 TECSIO.foreach(file) {|line| 262 261 col = 1 263 # line.rstrip! æ¹è¡å«ãæååãæ±ãããã«ãªã£ãã®ã§ãããã§ç©ºç½ãåãé¤ããªããªã£ã262 # line.rstrip! 改行含む文字列を扱うようになったので、ここで空白を取り除けなくなった 264 263 265 264 until line.empty? … … 267 266 if b_in_comment 268 267 case line 269 # ã³ã¡ã³ãçµäº268 # コメント終了 270 269 when /\A\*\// 271 270 b_in_comment = false 272 271 when /\A./ 273 272 ; 274 when /\s+/ # line.rstrip! ãæ¢ãããã \n ãªã©ã®ç©ºç½æåã¨ã¾ã£ã¡ããã«ã¼ã«ãå¿ 275 è¦ã«ãªã£ã 273 when /\s+/ # line.rstrip! を止めたため \n などの空白文字とまっちするルールが必要になった 276 274 ; 277 275 end … … 281 279 @q << [:STRING_LITERAL, Token.new(string, file, lineno, col)] 282 280 b_in_string = false 283 elsif line =~ /\A.*\\\n/ # æ¹è¡ \n 㯠'.' ã«ãããããªã281 elsif line =~ /\A.*\\\n/ # 改行 \n は '.' にマッチしない 284 282 string += $& 285 elsif line =~ /\A.*\n/ # æ¹è¡ \n 㯠'.' ã«ãããããªã283 elsif line =~ /\A.*\n/ # 改行 \n は '.' にマッチしない 286 284 string += line 287 # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èªåºãå)285 # この位置では error メソッドは使えない (token 読出し前) 288 286 puts "#{file}:#{lineno}:#{col}: error: string literal has newline without escape" 289 287 @@n_error += 1 … … 291 289 else 292 290 case line 293 # 空ç½ãããªããã»ã¹ãã£ã¬ã¯ãã£ã291 # 空白、プリプロセスディレクティブ 294 292 when /\A\s+/ 295 293 ; 296 # èå¥å294 # 識別子 297 295 when /\A[a-zA-Z_]\w*/ 298 296 word = $& 299 297 @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)] 300 # 16 é²æ°å®æ°298 # 16 進数定数 301 299 when /\A0x[0-9A-Fa-f]+/ 302 300 @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)] 303 # 8 é²æ°å®æ°301 # 8 進数定数 304 302 when /\A0[0-7]+/ 305 303 @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)] 306 # æµ®åå°æ°å®æ°304 # 浮動小数定数 307 305 when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/ 308 306 @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)] 309 # æ´æ°å®æ°307 # 整数定数 310 308 when /\A\d+/ 311 309 @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)] 312 # æåå®æ°310 # 文字定数 313 311 when /\A'(?:[^'\\]|\\.)'/ 314 312 @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)] 315 # æåå316 # "#include #include #include \"../systask/logtask.cfg\" æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã313 # 文字列 314 # "#include #include #include \"../systask/logtask.cfg\" 最後の " 忘れ)で無限ループ 317 315 # when /\A"(?:[^"\\]+|\\.)*"/ 318 when /\A"(?:[^"\\]|\\.)*"/ # ããã¯ãã¾ãè¡ãããã316 when /\A"(?:[^"\\]|\\.)*"/ # これはうまく行くようだ 319 317 @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)] 320 # æåå (æ¹è¡ãã)318 # 文字列 (改行あり) 321 319 when /\A"(?:[^"\\]|\\.)*\\\n$/ 322 320 string = $& 323 321 b_in_string = true 324 # æåå (æ¹è¡ãã, escape ãªã)322 # 文字列 (改行あり, escape なし) 325 323 when /\A("(?:[^"\\]|\e\.)*)\n$/ 326 324 string = $1 + "\\\n" 327 325 b_in_string = true 328 # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èªåºãå) # mikan cdl_error ã§ã¯ãªã326 # この位置では error メソッドは使えない (token 読出し前) # mikan cdl_error ではない 329 327 puts "#{file}:#{lineno}:#{col}: error: string literal has newline without escape" 330 328 @@n_error += 1 331 # å±±æ¬å¼§ã§å²ã¾ããæåå329 # 山括弧で囲まれた文字列 332 330 # when /\A<[0-9A-Za-z_\. \/]+>/ # AB: angle bracke 333 when /\A<(?:[^>\\]|\\.)*>/ # ããã¯ãã¾ãè¡ãããã331 when /\A<(?:[^>\\]|\\.)*>/ # これはうまく行くようだ 334 332 @q << [:AB_STRING_LITERAL, Token.new($&, file, lineno, col)] 335 # è¡ã³ã¡ã³ã333 # 行コメント 336 334 when /\A\/\/.*$/ 337 # èªã¿é£ã°ãã ã338 # ã³ã¡ã³ãéå§335 # 読み飛ばすだけ 336 # コメント開始 339 337 when /\A\/\*/ 340 338 b_in_comment = true 341 # '>>', '<<' ãªã©339 # '>>', '<<' など 342 340 when /\A>>/, /\A<</, /\A==/, /\A!=/, /\A\&\&/, /\A\|\|/ 343 341 @q << [$&, Token.new($&, file, lineno, col)] 344 342 when /\A::/, /\A=>/, /\A<=/, /\A>=/ 345 343 @q << [$&, Token.new($&, file, lineno, col)] 346 # '(', ')' ãªã©ä¸æåã®è¨å·ãã¾ãã¯æªç¥ã®è¨å·344 # '(', ')' など一文字の記号、または未知の記号 347 345 when /\A./ 348 346 @q << [$&, Token.new($&, file, lineno, col)] … … 368 366 } 369 367 370 # çµäºã®å°368 # 終了の印 371 369 @q << nil 372 370 … … 388 386 389 387 if token[0] == :IDENTIFIER then 390 # TYPE_NAME ãã¼ã¯ã³ã¸ç½®æã388 # TYPE_NAME トークンへ置換え 391 389 if Namespace.is_typename?( token[1].val ) then 392 390 token[0] = :TYPE_NAME 393 391 elsif @in_specifier && RESERVED2[ token[1].val.to_s ] then 394 # æå®åãã¼ã¯ã¼ãï¼ '[', ']' å 395 ã§ã®ã¿æå¹) 392 # 指定子キーワード( '[', ']' 内でのみ有効) 396 393 token[0] = RESERVED2[ token[1].val.to_s ] 397 394 end 398 395 end 399 396 400 if $debug then # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç)397 if $debug then # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生) 401 398 locale = @@current_locale[@@generator_nest] 402 399 if token then … … 430 427 @@n_info = 0 431 428 432 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼429 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切) 433 430 def self.error( msg, *arg ) 434 431 locale = nil … … 440 437 441 438 msg = TECSMsg.get_error_message( msg ) 442 # $1, $2, ... ã arg ã§ç½®æ439 # $1, $2, ... を arg で置換 443 440 count = 1 444 441 arg.each{ |a| … … 448 445 } 449 446 450 # import_C ã®ä¸ã§ã®ã¨ã©ã¼ï¼447 # import_C の中でのエラー? 451 448 if @@import_C then 452 449 C_parser.error( msg ) 453 450 else 454 451 455 # Node ã®è¨æ¶ãã ä½ç½® (locale) ã使ç¨ããå ´åãå¤æ´ä»¥åã«æ¯ã¹ã456 # åé¡çºçç®æã¨ç°ãªãä½ç½®ã«ã¨ã©ã¼ãåºããããæ§æ解æä¸ã®ã¨ã©ã¼457 # ã¯ã解æä¸ã®ä½ç½®ãåºåããï¼(new_XXX 㧠owner ãåè¦ç´ ã®ãã§ã458 # ã¯ããã㨠owner ã®è¡çªå·ãåºã¦ãã¾ãç¹ã§ããããçãã¦ãã)452 # Node の記憶する 位置 (locale) を使用した場合、変更以前に比べ、 453 # 問題発生箇所と異なる位置にエラーが出るため、構文解析中のエラー 454 # は、解析中の位置を出力する.(new_XXX で owner が子要素のチェッ 455 # クをすると owner の行番号が出てしまう点で、ずれが生じている) 459 456 460 457 if @@b_end_all_parse == false || locale == nil then … … 469 466 end 470 467 471 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼468 # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切) 472 469 def self.warning( msg, *arg ) 473 470 locale = nil … … 479 476 480 477 msg = TECSMsg.get_warning_message( msg ) 481 # $1, $2, ... ã arg ã§ç½®æ478 # $1, $2, ... を arg で置換 482 479 count = 1 483 480 arg.each{ |a| … … 487 484 } 488 485 489 # import_C ã®ä¸ã§ã®ã¦ã©ã¼ãã³ã°ï¼486 # import_C の中でのウォーニング? 490 487 if @@import_C then 491 488 C_parser.warning( msg ) … … 502 499 end 503 500 504 # ãã®ã¡ã½ããã¯æ§æ解æãæå³è§£æããã®ã¿å¼åºãå¯501 # このメソッドは構文解析、意味解析からのみ呼出し可 505 502 def self.info( msg, *arg ) 506 503 locale = nil … … 512 509 513 510 msg = TECSMsg.get_info_message( msg ) 514 # $1, $2, ... ã arg ã§ç½®æ511 # $1, $2, ... を arg で置換 515 512 count = 1 516 513 arg.each{ |a| … … 520 517 } 521 518 522 # import_C ã®ä¸ã§ã®ã¦ã©ã¼ãã³ã°ï¼519 # import_C の中でのウォーニング? 523 520 if @@import_C then 524 521 C_parser.info( msg ) … … 555 552 end 556 553 557 #=== '[' specifier å§ã554 #=== '[' specifier 始め 558 555 def set_in_specifier 559 556 # p "set_in_specifier" … … 561 558 end 562 559 563 #=== ']' specifier çµãã560 #=== ']' specifier 終わり 564 561 def unset_in_specifier 565 562 # p "unset_in_specifier" … … 567 564 end 568 565 569 # statement_specifier ã¯æ§æ解ééä¸ã§åç 570 §ããããã 566 # statement_specifier は構文解釈途中で参照したいため 571 567 @@statement_specifier_stack = [] 572 568 def self.add_statement_specifier( ss ) … … 585 581 end 586 582 587 #=== ãã¹ã¦ã®æ§æ解æãå®äºãããã¨ãå ±å583 #=== すべての構文解析が完了したことを報告 588 584 def self.end_all_parse 589 585 @@b_end_all_parse = true … … 2369 2365 module_eval(<<'.,.,', 'bnf.y.rb', 76) 2370 2366 def _reduce_13(val, _values, result) 2371 # é£æ¥ããæååã1ã¤ã®æååã«ã¾ã¨ãã2367 # 連接した文字列を1つの文字列にまとめる 2372 2368 str = "\"" + val[0].val.gsub( /\"(.*)\"/, "\\1" ) + val[1].val.gsub( /\"(.*)\"/, "\\1" ) + "\"" 2373 2369 result = Token.new( str, val[0].file, val[0].lineno, val[0].col ) … … 2947 2943 module_eval(<<'.,.,', 'bnf.y.rb', 379) 2948 2944 def _reduce_104(val, _values, result) 2949 # tag ãç¡ãå ´åãå 2950 é¨åãä¸ãã 2945 # tag が無い場合、内部名を与える 2951 2946 result = StructType.new( :"TAG__#{@@no_struct_tag_num}__" ) 2952 2947 @@no_struct_tag_num += 1 … … 3267 3262 def _reduce_153(val, _values, result) 3268 3263 val[0].add_param( val[2] ) 3269 # result = val[0] ä¸è¦3264 # result = val[0] 不要 3270 3265 3271 3266 result … … 3422 3417 result = val[1] 3423 3418 else 3424 # ã¨ã©ã¼ï¼ä»®ã§ val[0] ãè¿ã3419 # エラー:仮で val[0] を返す 3425 3420 result = val[0] 3426 3421 end … … 3568 3563 obj = val[3] 3569 3564 if obj.kind_of?( Cell ) || obj.kind_of?( Signature ) || obj.kind_of?( Celltype ) || obj.kind_of?( CompositeCelltype )then 3570 # cell, signature 以å¤ã¯ãæå®åãç½®ããªã3565 # cell, signature 以外は、指定子を置けない 3571 3566 else 3572 Generator.get_statement_specifier # ã¯ãªã¢3567 Generator.get_statement_specifier # クリア 3573 3568 Generator.error( "G1009 unexpected specifier" ) 3574 3569 end … … 3941 3936 val[1].check 3942 3937 else 3943 # mikan é¢æ°ã®é 3944 åã以ä¸ã®ã¡ãã»ã¼ã¸ã«ãªã 3938 # mikan 関数の配列も以下のメッセージになる 3945 3939 Generator.error( "G1010 Not function" ) 3946 3940 result = nil … … 3997 3991 def _reduce_265(val, _values, result) 3998 3992 if val[3].kind_of? Port then 3999 val[3].set_specifier val[1] # è¨å®é åºãã3993 val[3].set_specifier val[1] # 設定順序あり 4000 3994 Celltype.new_port( val[3] ) 4001 3995 else 4002 # Port 以å¤ã§ã¯æå®åã¯ã¨ã©ã¼3996 # Port 以外では指定子はエラー 4003 3997 Generator.error( "G1012 $1 : cannot put specifier here" , val[1] ) 4004 3998 end … … 4205 4199 def _reduce_298(val, _values, result) 4206 4200 val[3].each{ |i| # i:Decl 4207 i.set_kind( :ATTRIBUTE ) # è¨å®é åºãã4201 i.set_kind( :ATTRIBUTE ) # 設定順序あり 4208 4202 i.set_specifier_list( [val[1]] ) 4209 4203 i.check … … 4287 4281 def _reduce_309(val, _values, result) 4288 4282 val[3].each{ |i| # i:Decl 4289 i.set_kind( :VAR ) # è¨å®é åºãã4283 i.set_kind( :VAR ) # 設定順序あり 4290 4284 i.set_specifier_list( [val[1]] ) 4291 4285 i.check … … 4568 4562 def _reduce_354(val, _values, result) 4569 4563 if val[0].kind_of?( Port ) then 4570 CompositeCelltype.new_port( val[0] ) # é 4571 延ãã¦ç»é² 4564 CompositeCelltype.new_port( val[0] ) # 遅延して登録 4572 4565 end 4573 4566 … … 4579 4572 def _reduce_355(val, _values, result) 4580 4573 if val[3].kind_of?( Port ) then 4581 # port ä»¥å¤ val[3] ã«æå¹ãªå¤ãå 4582 ¥ã£ã¦ããªãã®ã§ã以ä¸ã®ã¡ã½ãããé©ç¨ã§ããªã 4583 # ç¾ç¶ port, cell 以å¤ã¯æå®åãåãä»ããªã 4584 # ï¼ãããå°æ¥ä»ã®æãæå®åãåãä»ããå¯è½æ§ãããã®ã§ããã®ä½ç½®ã«è¨è¿°ããï¼ 4574 # port 以外 val[3] に有効な値が入っていないので、以下のメソッドを適用できない 4575 # 現状 port, cell 以外は指定子を受け付けない 4576 # (しかし将来他の文も指定子を受け付ける可能性があるので、この位置に記述する) 4585 4577 val[3].set_specifier( Generator.get_statement_specifier ) 4586 CompositeCelltype.new_port( val[3] ) # é 4587 延ãã¦ç»é² (set_specifier å¾) 4578 CompositeCelltype.new_port( val[3] ) # 遅延して登録 (set_specifier 後) 4588 4579 elsif val[3].kind_of?( Cell ) then 4589 # Cell.end_of_parse ã«ã¦è¨å®4580 # Cell.end_of_parse にて設定 4590 4581 else 4591 Generator.get_statement_specifier # ã¯ãªã¢4582 Generator.get_statement_specifier # クリア 4592 4583 Generator.error( "G1013 unexpected specifier" ) 4593 4584 end … … 4877 4868 if obj.kind_of?( Cell ) then 4878 4869 else 4879 Generator.get_statement_specifier # ã¯ãªã¢4870 Generator.get_statement_specifier # クリア 4880 4871 Generator.error( "G9999 unexpected specifier" ) 4881 4872 end … … 5102 5093 5103 5094 5104 # ãã¡ã¤ã« => INCLUDE("header")ã®é 5105 å 5095 # ファイル => INCLUDE("header")の配列 5106 5096 Include = Hash.new {|hash, key| hash[key] = []} 5107 5097 … … 5157 5147 5158 5148 #= TECSIO 5159 # Ruby2.0(1.9) 対å¿ã«ä¼´ãå°å 5160 ¥ããã¯ã©ã¹ 5161 # SJIS 以å¤ã§ã¯ãASCII-8BIT ã¨ãã¦å 5162 ¥åãã 5149 # Ruby2.0(1.9) 対応に伴い導入したクラス 5150 # SJIS 以外では、ASCII-8BIT として入力する 5163 5151 class TECSIO 5164 def self.foreach(file) # ãããã¯å¼æ° { |line| } 5165 pr = Proc.new # ãã®ã¡ã½ããã®ãããã¯å¼æ°ã pr ã«ä»£å 5166 ¥ 5152 def self.foreach(file) # ブロック引数 { |line| } 5153 pr = Proc.new # このメソッドのブロック引数を pr に代入 5167 5154 if $b_no_kcode then 5168 5155 msg = "E".encode $Ruby19_File_Encode 5169 5156 if( $Ruby19_File_Encode == "Shift_JIS" ) 5170 5157 5171 # Shift JIS ã¯ããã£ãã Windows-31J ã¨ãã¦èªã¿è¾¼ã¾ããShift_JIS ã«å¤æãããï¼5172 # ã³ã¡ã³ãçã«å«ã¾ãã SJIS ã«ä¸é©åãªæåã³ã¼ã㯠'?' ã¾ã㯠REPLACEMENT CHARACTER ã«å¤æãããï¼5173 # EUC ã UTF-8 ã§è¨è¿°ããã CDL ãæ··å¨ãã¦ãã¦ããRuby ä¾å¤ãçºçãããã¨ãªãå¦çãé²ãããã¨ãã§ããï¼5174 # æåã³ã¼ãæå®ã SJIS ã§ãã£ã¦ãæååãªãã©ã«ã®ä¸ã«ãæåã³ã¼ããSJIS 以å¤ã®é ASCII ãå«ã¾ãã¦ããå ´åã5175 # Ruby 1.8 ã® tecsgen ã§ã¯æåã³ã¼ãæå®ã«å½±é¿ãªãå¦çããããã®ããRuby 1.9 以éã§ã¯ '?' ã«ç½®ãæããå¯è½æ§ãããï¼5158 # Shift JIS は、いったん Windows-31J として読み込ませ、Shift_JIS に変換させる. 5159 # コメント等に含まれる SJIS に不適切な文字コードは '?' または REPLACEMENT CHARACTER に変換される. 5160 # EUC や UTF-8 で記述された CDL が混在していても、Ruby 例外が発生することなく処理を進めることができる. 5161 # 文字コード指定が SJIS であって、文字列リテラルの中に、文字コードがSJIS 以外の非 ASCII が含まれている場合、 5162 # Ruby 1.8 の tecsgen では文字コード指定に影響なく処理されたものが、Ruby 1.9 以降では '?' に置き換わる可能性がある. 5176 5163 5177 5164 mode = "r:Windows-31J" … … 5197 5184 end 5198 5185 5199 #=== æåã³ã¼ããç¸éããå ´åä¸è´ããã5200 # msg 㨠str ã®æåã³ã¼ããç¸éããå ´åãstr ã msg ã®æåã³ã¼ãã«å¤æãã5201 # å¤æä¸å¯ã®æåã³ã¼ã㯠'?' (utf-8 ã®å ´å U+FFFD (REPLACEMENT CHARACTER )) ã«å¤æ5186 #=== 文字コードが相違する場合一致させる 5187 # msg と str の文字コードが相違する場合、str を msg の文字コードに変換する 5188 # 変換不可の文字コードは '?' (utf-8 の場合 U+FFFD (REPLACEMENT CHARACTER )) に変換 5202 5189 # 5203 # ãã®ã¡ã½ããã¯ãã¨ã©ã¼ã¡ãã»ã¼ã¸åºåã§ã使ç¨ããã¦ãããã¨ã«æ³¨æï¼5190 # このメソッドは、エラーメッセージ出力でも使用されていることに注意. 5204 5191 # 5205 5192 #msg_enc::Encode | String 5206 5193 def self.str_code_convert( msg, str ) 5207 5194 if $b_no_kcode == false then 5208 return str # Ruby V1.8 ã¾ã§5195 return str # Ruby V1.8 まで 5209 5196 end 5210 5197 if msg.encoding != str.encoding then 5211 option = { :invalid => :replace, :undef => :replace } # ä¾å¤ãçºçãããã'?' ã«å¤æãã(utf-8 ã¯0xfffd)5198 option = { :invalid => :replace, :undef => :replace } # 例外を発生させず、'?' に変換する(utf-8 は 0xfffd) 5212 5199 # return str.encode( msg.encoding, option ) 5213 5200 str = str.encode( "utf-8", option ) -
Property svn:mime-type
changed from
Note:
See TracChangeset
for help on using the changeset viewer.