Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: None
    • Labels:
      None
    • Environment:
      --1.9
    • Number of attachments :
      0

      Description

      The magic comment:

      # coding: ASCII-8BIT
      

      should only be effective when the "#" is in column 1 (MRI 1.9.2). Jruby recognizes it at any arbitrary location in the line (see rubyspec/language/magic_comment_spec).

        Activity

        Hide
        Hiro Asari added a comment -

        MRI 1.9.3 respects a magic comment that doesn't start in column 1.

        https://gist.github.com/1542577

        I'm resolving this as "Not a bug".

        Show
        Hiro Asari added a comment - MRI 1.9.3 respects a magic comment that doesn't start in column 1. https://gist.github.com/1542577 I'm resolving this as "Not a bug".
        Hide
        Hiro Asari added a comment -

        So, this is not exactly "not a bug".

        It appears that MRI respects and processes the magic comment if the comment is the first token on the line. If it is not the first token on the line, then it ignores it.

        [system] ~ $ cat test.rb 
          # encoding: CP861
        p __ENCODING__
        [system] ~ $ ruby2.0 -v test.rb 
        ruby 2.0.0dev (2012-01-14 trunk 34300) [x86_64-darwin11.2.0]
        #<Encoding:IBM861>
        [system] ~ $ cat test2.rb 
        1+1 # encoding: CP861
        p __ENCODING__
        [system] ~ $ ruby2.0 test2.rb 
        #<Encoding:US-ASCII>
        
        Show
        Hiro Asari added a comment - So, this is not exactly "not a bug". It appears that MRI respects and processes the magic comment if the comment is the first token on the line. If it is not the first token on the line, then it ignores it. [system] ~ $ cat test.rb # encoding: CP861 p __ENCODING__ [system] ~ $ ruby2.0 -v test.rb ruby 2.0.0dev (2012-01-14 trunk 34300) [x86_64-darwin11.2.0] #<Encoding:IBM861> [system] ~ $ cat test2.rb 1+1 # encoding: CP861 p __ENCODING__ [system] ~ $ ruby2.0 test2.rb #<Encoding:US-ASCII>
        Hide
        Hiro Asari added a comment -

        Fixed on the master 7de254f.

        Show
        Hiro Asari added a comment - Fixed on the master 7de254f.

          People

          • Assignee:
            Hiro Asari
            Reporter:
            Martin Harriman
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: