Control: tags -1 + patch

On Tue, Jan 28, 2014 at 07:39:56PM +0100, David Suárez wrote:
> El Martes, 28 de enero de 2014 14:35:37 Andreas Tille escribió:
> > Hi,
> > 
> > Dmitry E. Oboukhov has injected some Ruby 1.8 code into the wordnet
> > packaging.  I personally do not speak Ruby and thus can not fix the
> > problem in an other way than simply droping the goldendict-wordnet
> > binary package (its data package is created in this way).
> > 
> > Since Dmitry has not (yet) respondet to this bug report I would like
> > to ask the Ruby team to find a patch for the problem in the build
> > system that fixes the following:
> > 
> > 
> > WARNING: sentidx.vrb format error: ["pet%2:35:00::"]
> > debian/wn-for-goldendict.rb:300:in `initialize': undefined method `times'
> > for "\x01":String (NoMethodError) from debian/wn-for-goldendict.rb:158:in
> > `new'
> >         from debian/wn-for-goldendict.rb:158:in `get_data'
> >         from debian/wn-for-goldendict.rb:648:in `block (2 levels) in <main>'
> > from debian/wn-for-goldendict.rb:647:in `each'
> >         from debian/wn-for-goldendict.rb:647:in `block in <main>'
> >         from debian/wn-for-goldendict.rb:644:in `foreach'
> >         from debian/wn-for-goldendict.rb:644:in `<main>'
> > 
> > 
> > If I do not get any help I need to go the unfortunate route to kick
> > goldendict support again.
> 
> The code it's trying to convert an hexadecimal string to an integer.
> 
> line 296      -> @w_cnt = [data[3]].pack('H2')[0]
> changes to -> @w_cnt = data[3].hex

I don't think so ... he wants to replace pack(**)[0] with
pack(**).bytes.first

$ irb1.8
>> ['1'].pack('H2')[0]
=> 16
>> '1'.hex
=> 1
>> ['1'].pack('H2').bytes.first
=> 16

$ irb1.9.1
>> ['1'].pack('H2')[0]
=> "\x10" # <-- indexing the output of pack() in Ruby 1.9+ has a different 
semantics
>> '1'.hex
=> 1      # <-- not what you want
>> ['1'].pack('H2').bytes.first
=> 16     # <-- you want this

Try the attached patch. Please check the output files though.

-- 
Antonio Terceiro <terce...@debian.org>
diff -Nru wordnet-3.0/debian/control wordnet-3.0/debian/control
--- wordnet-3.0/debian/control	2013-05-23 03:48:45.000000000 -0300
+++ wordnet-3.0/debian/control	2014-01-28 16:31:30.000000000 -0300
@@ -22,7 +22,7 @@
                man-db,
                libxss-dev,
                libxft-dev,
-               ruby1.8,
+               ruby,
                imagemagick
 Standards-Version: 3.9.4
 Vcs-Browser: http://svn.debian.org/wsvn/debian-science/packages/wordnet/trunk/
diff -Nru wordnet-3.0/debian/rules wordnet-3.0/debian/rules
--- wordnet-3.0/debian/rules	2013-05-23 04:23:46.000000000 -0300
+++ wordnet-3.0/debian/rules	2014-01-28 16:36:00.000000000 -0300
@@ -48,7 +48,7 @@
 	set -e; \
 	if dpkg-architecture -qDEB_BUILD_ARCH|grep -q 'mips\|arm\|s390'; then \
 		if test "$$FORCE_GOLDENDICT_BUILD" -gt 0; then \
-			ruby1.8 debian/wn-for-goldendict.rb > $@; \
+			ruby debian/wn-for-goldendict.rb > $@ || ($(RM) $@; false); \
 		else \
 			echo "Building of goldendict-wordnet dictionary was skipped"; \
 			echo "to build this package use environment variable"; \
@@ -56,5 +56,5 @@
 			touch $@; \
 		fi; \
 	else \
-		ruby1.8 debian/wn-for-goldendict.rb > $@; \
+		ruby debian/wn-for-goldendict.rb > $@ || ($(RM) $@; false); \
 	fi
diff -Nru wordnet-3.0/debian/wn-for-goldendict.rb wordnet-3.0/debian/wn-for-goldendict.rb
--- wordnet-3.0/debian/wn-for-goldendict.rb	2012-06-05 13:12:14.000000000 -0300
+++ wordnet-3.0/debian/wn-for-goldendict.rb	2014-01-28 16:42:32.000000000 -0300
@@ -293,14 +293,14 @@
     @offset = data[0].to_i
     @lex_filenum = data[1]
     @pos = data[2]
-    @w_cnt = [data[3]].pack('H2')[0]
+    @w_cnt = [data[3]].pack('H2').bytes.first
     @words = []
     i = 4
     @lex_ids = []
     @w_cnt.times {
       @words << data[i].gsub(/_/, ' ').gsub(/\s*\((p|a|ip)\)\s*$/, '')
       i += 1
-      @lex_ids << [data[i]].pack('h')[0]
+      @lex_ids << [data[i]].pack('h').bytes.first
       i += 1
     }
 
@@ -362,8 +362,8 @@
     if (src_target == "0000")
       return other.words
     else
-      src = [src_target[0, 2]].pack('H2')[0]
-      target = [src_target[2, 2]].pack('H2')[0]
+      src = [src_target[0, 2]].pack('H2').bytes.first
+      target = [src_target[2, 2]].pack('H2').bytes.first
       h_src = words[src - 1]
       if (h_src == headword)
         return [other.words[target - 1]]
@@ -374,7 +374,7 @@
   end
   def get_frame_data(headword, frame)
     f_num = frame[0].to_i
-    w_num = [frame[1]].pack('H2')[0]
+    w_num = [frame[1]].pack('H2').bytes.first
     if (w_num == 0)
       return [$frames[f_num]]
     else

Attachment: signature.asc
Description: Digital signature

Reply via email to