Bugs: Browse | Submit New | Admin

[#28272] Errors from just require

Date:
2010-06-03 17:35
Priority:
3
Submitted By:
Iain Barnett (yb665)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Errors from just require

Detailed description
Hi,

My system is OSX 10.6.3 with ruby-191-p376. I installed the v1.28 gem and got errors.


This is the only code uncommented in my script makeFrameworkLayout.rb
#!/usr/bin/env ruby -wKU

require 'Getopt/Declare'


On running the script I get this:

$ ./makeFrameworkLayout.rb                                                                                         
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:309: warning: mismatched
indentations at 'end' with 'def' at 280
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:346: warning: mismatched
indentations at 'end' with 'class' at 122
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:687: warning: shadowing
outer local variable - i
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:694: warning: shadowing
outer local variable - i
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:700: warning: shadowing
outer local variable - i
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:1106: warning: shadowing
outer local variable - spec
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:1734: warning: mismatched
indentations at 'end' with 'class' at 71
./makeFrameworkLayout.rb:12:in `require':
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:1411: invalid multibyte
escape: /\255/ (SyntaxError)
	from ./makeFrameworkLayout.rb:12:in `<main>'


I checked the file in Vim and with Textmate, and the formatting is all over the place, although Vim's is better maybe
due to the way it views tab chars? I went through the file and corrected most of the formatting where I could, but still
get the following warnings:

/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:616: warning: mismatched
indentations at 'end' with 'begin' at 561
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:685: warning: shadowing
outer local variable - i
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:692: warning: shadowing
outer local variable - i
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:698: warning: shadowing
outer local variable - i
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:1053: warning: mismatched
indentations at 'end' with 'if' at 1047
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:1108: warning: shadowing
outer local variable - spec
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:1251: warning: mismatched
indentations at 'end' with 'if' at 1227
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:1625: warning: mismatched
indentations at 'end' with 'for' at 1615
(--def_casting_delegators--):1: warning: method redefined; discarding old scan
(--def_casting_delegators--):1: warning: method redefined; discarding old skip
(--def_casting_delegators--):1: warning: method redefined; discarding old match?
(--def_casting_delegators--):1: warning: method redefined; discarding old check
(--def_casting_delegators--):1: warning: method redefined; discarding old scan_until
(--def_casting_delegators--):1: warning: method redefined; discarding old skip_until
(--def_casting_delegators--):1: warning: method redefined; discarding old exist?
(--def_casting_delegators--):1: warning: method redefined; discarding old check_until


I updated the code at lines 1016 and 1411 to use regex's with the lang set to ASCII and it got rid of the "
./makeFrameworkLayout.rb:12:in `require':
/usr/local/ruby-191-p376/lib/ruby/gems/1.9.1/gems/getopt-declare-1.28/lib/Getopt/Declare.rb:1411: invalid multibyte
escape: /\255/ (SyntaxError)
	from ./makeFrameworkLayout.rb:12:in `<main>' "
error

Here are the changes:

       # PRESERVE ESCAPED '['s
      re1 = Regexp.new( Regexp.quote('[/'), nil, 'n')
      grammar.gsub!( re1,"\255")
      # grammar.gsub!(/\\\[/,"\255")

      re1 = Regexp.new( '\255', nil, 'n' ) 
      usage.gsub!( re1 , "[/" ) # REINSTATE ESCAPED '['s
      # usage.gsub!(/\255/,"[/") # REINSTATE ESCAPED '['s

I've attached the updated file. I ran the tests in the test dir against it, and they passed, but obviously it passed
before too, so it might take a further look.

I'm fairly new to Ruby, so if it's something wrong with my setup then please let me know.

Thanks
Iain Barnett

Add A Comment: Notepad

Please login


Followup

Message
Date: 2010-11-19 18:38
Sender: Gonzalo Garramuno

I am sorry but I cannot reproduce the errors above using:
ruby 1.9.0 (2008-10-04 revision 19669) [x86_64-linux]

getopt-declare runs without errors.

Attached Files:

Name Description Download
Declare.rb patched Declare.rb Download

Changes:

Field Old Value Date By
File Added4951: Declare.rb2010-06-03 17:35yb665