bonsaiviking

Abbreviated history of lib/rbreadline.rb in metasploit

Mar 17th, 2014
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 81.77 KB | None | 0 0
  1. commit 72dff034265c2ac1cea71ba84dcc3b49d5bcd552
  2. Author: HD Moore <[email protected]>
  3. Date:   Thu Sep 12 16:58:49 2013 -0500
  4.  
  5.     FixRM #8396 change all lib use of regex to 8-bit pattern
  6.  
  7. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  8. index a7006d2..26e7791 100644
  9. --- a/lib/rbreadline.rb
  10. +++ b/lib/rbreadline.rb
  11. @@ -5272,7 +5272,7 @@ module RbReadline
  12.     # Actually update the display, period.
  13.     def rl_forced_update_display()
  14.        if (@visible_line)
  15. -         @visible_line.gsub!(/[^\x00]/,0.chr)
  16. +         @visible_line.gsub!(/[^\x00]/n,0.chr)
  17.        end
  18.        rl_on_new_line()
  19.        @forced_display=true if !@forced_display
  20. @@ -8520,7 +8520,7 @@ module RbReadline
  21.           count -= 1
  22.        end
  23.  
  24. -      str = (flags == MB_FIND_NONZERO) ? string.sub(/\x00+$/,'') : string
  25. +      str = (flags == MB_FIND_NONZERO) ? string.sub(/\x00+$/n,'') : string
  26.  
  27.        case @encoding
  28.        when 'E'
  29.  
  30. commit 7e5e0f7fc814fee55a1eca148c51f2344da65e59
  31. Author: Tab Assassin <[email protected]>
  32. Date:   Fri Aug 30 16:28:33 2013 -0500
  33.  
  34.     Retab lib
  35.  
  36. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  37. index 1597ec0..a7006d2 100644
  38. --- a/lib/rbreadline.rb
  39. +++ b/lib/rbreadline.rb
  40. @@ -2448,7 +2448,7 @@ module RbReadline
  41.        end
  42.  
  43.        if string =~ /"(.*)"\s*:\s*(.*)$/
  44. -          key, funname = $1, $2
  45. +       key, funname = $1, $2
  46.  
  47.           rl_bind_key(key, rl_named_function(funname))
  48.        end
  49. @@ -3706,14 +3706,14 @@ module RbReadline
  50.           if (!@rl_display_fixed || @forced_display || lmargin != @last_lmargin)
  51.  
  52.              @forced_display = false
  53. -           # in case we scrolled to the right, the prompt is not visible,
  54. -           # so temporarily set wrap_offset and visible_wrap_offset to zero.
  55. -           old_vwo=@visible_wrap_offset
  56. -           old_wo=@wrap_offset
  57. -           if (lmargin != 0)
  58. -               @visible_wrap_offset=0
  59. -               @wrap_offset=0
  60. -           end
  61. +      # in case we scrolled to the right, the prompt is not visible,
  62. +      # so temporarily set wrap_offset and visible_wrap_offset to zero.
  63. +      old_vwo=@visible_wrap_offset
  64. +      old_wo=@wrap_offset
  65. +      if (lmargin != 0)
  66. +        @visible_wrap_offset=0
  67. +        @wrap_offset=0
  68. +      end
  69.              update_line(@visible_line,@last_lmargin,@invisible_line[lmargin..-1],
  70.              0,
  71.              @_rl_screenwidth + @visible_wrap_offset,
  72. @@ -3736,8 +3736,8 @@ module RbReadline
  73.              end
  74.              _rl_move_cursor_relative(@cpos_buffer_position - lmargin, @invisible_line ,lmargin)
  75.              @last_lmargin = lmargin
  76. -           @visible_wrap_offset=old_vwo
  77. -           @wrap_offset=old_wo
  78. +      @visible_wrap_offset=old_vwo
  79. +      @wrap_offset=old_wo
  80.           end
  81.        end
  82.        @rl_outstream.flush
  83. @@ -4351,9 +4351,9 @@ module RbReadline
  84.        # Cygwin will look like Windows, but we want to treat it like a Posix OS:
  85.        raise LoadError, "Cygwin is a Posix OS." if RUBY_PLATFORM =~ /\bcygwin\b/i
  86.  
  87. -     # Try to use win32api regardless of version.  This allows us to correctly
  88. -     # fall back to unixy stuff when not on Windows.  Requires some testing on
  89. -     # 1.8 for Windows, but msf ships 1.9, so don't worry about it for now.
  90. +    # Try to use win32api regardless of version.  This allows us to correctly
  91. +    # fall back to unixy stuff when not on Windows.  Requires some testing on
  92. +    # 1.8 for Windows, but msf ships 1.9, so don't worry about it for now.
  93.        #if RUBY_VERSION < '1.9.1'
  94.           require 'Win32API'
  95.        #else
  96.  
  97. commit d656e3185ff80b7264c30e994b2299a039e907a2
  98. Author: HD Moore <[email protected]>
  99. Date:   Fri Jun 29 00:18:28 2012 -0500
  100.  
  101.     Mark all libraries as defaulting to 8-bit strings
  102.  
  103. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  104. index dfccf9d..1597ec0 100644
  105. --- a/lib/rbreadline.rb
  106. +++ b/lib/rbreadline.rb
  107. @@ -1,3 +1,4 @@
  108. +# -*- coding: binary -*-
  109.  # rbreadline.rb -- a general facility for reading lines of input
  110.  #   with emacs style editing and completion.
  111.  
  112.  
  113. commit 52767b31045e39ef7604ddb1a5c864fd0d85980c
  114. Author: Tod Beardsley <[email protected]>
  115. Date:   Thu Oct 13 17:35:31 2011 +0000
  116.  
  117.     Fixes #5204. Adding Windows Console2 color support from mihi. Thanks!
  118.    
  119.    
  120.    
  121.     git-svn-id: file:///home/svn/framework3/trunk@13913 4d416f70-5f16-0410-b530-b9f4589650da
  122.  
  123. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  124. index f0cfa98..dfccf9d 100644
  125. --- a/lib/rbreadline.rb
  126. +++ b/lib/rbreadline.rb
  127. @@ -3705,10 +3705,18 @@ module RbReadline
  128.           if (!@rl_display_fixed || @forced_display || lmargin != @last_lmargin)
  129.  
  130.              @forced_display = false
  131. +           # in case we scrolled to the right, the prompt is not visible,
  132. +           # so temporarily set wrap_offset and visible_wrap_offset to zero.
  133. +           old_vwo=@visible_wrap_offset
  134. +           old_wo=@wrap_offset
  135. +           if (lmargin != 0)
  136. +               @visible_wrap_offset=0
  137. +               @wrap_offset=0
  138. +           end
  139.              update_line(@visible_line,@last_lmargin,@invisible_line[lmargin..-1],
  140.              0,
  141.              @_rl_screenwidth + @visible_wrap_offset,
  142. -            @_rl_screenwidth + (lmargin ? 0 : @wrap_offset),
  143. +            @_rl_screenwidth + (lmargin != 0 ? 0 : @wrap_offset),
  144.              0)
  145.              # If the visible new line is shorter than the old, but the number
  146.              #   of invisible characters is greater, and we are at the end of
  147. @@ -3727,6 +3735,8 @@ module RbReadline
  148.              end
  149.              _rl_move_cursor_relative(@cpos_buffer_position - lmargin, @invisible_line ,lmargin)
  150.              @last_lmargin = lmargin
  151. +           @visible_wrap_offset=old_vwo
  152. +           @wrap_offset=old_wo
  153.           end
  154.        end
  155.        @rl_outstream.flush
  156.  
  157. commit 8a4c23ffd4ec5a968ef7c4cba38c094d288cfe16
  158. Author: Joshua Drake <[email protected]>
  159. Date:   Tue Jan 25 02:15:25 2011 +0000
  160.  
  161.     small adjustment
  162.    
  163.     git-svn-id: file:///home/svn/framework3/trunk@11635 4d416f70-5f16-0410-b530-b9f4589650da
  164.  
  165. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  166. index 2a7eaf9..f0cfa98 100644
  167. --- a/lib/rbreadline.rb
  168. +++ b/lib/rbreadline.rb
  169. @@ -1151,6 +1151,7 @@ module RbReadline
  170.           if text.length == 0
  171.              text = "."
  172.           end
  173. +
  174.           @filename = ''
  175.           @directory = nil
  176.           dir = text.dup
  177. @@ -1167,8 +1168,8 @@ module RbReadline
  178.              @directory = Dir.new(dir)
  179.              @dirname = dir.dup
  180.           elsif File.directory?(File.dirname(dir)) and File.readable?(File.dirname(dir))
  181. -            @directory = Dir.new(File.dirname(dir))
  182.              @dirname = File.dirname(dir)
  183. +            @directory = Dir.new(@dirname)
  184.              @filename = File.basename(dir)
  185.           end
  186.  
  187.  
  188. commit 9f05e02b856f94f1d13df92a87def3e45e9d0a7d
  189. Author: James Lee <[email protected]>
  190. Date:   Wed Dec 29 20:31:22 2010 +0000
  191.  
  192.     a better fix for rbreadline, also fixes completion for ~/, see #3352
  193.    
  194.     git-svn-id: file:///home/svn/framework3/trunk@11451 4d416f70-5f16-0410-b530-b9f4589650da
  195.  
  196. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  197. index 2fbddf2..2a7eaf9 100644
  198. --- a/lib/rbreadline.rb
  199. +++ b/lib/rbreadline.rb
  200. @@ -1148,38 +1148,44 @@ module RbReadline
  201.              @directory = nil
  202.           end
  203.           text.delete!(0.chr)
  204. -         @filename = File.basename(text)
  205.           if text.length == 0
  206.              text = "."
  207.           end
  208. -         @dirname = File.dirname(text)
  209. -         # We aren't done yet.  We also support the "~user" syntax.
  210. -
  211. -         # Save the version of the directory that the user typed.
  212. -         @users_dirname = @dirname.dup
  213. +         @filename = ''
  214. +         @directory = nil
  215. +         dir = text.dup
  216. +         # We also support "~user" and "~/" syntax.
  217. +         if (dir[0,1] == '~')
  218. +            @users_dirname = dir.dup
  219. +            dir = File.expand_path(dir)
  220. +         end
  221.  
  222. -         if (@dirname[0,1] == '~')
  223. -            @dirname = File.expand_path(@dirname)
  224. +         # Try the whole thing as a directory and if that fails, try dirname
  225. +         # and basename.  If that doesn't work either, then it wasn't meant to
  226. +         # be; we don't have a directory to open or a filename to complete.
  227. +         if File.directory?(dir) and File.readable?(dir)
  228. +            @directory = Dir.new(dir)
  229. +            @dirname = dir.dup
  230. +         elsif File.directory?(File.dirname(dir)) and File.readable?(File.dirname(dir))
  231. +            @directory = Dir.new(File.dirname(dir))
  232. +            @dirname = File.dirname(dir)
  233. +            @filename = File.basename(dir)
  234.           end
  235.  
  236. +         # Save the version of the directory that the user typed if we didn't
  237. +         # have a reason to do so before
  238. +         @users_dirname ||= @dirname.dup
  239. +
  240.           # The directory completion hook should perform any necessary
  241.           #   dequoting.
  242. -         if (@rl_directory_completion_hook && send(rl_directory_completion_hook,@dirname))
  243. -            @users_dirname = @dirname.dup
  244. +         if (@rl_directory_completion_hook)
  245. +            send(rl_directory_completion_hook,@dirname)
  246.           elsif (@rl_completion_found_quote && @rl_filename_dequoting_function)
  247.              # delete single and double quotes
  248.              temp = send(@rl_filename_dequoting_function,@users_dirname, @rl_completion_quote_character)
  249.              @users_dirname = temp
  250.           end
  251.  
  252. -         if File.directory?(@dirname)
  253. -            @directory = Dir.new(@dirname)
  254. -         elsif File.directory?(File.dirname(@dirname))
  255. -            @directory = Dir.new(File.dirname(@dirname))
  256. -         else
  257. -            @directory = nil
  258. -         end
  259. -
  260.           # Now dequote a non-null filename.
  261.           if (@filename && @filename.length>0 && @rl_completion_found_quote && @rl_filename_dequoting_function)
  262.              # delete single and double quotes
  263. @@ -1204,7 +1210,7 @@ module RbReadline
  264.           # Special case for no filename.  If the user has disabled the
  265.           #   `match-hidden-files' variable, skip filenames beginning with `.'.
  266.           #All other entries except "." and ".." match.
  267. -         if (@filename_len == 0 || @filename == "/")
  268. +         if (@filename_len == 0)
  269.              next if (!@_rl_match_hidden_files && d_name[0,1] == '.')
  270.              break if (d_name != '.' && d_name != '..')
  271.           else
  272. @@ -1244,9 +1250,6 @@ module RbReadline
  273.           else
  274.              temp = entry.dup
  275.           end
  276. -         if (@_rl_complete_mark_directories && File.directory?(temp) && temp[-1,1] != '/')
  277. -            temp += "/"
  278. -         end
  279.           return (temp)
  280.        end
  281.     end
  282. @@ -2444,6 +2447,7 @@ module RbReadline
  283.  
  284.        if string =~ /"(.*)"\s*:\s*(.*)$/
  285.            key, funname = $1, $2
  286. +
  287.           rl_bind_key(key, rl_named_function(funname))
  288.        end
  289.  
  290. @@ -3335,7 +3339,6 @@ module RbReadline
  291.              @cpos_buffer_position = out
  292.              lb_linenum = newlines
  293.           end
  294. -
  295.           if (false && meta_char(c))
  296.              if (!@_rl_output_meta_chars && false)
  297.                 line[out,4] = "\\%03o" % c.ord
  298. @@ -4080,8 +4083,8 @@ module RbReadline
  299.           if (cxt.search_string_index == 0)
  300.              rl_ding()
  301.           else
  302. -               cxt.search_string_index -= 1
  303. -               cxt.search_string.chop!
  304. +            cxt.search_string_index -= 1
  305. +            cxt.search_string.chop!
  306.           end
  307.        when -4  # C-G, abort
  308.           rl_replace_line(cxt.lines[cxt.save_line], false)
  309. @@ -6299,6 +6302,7 @@ module RbReadline
  310.              end
  311.           end
  312.        end
  313. +
  314.        matchesp = matches
  315.        1
  316.     end
  317. @@ -8731,4 +8735,3 @@ module RbReadline
  318.    private :no_terminal?
  319.  
  320.  end
  321. -
  322.  
  323. commit 85efd12467196cb1a95658d164808c89e127512d
  324. Author: James Lee <[email protected]>
  325. Date:   Wed Dec 29 02:56:01 2010 +0000
  326.  
  327.     make sure the dirname is actually a directory before trying to read it's entries, fixes #3352. also fixes a typo and a bug where directories other than ./ wouldn't be considered for tabbing.
  328.    
  329.     git-svn-id: file:///home/svn/framework3/trunk@11441 4d416f70-5f16-0410-b530-b9f4589650da
  330.  
  331. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  332. index e150f93..2fbddf2 100644
  333. --- a/lib/rbreadline.rb
  334. +++ b/lib/rbreadline.rb
  335. @@ -1148,7 +1148,7 @@ module RbReadline
  336.              @directory = nil
  337.           end
  338.           text.delete!(0.chr)
  339. -         @filename = text.dup
  340. +         @filename = File.basename(text)
  341.           if text.length == 0
  342.              text = "."
  343.           end
  344. @@ -1168,11 +1168,17 @@ module RbReadline
  345.              @users_dirname = @dirname.dup
  346.           elsif (@rl_completion_found_quote && @rl_filename_dequoting_function)
  347.              # delete single and double quotes
  348. -            @temp = send(@rl_filename_dequoting_function,@users_dirname, @rl_completion_quote_character)
  349. +            temp = send(@rl_filename_dequoting_function,@users_dirname, @rl_completion_quote_character)
  350.              @users_dirname = temp
  351.           end
  352.  
  353. -         @directory = Dir.new(@dirname)
  354. +         if File.directory?(@dirname)
  355. +            @directory = Dir.new(@dirname)
  356. +         elsif File.directory?(File.dirname(@dirname))
  357. +            @directory = Dir.new(File.dirname(@dirname))
  358. +         else
  359. +            @directory = nil
  360. +         end
  361.  
  362.           # Now dequote a non-null filename.
  363.           if (@filename && @filename.length>0 && @rl_completion_found_quote && @rl_filename_dequoting_function)
  364. @@ -1198,7 +1204,7 @@ module RbReadline
  365.           # Special case for no filename.  If the user has disabled the
  366.           #   `match-hidden-files' variable, skip filenames beginning with `.'.
  367.           #All other entries except "." and ".." match.
  368. -         if (@filename_len == 0)
  369. +         if (@filename_len == 0 || @filename == "/")
  370.              next if (!@_rl_match_hidden_files && d_name[0,1] == '.')
  371.              break if (d_name != '.' && d_name != '..')
  372.           else
  373. @@ -1227,19 +1233,20 @@ module RbReadline
  374.           if (@dirname != '.')
  375.              if (@rl_complete_with_tilde_expansion && @users_dirname[0,1] == "~")
  376.                 temp = @dirname
  377. -               if(temp[-1,1] != '/')
  378. -                  temp += '/'
  379. -               end
  380.              else
  381.                 temp = @users_dirname
  382. -               if(temp[-1,1] != '/')
  383. -                  temp += '/'
  384. -               end
  385.              end
  386. +
  387. +            # make sure the directory name has a trailing slash before
  388. +            # appending the file name
  389. +            temp += '/' if (temp[-1,1] != '/')
  390.              temp += entry
  391.           else
  392.              temp = entry.dup
  393.           end
  394. +         if (@_rl_complete_mark_directories && File.directory?(temp) && temp[-1,1] != '/')
  395. +            temp += "/"
  396. +         end
  397.           return (temp)
  398.        end
  399.     end
  400. @@ -6292,7 +6299,6 @@ module RbReadline
  401.              end
  402.           end
  403.        end
  404. -
  405.        matchesp = matches
  406.        1
  407.     end
  408.  
  409. commit e92c073c22ad49ecef39d70fafb31f4cdbf3c93b
  410. Author: Joshua Drake <[email protected]>
  411. Date:   Tue Dec 14 22:09:38 2010 +0000
  412.  
  413.     Sync RbReadline with TIP, some diffs remain Metasploit specific
  414.    
  415.     git-svn-id: file:///home/svn/framework3/trunk@11338 4d416f70-5f16-0410-b530-b9f4589650da
  416.  
  417. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  418. index 88aa212..e150f93 100644
  419. --- a/lib/rbreadline.rb
  420. +++ b/lib/rbreadline.rb
  421. @@ -44,7 +44,7 @@ module RbReadline
  422.  
  423.     RL_LIBRARY_VERSION = "5.2"
  424.     RL_READLINE_VERSION  = 0x0502
  425. -   RB_READLINE_VERSION = "0.2.0"
  426. +   RB_READLINE_VERSION = "0.2.2"
  427.  
  428.     EOF = "\xFF"
  429.     ESC = "\C-["
  430. @@ -233,6 +233,8 @@ module RbReadline
  431.     :t_quit,:t_susp,:t_dsusp,:t_start,:t_stop,:t_lnext,:t_flush,:t_status).new
  432.     @_rl_last_tty_chars = nil
  433.  
  434. +   @_keyboard_input_timeout = 0.01
  435. +
  436.     # Variables exported by this file.
  437.     # The character that represents the start of a history expansion
  438.     #   request.  This is usually `!'.
  439. @@ -1202,6 +1204,7 @@ module RbReadline
  440.           else
  441.              # Otherwise, if these match up to the length of filename, then
  442.              #   it is a match.
  443. +
  444.              if (@_rl_completion_case_fold)
  445.                 break if d_name =~ /^#{Regexp.escape(@filename)}/i
  446.              else
  447. @@ -2432,13 +2435,9 @@ module RbReadline
  448.           return 0
  449.        end
  450.  
  451. -      key,funname = string.split(/\s*:\s*/)
  452. -
  453. -      begin
  454. -         key = instance_eval(key)
  455. +      if string =~ /"(.*)"\s*:\s*(.*)$/
  456. +          key, funname = $1, $2
  457.           rl_bind_key(key, rl_named_function(funname))
  458. -      rescue ::Exception => e
  459. -         $stderr.puts "[-] RbReadline error parsing inputrc: #{e} '#{key}'"
  460.        end
  461.  
  462.        0
  463. @@ -2527,7 +2526,7 @@ module RbReadline
  464.        @_rl_out_stream = @rl_outstream
  465.  
  466.        # Allocate data structures.
  467. -      @rl_line_buffer ||= 0.chr * DEFAULT_BUFFER_SIZE
  468. +      @rl_line_buffer = ""
  469.  
  470.        # Initialize the terminal interface.
  471.        @rl_terminal_name ||= ENV["TERM"]
  472. @@ -2567,7 +2566,7 @@ module RbReadline
  473.  
  474.     def _rl_init_line_state()
  475.        @rl_point = @rl_end = @rl_mark = 0
  476. -      @rl_line_buffer = 0.chr * @rl_line_buffer.length
  477. +      @rl_line_buffer = ""
  478.     end
  479.  
  480.     # Set the history pointer back to the last entry in the history.
  481. @@ -2785,7 +2784,7 @@ module RbReadline
  482.                 @_rl_last_c_pos = 1
  483.                 @_rl_last_v_pos+=1
  484.                 if (old[ostart,1] != 0.chr && new[0,1] != 0.chr)
  485. -                  old[ostart] = new[0]
  486. +                  old[ostart,1] = new[0,1]
  487.                 end
  488.              end
  489.  
  490. @@ -2798,7 +2797,7 @@ module RbReadline
  491.              @_rl_last_c_pos = 1
  492.              @_rl_last_v_pos+=1
  493.              if (old[ostart,1] != 0.chr && new[0,1] != 0.chr)
  494. -               old[ostart] = new[0]
  495. +               old[ostart,1] = new[0,1]
  496.              end
  497.           end
  498.        end
  499. @@ -2840,7 +2839,7 @@ module RbReadline
  500.        else
  501.           ofd = 0
  502.           nfd = 0
  503. -         while(ofd < omax && old[ostart+ofd,1] != 0.chr && old[ostart+ofd] == new[nfd])
  504. +         while(ofd < omax && old[ostart+ofd,1] != 0.chr && old[ostart+ofd,1] == new[nfd,1])
  505.              ofd += 1
  506.              nfd += 1
  507.           end
  508. @@ -2887,7 +2886,7 @@ module RbReadline
  509.        else
  510.           ols = oe - 1         # find last same
  511.           nls = ne - 1
  512. -         while ((ols > ofd) && (nls > nfd) && old[ostart+ols] == new[nls])
  513. +         while ((ols > ofd) && (nls > nfd) && old[ostart+ols,1] == new[nls,1])
  514.              if (old[ostart+ols,1] != " ")
  515.                 wsatend = false
  516.              end
  517. @@ -3119,9 +3118,9 @@ module RbReadline
  518.        #   lines.
  519.        modmark = 0
  520.        if (@_rl_mark_modified_lines && current_history() && @rl_undo_list)
  521. -         line[out] = '*'
  522. +         line[out,1] = '*'
  523.           out += 1
  524. -         line[out] = 0.chr
  525. +         line[out,1] = 0.chr
  526.           modmark = 1
  527.        end
  528.  
  529. @@ -3166,7 +3165,7 @@ module RbReadline
  530.              line[out,@local_prompt_len] = @local_prompt
  531.              out += @local_prompt_len
  532.           end
  533. -         line[out] = 0.chr
  534. +         line[out,1] = 0.chr
  535.           @wrap_offset = @local_prompt_len - @prompt_visible_length
  536.        else
  537.           prompt_this_line = @rl_display_prompt.rindex("\n")
  538. @@ -3180,7 +3179,7 @@ module RbReadline
  539.                 _rl_output_some_chars(@rl_display_prompt,0,pmtlen)
  540.                 # Make sure we are at column zero even after a newline,
  541.                 #regardless of the state of terminal output processing.
  542. -               if (pmtlen < 2 || @rl_display_prompt[prompt_this_line-2] != "\r")
  543. +               if (pmtlen < 2 || @rl_display_prompt[prompt_this_line-2,1] != "\r")
  544.                    cr()
  545.                 end
  546.              end
  547. @@ -3210,7 +3209,7 @@ module RbReadline
  548.           end
  549.           line[out,pmtlen] = @rl_display_prompt[prompt_this_line,pmtlen]
  550.           out += pmtlen
  551. -         line[out] = 0.chr
  552. +         line[out,1] = 0.chr
  553.           @wrap_offset = @prompt_invis_chars_first_line = 0
  554.        end
  555.        # inv_lbreaks[i] is where line i starts in the buffer.
  556. @@ -3286,7 +3285,7 @@ module RbReadline
  557.              wc = @rl_line_buffer[0,@rl_end].scan(/./mu)[0]
  558.              wc_bytes = wc ? wc.length : 1
  559.           when 'X'
  560. -            wc = @rl_line_buffer[0,@rl_end].force_encoding(@encoding_name)[0,1]
  561. +            wc = @rl_line_buffer[0,@rl_end].force_encoding(@encoding_name)[0]
  562.              wc_bytes = wc ? wc.bytesize : 1
  563.           end
  564.        else
  565. @@ -3343,7 +3342,7 @@ module RbReadline
  566.                 end
  567.                 out += 4
  568.              else
  569. -               line[out] = c
  570. +               line[out,1] = c
  571.                 out += 1
  572.                 lpos+=1
  573.                 if (lpos >= @_rl_screenwidth)
  574. @@ -3362,26 +3361,26 @@ module RbReadline
  575.                 @inv_lbreaks[newlines+=1] = out + temp2
  576.                 lpos = temp - temp2
  577.                 while (out < newout)
  578. -                  line[out] = ' '
  579. +                  line[out,1] = ' '
  580.                    out += 1
  581.                 end
  582.  
  583.              else
  584.  
  585.                 while (out < newout)
  586. -                  line[out] = ' '
  587. +                  line[out,1] = ' '
  588.                    out += 1
  589.                 end
  590.                 lpos += temp
  591.              end
  592.  
  593.           elsif (c == "\n" && !@_rl_horizontal_scroll_mode && @_rl_term_up)
  594. -            line[out] = 0.chr # XXX - sentinel
  595. +            line[out,1] = 0.chr # XXX - sentinel
  596.              out += 1
  597.              @inv_lbreaks[newlines+=1] = out
  598.              lpos = 0
  599.           elsif (ctrl_char(c) || c == RUBOUT)
  600. -            line[out] = '^'
  601. +            line[out,1] = '^'
  602.              out += 1
  603.              lpos+=1
  604.              if (lpos >= @_rl_screenwidth)
  605. @@ -3389,7 +3388,8 @@ module RbReadline
  606.                 @_rl_wrapped_line[newlines] = _rl_wrapped_multicolumn
  607.                 lpos = 0
  608.              end
  609. -            line[out] = ctrl_char(c) ? (c[0].ord|0x40).chr.upcase : '?' # c[0].ord magically works for 1.9.1 and 1.8 both!
  610. +            # NOTE: c[0].ord works identically on both 1.8 and 1.9
  611. +            line[out,1] = ctrl_char(c) ? (c[0].ord|0x40).chr.upcase : '?'
  612.              out += 1
  613.              lpos+=1
  614.              if (lpos >= @_rl_screenwidth)
  615. @@ -3404,7 +3404,7 @@ module RbReadline
  616.                 if (@_rl_screenwidth < lpos + wc_width)
  617.                    for i in lpos ... @_rl_screenwidth
  618.                       # The space will be removed in update_line()
  619. -                     line[out] = ' '
  620. +                     line[out,1] = ' '
  621.                       out += 1
  622.                       _rl_wrapped_multicolumn+=1
  623.                       lpos+=1
  624. @@ -3430,7 +3430,7 @@ module RbReadline
  625.                    end
  626.                 end
  627.              else
  628. -               line[out] = c
  629. +               line[out,1] = c
  630.                 out += 1
  631.                 lpos+=1
  632.                 if (lpos >= @_rl_screenwidth)
  633. @@ -3455,7 +3455,7 @@ module RbReadline
  634.                 wc = @rl_line_buffer[_in,@rl_end - _in].scan(/./mu)[0]
  635.                 wc_bytes = wc ? wc.length : 1
  636.              when 'X'
  637. -               wc = @rl_line_buffer[_in,@rl_end - _in].force_encoding(@encoding_name)[0,1]
  638. +               wc = @rl_line_buffer[_in,@rl_end - _in].force_encoding(@encoding_name)[0]
  639.                 wc_bytes = wc ? wc.bytesize : 1
  640.              end
  641.  
  642. @@ -3680,7 +3680,7 @@ module RbReadline
  643.           # If the first character on the screen isn't the first character
  644.           #in the display line, indicate this with a special character.
  645.           if (lmargin > 0)
  646. -            line[lmargin] = '<'
  647. +            line[lmargin,1] = '<'
  648.           end
  649.  
  650.           # If SCREENWIDTH characters starting at LMARGIN do not encompass
  651. @@ -3689,7 +3689,7 @@ module RbReadline
  652.           # wrap offset into account.
  653.           t = lmargin + m_offset(lmargin, @wrap_offset) + @_rl_screenwidth
  654.           if (t < out)
  655. -            line[t - 1] = '>'
  656. +            line[t - 1,1] = '>'
  657.           end
  658.           if (!@rl_display_fixed || @forced_display || lmargin != @last_lmargin)
  659.  
  660. @@ -3738,7 +3738,7 @@ module RbReadline
  661.     # Tell the update routines that we have moved onto a new (empty) line.
  662.     def rl_on_new_line()
  663.        if (@visible_line)
  664. -         @visible_line[0] = 0.chr
  665. +         @visible_line[0,1] = 0.chr
  666.        end
  667.        @_rl_last_c_pos = @_rl_last_v_pos = 0
  668.        @_rl_vis_botlin = @last_lmargin = 0
  669. @@ -3971,6 +3971,10 @@ module RbReadline
  670.        ((ctrl_char(c) || meta_char(c) || (c) == RUBOUT) && ((c) != "\C-G"))
  671.     end
  672.  
  673. +   def _rl_input_available
  674. +      IO.select([ $stdin ], nil, [ $stdin ], @_keyboard_input_timeout)
  675. +   end
  676. +
  677.     # Process just-read character C according to isearch context CXT.  Return
  678.     #   -1 if the caller should just free the context and return, 0 if we should
  679.     #   break out of the loop, and 1 if we should continue to read characters.
  680. @@ -4036,12 +4040,10 @@ module RbReadline
  681.           # search again
  682.        when -1
  683.           if (cxt.search_string_index == 0)
  684. -            # XXX: This variable is not defined
  685. -            # if (last_isearch_string)
  686. -            if(false)
  687. -               cxt.search_string_size = 64 + last_isearch_string_len
  688. -               cxt.search_string = last_isearch_string.dup
  689. -               cxt.search_string_index = last_isearch_string_len
  690. +            if (@last_isearch_string)
  691. +               cxt.search_string_size = 64 + @last_isearch_string_len
  692. +               cxt.search_string = @last_isearch_string.dup
  693. +               cxt.search_string_index = @last_isearch_string_len
  694.                 rl_display_search(cxt.search_string, (cxt.sflags & SF_REVERSE)!=0, -1)
  695.              else
  696.                 return (1)
  697. @@ -4071,7 +4073,8 @@ module RbReadline
  698.           if (cxt.search_string_index == 0)
  699.              rl_ding()
  700.           else
  701. -            cxt.search_string[cxt.search_string_index-=1] = 0.chr
  702. +               cxt.search_string_index -= 1
  703. +               cxt.search_string.chop!
  704.           end
  705.        when -4  # C-G, abort
  706.           rl_replace_line(cxt.lines[cxt.save_line], false)
  707. @@ -4337,10 +4340,10 @@ module RbReadline
  708.        #      DLL = {}
  709.        #      TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG}
  710.        #
  711. -      #      def initialize(dllname, func, import, export = "0")
  712. +      #      def initialize(dllname, func, import, export = "0", calltype = :stdcall)
  713.        #         @proto = [import].join.tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '\1')
  714.        #         handle = DLL[dllname] ||= DL.dlopen(dllname)
  715. -      #         @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func)
  716. +      #         @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func, calltype)
  717.        #      end
  718.        #
  719.        #      def call(*args)
  720. @@ -4402,15 +4405,15 @@ module RbReadline
  721.  
  722.        def rl_getc(stream)
  723.           while (@kbhit.Call == 0)
  724. -            # if there is no data to read, yeild the processor for other
  725. -            # threads until there is
  726. -            sleep(0.001)
  727. +            # If there is no input, yield the processor for other threads
  728. +            sleep(@_keyboard_input_timeout)
  729.           end
  730.           c = @getch.Call
  731.           alt = (@GetKeyState.call(VK_LMENU) & 0x80) != 0
  732.           if c==0 || c==0xE0
  733.              while (@kbhit.Call == 0)
  734. -               sleep(0.001)
  735. +               # If there is no input, yield the processor for other threads
  736. +               sleep(@_keyboard_input_timeout)
  737.              end
  738.              r = c.chr + @getch.Call.chr
  739.           else
  740. @@ -4459,7 +4462,7 @@ module RbReadline
  741.        end
  742.     end
  743.  
  744. -  if(Object.const_defined?('Encoding') and Encoding.respond_to?('default_external'))
  745. +   if (Object.const_defined?('Encoding') and Encoding.respond_to?('default_external'))
  746.        @encoding = "X"      # ruby 1.9.x or greater
  747.        @encoding_name = Encoding.default_external.to_s
  748.     end
  749. @@ -6052,7 +6055,7 @@ module RbReadline
  750.        t = Time.now.to_i
  751.        ts = "X%u" % t
  752.        ret = ts.dup
  753. -      ret[0] = @history_comment_char
  754. +      ret[0,1] = @history_comment_char
  755.  
  756.        ret
  757.     end
  758. @@ -6126,7 +6129,7 @@ module RbReadline
  759.              #   to quote anything in single quotes, especially not the closing
  760.              #   quote.  If you don't like this, take out the check on the value
  761.              #   of quote_char.
  762. -            if (quote_char != "'" && @rl_line_buffer[scan] == "\\")
  763. +            if (quote_char != "'" && @rl_line_buffer[scan,1] == "\\")
  764.                 pass_next = true
  765.                 found_quote |= RL_QF_BACKSLASH
  766.                 next
  767. @@ -6500,7 +6503,7 @@ module RbReadline
  768.           if (to_print != full_pathname)
  769.  
  770.              if full_pathname.nil? || full_pathname.length==0
  771. -               dn = "/"
  772. +               dn = '/'
  773.              else
  774.                 dn = File.dirname(full_pathname)
  775.              end
  776. @@ -7115,7 +7118,7 @@ module RbReadline
  777.     def _rl_scxt_alloc(type, flags)
  778.        cxt = Struct.new(:type,:sflags,:search_string,:search_string_index,:search_string_size,:lines,:allocated_line,
  779.        :hlen,:hindex,:save_point,:save_mark,:save_line,:last_found_line,:prev_line_found,:save_undo_list,:history_pos,
  780. -      :direction,:lastc,:sline,:sline_len,:sline_index,:search_terminators, :mb).new
  781. +      :direction,:lastc,:sline,:sline_len,:sline_index,:search_terminators,:mb).new
  782.  
  783.        cxt.type = type
  784.        cxt.sflags = flags
  785. @@ -7172,7 +7175,7 @@ module RbReadline
  786.        # Allocate space for this many lines, +1 for the current input line,
  787.        #   and remember those lines.
  788.        cxt.hlen = i
  789. -      cxt.lines = Array.new(cxt.hlen+1)
  790. +      cxt.lines = []
  791.        for i in 0 ... cxt.hlen
  792.           cxt.lines[i] = hlist[i].line
  793.        end
  794. @@ -7182,7 +7185,7 @@ module RbReadline
  795.        else
  796.           # Keep track of this so we can free it.
  797.           cxt.allocated_line = @rl_line_buffer.dup
  798. -         cxt.lines[i] = cxt.allocated_line
  799. +         cxt.lines << cxt.allocated_line
  800.        end
  801.  
  802.        cxt.hlen+=1
  803. @@ -7195,7 +7198,7 @@ module RbReadline
  804.        # Initialize search parameters.
  805.        cxt.search_string_size = 128
  806.        cxt.search_string_index = 0
  807. -      cxt.search_string = 0.chr * cxt.search_string_size
  808. +      cxt.search_string = ""
  809.  
  810.        # Normalize DIRECTION into 1 or -1.
  811.        cxt.direction = (direction >= 0) ? 1 : -1
  812. @@ -8052,7 +8055,7 @@ module RbReadline
  813.        @rl_undo_list = nil
  814.  
  815.        # Use the line buffer to read the search string.
  816. -      @rl_line_buffer[0] = 0.chr
  817. +      @rl_line_buffer[0,1] = 0.chr
  818.        @rl_end = @rl_point = 0
  819.  
  820.        _p = _rl_make_prompt_for_search(pchar ? pchar : ':')
  821. @@ -8341,8 +8344,8 @@ module RbReadline
  822.                 # slash.
  823.                 if (@rl_point>0 && @rl_line_buffer[@rl_point,1] == 0.chr && @rl_line_buffer[@rl_point - 1,1] == '/' )
  824.  
  825. -               elsif (@rl_line_buffer[@rl_point,1] != '/' )
  826. -                  rl_insert_text("/")
  827. +               elsif (@rl_line_buffer[@rl_point,1] != '/')
  828. +                  rl_insert_text('/')
  829.                 end
  830.              end
  831.              # Don't add anything if the filename is a symlink and resolves to a
  832. @@ -8495,20 +8498,20 @@ module RbReadline
  833.           count -= 1
  834.        end
  835.  
  836. +      str = (flags == MB_FIND_NONZERO) ? string.sub(/\x00+$/,'') : string
  837. +
  838.        case @encoding
  839.        when 'E'
  840. -         point += string[point..-1].scan(/./me)[0,count].to_s.length
  841. +         point += str[point..-1].scan(/./me)[0,count].to_s.length
  842.        when 'S'
  843. -         point += string[point..-1].scan(/./ms)[0,count].to_s.length
  844. +         point += str[point..-1].scan(/./ms)[0,count].to_s.length
  845.        when 'U'
  846. -         point += string[point..-1].scan(/./mu)[0,count].to_s.length
  847. +         point += str[point..-1].scan(/./mu)[0,count].to_s.length
  848.        when 'X'
  849. -         point += string[point..-1].force_encoding(@encoding_name)[0,count].bytesize
  850. +         point += str[point..-1].force_encoding(@encoding_name)[0,count].bytesize
  851.        else
  852.           point += count
  853. -      end
  854. -      if flags == MB_FIND_NONZERO
  855. -         point = string.length if point>=string.length
  856. +         point = str.length if point >= str.length
  857.        end
  858.        point
  859.     end
  860. @@ -8574,7 +8577,7 @@ module RbReadline
  861.           len = src.scan(/./mu)[0].to_s.length
  862.        when 'X'
  863.           src = src.dup.force_encoding(@encoding_name)
  864. -         len = src.valid_encoding? ? src[0,1].bytesize : 0
  865. +         len = src.valid_encoding? ? src[0].bytesize : 0
  866.        else
  867.           len = 1
  868.        end
  869.  
  870. commit 4e14aa184257402ca5319b0a93ea753b4983be01
  871. Author: James Lee <[email protected]>
  872. Date:   Thu Oct 14 19:35:41 2010 +0000
  873.  
  874.     try to load win32api regardless of ruby version, so we correctly fall back to unixy stty stuff
  875.    
  876.     git-svn-id: file:///home/svn/framework3/trunk@10687 4d416f70-5f16-0410-b530-b9f4589650da
  877.  
  878. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  879. index e0d19f5..88aa212 100644
  880. --- a/lib/rbreadline.rb
  881. +++ b/lib/rbreadline.rb
  882. @@ -4326,33 +4326,36 @@ module RbReadline
  883.        # Cygwin will look like Windows, but we want to treat it like a Posix OS:
  884.        raise LoadError, "Cygwin is a Posix OS." if RUBY_PLATFORM =~ /\bcygwin\b/i
  885.  
  886. -      if RUBY_VERSION < '1.9.1'
  887. +     # Try to use win32api regardless of version.  This allows us to correctly
  888. +     # fall back to unixy stuff when not on Windows.  Requires some testing on
  889. +     # 1.8 for Windows, but msf ships 1.9, so don't worry about it for now.
  890. +      #if RUBY_VERSION < '1.9.1'
  891.           require 'Win32API'
  892. -      else
  893. -         require 'dl'
  894. -         class Win32API
  895. -            DLL = {}
  896. -            TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG}
  897. -
  898. -            def initialize(dllname, func, import, export = "0")
  899. -               @proto = [import].join.tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '')
  900. -               handle = DLL[dllname] ||= DL.dlopen(dllname)
  901. -               @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func)
  902. -            end
  903. -
  904. -            def call(*args)
  905. -               import = @proto.split("")
  906. -               args.each_with_index do |x, i|
  907. -                  args[i], = [x == 0 ? nil : x].pack("p").unpack("l!*") if import[i] == "S"
  908. -                  args[i], = [x].pack("I").unpack("i") if import[i] == "I"
  909. -               end
  910. -               ret, = @func.call(args)
  911. -               return ret || 0
  912. -            end
  913. -
  914. -            alias Call call
  915. -         end
  916. -      end
  917. +      #else
  918. +      #   require 'dl'
  919. +      #   class Win32API
  920. +      #      DLL = {}
  921. +      #      TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG}
  922. +      #
  923. +      #      def initialize(dllname, func, import, export = "0")
  924. +      #         @proto = [import].join.tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '')
  925. +      #         handle = DLL[dllname] ||= DL.dlopen(dllname)
  926. +      #         @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func)
  927. +      #      end
  928. +      #
  929. +      #      def call(*args)
  930. +      #         import = @proto.split("")
  931. +      #         args.each_with_index do |x, i|
  932. +      #            args[i], = [x == 0 ? nil : x].pack("p").unpack("l!*") if import[i] == "S"
  933. +      #            args[i], = [x].pack("I").unpack("i") if import[i] == "I"
  934. +      #         end
  935. +      #         ret, = @func.call(args)
  936. +      #         return ret || 0
  937. +      #      end
  938. +      #
  939. +      #      alias Call call
  940. +      #   end
  941. +      #end
  942.  
  943.        STD_OUTPUT_HANDLE = -11
  944.        STD_INPUT_HANDLE  = -10
  945.  
  946. commit a10b3cf9fc9aa86bb80bc99a8174db2a7cb5fc28
  947. Author: James Lee <[email protected]>
  948. Date:   Thu Oct 14 18:38:59 2010 +0000
  949.  
  950.     getch() blocks all background threads until the user hits a key, make sure there is something there to read before calling it. also, use the windowsy stuff on mingw since official ruby installer uses mingw now. this fixes a long-standing bug on windows that originally forced us to use cygwin.
  951.    
  952.     git-svn-id: file:///home/svn/framework3/trunk@10681 4d416f70-5f16-0410-b530-b9f4589650da
  953.  
  954. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  955. index e61f235..e0d19f5 100644
  956. --- a/lib/rbreadline.rb
  957. +++ b/lib/rbreadline.rb
  958. @@ -4325,7 +4325,6 @@ module RbReadline
  959.     begin
  960.        # Cygwin will look like Windows, but we want to treat it like a Posix OS:
  961.        raise LoadError, "Cygwin is a Posix OS." if RUBY_PLATFORM =~ /\bcygwin\b/i
  962. -      raise LoadError, "Not Windows" if RUBY_PLATFORM !~ /mswin|mingw/
  963.  
  964.        if RUBY_VERSION < '1.9.1'
  965.           require 'Win32API'
  966. @@ -4399,9 +4398,17 @@ module RbReadline
  967.        end
  968.  
  969.        def rl_getc(stream)
  970. +         while (@kbhit.Call == 0)
  971. +            # if there is no data to read, yeild the processor for other
  972. +            # threads until there is
  973. +            sleep(0.001)
  974. +         end
  975.           c = @getch.Call
  976.           alt = (@GetKeyState.call(VK_LMENU) & 0x80) != 0
  977.           if c==0 || c==0xE0
  978. +            while (@kbhit.Call == 0)
  979. +               sleep(0.001)
  980. +            end
  981.              r = c.chr + @getch.Call.chr
  982.           else
  983.              r = c.chr
  984.  
  985. commit 1e47a49b7e2d90b2d4d958853189024fc51911ad
  986. Author: James Lee <[email protected]>
  987. Date:   Wed May 26 19:54:32 2010 +0000
  988.  
  989.     match whitespace to the rbreadline standard instead of the msf standard
  990.    
  991.     git-svn-id: file:///home/svn/framework3/trunk@9373 4d416f70-5f16-0410-b530-b9f4589650da
  992.  
  993. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  994. index fbf07e7..e61f235 100644
  995. --- a/lib/rbreadline.rb
  996. +++ b/lib/rbreadline.rb
  997. @@ -1197,7 +1197,7 @@ module RbReadline
  998.           #   `match-hidden-files' variable, skip filenames beginning with `.'.
  999.           #All other entries except "." and ".." match.
  1000.           if (@filename_len == 0)
  1001. -               next if (!@_rl_match_hidden_files && d_name[0,1] == '.')
  1002. +            next if (!@_rl_match_hidden_files && d_name[0,1] == '.')
  1003.              break if (d_name != '.' && d_name != '..')
  1004.           else
  1005.              # Otherwise, if these match up to the length of filename, then
  1006. @@ -2117,10 +2117,10 @@ module RbReadline
  1007.        end
  1008.        return (_rl_read_init_file(filename, 0))
  1009.  =end
  1010. -      #
  1011. -      # This code is too problematic at the moment
  1012. -      # Just hardcode things and move on
  1013. -      #
  1014. +      #
  1015. +      # This code is too problematic at the moment
  1016. +      # Just hardcode things and move on
  1017. +      #
  1018.        return 0
  1019.     end
  1020.  
  1021. @@ -2439,7 +2439,7 @@ module RbReadline
  1022.           rl_bind_key(key, rl_named_function(funname))
  1023.        rescue ::Exception => e
  1024.           $stderr.puts "[-] RbReadline error parsing inputrc: #{e} '#{key}'"
  1025. -     end
  1026. +      end
  1027.  
  1028.        0
  1029.     end
  1030. @@ -3823,8 +3823,8 @@ module RbReadline
  1031.           str[start ... _end].scan(/./me).each {|s| width += s.length }
  1032.        when 'X'
  1033.           tmp = str[start ... _end]
  1034. -        return 0 if not tmp
  1035. -        tmp.force_encoding(@encoding_name).codepoints.each {|s| width += s > 0x1000 ? 2 : 1 }
  1036. +         return 0 if not tmp
  1037. +         tmp.force_encoding(@encoding_name).codepoints.each {|s| width += s > 0x1000 ? 2 : 1 }
  1038.        end
  1039.        width
  1040.     end
  1041. @@ -4036,10 +4036,10 @@ module RbReadline
  1042.           # search again
  1043.        when -1
  1044.           if (cxt.search_string_index == 0)
  1045. -           # XXX: This variable is not defined
  1046. +            # XXX: This variable is not defined
  1047.              # if (last_isearch_string)
  1048.              if(false)
  1049. -              cxt.search_string_size = 64 + last_isearch_string_len
  1050. +               cxt.search_string_size = 64 + last_isearch_string_len
  1051.                 cxt.search_string = last_isearch_string.dup
  1052.                 cxt.search_string_index = last_isearch_string_len
  1053.                 rl_display_search(cxt.search_string, (cxt.sflags & SF_REVERSE)!=0, -1)
  1054. @@ -8406,7 +8406,7 @@ module RbReadline
  1055.           #else
  1056.           # If we have to turn on insert-mode, then do so.
  1057.           if (@_rl_term_im)
  1058. -               @_rl_out_stream.write(@_rl_term_im)
  1059. +            @_rl_out_stream.write(@_rl_term_im)
  1060.           end
  1061.           # If there is a special command for inserting characters, then
  1062.           # use that first to open up the space.
  1063.  
  1064. commit 63e70f2d789c905ee6df1473dc9a35e1d1b4ef63
  1065. Author: Joshua Drake <[email protected]>
  1066. Date:   Tue Apr 13 19:44:04 2010 +0000
  1067.  
  1068.     fix up a bunch of incorrect 1.8/1.9 compat fixes, fixes #1540
  1069.    
  1070.     git-svn-id: file:///home/svn/framework3/trunk@9063 4d416f70-5f16-0410-b530-b9f4589650da
  1071.  
  1072. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  1073. index 0f12ae4..fbf07e7 100644
  1074. --- a/lib/rbreadline.rb
  1075. +++ b/lib/rbreadline.rb
  1076. @@ -53,7 +53,7 @@ module RbReadline
  1077.     RETURN = "\C-M"
  1078.     ABORT_CHAR = "\C-G"
  1079.     TAB = "\t"
  1080. -   RUBOUT = "x7f"
  1081. +   RUBOUT = "\x7f"
  1082.     NEWLINE = "\n"
  1083.  
  1084.     DEFAULT_BUFFER_SIZE = 256
  1085. @@ -236,17 +236,17 @@ module RbReadline
  1086.     # Variables exported by this file.
  1087.     # The character that represents the start of a history expansion
  1088.     #   request.  This is usually `!'.
  1089. -   @history_expansion_char = ?!
  1090. +   @history_expansion_char = "!"
  1091.  
  1092.     # The character that invokes word substitution if found at the start of
  1093.     #   a line.  This is usually `^'.
  1094. -   @history_subst_char = ?^
  1095. +   @history_subst_char = "^"
  1096.  
  1097.     # During tokenization, if this character is seen as the first character
  1098.     #   of a word, then it, and all subsequent characters upto a newline are
  1099.     #   ignored.  For a Bourne shell, this should be '#'.  Bash special cases
  1100.     #   the interactive comment character to not be a comment delimiter.
  1101. -   @history_comment_char = ?\0
  1102. +   @history_comment_char = 0.chr
  1103.  
  1104.     # The list of characters which inhibit the expansion of text if found
  1105.     #   immediately following history_expansion_char.
  1106. @@ -1156,7 +1156,7 @@ module RbReadline
  1107.           # Save the version of the directory that the user typed.
  1108.           @users_dirname = @dirname.dup
  1109.  
  1110. -         if (@dirname[0] == ?~)
  1111. +         if (@dirname[0,1] == '~')
  1112.              @dirname = File.expand_path(@dirname)
  1113.           end
  1114.  
  1115. @@ -1197,16 +1197,11 @@ module RbReadline
  1116.           #   `match-hidden-files' variable, skip filenames beginning with `.'.
  1117.           #All other entries except "." and ".." match.
  1118.           if (@filename_len == 0)
  1119. -            if (!@_rl_match_hidden_files && d_name[0]==?.)
  1120. -               next
  1121. -            end
  1122. -            if (d_name != '.' && d_name != '..')
  1123. -               break
  1124. -            end
  1125. +               next if (!@_rl_match_hidden_files && d_name[0,1] == '.')
  1126. +            break if (d_name != '.' && d_name != '..')
  1127.           else
  1128.              # Otherwise, if these match up to the length of filename, then
  1129.              #   it is a match.
  1130. -
  1131.              if (@_rl_completion_case_fold)
  1132.                 break if d_name =~ /^#{Regexp.escape(@filename)}/i
  1133.              else
  1134. @@ -1227,14 +1222,14 @@ module RbReadline
  1135.           return nil
  1136.        else
  1137.           if (@dirname != '.')
  1138. -            if (@rl_complete_with_tilde_expansion && @users_dirname[0] == ?~)
  1139. +            if (@rl_complete_with_tilde_expansion && @users_dirname[0,1] == "~")
  1140.                 temp = @dirname
  1141. -               if(temp[-1] != ?/)
  1142. +               if(temp[-1,1] != '/')
  1143.                    temp += '/'
  1144.                 end
  1145.              else
  1146.                 temp = @users_dirname
  1147. -               if(temp[-1] != ?/)
  1148. +               if(temp[-1,1] != '/')
  1149.                    temp += '/'
  1150.                 end
  1151.              end
  1152. @@ -1253,8 +1248,8 @@ module RbReadline
  1153.        return nil if RUBY_PLATFORM =~ /mswin|mingw/
  1154.  
  1155.        if (state == 0)
  1156. -         first_char = text[0]
  1157. -         first_char_loc = (text[0] == ?~ ? 1 : 0)
  1158. +         first_char = text[0,1]
  1159. +         first_char_loc = (first_char == '~' ? 1 : 0)
  1160.  
  1161.           username = text[first_char_loc..-1]
  1162.           namelen = username.length
  1163. @@ -1273,7 +1268,7 @@ module RbReadline
  1164.           value = text.dup
  1165.           value[first_char_loc..-1] = entry.name
  1166.  
  1167. -         if (first_char == ?~)
  1168. +         if (first_char == '~')
  1169.              @rl_filename_completion_desired = true
  1170.           end
  1171.  
  1172. @@ -1481,11 +1476,11 @@ module RbReadline
  1173.        _end = @rl_point
  1174.        start = _end - 1
  1175.  
  1176. -      if (@rl_point == @rl_end && @rl_line_buffer[@rl_point] == ?~ )
  1177. +      if (@rl_point == @rl_end && @rl_line_buffer[@rl_point,1] == '~' )
  1178.           homedir = File.expand_path("~")
  1179.           _rl_replace_text(homedir, start, _end)
  1180.           return (0)
  1181. -      elsif (@rl_line_buffer[start] != ?~)
  1182. +      elsif (@rl_line_buffer[start,1] != '~')
  1183.           while(!whitespace(@rl_line_buffer[start,1]) && start >= 0)
  1184.              start -= 1
  1185.           end
  1186. @@ -1504,7 +1499,7 @@ module RbReadline
  1187.        # If the first character of the current word is a tilde, perform
  1188.        #tilde expansion and insert the result.  If not a tilde, do
  1189.        #   nothing.
  1190. -      if (@rl_line_buffer[start] == ?~)
  1191. +      if (@rl_line_buffer[start,1] == '~')
  1192.  
  1193.           len = _end - start + 1
  1194.           temp = @rl_line_buffer[start,len]
  1195. @@ -1877,7 +1872,7 @@ module RbReadline
  1196.           @_rl_screenwidth = wc
  1197.           @_rl_screenheight = wr
  1198.        else
  1199. -         wr,wc = `stty size `.split(' ').map{|x| x.to_i}
  1200. +         wr,wc = `stty size`.split(' ').map{|x| x.to_i}
  1201.           @_rl_screenwidth = wc
  1202.           @_rl_screenheight = wr
  1203.           if ignore_env==0 && ENV['LINES']
  1204. @@ -2070,7 +2065,7 @@ module RbReadline
  1205.     # New public way to set the system default editing chars to their readline
  1206.     #   equivalents.
  1207.     def rl_tty_set_default_bindings(kmap)
  1208. -      h = Hash[*`stty -a `.scan(/(\w+) = ([^;]+);/).flatten]
  1209. +      h = Hash[*`stty -a`.scan(/(\w+) = ([^;]+);/).flatten]
  1210.        h.each {|k,v| v.gsub!(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
  1211.        kmap[h['erase']] = :rl_rubout
  1212.        kmap[h['kill']] = :rl_unix_line_discard
  1213. @@ -2423,7 +2418,7 @@ module RbReadline
  1214.     def rl_parse_and_bind(string)
  1215.  
  1216.        # If this is a parser directive, act on it.
  1217. -      if (string[0,1] == ?$)
  1218. +      if (string[0,1] == "$")
  1219.           handle_parser_directive(string[1..-1])
  1220.           return 0
  1221.        end
  1222. @@ -2728,7 +2723,7 @@ module RbReadline
  1223.                 _rl_clear_to_eol(@_rl_wrapped_line[current_line])
  1224.              end
  1225.  
  1226. -            if new[0] != ?\0
  1227. +            if new[0,1] != 0.chr
  1228.                 case @encoding
  1229.                 when 'E'
  1230.                    wc = new.scan(/./me)[0]
  1231. @@ -2760,7 +2755,7 @@ module RbReadline
  1232.                 @_rl_last_c_pos = tempwidth
  1233.                 @_rl_last_v_pos+=1
  1234.  
  1235. -               if old[ostart] != ?\0
  1236. +               if old[ostart,1] != 0.chr
  1237.                    case @encoding
  1238.                    when 'E'
  1239.                       wc = old[ostart..-1].scan(/./me)[0]
  1240. @@ -2789,20 +2784,20 @@ module RbReadline
  1241.                 @rl_outstream.write(' ')
  1242.                 @_rl_last_c_pos = 1
  1243.                 @_rl_last_v_pos+=1
  1244. -               if (old[ostart] != ?\0 && new[0] != ?\0)
  1245. +               if (old[ostart,1] != 0.chr && new[0,1] != 0.chr)
  1246.                    old[ostart] = new[0]
  1247.                 end
  1248.              end
  1249.  
  1250.           else
  1251. -            if (new[0] != ?\0)
  1252. +            if (new[0,1] != 0.chr)
  1253.                 @rl_outstream.write(new[0,1])
  1254.              else
  1255.                 @rl_outstream.write(' ')
  1256.              end
  1257.              @_rl_last_c_pos = 1
  1258.              @_rl_last_v_pos+=1
  1259. -            if (old[ostart]!= ?\0 && new[0] != ?\0)
  1260. +            if (old[ostart,1] != 0.chr && new[0,1] != 0.chr)
  1261.                 old[ostart] = new[0]
  1262.              end
  1263.           end
  1264. @@ -2832,7 +2827,7 @@ module RbReadline
  1265.                 old_offset = ostart
  1266.                 ofd = 0
  1267.                 nfd = 0
  1268. -               while(ofd < omax && old[ostart+ofd] != ?\0 &&
  1269. +               while(ofd < omax && old[ostart+ofd,1] != 0.chr &&
  1270.                    _rl_compare_chars(old, old_offset, new, new_offset))
  1271.  
  1272.                    old_offset = _rl_find_next_mbchar(old, old_offset, 1, MB_FIND_ANY)
  1273. @@ -2845,7 +2840,7 @@ module RbReadline
  1274.        else
  1275.           ofd = 0
  1276.           nfd = 0
  1277. -         while(ofd < omax && old[ostart+ofd] != ?\0 && old[ostart+ofd] == new[nfd])
  1278. +         while(ofd < omax && old[ostart+ofd,1] != 0.chr && old[ostart+ofd] == new[nfd])
  1279.              ofd += 1
  1280.              nfd += 1
  1281.           end
  1282. @@ -2882,7 +2877,7 @@ module RbReadline
  1283.              if (!_rl_compare_chars(old, ostart+ols, new, nls))
  1284.                 break
  1285.              end
  1286. -            if (old[ostart+ols] == ?\x20)
  1287. +            if (old[ostart+ols,1] == " ")
  1288.                 wsatend = false
  1289.              end
  1290.  
  1291. @@ -2893,7 +2888,7 @@ module RbReadline
  1292.           ols = oe - 1         # find last same
  1293.           nls = ne - 1
  1294.           while ((ols > ofd) && (nls > nfd) && old[ostart+ols] == new[nls])
  1295. -            if (old[ostart+ols] != ?\x20 )
  1296. +            if (old[ostart+ols,1] != " ")
  1297.                 wsatend = false
  1298.              end
  1299.              ols-=1
  1300. @@ -2905,14 +2900,14 @@ module RbReadline
  1301.           ols = oe
  1302.           nls = ne
  1303.        elsif (!_rl_compare_chars(old, ostart+ols, new, nls))
  1304. -         if (old[ostart+ols] != ?\0)         # don't step past the NUL
  1305. +         if (old[ostart+ols,1] != 0.chr)         # don't step past the NUL
  1306.              if !@rl_byte_oriented
  1307.                 ols = _rl_find_next_mbchar(old, ostart+ols, 1, MB_FIND_ANY) - ostart
  1308.              else
  1309.                 ols+=1
  1310.              end
  1311.           end
  1312. -         if (new[nls] != ?\0 )
  1313. +         if (new[nls,1] != 0.chr )
  1314.              if !@rl_byte_oriented
  1315.                 nls = _rl_find_next_mbchar(new, nls, 1, MB_FIND_ANY)
  1316.              else
  1317. @@ -3014,12 +3009,12 @@ module RbReadline
  1318.              #   _rl_horizontal_scroll_mode == 1, inserting the characters with
  1319.              #   _rl_term_IC or _rl_term_ic will screw up the screen because of the
  1320.              #   invisible characters.  We need to just draw them.
  1321. -            if (old[ostart+ols,1] != ?\0 && (!@_rl_horizontal_scroll_mode || @_rl_last_c_pos > 0 ||
  1322. +            if (old[ostart+ols,1] != 0.chr && (!@_rl_horizontal_scroll_mode || @_rl_last_c_pos > 0 ||
  1323.                 lendiff <= @prompt_visible_length || current_invis_chars==0))
  1324.  
  1325.                 insert_some_chars(new[nfd..-1], lendiff, col_lendiff)
  1326.                 @_rl_last_c_pos += col_lendiff
  1327. -            elsif ((@rl_byte_oriented) && old[ostart+ols] == ?\0 && lendiff > 0)
  1328. +            elsif ((@rl_byte_oriented) && old[ostart+ols,1] == 0.chr && lendiff > 0)
  1329.                 # At the end of a line the characters do not have to
  1330.                 # be "inserted".  They can just be placed on the screen.
  1331.                 # However, this screws up the rest of this block, which
  1332. @@ -3185,7 +3180,7 @@ module RbReadline
  1333.                 _rl_output_some_chars(@rl_display_prompt,0,pmtlen)
  1334.                 # Make sure we are at column zero even after a newline,
  1335.                 #regardless of the state of terminal output processing.
  1336. -               if (pmtlen < 2 || @rl_display_prompt[prompt_this_line-2] != ?\r)
  1337. +               if (pmtlen < 2 || @rl_display_prompt[prompt_this_line-2] != "\r")
  1338.                    cr()
  1339.                 end
  1340.              end
  1341. @@ -3334,6 +3329,7 @@ module RbReadline
  1342.              @cpos_buffer_position = out
  1343.              lb_linenum = newlines
  1344.           end
  1345. +
  1346.           if (false && meta_char(c))
  1347.              if (!@_rl_output_meta_chars && false)
  1348.                 line[out,4] = "\\%03o" % c.ord
  1349. @@ -3393,7 +3389,7 @@ module RbReadline
  1350.                 @_rl_wrapped_line[newlines] = _rl_wrapped_multicolumn
  1351.                 lpos = 0
  1352.              end
  1353. -            line[out] = ctrl_char(c) ? (c[0].ord|0x40).chr.upcase : '?'
  1354. +            line[out] = ctrl_char(c) ? (c[0].ord|0x40).chr.upcase : '?' # c[0].ord magically works for 1.9.1 and 1.8 both!
  1355.              out += 1
  1356.              lpos+=1
  1357.              if (lpos >= @_rl_screenwidth)
  1358. @@ -3468,7 +3464,7 @@ module RbReadline
  1359.           end
  1360.        end
  1361.  
  1362. -      line[out] = 0.chr
  1363. +      line[out,1] = 0.chr
  1364.  
  1365.        if (@cpos_buffer_position < 0)
  1366.           @cpos_buffer_position = out
  1367. @@ -4293,7 +4289,7 @@ module RbReadline
  1368.           if(map.keys.detect{|x| x =~ /^#{Regexp.escape(key)}/})
  1369.              key += _rl_subseq_getchar(key)
  1370.              return _rl_dispatch_subseq(key,map,got_subseq)
  1371. -         elsif(key.length>1 && key[1] < ?\x7F)
  1372. +         elsif(key.length>1 && key[1].ord < 0x7f)
  1373.              _rl_abort_internal()
  1374.              return -1
  1375.           else
  1376. @@ -5637,7 +5633,7 @@ module RbReadline
  1377.        # If the cursor is the only thing on an otherwise-blank last line,
  1378.        #   compensate so we don't print an extra CRLF.
  1379.        if (@_rl_vis_botlin && @_rl_last_c_pos == 0 &&
  1380. -         @visible_line[@vis_lbreaks[@_rl_vis_botlin]] == ?\0 )
  1381. +         @visible_line[@vis_lbreaks[@_rl_vis_botlin],1] == 0.chr )
  1382.           @_rl_vis_botlin-=1
  1383.           full_lines = true
  1384.        end
  1385. @@ -6120,7 +6116,7 @@ module RbReadline
  1386.              #   to quote anything in single quotes, especially not the closing
  1387.              #   quote.  If you don't like this, take out the check on the value
  1388.              #   of quote_char.
  1389. -            if (quote_char != "'" && @rl_line_buffer[scan] == ?\\)
  1390. +            if (quote_char != "'" && @rl_line_buffer[scan] == "\\")
  1391.                 pass_next = true
  1392.                 found_quote |= RL_QF_BACKSLASH
  1393.                 next
  1394. @@ -6506,10 +6502,10 @@ module RbReadline
  1395.              slen = s.length
  1396.              tlen = to_print.length
  1397.              new_full_pathname = s.dup
  1398. -            if (s[-1] == ?/ )
  1399. +            if (s[-1,1] == '/' )
  1400.                 slen-=1
  1401.              else
  1402. -               new_full_pathname[slen] = ?/
  1403. +               new_full_pathname[slen,1] = '/'
  1404.              end
  1405.              new_full_pathname[slen .. -1] = '/' + to_print
  1406.  
  1407. @@ -6575,7 +6571,7 @@ module RbReadline
  1408.     def fnwidth(string)
  1409.        left = string.length + 1
  1410.        width = pos = 0
  1411. -      while (string[pos] && string[pos] != ?\0)
  1412. +      while (string[pos] && string[pos,1] != 0.chr)
  1413.           if (ctrl_char(string[0,1]) || string[0,1] == RUBOUT)
  1414.              width += 2
  1415.              pos+=1
  1416. @@ -6856,7 +6852,7 @@ module RbReadline
  1417.  
  1418.     def save_tty_chars()
  1419.        @_rl_last_tty_chars = @_rl_tty_chars
  1420. -      h = Hash[*`stty -a `.scan(/(\w+) = ([^;]+);/).flatten]
  1421. +      h = Hash[*`stty -a`.scan(/(\w+) = ([^;]+);/).flatten]
  1422.        h.each {|k,v| v.gsub!(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
  1423.        @_rl_tty_chars.t_erase = h['erase']
  1424.        @_rl_tty_chars.t_kill = h['kill']
  1425. @@ -6874,7 +6870,7 @@ module RbReadline
  1426.        @_rl_tty_chars.t_werase = h['werase']
  1427.        @_rl_tty_chars.t_lnext = h['lnext']
  1428.        @_rl_tty_chars.t_status = -1
  1429. -      @otio = `stty -g `
  1430. +      @otio = `stty -g`
  1431.     end
  1432.  
  1433.     def _rl_bind_tty_special_chars(kmap)
  1434. @@ -6885,7 +6881,7 @@ module RbReadline
  1435.     end
  1436.  
  1437.     def prepare_terminal_settings(meta_flag)
  1438. -      @readline_echoing_p = (`stty -a `.scan(/-*echo\b/).first == 'echo')
  1439. +      @readline_echoing_p = (`stty -a`.scan(/-*echo\b/).first == 'echo')
  1440.  
  1441.        # First, the basic settings to put us into character-at-a-time, no-echo
  1442.        #   input mode.
  1443. @@ -6894,7 +6890,7 @@ module RbReadline
  1444.        # If this terminal doesn't care how the 8th bit is used, then we can
  1445.        #   use it for the meta-key.  If only one of even or odd parity is
  1446.        #  specified, then the terminal is using parity, and we cannot.
  1447. -      if (`stty -a `.scan(/-parenb\b/).first == '-parenb')
  1448. +      if (`stty -a`.scan(/-parenb\b/).first == '-parenb')
  1449.           setting << " pass8"
  1450.        end
  1451.  
  1452. @@ -6905,7 +6901,7 @@ module RbReadline
  1453.  
  1454.        #setting << " -isig"
  1455.  
  1456. -      `stty #{setting} `
  1457. +      `stty #{setting}`
  1458.     end
  1459.  
  1460.     def _rl_control_keypad(on)
  1461. @@ -6992,7 +6988,7 @@ module RbReadline
  1462.        @rl_outstream.flush
  1463.  
  1464.        # restore terminal setting
  1465. -      `stty #{@otio} `
  1466. +      `stty #{@otio}`
  1467.  
  1468.        @terminal_prepped = false
  1469.        rl_unsetstate(RL_STATE_TERMPREPPED)
  1470. @@ -8333,9 +8329,9 @@ module RbReadline
  1471.                 # This is clumsy.  Avoid putting in a double slash if point
  1472.                 # is at the end of the line and the previous character is a
  1473.                 # slash.
  1474. -               if (@rl_point>0 && @rl_line_buffer[@rl_point] == ?\0 && @rl_line_buffer[@rl_point - 1] == ?/ )
  1475. +               if (@rl_point>0 && @rl_line_buffer[@rl_point,1] == 0.chr && @rl_line_buffer[@rl_point - 1,1] == '/' )
  1476.  
  1477. -               elsif (@rl_line_buffer[@rl_point] != ?/ )
  1478. +               elsif (@rl_line_buffer[@rl_point,1] != '/' )
  1479.                    rl_insert_text("/")
  1480.                 end
  1481.              end
  1482. @@ -8410,7 +8406,7 @@ module RbReadline
  1483.           #else
  1484.           # If we have to turn on insert-mode, then do so.
  1485.           if (@_rl_term_im)
  1486. -            @_rl_out_stream.write(@_rl_term_im)
  1487. +               @_rl_out_stream.write(@_rl_term_im)
  1488.           end
  1489.           # If there is a special command for inserting characters, then
  1490.           # use that first to open up the space.
  1491. @@ -8558,7 +8554,7 @@ module RbReadline
  1492.     # if an invalid multibyte sequence was encountered. It returns (size_t)(-2)
  1493.     # if it couldn't parse a complete  multibyte character.
  1494.     def _rl_get_char_len(src)
  1495. -      return 0 if src[0,1] == ?\0 || src.length==0
  1496. +      return 0 if src[0,1] == 0.chr || src.length==0
  1497.        case @encoding
  1498.        when 'E'
  1499.           len = src.scan(/./me)[0].to_s.length
  1500.  
  1501. commit 0251f21dc99d6199e8eba4edd5918b2cabeec3cb
  1502. Author: HD Moore <[email protected]>
  1503. Date:   Mon Nov 16 18:30:07 2009 +0000
  1504.  
  1505.     See #509
  1506.    
  1507.    
  1508.     git-svn-id: file:///home/svn/framework3/trunk@7536 4d416f70-5f16-0410-b530-b9f4589650da
  1509.  
  1510. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  1511. index 8d5af6a..fad8644 100644
  1512. --- a/lib/rbreadline.rb
  1513. +++ b/lib/rbreadline.rb
  1514. @@ -2102,12 +2102,8 @@ module RbReadline
  1515.     #   otherwise errno is returned.
  1516.     def rl_read_init_file(filename)
  1517.  
  1518. -   #
  1519. -   # This code is too problematic at the moment
  1520. -   # Just hardcode things and move on
  1521. -   #
  1522. -      return 0
  1523.  
  1524. +=begin
  1525.        # Default the filename.
  1526.        filename ||= @last_readline_init_file
  1527.        filename ||= ENV["INPUTRC"]
  1528. @@ -2124,7 +2120,13 @@ module RbReadline
  1529.           return 0 if (_rl_read_init_file(filename, 0) == 0)
  1530.           filename = "~/_inputrc"
  1531.        end
  1532. -      return (_rl_read_init_file(filename, 0))
  1533. +      return (_rl_read_init_file(filename, 0))
  1534. +=end
  1535. +      #
  1536. +      # This code is too problematic at the moment
  1537. +      # Just hardcode things and move on
  1538. +      #
  1539. +      return 0
  1540.     end
  1541.  
  1542.     def _rl_read_init_file(filename, include_level)
  1543.  
  1544. commit 500eb85a58d6d54de0a2f3a0ac12ad77074c4754
  1545. Author: HD Moore <[email protected]>
  1546. Date:   Thu Nov 12 06:31:50 2009 +0000
  1547.  
  1548.     Fix a typo in ^L support
  1549.    
  1550.    
  1551.     git-svn-id: file:///home/svn/framework3/trunk@7476 4d416f70-5f16-0410-b530-b9f4589650da
  1552.  
  1553. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  1554. index c135415..8d5af6a 100644
  1555. --- a/lib/rbreadline.rb
  1556. +++ b/lib/rbreadline.rb
  1557. @@ -4575,7 +4575,7 @@ module RbReadline
  1558.  
  1559.     def _rl_clear_screen()
  1560.        if (@_rl_term_clrpag)
  1561. -         @rl_outstream.write(@_rl_tirberm_clrpag)
  1562. +         @rl_outstream.write(@_rl_term_clrpag)
  1563.        else
  1564.           rl_crlf()
  1565.        end
  1566.  
  1567. commit 48fb44560901b9ae9896ee0cf16cb3f91fcd487c
  1568. Author: HD Moore <[email protected]>
  1569. Date:   Fri Nov 6 15:27:13 2009 +0000
  1570.  
  1571.     Fixes #446. Oddly enough, stty on cygwin uses term escapes in stderr as well as stdout to set the console mode. This is going to reopen #426 (errors when stdin isnt a tty). A better solution for #426 is going to be checking for stdin = terminal and ignoring readline entirely
  1572.    
  1573.    
  1574.     git-svn-id: file:///home/svn/framework3/trunk@7374 4d416f70-5f16-0410-b530-b9f4589650da
  1575.  
  1576. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  1577. index bdc8fb9..c135415 100644
  1578. --- a/lib/rbreadline.rb
  1579. +++ b/lib/rbreadline.rb
  1580. @@ -9,10 +9,10 @@
  1581.  =begin
  1582.  Copyright (c) 2009, Park Heesob
  1583.  All rights reserved.
  1584. -
  1585. +
  1586.  Redistribution and use in source and binary forms, with or without
  1587.  modification, are permitted provided that the following conditions are met:
  1588. -
  1589. +
  1590.  * Redistributions of source code must retain the above copyright notice, this
  1591.    list of conditions and the following disclaimer.
  1592.  * Redistributions in binary form must reproduce the above copyright notice
  1593. @@ -21,7 +21,7 @@ modification, are permitted provided that the following conditions are met:
  1594.  * Neither the name of Park Heesob nor the names of its contributors
  1595.    may be used to endorse or promote products derived from this software
  1596.    without specific prior written permission.
  1597. -
  1598. +
  1599.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  1600.  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1601.  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  1602. @@ -1877,7 +1877,7 @@ module RbReadline
  1603.           @_rl_screenwidth = wc
  1604.           @_rl_screenheight = wr
  1605.        else
  1606. -         wr,wc = `stty size 2>/dev/null`.split(' ').map{|x| x.to_i}
  1607. +         wr,wc = `stty size `.split(' ').map{|x| x.to_i}
  1608.           @_rl_screenwidth = wc
  1609.           @_rl_screenheight = wr
  1610.           if ignore_env==0 && ENV['LINES']
  1611. @@ -2070,7 +2070,7 @@ module RbReadline
  1612.     # New public way to set the system default editing chars to their readline
  1613.     #   equivalents.
  1614.     def rl_tty_set_default_bindings(kmap)
  1615. -      h = Hash[*`stty -a 2>/dev/null`.scan(/(\w+) = ([^;]+);/).flatten]
  1616. +      h = Hash[*`stty -a `.scan(/(\w+) = ([^;]+);/).flatten]
  1617.        h.each {|k,v| v.gsub!(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
  1618.        kmap[h['erase']] = :rl_rubout
  1619.        kmap[h['kill']] = :rl_unix_line_discard
  1620. @@ -2101,13 +2101,13 @@ module RbReadline
  1621.     #   If the file existed and could be opened and read, 0 is returned,
  1622.     #   otherwise errno is returned.
  1623.     def rl_read_init_file(filename)
  1624. -  
  1625. +
  1626.     #
  1627.     # This code is too problematic at the moment
  1628.     # Just hardcode things and move on
  1629.     #
  1630.        return 0
  1631. -  
  1632. +
  1633.        # Default the filename.
  1634.        filename ||= @last_readline_init_file
  1635.        filename ||= ENV["INPUTRC"]
  1636. @@ -2187,7 +2187,7 @@ module RbReadline
  1637.           if args[5..-1] == "emacs"
  1638.              mode = @emacs_mode
  1639.           elsif args[5..-1] == "vi"
  1640. -            $stderr.puts "*** Warning: vi-mode not supported, switching back to emacs mode"         
  1641. +            $stderr.puts "*** Warning: vi-mode not supported, switching back to emacs mode"
  1642.              mode = @emacs_mode
  1643.           else
  1644.              mode = @no_mode
  1645. @@ -2338,7 +2338,7 @@ module RbReadline
  1646.        when "editing-mode"
  1647.           case value
  1648.           when "vi"
  1649. -            $stderr.puts "*** Warning: vi editing-mode not supported, switching back to emacs"              
  1650. +            $stderr.puts "*** Warning: vi editing-mode not supported, switching back to emacs"
  1651.              #@_rl_keymap = @vi_insertion_keymap
  1652.              #@rl_editing_mode = @vi_mode
  1653.              @_rl_keymap = @emacs_standard_keymap
  1654. @@ -2442,7 +2442,7 @@ module RbReadline
  1655.           rl_bind_key(key, rl_named_function(funname))
  1656.        rescue ::Exception => e
  1657.           $stderr.puts "[-] RbReadline error parsing inputrc: #{e} '#{key}'"
  1658. -     end  
  1659. +     end
  1660.  
  1661.        0
  1662.     end
  1663. @@ -4039,7 +4039,7 @@ module RbReadline
  1664.        when -1
  1665.           if (cxt.search_string_index == 0)
  1666.             # XXX: This variable is not defined
  1667. -            # if (last_isearch_string)
  1668. +            # if (last_isearch_string)
  1669.              if(false)
  1670.                cxt.search_string_size = 64 + last_isearch_string_len
  1671.                 cxt.search_string = last_isearch_string.dup
  1672. @@ -6854,7 +6854,7 @@ module RbReadline
  1673.  
  1674.     def save_tty_chars()
  1675.        @_rl_last_tty_chars = @_rl_tty_chars
  1676. -      h = Hash[*`stty -a 2>/dev/null`.scan(/(\w+) = ([^;]+);/).flatten]
  1677. +      h = Hash[*`stty -a `.scan(/(\w+) = ([^;]+);/).flatten]
  1678.        h.each {|k,v| v.gsub!(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
  1679.        @_rl_tty_chars.t_erase = h['erase']
  1680.        @_rl_tty_chars.t_kill = h['kill']
  1681. @@ -6872,7 +6872,7 @@ module RbReadline
  1682.        @_rl_tty_chars.t_werase = h['werase']
  1683.        @_rl_tty_chars.t_lnext = h['lnext']
  1684.        @_rl_tty_chars.t_status = -1
  1685. -      @otio = `stty -g 2>/dev/null`
  1686. +      @otio = `stty -g `
  1687.     end
  1688.  
  1689.     def _rl_bind_tty_special_chars(kmap)
  1690. @@ -6883,7 +6883,7 @@ module RbReadline
  1691.     end
  1692.  
  1693.     def prepare_terminal_settings(meta_flag)
  1694. -      @readline_echoing_p = (`stty -a 2>/dev/null`.scan(/-*echo\b/).first == 'echo')
  1695. +      @readline_echoing_p = (`stty -a `.scan(/-*echo\b/).first == 'echo')
  1696.  
  1697.        # First, the basic settings to put us into character-at-a-time, no-echo
  1698.        #   input mode.
  1699. @@ -6892,7 +6892,7 @@ module RbReadline
  1700.        # If this terminal doesn't care how the 8th bit is used, then we can
  1701.        #   use it for the meta-key.  If only one of even or odd parity is
  1702.        #  specified, then the terminal is using parity, and we cannot.
  1703. -      if (`stty -a 2>/dev/null`.scan(/-parenb\b/).first == '-parenb')
  1704. +      if (`stty -a `.scan(/-parenb\b/).first == '-parenb')
  1705.           setting << " pass8"
  1706.        end
  1707.  
  1708. @@ -6903,7 +6903,7 @@ module RbReadline
  1709.  
  1710.        #setting << " -isig"
  1711.  
  1712. -      `stty #{setting} 2>/dev/null`
  1713. +      `stty #{setting} `
  1714.     end
  1715.  
  1716.     def _rl_control_keypad(on)
  1717. @@ -6990,7 +6990,7 @@ module RbReadline
  1718.        @rl_outstream.flush
  1719.  
  1720.        # restore terminal setting
  1721. -      `stty #{@otio} 2>/dev/null`
  1722. +      `stty #{@otio} `
  1723.  
  1724.        @terminal_prepped = false
  1725.        rl_unsetstate(RL_STATE_TERMPREPPED)
  1726. @@ -8713,4 +8713,5 @@ module RbReadline
  1727.    end
  1728.    private :no_terminal?
  1729.  
  1730. -end
  1731. +end
  1732. +
  1733.  
  1734. commit 8377077297e46a9ca095e77b0d7bc5b4caf7951a
  1735. Author: HD Moore <[email protected]>
  1736. Date:   Wed Oct 28 19:37:19 2009 +0000
  1737.  
  1738.     Huide the error output from stty execs. Fixes #426
  1739.    
  1740.    
  1741.     git-svn-id: file:///home/svn/framework3/trunk@7299 4d416f70-5f16-0410-b530-b9f4589650da
  1742.  
  1743. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  1744. index c4bf6d3..bdc8fb9 100644
  1745. --- a/lib/rbreadline.rb
  1746. +++ b/lib/rbreadline.rb
  1747. @@ -1877,7 +1877,7 @@ module RbReadline
  1748.           @_rl_screenwidth = wc
  1749.           @_rl_screenheight = wr
  1750.        else
  1751. -         wr,wc = `stty size`.split(' ').map{|x| x.to_i}
  1752. +         wr,wc = `stty size 2>/dev/null`.split(' ').map{|x| x.to_i}
  1753.           @_rl_screenwidth = wc
  1754.           @_rl_screenheight = wr
  1755.           if ignore_env==0 && ENV['LINES']
  1756. @@ -2070,7 +2070,7 @@ module RbReadline
  1757.     # New public way to set the system default editing chars to their readline
  1758.     #   equivalents.
  1759.     def rl_tty_set_default_bindings(kmap)
  1760. -      h = Hash[*`stty -a`.scan(/(\w+) = ([^;]+);/).flatten]
  1761. +      h = Hash[*`stty -a 2>/dev/null`.scan(/(\w+) = ([^;]+);/).flatten]
  1762.        h.each {|k,v| v.gsub!(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
  1763.        kmap[h['erase']] = :rl_rubout
  1764.        kmap[h['kill']] = :rl_unix_line_discard
  1765. @@ -6854,7 +6854,7 @@ module RbReadline
  1766.  
  1767.     def save_tty_chars()
  1768.        @_rl_last_tty_chars = @_rl_tty_chars
  1769. -      h = Hash[*`stty -a`.scan(/(\w+) = ([^;]+);/).flatten]
  1770. +      h = Hash[*`stty -a 2>/dev/null`.scan(/(\w+) = ([^;]+);/).flatten]
  1771.        h.each {|k,v| v.gsub!(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
  1772.        @_rl_tty_chars.t_erase = h['erase']
  1773.        @_rl_tty_chars.t_kill = h['kill']
  1774. @@ -6872,7 +6872,7 @@ module RbReadline
  1775.        @_rl_tty_chars.t_werase = h['werase']
  1776.        @_rl_tty_chars.t_lnext = h['lnext']
  1777.        @_rl_tty_chars.t_status = -1
  1778. -      @otio = `stty -g`
  1779. +      @otio = `stty -g 2>/dev/null`
  1780.     end
  1781.  
  1782.     def _rl_bind_tty_special_chars(kmap)
  1783. @@ -6883,7 +6883,7 @@ module RbReadline
  1784.     end
  1785.  
  1786.     def prepare_terminal_settings(meta_flag)
  1787. -      @readline_echoing_p = (`stty -a`.scan(/-*echo\b/).first == 'echo')
  1788. +      @readline_echoing_p = (`stty -a 2>/dev/null`.scan(/-*echo\b/).first == 'echo')
  1789.  
  1790.        # First, the basic settings to put us into character-at-a-time, no-echo
  1791.        #   input mode.
  1792. @@ -6892,7 +6892,7 @@ module RbReadline
  1793.        # If this terminal doesn't care how the 8th bit is used, then we can
  1794.        #   use it for the meta-key.  If only one of even or odd parity is
  1795.        #  specified, then the terminal is using parity, and we cannot.
  1796. -      if (`stty -a`.scan(/-parenb\b/).first == '-parenb')
  1797. +      if (`stty -a 2>/dev/null`.scan(/-parenb\b/).first == '-parenb')
  1798.           setting << " pass8"
  1799.        end
  1800.  
  1801. @@ -6903,7 +6903,7 @@ module RbReadline
  1802.  
  1803.        #setting << " -isig"
  1804.  
  1805. -      `stty #{setting}`
  1806. +      `stty #{setting} 2>/dev/null`
  1807.     end
  1808.  
  1809.     def _rl_control_keypad(on)
  1810. @@ -6990,7 +6990,7 @@ module RbReadline
  1811.        @rl_outstream.flush
  1812.  
  1813.        # restore terminal setting
  1814. -      `stty #{@otio}`
  1815. +      `stty #{@otio} 2>/dev/null`
  1816.  
  1817.        @terminal_prepped = false
  1818.        rl_unsetstate(RL_STATE_TERMPREPPED)
  1819.  
  1820. commit 54437321eb9ee083a5da9c7f0e5dea8f8f0b5f53
  1821. Author: HD Moore <[email protected]>
  1822. Date:   Fri Oct 2 00:03:55 2009 +0000
  1823.  
  1824.     Disable inputrc processing, its not deterministic and will be impossible to support as implemented.
  1825.    
  1826.    
  1827.     git-svn-id: file:///home/svn/framework3/trunk@7111 4d416f70-5f16-0410-b530-b9f4589650da
  1828.  
  1829. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  1830. index 8d301a5..c4bf6d3 100644
  1831. --- a/lib/rbreadline.rb
  1832. +++ b/lib/rbreadline.rb
  1833. @@ -2101,6 +2101,13 @@ module RbReadline
  1834.     #   If the file existed and could be opened and read, 0 is returned,
  1835.     #   otherwise errno is returned.
  1836.     def rl_read_init_file(filename)
  1837. +  
  1838. +   #
  1839. +   # This code is too problematic at the moment
  1840. +   # Just hardcode things and move on
  1841. +   #
  1842. +      return 0
  1843. +  
  1844.        # Default the filename.
  1845.        filename ||= @last_readline_init_file
  1846.        filename ||= ENV["INPUTRC"]
  1847.  
  1848. commit 4e244d654d7be556ac7df88e519e7cce33cd9470
  1849. Author: HD Moore <[email protected]>
  1850. Date:   Thu Oct 1 21:02:50 2009 +0000
  1851.  
  1852.     Catch parsing errors in the inputrc file
  1853.    
  1854.    
  1855.     git-svn-id: file:///home/svn/framework3/trunk@7110 4d416f70-5f16-0410-b530-b9f4589650da
  1856.  
  1857. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  1858. index 2f849b8..8d301a5 100644
  1859. --- a/lib/rbreadline.rb
  1860. +++ b/lib/rbreadline.rb
  1861. @@ -2429,8 +2429,13 @@ module RbReadline
  1862.        end
  1863.  
  1864.        key,funname = string.split(/\s*:\s*/)
  1865. -      key = instance_eval(key)
  1866. -      rl_bind_key(key, rl_named_function(funname))
  1867. +
  1868. +      begin
  1869. +         key = instance_eval(key)
  1870. +         rl_bind_key(key, rl_named_function(funname))
  1871. +      rescue ::Exception => e
  1872. +         $stderr.puts "[-] RbReadline error parsing inputrc: #{e} '#{key}'"
  1873. +     end  
  1874.  
  1875.        0
  1876.     end
  1877.  
  1878. commit b4d6ba117033bd8bd841c5f0aa0e637fa204eaf8
  1879. Author: HD Moore <[email protected]>
  1880. Date:   Thu Oct 1 16:47:48 2009 +0000
  1881.  
  1882.     Check for nil before trying to replace a line
  1883.    
  1884.     git-svn-id: file:///home/svn/framework3/trunk@7108 4d416f70-5f16-0410-b530-b9f4589650da
  1885.  
  1886. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  1887. index f8774c2..2f849b8 100644
  1888. --- a/lib/rbreadline.rb
  1889. +++ b/lib/rbreadline.rb
  1890. @@ -4184,7 +4184,9 @@ module RbReadline
  1891.        #   the location.
  1892.        if (cxt.sflags & SF_FOUND)!=0
  1893.           cxt.prev_line_found = cxt.lines[cxt.history_pos]
  1894. -         rl_replace_line(cxt.lines[cxt.history_pos], false)
  1895. +         if (cxt.prev_line_found)
  1896. +           rl_replace_line(cxt.lines[cxt.history_pos], false)
  1897. +         end
  1898.           @rl_point = cxt.sline_index
  1899.           cxt.last_found_line = cxt.history_pos
  1900.           rl_display_search(cxt.search_string, (cxt.sflags & SF_REVERSE)!=0, (cxt.history_pos == cxt.save_line) ? -1 : cxt.history_pos)
  1901.  
  1902. commit 92359fecc542504c2456566bb52a9cca6c98ef3c
  1903. Author: HD Moore <[email protected]>
  1904. Date:   Thu Oct 1 16:27:18 2009 +0000
  1905.  
  1906.     Fix some 1.9 compat issues, wrap missing methods, extend to the cxt structure to include mb (used elsewhere)
  1907.    
  1908.    
  1909.     git-svn-id: file:///home/svn/framework3/trunk@7107 4d416f70-5f16-0410-b530-b9f4589650da
  1910.  
  1911. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  1912. index 792fc55..f8774c2 100644
  1913. --- a/lib/rbreadline.rb
  1914. +++ b/lib/rbreadline.rb
  1915. @@ -2414,7 +2414,7 @@ module RbReadline
  1916.     def rl_parse_and_bind(string)
  1917.  
  1918.        # If this is a parser directive, act on it.
  1919. -      if (string[0] == ?$)
  1920. +      if (string[0,1] == ?$)
  1921.           handle_parser_directive(string[1..-1])
  1922.           return 0
  1923.        end
  1924. @@ -3000,7 +3000,7 @@ module RbReadline
  1925.              #   _rl_horizontal_scroll_mode == 1, inserting the characters with
  1926.              #   _rl_term_IC or _rl_term_ic will screw up the screen because of the
  1927.              #   invisible characters.  We need to just draw them.
  1928. -            if (old[ostart+ols] != ?\0 && (!@_rl_horizontal_scroll_mode || @_rl_last_c_pos > 0 ||
  1929. +            if (old[ostart+ols,1] != ?\0 && (!@_rl_horizontal_scroll_mode || @_rl_last_c_pos > 0 ||
  1930.                 lendiff <= @prompt_visible_length || current_invis_chars==0))
  1931.  
  1932.                 insert_some_chars(new[nfd..-1], lendiff, col_lendiff)
  1933. @@ -3119,7 +3119,7 @@ module RbReadline
  1934.        # If someone thought that the redisplay was handled, but the currently
  1935.        #   visible line has a different modification state than the one about
  1936.        #   to become visible, then correct the caller's misconception.
  1937. -      if (@visible_line[0] != @invisible_line[0])
  1938. +      if (@visible_line[0,1] != @invisible_line[0,1])
  1939.           @rl_display_fixed = false
  1940.        end
  1941.  
  1942. @@ -3277,7 +3277,7 @@ module RbReadline
  1943.              wc = @rl_line_buffer[0,@rl_end].scan(/./mu)[0]
  1944.              wc_bytes = wc ? wc.length : 1
  1945.           when 'X'
  1946. -            wc = @rl_line_buffer[0,@rl_end].force_encoding(@encoding_name)[0]
  1947. +            wc = @rl_line_buffer[0,@rl_end].force_encoding(@encoding_name)[0,1]
  1948.              wc_bytes = wc ? wc.bytesize : 1
  1949.           end
  1950.        else
  1951. @@ -3445,7 +3445,7 @@ module RbReadline
  1952.                 wc = @rl_line_buffer[_in,@rl_end - _in].scan(/./mu)[0]
  1953.                 wc_bytes = wc ? wc.length : 1
  1954.              when 'X'
  1955. -               wc = @rl_line_buffer[_in,@rl_end - _in].force_encoding(@encoding_name)[0]
  1956. +               wc = @rl_line_buffer[_in,@rl_end - _in].force_encoding(@encoding_name)[0,1]
  1957.                 wc_bytes = wc ? wc.bytesize : 1
  1958.              end
  1959.  
  1960. @@ -3812,7 +3812,9 @@ module RbReadline
  1961.        when 'E'
  1962.           str[start ... _end].scan(/./me).each {|s| width += s.length }
  1963.        when 'X'
  1964. -         str[start ... _end].force_encoding(@encoding_name).codepoints.each {|s| width += s > 0x1000 ? 2 : 1 }
  1965. +         tmp = str[start ... _end]
  1966. +        return 0 if not tmp
  1967. +        tmp.force_encoding(@encoding_name).codepoints.each {|s| width += s > 0x1000 ? 2 : 1 }
  1968.        end
  1969.        width
  1970.     end
  1971. @@ -3987,7 +3989,7 @@ module RbReadline
  1972.        #   variable isearch-terminators) are used to terminate the search but
  1973.        #   not subsequently execute the character as a command.  The default
  1974.        #   value is "\033\012" (ESC and C-J).
  1975. -      if (cxt.search_terminators.include?(cxt.lastc))
  1976. +      if (cxt.lastc.class == ::String and cxt.search_terminators.include?(cxt.lastc))
  1977.           # ESC still terminates the search, but if there is pending
  1978.           #input or if input arrives within 0.1 seconds (on systems
  1979.           #with select(2)) it is used as a prefix character
  1980. @@ -4024,8 +4026,10 @@ module RbReadline
  1981.           # search again
  1982.        when -1
  1983.           if (cxt.search_string_index == 0)
  1984. -            if (last_isearch_string)
  1985. -               cxt.search_string_size = 64 + last_isearch_string_len
  1986. +           # XXX: This variable is not defined
  1987. +            # if (last_isearch_string)
  1988. +            if(false)
  1989. +              cxt.search_string_size = 64 + last_isearch_string_len
  1990.                 cxt.search_string = last_isearch_string.dup
  1991.                 cxt.search_string_index = last_isearch_string_len
  1992.                 rl_display_search(cxt.search_string, (cxt.sflags & SF_REVERSE)!=0, -1)
  1993. @@ -7089,7 +7093,7 @@ module RbReadline
  1994.     def _rl_scxt_alloc(type, flags)
  1995.        cxt = Struct.new(:type,:sflags,:search_string,:search_string_index,:search_string_size,:lines,:allocated_line,
  1996.        :hlen,:hindex,:save_point,:save_mark,:save_line,:last_found_line,:prev_line_found,:save_undo_list,:history_pos,
  1997. -      :direction,:lastc,:sline,:sline_len,:sline_index,:search_terminators).new
  1998. +      :direction,:lastc,:sline,:sline_len,:sline_index,:search_terminators, :mb).new
  1999.  
  2000.        cxt.type = type
  2001.        cxt.sflags = flags
  2002. @@ -8538,7 +8542,7 @@ module RbReadline
  2003.     # if an invalid multibyte sequence was encountered. It returns (size_t)(-2)
  2004.     # if it couldn't parse a complete  multibyte character.
  2005.     def _rl_get_char_len(src)
  2006. -      return 0 if src[0] == ?\0 || src.length==0
  2007. +      return 0 if src[0,1] == ?\0 || src.length==0
  2008.        case @encoding
  2009.        when 'E'
  2010.           len = src.scan(/./me)[0].to_s.length
  2011. @@ -8548,7 +8552,7 @@ module RbReadline
  2012.           len = src.scan(/./mu)[0].to_s.length
  2013.        when 'X'
  2014.           src = src.dup.force_encoding(@encoding_name)
  2015. -         len = src.valid_encoding? ? src[0].bytesize : 0
  2016. +         len = src.valid_encoding? ? src[0,1].bytesize : 0
  2017.        else
  2018.           len = 1
  2019.        end
  2020.  
  2021. commit 3c79917fb0e9dd38baf5303c560a5c1a0aca514f
  2022. Author: HD Moore <[email protected]>
  2023. Date:   Wed Sep 30 20:36:04 2009 +0000
  2024.  
  2025.     Disable vi editing-mode, as its not completely implemented
  2026.    
  2027.    
  2028.     git-svn-id: file:///home/svn/framework3/trunk@7097 4d416f70-5f16-0410-b530-b9f4589650da
  2029.  
  2030. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  2031. index a4dd790..792fc55 100644
  2032. --- a/lib/rbreadline.rb
  2033. +++ b/lib/rbreadline.rb
  2034. @@ -624,7 +624,8 @@ module RbReadline
  2035.        "\C-x" => :rl_insert  ,
  2036.        "\C-y" => :rl_yank  ,
  2037.        "\C-z" => :rl_insert  ,
  2038. -      "\C-[" => :rl_vi_movement_mode  ,
  2039. +#      "\C-[" => :rl_vi_movement_mode,
  2040. +# XXX: NOT IMPLEMENTED
  2041.        "\C-\\" => :rl_insert  ,
  2042.        "\C-]" => :rl_insert  ,
  2043.        "\C-^" => :rl_insert  ,
  2044. @@ -2179,7 +2180,8 @@ module RbReadline
  2045.           if args[5..-1] == "emacs"
  2046.              mode = @emacs_mode
  2047.           elsif args[5..-1] == "vi"
  2048. -            mode = @vi_mode
  2049. +            $stderr.puts "*** Warning: vi-mode not supported, switching back to emacs mode"         
  2050. +            mode = @emacs_mode
  2051.           else
  2052.              mode = @no_mode
  2053.           end
  2054. @@ -2329,8 +2331,11 @@ module RbReadline
  2055.        when "editing-mode"
  2056.           case value
  2057.           when "vi"
  2058. -            @_rl_keymap = @vi_insertion_keymap
  2059. -            @rl_editing_mode = @vi_mode
  2060. +            $stderr.puts "*** Warning: vi editing-mode not supported, switching back to emacs"              
  2061. +            #@_rl_keymap = @vi_insertion_keymap
  2062. +            #@rl_editing_mode = @vi_mode
  2063. +            @_rl_keymap = @emacs_standard_keymap
  2064. +            @rl_editing_mode = @emacs_mode
  2065.           when "emacs"
  2066.              @_rl_keymap = @emacs_standard_keymap
  2067.              @rl_editing_mode = @emacs_mode
  2068.  
  2069. commit 0c802ea3e1544e1783ca9a7bafd30343f36214bb
  2070. Author: HD Moore <[email protected]>
  2071. Date:   Wed Sep 30 03:25:39 2009 +0000
  2072.  
  2073.     Fixes #345. Adds a more stringent check for ::Encoding class being defined, should work around false positives with getbyte
  2074.    
  2075.    
  2076.     git-svn-id: file:///home/svn/framework3/trunk@7095 4d416f70-5f16-0410-b530-b9f4589650da
  2077.  
  2078. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  2079. index b96cee5..a4dd790 100644
  2080. --- a/lib/rbreadline.rb
  2081. +++ b/lib/rbreadline.rb
  2082. @@ -4428,7 +4428,7 @@ module RbReadline
  2083.        end
  2084.     end
  2085.  
  2086. -   if defined? ''.getbyte
  2087. +  if(Object.const_defined?('Encoding') and Encoding.respond_to?('default_external'))
  2088.        @encoding = "X"      # ruby 1.9.x or greater
  2089.        @encoding_name = Encoding.default_external.to_s
  2090.     end
  2091.  
  2092. commit 3500745d70535b3d0141a59476c0b49c33eec6da
  2093. Author: HD Moore <[email protected]>
  2094. Date:   Tue Sep 29 03:42:26 2009 +0000
  2095.  
  2096.     Revert previous changes, easier to just include infocmp and terminfo
  2097.    
  2098.    
  2099.     git-svn-id: file:///home/svn/framework3/trunk@7092 4d416f70-5f16-0410-b530-b9f4589650da
  2100.  
  2101. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  2102. index 2231c81..b96cee5 100644
  2103. --- a/lib/rbreadline.rb
  2104. +++ b/lib/rbreadline.rb
  2105. @@ -1822,10 +1822,7 @@ module RbReadline
  2106.  
  2107.     def get_term_capabilities(buffer)
  2108.        hash = {}
  2109. -      buff = IO.popen('infocmp -C 2>/dev/null').read
  2110. -     if(buff and not buff.empty? and buff !~ /couldn't open terminfo/)
  2111. -        buff.split(':').select{|x| x =~ /(.*)=(.*)/ and hash[$1]=$2.gsub('\\E',"\e").gsub(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
  2112. -      end
  2113. +      `infocmp -C`.split(':').select{|x| x =~ /(.*)=(.*)/ and hash[$1]=$2.gsub('\\E',"\e").gsub(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
  2114.        @_rl_term_at7          =     hash["@7"]
  2115.        @_rl_term_DC           =     hash["DC"]
  2116.        @_rl_term_IC           =     hash["IC"]
  2117.  
  2118. commit 7b28cdacd833891635486de8ec801b27eab7d349
  2119. Author: HD Moore <[email protected]>
  2120. Date:   Tue Sep 29 03:30:15 2009 +0000
  2121.  
  2122.     Handle lacking infocmp a little smoother
  2123.    
  2124.    
  2125.     git-svn-id: file:///home/svn/framework3/trunk@7091 4d416f70-5f16-0410-b530-b9f4589650da
  2126.  
  2127. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  2128. index 7660bc4..2231c81 100644
  2129. --- a/lib/rbreadline.rb
  2130. +++ b/lib/rbreadline.rb
  2131. @@ -1822,7 +1822,10 @@ module RbReadline
  2132.  
  2133.     def get_term_capabilities(buffer)
  2134.        hash = {}
  2135. -      IO.popen('infocmp -C 2>/dev/null').read.split(':').select{|x| x =~ /(.*)=(.*)/ and hash[$1]=$2.gsub('\\E',"\e").gsub(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
  2136. +      buff = IO.popen('infocmp -C 2>/dev/null').read
  2137. +     if(buff and not buff.empty? and buff !~ /couldn't open terminfo/)
  2138. +        buff.split(':').select{|x| x =~ /(.*)=(.*)/ and hash[$1]=$2.gsub('\\E',"\e").gsub(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
  2139. +      end
  2140.        @_rl_term_at7          =     hash["@7"]
  2141.        @_rl_term_DC           =     hash["DC"]
  2142.        @_rl_term_IC           =     hash["IC"]
  2143.  
  2144. commit 542b3de249c2d7fd71114d837e8cb9bd1090c526
  2145. Author: HD Moore <[email protected]>
  2146. Date:   Tue Sep 29 03:26:23 2009 +0000
  2147.  
  2148.     Handle the case where there is no infocmp
  2149.    
  2150.    
  2151.     git-svn-id: file:///home/svn/framework3/trunk@7090 4d416f70-5f16-0410-b530-b9f4589650da
  2152.  
  2153. diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
  2154. index b96cee5..7660bc4 100644
  2155. --- a/lib/rbreadline.rb
  2156. +++ b/lib/rbreadline.rb
  2157. @@ -1822,7 +1822,7 @@ module RbReadline
  2158.  
  2159.     def get_term_capabilities(buffer)
  2160.        hash = {}
  2161. -      `infocmp -C`.split(':').select{|x| x =~ /(.*)=(.*)/ and hash[$1]=$2.gsub('\\E',"\e").gsub(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
  2162. +      IO.popen('infocmp -C 2>/dev/null').read.split(':').select{|x| x =~ /(.*)=(.*)/ and hash[$1]=$2.gsub('\\E',"\e").gsub(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
  2163.        @_rl_term_at7          =     hash["@7"]
  2164.        @_rl_term_DC           =     hash["DC"]
  2165.        @_rl_term_IC           =     hash["IC"]
Advertisement
Add Comment
Please, Sign In to add comment