[BUG: 1.9] encoding warning


#1

e$B!!$5$5$@$G$9!%e(B

e$B!!0J2<$N$h$&$K!$e(B-v e$B$de(B -w e$BIU$-$Ne(B ruby e$B$Ge(B erb
e$B$re(B require e$B$9$k$H!$e(B"coding:
…" e$B$N>l=j$,0c$&$h!$$H$$$&7Y9p$,=P$^$9!%e(B

$ cat test.rb
require ‘erb’

$ /tmp/trunk/bin/ruby -v test.rb
ruby 1.9.2dev (2009-02-05 trunk 22076) [x86_64-linux]
test.rb:1: warning: encoding ‘UTF-8’ is ignored, valid only in the first
line except for shebang line.
test.rb:1: warning: encoding ‘Big5’ is ignored, valid only in the first
line except for shebang line.

e$B!!$3$l$O!$e(B2e$B$D$NLdBj$,$"$k$+$H;W$$$^$9!%e(B

(1) erb e$B$N@bL@$N%3%a%s%H$KH?1~$7$F7Y9p$r$7$F$$$ke(B

e$B!!$A$g$C$H8+$F$_$k$H!$e(B68
e$B9TL$K%3%a%s%HCf$N%5%s%W%k%3!<%I$H$7$Fe(B

# -- coding: UTF-8 --

e$B$H$$$&9T$,!$e(B72 e$B9TL$Ke(B

<%#-- coding: Big5 --%>

e$B$H$$$&9T$,$"$j$^$9!%$3$l$KBP$7$F$N7Y9p$8$c$J$$$+$H;W$$$^$9!%$A$g$C$H$d$je(B
e$B$9$.!)e(B

(2) require e$B$7$F$$$k9T$N7Y9p$H$7$F=P$F$$$ke(B

test.rb:1: warning: encoding ‘UTF-8’ is ignored, valid only in the first
line except for shebang line.

e$B$H!$e(Brequire
e$B$7$F$$$k9T$,7Y9p9T$H$7$FI=<($5$l$F$$$^$9!%B?J,!$e(Berb.rb:68 e$B$He(B
e$B$+$HI=<($7$F$/$l$?$[$&$,$$$$$H;W$$$^$9!%e(B

e$B!!e(B(1) e$B$O$I$&$+$J!$$H;W$$$^$9!%e(B(2)
e$B$O!$D>$7$?$[$&$,$$$$$s$G$O$J$$$+$H;W$$e(B
e$B$^$9!%e(B

(1) e$B$Ne(B ad-hoc e$B$J2r7h:v$H$7$F!$e(B=begin/=end

e$B$G0O$C$F$7$^$&$C$F$N$,e(B

e$B$"$k$h$&$G$9!%e(B


#2

e$B1sF#$G$9!#e(B

2009/2/5 SASADA Koichi removed_email_address@domain.invalid:

test.rb:1: warning: encoding ‘UTF-8’ is ignored, valid only in the first

# -- coding: UTF-8 --

(1) e$B$Ne(B ad-hoc e$B$J2r7h:v$H$7$F!$e(B=begin/=end e$B$G0O$C$F$7$^$&$C$F$N$,e(B

e$B$"$k$h$&$G$9!%e(B


// SASADA Koichi at atdot dot net

e$B$3$N7o!"$I$&$J$k$b$N$G$7$g$&!#e(Bhoe e$B$G<B:]$KH/>I$7$F$$$^$9!#e(B

$ sow19
/home/mame/work/ruby19/local/lib/ruby/gems/1.9.1/gems/hoe-1.12.1/bin/sow:10:
warning: encoding ‘UTF-8’ is ignored, valid only in the first line
except for shebang line.
/home/mame/work/ruby19/local/lib/ruby/gems/1.9.1/gems/hoe-1.12.1/bin/sow:10:
warning: encoding ‘Big5’ is ignored, valid only in the first line
except for shebang line.
usage: sow19 [-d|-t] project
-t = add project to subdir under ‘trunk’
-d = add project to subdir under ‘dev’

e$B<B32$O$J$$$b$N$N!"$J$+$J$+$a$6$o$j$G$9!#e(B

e$B$H$j$"$($:%Q%C%A$G$9!#e(B

Index: lib/erb.rb

— lib/erb.rb (revision 23115)
+++ lib/erb.rb (working copy)
@@ -65,6 +65,7 @@

a magic comment, however, it returns a string in the encoding

specified

by the magic comment.

+=begin

# -- coding: UTF-8 --

require ‘erb’

@@ -73,6 +74,7 @@

__ENCODING__ is <%= __ENCODING__ %>.

EOF

puts template.result

+=end

Prints: __ENCODING__ is Big5.

Index: parse.y

— parse.y (revision 23115)
+++ parse.y (working copy)
@@ -6089,7 +6089,7 @@
magic_comment_encoding(struct parser_params *parser, const char
*name, const char *val)
{
if (!comment_at_top(parser)) {

  • rb_warning(“encoding ‘%s’ is ignored, valid only in the first line
    except for shebang line.”,
  • rb_warningS(“encoding ‘%s’ is ignored, valid only in the first line
    except for shebang line.”,
    val);
    return;
    }

#3

begin/end で直すのに一票。そういう手があったのには気がつかなかったです。

よろしくお願いします。 Martin.


#4

e$B%A%1%C%He(B #1110 e$B$,99?7$5$l$^$7$?!#e(B (by Yuki S.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
ruby -v e$BCN$i$s$K%;%C%He(B

applied in an ancient changeset.

http://redmine.ruby-lang.org/issues/show/1110