Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commit 72dff034265c2ac1cea71ba84dcc3b49d5bcd552
- Author: HD Moore <[email protected]>
- Date: Thu Sep 12 16:58:49 2013 -0500
- FixRM #8396 change all lib use of regex to 8-bit pattern
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index a7006d2..26e7791 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -5272,7 +5272,7 @@ module RbReadline
- # Actually update the display, period.
- def rl_forced_update_display()
- if (@visible_line)
- - @visible_line.gsub!(/[^\x00]/,0.chr)
- + @visible_line.gsub!(/[^\x00]/n,0.chr)
- end
- rl_on_new_line()
- @forced_display=true if !@forced_display
- @@ -8520,7 +8520,7 @@ module RbReadline
- count -= 1
- end
- - str = (flags == MB_FIND_NONZERO) ? string.sub(/\x00+$/,'') : string
- + str = (flags == MB_FIND_NONZERO) ? string.sub(/\x00+$/n,'') : string
- case @encoding
- when 'E'
- commit 7e5e0f7fc814fee55a1eca148c51f2344da65e59
- Author: Tab Assassin <[email protected]>
- Date: Fri Aug 30 16:28:33 2013 -0500
- Retab lib
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index 1597ec0..a7006d2 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -2448,7 +2448,7 @@ module RbReadline
- end
- if string =~ /"(.*)"\s*:\s*(.*)$/
- - key, funname = $1, $2
- + key, funname = $1, $2
- rl_bind_key(key, rl_named_function(funname))
- end
- @@ -3706,14 +3706,14 @@ module RbReadline
- if (!@rl_display_fixed || @forced_display || lmargin != @last_lmargin)
- @forced_display = false
- - # in case we scrolled to the right, the prompt is not visible,
- - # so temporarily set wrap_offset and visible_wrap_offset to zero.
- - old_vwo=@visible_wrap_offset
- - old_wo=@wrap_offset
- - if (lmargin != 0)
- - @visible_wrap_offset=0
- - @wrap_offset=0
- - end
- + # in case we scrolled to the right, the prompt is not visible,
- + # so temporarily set wrap_offset and visible_wrap_offset to zero.
- + old_vwo=@visible_wrap_offset
- + old_wo=@wrap_offset
- + if (lmargin != 0)
- + @visible_wrap_offset=0
- + @wrap_offset=0
- + end
- update_line(@visible_line,@last_lmargin,@invisible_line[lmargin..-1],
- 0,
- @_rl_screenwidth + @visible_wrap_offset,
- @@ -3736,8 +3736,8 @@ module RbReadline
- end
- _rl_move_cursor_relative(@cpos_buffer_position - lmargin, @invisible_line ,lmargin)
- @last_lmargin = lmargin
- - @visible_wrap_offset=old_vwo
- - @wrap_offset=old_wo
- + @visible_wrap_offset=old_vwo
- + @wrap_offset=old_wo
- end
- end
- @rl_outstream.flush
- @@ -4351,9 +4351,9 @@ module RbReadline
- # Cygwin will look like Windows, but we want to treat it like a Posix OS:
- raise LoadError, "Cygwin is a Posix OS." if RUBY_PLATFORM =~ /\bcygwin\b/i
- - # Try to use win32api regardless of version. This allows us to correctly
- - # fall back to unixy stuff when not on Windows. Requires some testing on
- - # 1.8 for Windows, but msf ships 1.9, so don't worry about it for now.
- + # Try to use win32api regardless of version. This allows us to correctly
- + # fall back to unixy stuff when not on Windows. Requires some testing on
- + # 1.8 for Windows, but msf ships 1.9, so don't worry about it for now.
- #if RUBY_VERSION < '1.9.1'
- require 'Win32API'
- #else
- commit d656e3185ff80b7264c30e994b2299a039e907a2
- Author: HD Moore <[email protected]>
- Date: Fri Jun 29 00:18:28 2012 -0500
- Mark all libraries as defaulting to 8-bit strings
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index dfccf9d..1597ec0 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -1,3 +1,4 @@
- +# -*- coding: binary -*-
- # rbreadline.rb -- a general facility for reading lines of input
- # with emacs style editing and completion.
- commit 52767b31045e39ef7604ddb1a5c864fd0d85980c
- Author: Tod Beardsley <[email protected]>
- Date: Thu Oct 13 17:35:31 2011 +0000
- Fixes #5204. Adding Windows Console2 color support from mihi. Thanks!
- git-svn-id: file:///home/svn/framework3/trunk@13913 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index f0cfa98..dfccf9d 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -3705,10 +3705,18 @@ module RbReadline
- if (!@rl_display_fixed || @forced_display || lmargin != @last_lmargin)
- @forced_display = false
- + # in case we scrolled to the right, the prompt is not visible,
- + # so temporarily set wrap_offset and visible_wrap_offset to zero.
- + old_vwo=@visible_wrap_offset
- + old_wo=@wrap_offset
- + if (lmargin != 0)
- + @visible_wrap_offset=0
- + @wrap_offset=0
- + end
- update_line(@visible_line,@last_lmargin,@invisible_line[lmargin..-1],
- 0,
- @_rl_screenwidth + @visible_wrap_offset,
- - @_rl_screenwidth + (lmargin ? 0 : @wrap_offset),
- + @_rl_screenwidth + (lmargin != 0 ? 0 : @wrap_offset),
- 0)
- # If the visible new line is shorter than the old, but the number
- # of invisible characters is greater, and we are at the end of
- @@ -3727,6 +3735,8 @@ module RbReadline
- end
- _rl_move_cursor_relative(@cpos_buffer_position - lmargin, @invisible_line ,lmargin)
- @last_lmargin = lmargin
- + @visible_wrap_offset=old_vwo
- + @wrap_offset=old_wo
- end
- end
- @rl_outstream.flush
- commit 8a4c23ffd4ec5a968ef7c4cba38c094d288cfe16
- Author: Joshua Drake <[email protected]>
- Date: Tue Jan 25 02:15:25 2011 +0000
- small adjustment
- git-svn-id: file:///home/svn/framework3/trunk@11635 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index 2a7eaf9..f0cfa98 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -1151,6 +1151,7 @@ module RbReadline
- if text.length == 0
- text = "."
- end
- +
- @filename = ''
- @directory = nil
- dir = text.dup
- @@ -1167,8 +1168,8 @@ module RbReadline
- @directory = Dir.new(dir)
- @dirname = dir.dup
- elsif File.directory?(File.dirname(dir)) and File.readable?(File.dirname(dir))
- - @directory = Dir.new(File.dirname(dir))
- @dirname = File.dirname(dir)
- + @directory = Dir.new(@dirname)
- @filename = File.basename(dir)
- end
- commit 9f05e02b856f94f1d13df92a87def3e45e9d0a7d
- Author: James Lee <[email protected]>
- Date: Wed Dec 29 20:31:22 2010 +0000
- a better fix for rbreadline, also fixes completion for ~/, see #3352
- git-svn-id: file:///home/svn/framework3/trunk@11451 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index 2fbddf2..2a7eaf9 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -1148,38 +1148,44 @@ module RbReadline
- @directory = nil
- end
- text.delete!(0.chr)
- - @filename = File.basename(text)
- if text.length == 0
- text = "."
- end
- - @dirname = File.dirname(text)
- - # We aren't done yet. We also support the "~user" syntax.
- -
- - # Save the version of the directory that the user typed.
- - @users_dirname = @dirname.dup
- + @filename = ''
- + @directory = nil
- + dir = text.dup
- + # We also support "~user" and "~/" syntax.
- + if (dir[0,1] == '~')
- + @users_dirname = dir.dup
- + dir = File.expand_path(dir)
- + end
- - if (@dirname[0,1] == '~')
- - @dirname = File.expand_path(@dirname)
- + # Try the whole thing as a directory and if that fails, try dirname
- + # and basename. If that doesn't work either, then it wasn't meant to
- + # be; we don't have a directory to open or a filename to complete.
- + if File.directory?(dir) and File.readable?(dir)
- + @directory = Dir.new(dir)
- + @dirname = dir.dup
- + elsif File.directory?(File.dirname(dir)) and File.readable?(File.dirname(dir))
- + @directory = Dir.new(File.dirname(dir))
- + @dirname = File.dirname(dir)
- + @filename = File.basename(dir)
- end
- + # Save the version of the directory that the user typed if we didn't
- + # have a reason to do so before
- + @users_dirname ||= @dirname.dup
- +
- # The directory completion hook should perform any necessary
- # dequoting.
- - if (@rl_directory_completion_hook && send(rl_directory_completion_hook,@dirname))
- - @users_dirname = @dirname.dup
- + if (@rl_directory_completion_hook)
- + send(rl_directory_completion_hook,@dirname)
- elsif (@rl_completion_found_quote && @rl_filename_dequoting_function)
- # delete single and double quotes
- temp = send(@rl_filename_dequoting_function,@users_dirname, @rl_completion_quote_character)
- @users_dirname = temp
- end
- - if File.directory?(@dirname)
- - @directory = Dir.new(@dirname)
- - elsif File.directory?(File.dirname(@dirname))
- - @directory = Dir.new(File.dirname(@dirname))
- - else
- - @directory = nil
- - end
- -
- # Now dequote a non-null filename.
- if (@filename && @filename.length>0 && @rl_completion_found_quote && @rl_filename_dequoting_function)
- # delete single and double quotes
- @@ -1204,7 +1210,7 @@ module RbReadline
- # Special case for no filename. If the user has disabled the
- # `match-hidden-files' variable, skip filenames beginning with `.'.
- #All other entries except "." and ".." match.
- - if (@filename_len == 0 || @filename == "/")
- + if (@filename_len == 0)
- next if (!@_rl_match_hidden_files && d_name[0,1] == '.')
- break if (d_name != '.' && d_name != '..')
- else
- @@ -1244,9 +1250,6 @@ module RbReadline
- else
- temp = entry.dup
- end
- - if (@_rl_complete_mark_directories && File.directory?(temp) && temp[-1,1] != '/')
- - temp += "/"
- - end
- return (temp)
- end
- end
- @@ -2444,6 +2447,7 @@ module RbReadline
- if string =~ /"(.*)"\s*:\s*(.*)$/
- key, funname = $1, $2
- +
- rl_bind_key(key, rl_named_function(funname))
- end
- @@ -3335,7 +3339,6 @@ module RbReadline
- @cpos_buffer_position = out
- lb_linenum = newlines
- end
- -
- if (false && meta_char(c))
- if (!@_rl_output_meta_chars && false)
- line[out,4] = "\\%03o" % c.ord
- @@ -4080,8 +4083,8 @@ module RbReadline
- if (cxt.search_string_index == 0)
- rl_ding()
- else
- - cxt.search_string_index -= 1
- - cxt.search_string.chop!
- + cxt.search_string_index -= 1
- + cxt.search_string.chop!
- end
- when -4 # C-G, abort
- rl_replace_line(cxt.lines[cxt.save_line], false)
- @@ -6299,6 +6302,7 @@ module RbReadline
- end
- end
- end
- +
- matchesp = matches
- 1
- end
- @@ -8731,4 +8735,3 @@ module RbReadline
- private :no_terminal?
- end
- -
- commit 85efd12467196cb1a95658d164808c89e127512d
- Author: James Lee <[email protected]>
- Date: Wed Dec 29 02:56:01 2010 +0000
- 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.
- git-svn-id: file:///home/svn/framework3/trunk@11441 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index e150f93..2fbddf2 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -1148,7 +1148,7 @@ module RbReadline
- @directory = nil
- end
- text.delete!(0.chr)
- - @filename = text.dup
- + @filename = File.basename(text)
- if text.length == 0
- text = "."
- end
- @@ -1168,11 +1168,17 @@ module RbReadline
- @users_dirname = @dirname.dup
- elsif (@rl_completion_found_quote && @rl_filename_dequoting_function)
- # delete single and double quotes
- - @temp = send(@rl_filename_dequoting_function,@users_dirname, @rl_completion_quote_character)
- + temp = send(@rl_filename_dequoting_function,@users_dirname, @rl_completion_quote_character)
- @users_dirname = temp
- end
- - @directory = Dir.new(@dirname)
- + if File.directory?(@dirname)
- + @directory = Dir.new(@dirname)
- + elsif File.directory?(File.dirname(@dirname))
- + @directory = Dir.new(File.dirname(@dirname))
- + else
- + @directory = nil
- + end
- # Now dequote a non-null filename.
- if (@filename && @filename.length>0 && @rl_completion_found_quote && @rl_filename_dequoting_function)
- @@ -1198,7 +1204,7 @@ module RbReadline
- # Special case for no filename. If the user has disabled the
- # `match-hidden-files' variable, skip filenames beginning with `.'.
- #All other entries except "." and ".." match.
- - if (@filename_len == 0)
- + if (@filename_len == 0 || @filename == "/")
- next if (!@_rl_match_hidden_files && d_name[0,1] == '.')
- break if (d_name != '.' && d_name != '..')
- else
- @@ -1227,19 +1233,20 @@ module RbReadline
- if (@dirname != '.')
- if (@rl_complete_with_tilde_expansion && @users_dirname[0,1] == "~")
- temp = @dirname
- - if(temp[-1,1] != '/')
- - temp += '/'
- - end
- else
- temp = @users_dirname
- - if(temp[-1,1] != '/')
- - temp += '/'
- - end
- end
- +
- + # make sure the directory name has a trailing slash before
- + # appending the file name
- + temp += '/' if (temp[-1,1] != '/')
- temp += entry
- else
- temp = entry.dup
- end
- + if (@_rl_complete_mark_directories && File.directory?(temp) && temp[-1,1] != '/')
- + temp += "/"
- + end
- return (temp)
- end
- end
- @@ -6292,7 +6299,6 @@ module RbReadline
- end
- end
- end
- -
- matchesp = matches
- 1
- end
- commit e92c073c22ad49ecef39d70fafb31f4cdbf3c93b
- Author: Joshua Drake <[email protected]>
- Date: Tue Dec 14 22:09:38 2010 +0000
- Sync RbReadline with TIP, some diffs remain Metasploit specific
- git-svn-id: file:///home/svn/framework3/trunk@11338 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index 88aa212..e150f93 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -44,7 +44,7 @@ module RbReadline
- RL_LIBRARY_VERSION = "5.2"
- RL_READLINE_VERSION = 0x0502
- - RB_READLINE_VERSION = "0.2.0"
- + RB_READLINE_VERSION = "0.2.2"
- EOF = "\xFF"
- ESC = "\C-["
- @@ -233,6 +233,8 @@ module RbReadline
- :t_quit,:t_susp,:t_dsusp,:t_start,:t_stop,:t_lnext,:t_flush,:t_status).new
- @_rl_last_tty_chars = nil
- + @_keyboard_input_timeout = 0.01
- +
- # Variables exported by this file.
- # The character that represents the start of a history expansion
- # request. This is usually `!'.
- @@ -1202,6 +1204,7 @@ module RbReadline
- else
- # Otherwise, if these match up to the length of filename, then
- # it is a match.
- +
- if (@_rl_completion_case_fold)
- break if d_name =~ /^#{Regexp.escape(@filename)}/i
- else
- @@ -2432,13 +2435,9 @@ module RbReadline
- return 0
- end
- - key,funname = string.split(/\s*:\s*/)
- -
- - begin
- - key = instance_eval(key)
- + if string =~ /"(.*)"\s*:\s*(.*)$/
- + key, funname = $1, $2
- rl_bind_key(key, rl_named_function(funname))
- - rescue ::Exception => e
- - $stderr.puts "[-] RbReadline error parsing inputrc: #{e} '#{key}'"
- end
- 0
- @@ -2527,7 +2526,7 @@ module RbReadline
- @_rl_out_stream = @rl_outstream
- # Allocate data structures.
- - @rl_line_buffer ||= 0.chr * DEFAULT_BUFFER_SIZE
- + @rl_line_buffer = ""
- # Initialize the terminal interface.
- @rl_terminal_name ||= ENV["TERM"]
- @@ -2567,7 +2566,7 @@ module RbReadline
- def _rl_init_line_state()
- @rl_point = @rl_end = @rl_mark = 0
- - @rl_line_buffer = 0.chr * @rl_line_buffer.length
- + @rl_line_buffer = ""
- end
- # Set the history pointer back to the last entry in the history.
- @@ -2785,7 +2784,7 @@ module RbReadline
- @_rl_last_c_pos = 1
- @_rl_last_v_pos+=1
- if (old[ostart,1] != 0.chr && new[0,1] != 0.chr)
- - old[ostart] = new[0]
- + old[ostart,1] = new[0,1]
- end
- end
- @@ -2798,7 +2797,7 @@ module RbReadline
- @_rl_last_c_pos = 1
- @_rl_last_v_pos+=1
- if (old[ostart,1] != 0.chr && new[0,1] != 0.chr)
- - old[ostart] = new[0]
- + old[ostart,1] = new[0,1]
- end
- end
- end
- @@ -2840,7 +2839,7 @@ module RbReadline
- else
- ofd = 0
- nfd = 0
- - while(ofd < omax && old[ostart+ofd,1] != 0.chr && old[ostart+ofd] == new[nfd])
- + while(ofd < omax && old[ostart+ofd,1] != 0.chr && old[ostart+ofd,1] == new[nfd,1])
- ofd += 1
- nfd += 1
- end
- @@ -2887,7 +2886,7 @@ module RbReadline
- else
- ols = oe - 1 # find last same
- nls = ne - 1
- - while ((ols > ofd) && (nls > nfd) && old[ostart+ols] == new[nls])
- + while ((ols > ofd) && (nls > nfd) && old[ostart+ols,1] == new[nls,1])
- if (old[ostart+ols,1] != " ")
- wsatend = false
- end
- @@ -3119,9 +3118,9 @@ module RbReadline
- # lines.
- modmark = 0
- if (@_rl_mark_modified_lines && current_history() && @rl_undo_list)
- - line[out] = '*'
- + line[out,1] = '*'
- out += 1
- - line[out] = 0.chr
- + line[out,1] = 0.chr
- modmark = 1
- end
- @@ -3166,7 +3165,7 @@ module RbReadline
- line[out,@local_prompt_len] = @local_prompt
- out += @local_prompt_len
- end
- - line[out] = 0.chr
- + line[out,1] = 0.chr
- @wrap_offset = @local_prompt_len - @prompt_visible_length
- else
- prompt_this_line = @rl_display_prompt.rindex("\n")
- @@ -3180,7 +3179,7 @@ module RbReadline
- _rl_output_some_chars(@rl_display_prompt,0,pmtlen)
- # Make sure we are at column zero even after a newline,
- #regardless of the state of terminal output processing.
- - if (pmtlen < 2 || @rl_display_prompt[prompt_this_line-2] != "\r")
- + if (pmtlen < 2 || @rl_display_prompt[prompt_this_line-2,1] != "\r")
- cr()
- end
- end
- @@ -3210,7 +3209,7 @@ module RbReadline
- end
- line[out,pmtlen] = @rl_display_prompt[prompt_this_line,pmtlen]
- out += pmtlen
- - line[out] = 0.chr
- + line[out,1] = 0.chr
- @wrap_offset = @prompt_invis_chars_first_line = 0
- end
- # inv_lbreaks[i] is where line i starts in the buffer.
- @@ -3286,7 +3285,7 @@ module RbReadline
- wc = @rl_line_buffer[0,@rl_end].scan(/./mu)[0]
- wc_bytes = wc ? wc.length : 1
- when 'X'
- - wc = @rl_line_buffer[0,@rl_end].force_encoding(@encoding_name)[0,1]
- + wc = @rl_line_buffer[0,@rl_end].force_encoding(@encoding_name)[0]
- wc_bytes = wc ? wc.bytesize : 1
- end
- else
- @@ -3343,7 +3342,7 @@ module RbReadline
- end
- out += 4
- else
- - line[out] = c
- + line[out,1] = c
- out += 1
- lpos+=1
- if (lpos >= @_rl_screenwidth)
- @@ -3362,26 +3361,26 @@ module RbReadline
- @inv_lbreaks[newlines+=1] = out + temp2
- lpos = temp - temp2
- while (out < newout)
- - line[out] = ' '
- + line[out,1] = ' '
- out += 1
- end
- else
- while (out < newout)
- - line[out] = ' '
- + line[out,1] = ' '
- out += 1
- end
- lpos += temp
- end
- elsif (c == "\n" && !@_rl_horizontal_scroll_mode && @_rl_term_up)
- - line[out] = 0.chr # XXX - sentinel
- + line[out,1] = 0.chr # XXX - sentinel
- out += 1
- @inv_lbreaks[newlines+=1] = out
- lpos = 0
- elsif (ctrl_char(c) || c == RUBOUT)
- - line[out] = '^'
- + line[out,1] = '^'
- out += 1
- lpos+=1
- if (lpos >= @_rl_screenwidth)
- @@ -3389,7 +3388,8 @@ module RbReadline
- @_rl_wrapped_line[newlines] = _rl_wrapped_multicolumn
- lpos = 0
- end
- - line[out] = ctrl_char(c) ? (c[0].ord|0x40).chr.upcase : '?' # c[0].ord magically works for 1.9.1 and 1.8 both!
- + # NOTE: c[0].ord works identically on both 1.8 and 1.9
- + line[out,1] = ctrl_char(c) ? (c[0].ord|0x40).chr.upcase : '?'
- out += 1
- lpos+=1
- if (lpos >= @_rl_screenwidth)
- @@ -3404,7 +3404,7 @@ module RbReadline
- if (@_rl_screenwidth < lpos + wc_width)
- for i in lpos ... @_rl_screenwidth
- # The space will be removed in update_line()
- - line[out] = ' '
- + line[out,1] = ' '
- out += 1
- _rl_wrapped_multicolumn+=1
- lpos+=1
- @@ -3430,7 +3430,7 @@ module RbReadline
- end
- end
- else
- - line[out] = c
- + line[out,1] = c
- out += 1
- lpos+=1
- if (lpos >= @_rl_screenwidth)
- @@ -3455,7 +3455,7 @@ module RbReadline
- wc = @rl_line_buffer[_in,@rl_end - _in].scan(/./mu)[0]
- wc_bytes = wc ? wc.length : 1
- when 'X'
- - wc = @rl_line_buffer[_in,@rl_end - _in].force_encoding(@encoding_name)[0,1]
- + wc = @rl_line_buffer[_in,@rl_end - _in].force_encoding(@encoding_name)[0]
- wc_bytes = wc ? wc.bytesize : 1
- end
- @@ -3680,7 +3680,7 @@ module RbReadline
- # If the first character on the screen isn't the first character
- #in the display line, indicate this with a special character.
- if (lmargin > 0)
- - line[lmargin] = '<'
- + line[lmargin,1] = '<'
- end
- # If SCREENWIDTH characters starting at LMARGIN do not encompass
- @@ -3689,7 +3689,7 @@ module RbReadline
- # wrap offset into account.
- t = lmargin + m_offset(lmargin, @wrap_offset) + @_rl_screenwidth
- if (t < out)
- - line[t - 1] = '>'
- + line[t - 1,1] = '>'
- end
- if (!@rl_display_fixed || @forced_display || lmargin != @last_lmargin)
- @@ -3738,7 +3738,7 @@ module RbReadline
- # Tell the update routines that we have moved onto a new (empty) line.
- def rl_on_new_line()
- if (@visible_line)
- - @visible_line[0] = 0.chr
- + @visible_line[0,1] = 0.chr
- end
- @_rl_last_c_pos = @_rl_last_v_pos = 0
- @_rl_vis_botlin = @last_lmargin = 0
- @@ -3971,6 +3971,10 @@ module RbReadline
- ((ctrl_char(c) || meta_char(c) || (c) == RUBOUT) && ((c) != "\C-G"))
- end
- + def _rl_input_available
- + IO.select([ $stdin ], nil, [ $stdin ], @_keyboard_input_timeout)
- + end
- +
- # Process just-read character C according to isearch context CXT. Return
- # -1 if the caller should just free the context and return, 0 if we should
- # break out of the loop, and 1 if we should continue to read characters.
- @@ -4036,12 +4040,10 @@ module RbReadline
- # search again
- when -1
- if (cxt.search_string_index == 0)
- - # XXX: This variable is not defined
- - # if (last_isearch_string)
- - if(false)
- - cxt.search_string_size = 64 + last_isearch_string_len
- - cxt.search_string = last_isearch_string.dup
- - cxt.search_string_index = last_isearch_string_len
- + if (@last_isearch_string)
- + cxt.search_string_size = 64 + @last_isearch_string_len
- + cxt.search_string = @last_isearch_string.dup
- + cxt.search_string_index = @last_isearch_string_len
- rl_display_search(cxt.search_string, (cxt.sflags & SF_REVERSE)!=0, -1)
- else
- return (1)
- @@ -4071,7 +4073,8 @@ module RbReadline
- if (cxt.search_string_index == 0)
- rl_ding()
- else
- - cxt.search_string[cxt.search_string_index-=1] = 0.chr
- + cxt.search_string_index -= 1
- + cxt.search_string.chop!
- end
- when -4 # C-G, abort
- rl_replace_line(cxt.lines[cxt.save_line], false)
- @@ -4337,10 +4340,10 @@ module RbReadline
- # DLL = {}
- # TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG}
- #
- - # def initialize(dllname, func, import, export = "0")
- + # def initialize(dllname, func, import, export = "0", calltype = :stdcall)
- # @proto = [import].join.tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '\1')
- # handle = DLL[dllname] ||= DL.dlopen(dllname)
- - # @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func)
- + # @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func, calltype)
- # end
- #
- # def call(*args)
- @@ -4402,15 +4405,15 @@ module RbReadline
- def rl_getc(stream)
- while (@kbhit.Call == 0)
- - # if there is no data to read, yeild the processor for other
- - # threads until there is
- - sleep(0.001)
- + # If there is no input, yield the processor for other threads
- + sleep(@_keyboard_input_timeout)
- end
- c = @getch.Call
- alt = (@GetKeyState.call(VK_LMENU) & 0x80) != 0
- if c==0 || c==0xE0
- while (@kbhit.Call == 0)
- - sleep(0.001)
- + # If there is no input, yield the processor for other threads
- + sleep(@_keyboard_input_timeout)
- end
- r = c.chr + @getch.Call.chr
- else
- @@ -4459,7 +4462,7 @@ module RbReadline
- end
- end
- - if(Object.const_defined?('Encoding') and Encoding.respond_to?('default_external'))
- + if (Object.const_defined?('Encoding') and Encoding.respond_to?('default_external'))
- @encoding = "X" # ruby 1.9.x or greater
- @encoding_name = Encoding.default_external.to_s
- end
- @@ -6052,7 +6055,7 @@ module RbReadline
- t = Time.now.to_i
- ts = "X%u" % t
- ret = ts.dup
- - ret[0] = @history_comment_char
- + ret[0,1] = @history_comment_char
- ret
- end
- @@ -6126,7 +6129,7 @@ module RbReadline
- # to quote anything in single quotes, especially not the closing
- # quote. If you don't like this, take out the check on the value
- # of quote_char.
- - if (quote_char != "'" && @rl_line_buffer[scan] == "\\")
- + if (quote_char != "'" && @rl_line_buffer[scan,1] == "\\")
- pass_next = true
- found_quote |= RL_QF_BACKSLASH
- next
- @@ -6500,7 +6503,7 @@ module RbReadline
- if (to_print != full_pathname)
- if full_pathname.nil? || full_pathname.length==0
- - dn = "/"
- + dn = '/'
- else
- dn = File.dirname(full_pathname)
- end
- @@ -7115,7 +7118,7 @@ module RbReadline
- def _rl_scxt_alloc(type, flags)
- cxt = Struct.new(:type,:sflags,:search_string,:search_string_index,:search_string_size,:lines,:allocated_line,
- :hlen,:hindex,:save_point,:save_mark,:save_line,:last_found_line,:prev_line_found,:save_undo_list,:history_pos,
- - :direction,:lastc,:sline,:sline_len,:sline_index,:search_terminators, :mb).new
- + :direction,:lastc,:sline,:sline_len,:sline_index,:search_terminators,:mb).new
- cxt.type = type
- cxt.sflags = flags
- @@ -7172,7 +7175,7 @@ module RbReadline
- # Allocate space for this many lines, +1 for the current input line,
- # and remember those lines.
- cxt.hlen = i
- - cxt.lines = Array.new(cxt.hlen+1)
- + cxt.lines = []
- for i in 0 ... cxt.hlen
- cxt.lines[i] = hlist[i].line
- end
- @@ -7182,7 +7185,7 @@ module RbReadline
- else
- # Keep track of this so we can free it.
- cxt.allocated_line = @rl_line_buffer.dup
- - cxt.lines[i] = cxt.allocated_line
- + cxt.lines << cxt.allocated_line
- end
- cxt.hlen+=1
- @@ -7195,7 +7198,7 @@ module RbReadline
- # Initialize search parameters.
- cxt.search_string_size = 128
- cxt.search_string_index = 0
- - cxt.search_string = 0.chr * cxt.search_string_size
- + cxt.search_string = ""
- # Normalize DIRECTION into 1 or -1.
- cxt.direction = (direction >= 0) ? 1 : -1
- @@ -8052,7 +8055,7 @@ module RbReadline
- @rl_undo_list = nil
- # Use the line buffer to read the search string.
- - @rl_line_buffer[0] = 0.chr
- + @rl_line_buffer[0,1] = 0.chr
- @rl_end = @rl_point = 0
- _p = _rl_make_prompt_for_search(pchar ? pchar : ':')
- @@ -8341,8 +8344,8 @@ module RbReadline
- # slash.
- if (@rl_point>0 && @rl_line_buffer[@rl_point,1] == 0.chr && @rl_line_buffer[@rl_point - 1,1] == '/' )
- - elsif (@rl_line_buffer[@rl_point,1] != '/' )
- - rl_insert_text("/")
- + elsif (@rl_line_buffer[@rl_point,1] != '/')
- + rl_insert_text('/')
- end
- end
- # Don't add anything if the filename is a symlink and resolves to a
- @@ -8495,20 +8498,20 @@ module RbReadline
- count -= 1
- end
- + str = (flags == MB_FIND_NONZERO) ? string.sub(/\x00+$/,'') : string
- +
- case @encoding
- when 'E'
- - point += string[point..-1].scan(/./me)[0,count].to_s.length
- + point += str[point..-1].scan(/./me)[0,count].to_s.length
- when 'S'
- - point += string[point..-1].scan(/./ms)[0,count].to_s.length
- + point += str[point..-1].scan(/./ms)[0,count].to_s.length
- when 'U'
- - point += string[point..-1].scan(/./mu)[0,count].to_s.length
- + point += str[point..-1].scan(/./mu)[0,count].to_s.length
- when 'X'
- - point += string[point..-1].force_encoding(@encoding_name)[0,count].bytesize
- + point += str[point..-1].force_encoding(@encoding_name)[0,count].bytesize
- else
- point += count
- - end
- - if flags == MB_FIND_NONZERO
- - point = string.length if point>=string.length
- + point = str.length if point >= str.length
- end
- point
- end
- @@ -8574,7 +8577,7 @@ module RbReadline
- len = src.scan(/./mu)[0].to_s.length
- when 'X'
- src = src.dup.force_encoding(@encoding_name)
- - len = src.valid_encoding? ? src[0,1].bytesize : 0
- + len = src.valid_encoding? ? src[0].bytesize : 0
- else
- len = 1
- end
- commit 4e14aa184257402ca5319b0a93ea753b4983be01
- Author: James Lee <[email protected]>
- Date: Thu Oct 14 19:35:41 2010 +0000
- try to load win32api regardless of ruby version, so we correctly fall back to unixy stty stuff
- git-svn-id: file:///home/svn/framework3/trunk@10687 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index e0d19f5..88aa212 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -4326,33 +4326,36 @@ module RbReadline
- # Cygwin will look like Windows, but we want to treat it like a Posix OS:
- raise LoadError, "Cygwin is a Posix OS." if RUBY_PLATFORM =~ /\bcygwin\b/i
- - if RUBY_VERSION < '1.9.1'
- + # Try to use win32api regardless of version. This allows us to correctly
- + # fall back to unixy stuff when not on Windows. Requires some testing on
- + # 1.8 for Windows, but msf ships 1.9, so don't worry about it for now.
- + #if RUBY_VERSION < '1.9.1'
- require 'Win32API'
- - else
- - require 'dl'
- - class Win32API
- - DLL = {}
- - TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG}
- -
- - def initialize(dllname, func, import, export = "0")
- - @proto = [import].join.tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '')
- - handle = DLL[dllname] ||= DL.dlopen(dllname)
- - @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func)
- - end
- -
- - def call(*args)
- - import = @proto.split("")
- - args.each_with_index do |x, i|
- - args[i], = [x == 0 ? nil : x].pack("p").unpack("l!*") if import[i] == "S"
- - args[i], = [x].pack("I").unpack("i") if import[i] == "I"
- - end
- - ret, = @func.call(args)
- - return ret || 0
- - end
- -
- - alias Call call
- - end
- - end
- + #else
- + # require 'dl'
- + # class Win32API
- + # DLL = {}
- + # TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG}
- + #
- + # def initialize(dllname, func, import, export = "0")
- + # @proto = [import].join.tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '')
- + # handle = DLL[dllname] ||= DL.dlopen(dllname)
- + # @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func)
- + # end
- + #
- + # def call(*args)
- + # import = @proto.split("")
- + # args.each_with_index do |x, i|
- + # args[i], = [x == 0 ? nil : x].pack("p").unpack("l!*") if import[i] == "S"
- + # args[i], = [x].pack("I").unpack("i") if import[i] == "I"
- + # end
- + # ret, = @func.call(args)
- + # return ret || 0
- + # end
- + #
- + # alias Call call
- + # end
- + #end
- STD_OUTPUT_HANDLE = -11
- STD_INPUT_HANDLE = -10
- commit a10b3cf9fc9aa86bb80bc99a8174db2a7cb5fc28
- Author: James Lee <[email protected]>
- Date: Thu Oct 14 18:38:59 2010 +0000
- 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.
- git-svn-id: file:///home/svn/framework3/trunk@10681 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index e61f235..e0d19f5 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -4325,7 +4325,6 @@ module RbReadline
- begin
- # Cygwin will look like Windows, but we want to treat it like a Posix OS:
- raise LoadError, "Cygwin is a Posix OS." if RUBY_PLATFORM =~ /\bcygwin\b/i
- - raise LoadError, "Not Windows" if RUBY_PLATFORM !~ /mswin|mingw/
- if RUBY_VERSION < '1.9.1'
- require 'Win32API'
- @@ -4399,9 +4398,17 @@ module RbReadline
- end
- def rl_getc(stream)
- + while (@kbhit.Call == 0)
- + # if there is no data to read, yeild the processor for other
- + # threads until there is
- + sleep(0.001)
- + end
- c = @getch.Call
- alt = (@GetKeyState.call(VK_LMENU) & 0x80) != 0
- if c==0 || c==0xE0
- + while (@kbhit.Call == 0)
- + sleep(0.001)
- + end
- r = c.chr + @getch.Call.chr
- else
- r = c.chr
- commit 1e47a49b7e2d90b2d4d958853189024fc51911ad
- Author: James Lee <[email protected]>
- Date: Wed May 26 19:54:32 2010 +0000
- match whitespace to the rbreadline standard instead of the msf standard
- git-svn-id: file:///home/svn/framework3/trunk@9373 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index fbf07e7..e61f235 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -1197,7 +1197,7 @@ module RbReadline
- # `match-hidden-files' variable, skip filenames beginning with `.'.
- #All other entries except "." and ".." match.
- if (@filename_len == 0)
- - next if (!@_rl_match_hidden_files && d_name[0,1] == '.')
- + next if (!@_rl_match_hidden_files && d_name[0,1] == '.')
- break if (d_name != '.' && d_name != '..')
- else
- # Otherwise, if these match up to the length of filename, then
- @@ -2117,10 +2117,10 @@ module RbReadline
- end
- return (_rl_read_init_file(filename, 0))
- =end
- - #
- - # This code is too problematic at the moment
- - # Just hardcode things and move on
- - #
- + #
- + # This code is too problematic at the moment
- + # Just hardcode things and move on
- + #
- return 0
- end
- @@ -2439,7 +2439,7 @@ module RbReadline
- rl_bind_key(key, rl_named_function(funname))
- rescue ::Exception => e
- $stderr.puts "[-] RbReadline error parsing inputrc: #{e} '#{key}'"
- - end
- + end
- 0
- end
- @@ -3823,8 +3823,8 @@ module RbReadline
- str[start ... _end].scan(/./me).each {|s| width += s.length }
- when 'X'
- tmp = str[start ... _end]
- - return 0 if not tmp
- - tmp.force_encoding(@encoding_name).codepoints.each {|s| width += s > 0x1000 ? 2 : 1 }
- + return 0 if not tmp
- + tmp.force_encoding(@encoding_name).codepoints.each {|s| width += s > 0x1000 ? 2 : 1 }
- end
- width
- end
- @@ -4036,10 +4036,10 @@ module RbReadline
- # search again
- when -1
- if (cxt.search_string_index == 0)
- - # XXX: This variable is not defined
- + # XXX: This variable is not defined
- # if (last_isearch_string)
- if(false)
- - cxt.search_string_size = 64 + last_isearch_string_len
- + cxt.search_string_size = 64 + last_isearch_string_len
- cxt.search_string = last_isearch_string.dup
- cxt.search_string_index = last_isearch_string_len
- rl_display_search(cxt.search_string, (cxt.sflags & SF_REVERSE)!=0, -1)
- @@ -8406,7 +8406,7 @@ module RbReadline
- #else
- # If we have to turn on insert-mode, then do so.
- if (@_rl_term_im)
- - @_rl_out_stream.write(@_rl_term_im)
- + @_rl_out_stream.write(@_rl_term_im)
- end
- # If there is a special command for inserting characters, then
- # use that first to open up the space.
- commit 63e70f2d789c905ee6df1473dc9a35e1d1b4ef63
- Author: Joshua Drake <[email protected]>
- Date: Tue Apr 13 19:44:04 2010 +0000
- fix up a bunch of incorrect 1.8/1.9 compat fixes, fixes #1540
- git-svn-id: file:///home/svn/framework3/trunk@9063 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index 0f12ae4..fbf07e7 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -53,7 +53,7 @@ module RbReadline
- RETURN = "\C-M"
- ABORT_CHAR = "\C-G"
- TAB = "\t"
- - RUBOUT = "x7f"
- + RUBOUT = "\x7f"
- NEWLINE = "\n"
- DEFAULT_BUFFER_SIZE = 256
- @@ -236,17 +236,17 @@ module RbReadline
- # Variables exported by this file.
- # The character that represents the start of a history expansion
- # request. This is usually `!'.
- - @history_expansion_char = ?!
- + @history_expansion_char = "!"
- # The character that invokes word substitution if found at the start of
- # a line. This is usually `^'.
- - @history_subst_char = ?^
- + @history_subst_char = "^"
- # During tokenization, if this character is seen as the first character
- # of a word, then it, and all subsequent characters upto a newline are
- # ignored. For a Bourne shell, this should be '#'. Bash special cases
- # the interactive comment character to not be a comment delimiter.
- - @history_comment_char = ?\0
- + @history_comment_char = 0.chr
- # The list of characters which inhibit the expansion of text if found
- # immediately following history_expansion_char.
- @@ -1156,7 +1156,7 @@ module RbReadline
- # Save the version of the directory that the user typed.
- @users_dirname = @dirname.dup
- - if (@dirname[0] == ?~)
- + if (@dirname[0,1] == '~')
- @dirname = File.expand_path(@dirname)
- end
- @@ -1197,16 +1197,11 @@ module RbReadline
- # `match-hidden-files' variable, skip filenames beginning with `.'.
- #All other entries except "." and ".." match.
- if (@filename_len == 0)
- - if (!@_rl_match_hidden_files && d_name[0]==?.)
- - next
- - end
- - if (d_name != '.' && d_name != '..')
- - break
- - end
- + next if (!@_rl_match_hidden_files && d_name[0,1] == '.')
- + break if (d_name != '.' && d_name != '..')
- else
- # Otherwise, if these match up to the length of filename, then
- # it is a match.
- -
- if (@_rl_completion_case_fold)
- break if d_name =~ /^#{Regexp.escape(@filename)}/i
- else
- @@ -1227,14 +1222,14 @@ module RbReadline
- return nil
- else
- if (@dirname != '.')
- - if (@rl_complete_with_tilde_expansion && @users_dirname[0] == ?~)
- + if (@rl_complete_with_tilde_expansion && @users_dirname[0,1] == "~")
- temp = @dirname
- - if(temp[-1] != ?/)
- + if(temp[-1,1] != '/')
- temp += '/'
- end
- else
- temp = @users_dirname
- - if(temp[-1] != ?/)
- + if(temp[-1,1] != '/')
- temp += '/'
- end
- end
- @@ -1253,8 +1248,8 @@ module RbReadline
- return nil if RUBY_PLATFORM =~ /mswin|mingw/
- if (state == 0)
- - first_char = text[0]
- - first_char_loc = (text[0] == ?~ ? 1 : 0)
- + first_char = text[0,1]
- + first_char_loc = (first_char == '~' ? 1 : 0)
- username = text[first_char_loc..-1]
- namelen = username.length
- @@ -1273,7 +1268,7 @@ module RbReadline
- value = text.dup
- value[first_char_loc..-1] = entry.name
- - if (first_char == ?~)
- + if (first_char == '~')
- @rl_filename_completion_desired = true
- end
- @@ -1481,11 +1476,11 @@ module RbReadline
- _end = @rl_point
- start = _end - 1
- - if (@rl_point == @rl_end && @rl_line_buffer[@rl_point] == ?~ )
- + if (@rl_point == @rl_end && @rl_line_buffer[@rl_point,1] == '~' )
- homedir = File.expand_path("~")
- _rl_replace_text(homedir, start, _end)
- return (0)
- - elsif (@rl_line_buffer[start] != ?~)
- + elsif (@rl_line_buffer[start,1] != '~')
- while(!whitespace(@rl_line_buffer[start,1]) && start >= 0)
- start -= 1
- end
- @@ -1504,7 +1499,7 @@ module RbReadline
- # If the first character of the current word is a tilde, perform
- #tilde expansion and insert the result. If not a tilde, do
- # nothing.
- - if (@rl_line_buffer[start] == ?~)
- + if (@rl_line_buffer[start,1] == '~')
- len = _end - start + 1
- temp = @rl_line_buffer[start,len]
- @@ -1877,7 +1872,7 @@ module RbReadline
- @_rl_screenwidth = wc
- @_rl_screenheight = wr
- else
- - wr,wc = `stty size `.split(' ').map{|x| x.to_i}
- + wr,wc = `stty size`.split(' ').map{|x| x.to_i}
- @_rl_screenwidth = wc
- @_rl_screenheight = wr
- if ignore_env==0 && ENV['LINES']
- @@ -2070,7 +2065,7 @@ module RbReadline
- # New public way to set the system default editing chars to their readline
- # equivalents.
- def rl_tty_set_default_bindings(kmap)
- - h = Hash[*`stty -a `.scan(/(\w+) = ([^;]+);/).flatten]
- + h = Hash[*`stty -a`.scan(/(\w+) = ([^;]+);/).flatten]
- h.each {|k,v| v.gsub!(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
- kmap[h['erase']] = :rl_rubout
- kmap[h['kill']] = :rl_unix_line_discard
- @@ -2423,7 +2418,7 @@ module RbReadline
- def rl_parse_and_bind(string)
- # If this is a parser directive, act on it.
- - if (string[0,1] == ?$)
- + if (string[0,1] == "$")
- handle_parser_directive(string[1..-1])
- return 0
- end
- @@ -2728,7 +2723,7 @@ module RbReadline
- _rl_clear_to_eol(@_rl_wrapped_line[current_line])
- end
- - if new[0] != ?\0
- + if new[0,1] != 0.chr
- case @encoding
- when 'E'
- wc = new.scan(/./me)[0]
- @@ -2760,7 +2755,7 @@ module RbReadline
- @_rl_last_c_pos = tempwidth
- @_rl_last_v_pos+=1
- - if old[ostart] != ?\0
- + if old[ostart,1] != 0.chr
- case @encoding
- when 'E'
- wc = old[ostart..-1].scan(/./me)[0]
- @@ -2789,20 +2784,20 @@ module RbReadline
- @rl_outstream.write(' ')
- @_rl_last_c_pos = 1
- @_rl_last_v_pos+=1
- - if (old[ostart] != ?\0 && new[0] != ?\0)
- + if (old[ostart,1] != 0.chr && new[0,1] != 0.chr)
- old[ostart] = new[0]
- end
- end
- else
- - if (new[0] != ?\0)
- + if (new[0,1] != 0.chr)
- @rl_outstream.write(new[0,1])
- else
- @rl_outstream.write(' ')
- end
- @_rl_last_c_pos = 1
- @_rl_last_v_pos+=1
- - if (old[ostart]!= ?\0 && new[0] != ?\0)
- + if (old[ostart,1] != 0.chr && new[0,1] != 0.chr)
- old[ostart] = new[0]
- end
- end
- @@ -2832,7 +2827,7 @@ module RbReadline
- old_offset = ostart
- ofd = 0
- nfd = 0
- - while(ofd < omax && old[ostart+ofd] != ?\0 &&
- + while(ofd < omax && old[ostart+ofd,1] != 0.chr &&
- _rl_compare_chars(old, old_offset, new, new_offset))
- old_offset = _rl_find_next_mbchar(old, old_offset, 1, MB_FIND_ANY)
- @@ -2845,7 +2840,7 @@ module RbReadline
- else
- ofd = 0
- nfd = 0
- - while(ofd < omax && old[ostart+ofd] != ?\0 && old[ostart+ofd] == new[nfd])
- + while(ofd < omax && old[ostart+ofd,1] != 0.chr && old[ostart+ofd] == new[nfd])
- ofd += 1
- nfd += 1
- end
- @@ -2882,7 +2877,7 @@ module RbReadline
- if (!_rl_compare_chars(old, ostart+ols, new, nls))
- break
- end
- - if (old[ostart+ols] == ?\x20)
- + if (old[ostart+ols,1] == " ")
- wsatend = false
- end
- @@ -2893,7 +2888,7 @@ module RbReadline
- ols = oe - 1 # find last same
- nls = ne - 1
- while ((ols > ofd) && (nls > nfd) && old[ostart+ols] == new[nls])
- - if (old[ostart+ols] != ?\x20 )
- + if (old[ostart+ols,1] != " ")
- wsatend = false
- end
- ols-=1
- @@ -2905,14 +2900,14 @@ module RbReadline
- ols = oe
- nls = ne
- elsif (!_rl_compare_chars(old, ostart+ols, new, nls))
- - if (old[ostart+ols] != ?\0) # don't step past the NUL
- + if (old[ostart+ols,1] != 0.chr) # don't step past the NUL
- if !@rl_byte_oriented
- ols = _rl_find_next_mbchar(old, ostart+ols, 1, MB_FIND_ANY) - ostart
- else
- ols+=1
- end
- end
- - if (new[nls] != ?\0 )
- + if (new[nls,1] != 0.chr )
- if !@rl_byte_oriented
- nls = _rl_find_next_mbchar(new, nls, 1, MB_FIND_ANY)
- else
- @@ -3014,12 +3009,12 @@ module RbReadline
- # _rl_horizontal_scroll_mode == 1, inserting the characters with
- # _rl_term_IC or _rl_term_ic will screw up the screen because of the
- # invisible characters. We need to just draw them.
- - if (old[ostart+ols,1] != ?\0 && (!@_rl_horizontal_scroll_mode || @_rl_last_c_pos > 0 ||
- + if (old[ostart+ols,1] != 0.chr && (!@_rl_horizontal_scroll_mode || @_rl_last_c_pos > 0 ||
- lendiff <= @prompt_visible_length || current_invis_chars==0))
- insert_some_chars(new[nfd..-1], lendiff, col_lendiff)
- @_rl_last_c_pos += col_lendiff
- - elsif ((@rl_byte_oriented) && old[ostart+ols] == ?\0 && lendiff > 0)
- + elsif ((@rl_byte_oriented) && old[ostart+ols,1] == 0.chr && lendiff > 0)
- # At the end of a line the characters do not have to
- # be "inserted". They can just be placed on the screen.
- # However, this screws up the rest of this block, which
- @@ -3185,7 +3180,7 @@ module RbReadline
- _rl_output_some_chars(@rl_display_prompt,0,pmtlen)
- # Make sure we are at column zero even after a newline,
- #regardless of the state of terminal output processing.
- - if (pmtlen < 2 || @rl_display_prompt[prompt_this_line-2] != ?\r)
- + if (pmtlen < 2 || @rl_display_prompt[prompt_this_line-2] != "\r")
- cr()
- end
- end
- @@ -3334,6 +3329,7 @@ module RbReadline
- @cpos_buffer_position = out
- lb_linenum = newlines
- end
- +
- if (false && meta_char(c))
- if (!@_rl_output_meta_chars && false)
- line[out,4] = "\\%03o" % c.ord
- @@ -3393,7 +3389,7 @@ module RbReadline
- @_rl_wrapped_line[newlines] = _rl_wrapped_multicolumn
- lpos = 0
- end
- - line[out] = ctrl_char(c) ? (c[0].ord|0x40).chr.upcase : '?'
- + line[out] = ctrl_char(c) ? (c[0].ord|0x40).chr.upcase : '?' # c[0].ord magically works for 1.9.1 and 1.8 both!
- out += 1
- lpos+=1
- if (lpos >= @_rl_screenwidth)
- @@ -3468,7 +3464,7 @@ module RbReadline
- end
- end
- - line[out] = 0.chr
- + line[out,1] = 0.chr
- if (@cpos_buffer_position < 0)
- @cpos_buffer_position = out
- @@ -4293,7 +4289,7 @@ module RbReadline
- if(map.keys.detect{|x| x =~ /^#{Regexp.escape(key)}/})
- key += _rl_subseq_getchar(key)
- return _rl_dispatch_subseq(key,map,got_subseq)
- - elsif(key.length>1 && key[1] < ?\x7F)
- + elsif(key.length>1 && key[1].ord < 0x7f)
- _rl_abort_internal()
- return -1
- else
- @@ -5637,7 +5633,7 @@ module RbReadline
- # If the cursor is the only thing on an otherwise-blank last line,
- # compensate so we don't print an extra CRLF.
- if (@_rl_vis_botlin && @_rl_last_c_pos == 0 &&
- - @visible_line[@vis_lbreaks[@_rl_vis_botlin]] == ?\0 )
- + @visible_line[@vis_lbreaks[@_rl_vis_botlin],1] == 0.chr )
- @_rl_vis_botlin-=1
- full_lines = true
- end
- @@ -6120,7 +6116,7 @@ module RbReadline
- # to quote anything in single quotes, especially not the closing
- # quote. If you don't like this, take out the check on the value
- # of quote_char.
- - if (quote_char != "'" && @rl_line_buffer[scan] == ?\\)
- + if (quote_char != "'" && @rl_line_buffer[scan] == "\\")
- pass_next = true
- found_quote |= RL_QF_BACKSLASH
- next
- @@ -6506,10 +6502,10 @@ module RbReadline
- slen = s.length
- tlen = to_print.length
- new_full_pathname = s.dup
- - if (s[-1] == ?/ )
- + if (s[-1,1] == '/' )
- slen-=1
- else
- - new_full_pathname[slen] = ?/
- + new_full_pathname[slen,1] = '/'
- end
- new_full_pathname[slen .. -1] = '/' + to_print
- @@ -6575,7 +6571,7 @@ module RbReadline
- def fnwidth(string)
- left = string.length + 1
- width = pos = 0
- - while (string[pos] && string[pos] != ?\0)
- + while (string[pos] && string[pos,1] != 0.chr)
- if (ctrl_char(string[0,1]) || string[0,1] == RUBOUT)
- width += 2
- pos+=1
- @@ -6856,7 +6852,7 @@ module RbReadline
- def save_tty_chars()
- @_rl_last_tty_chars = @_rl_tty_chars
- - h = Hash[*`stty -a `.scan(/(\w+) = ([^;]+);/).flatten]
- + h = Hash[*`stty -a`.scan(/(\w+) = ([^;]+);/).flatten]
- h.each {|k,v| v.gsub!(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
- @_rl_tty_chars.t_erase = h['erase']
- @_rl_tty_chars.t_kill = h['kill']
- @@ -6874,7 +6870,7 @@ module RbReadline
- @_rl_tty_chars.t_werase = h['werase']
- @_rl_tty_chars.t_lnext = h['lnext']
- @_rl_tty_chars.t_status = -1
- - @otio = `stty -g `
- + @otio = `stty -g`
- end
- def _rl_bind_tty_special_chars(kmap)
- @@ -6885,7 +6881,7 @@ module RbReadline
- end
- def prepare_terminal_settings(meta_flag)
- - @readline_echoing_p = (`stty -a `.scan(/-*echo\b/).first == 'echo')
- + @readline_echoing_p = (`stty -a`.scan(/-*echo\b/).first == 'echo')
- # First, the basic settings to put us into character-at-a-time, no-echo
- # input mode.
- @@ -6894,7 +6890,7 @@ module RbReadline
- # If this terminal doesn't care how the 8th bit is used, then we can
- # use it for the meta-key. If only one of even or odd parity is
- # specified, then the terminal is using parity, and we cannot.
- - if (`stty -a `.scan(/-parenb\b/).first == '-parenb')
- + if (`stty -a`.scan(/-parenb\b/).first == '-parenb')
- setting << " pass8"
- end
- @@ -6905,7 +6901,7 @@ module RbReadline
- #setting << " -isig"
- - `stty #{setting} `
- + `stty #{setting}`
- end
- def _rl_control_keypad(on)
- @@ -6992,7 +6988,7 @@ module RbReadline
- @rl_outstream.flush
- # restore terminal setting
- - `stty #{@otio} `
- + `stty #{@otio}`
- @terminal_prepped = false
- rl_unsetstate(RL_STATE_TERMPREPPED)
- @@ -8333,9 +8329,9 @@ module RbReadline
- # This is clumsy. Avoid putting in a double slash if point
- # is at the end of the line and the previous character is a
- # slash.
- - if (@rl_point>0 && @rl_line_buffer[@rl_point] == ?\0 && @rl_line_buffer[@rl_point - 1] == ?/ )
- + if (@rl_point>0 && @rl_line_buffer[@rl_point,1] == 0.chr && @rl_line_buffer[@rl_point - 1,1] == '/' )
- - elsif (@rl_line_buffer[@rl_point] != ?/ )
- + elsif (@rl_line_buffer[@rl_point,1] != '/' )
- rl_insert_text("/")
- end
- end
- @@ -8410,7 +8406,7 @@ module RbReadline
- #else
- # If we have to turn on insert-mode, then do so.
- if (@_rl_term_im)
- - @_rl_out_stream.write(@_rl_term_im)
- + @_rl_out_stream.write(@_rl_term_im)
- end
- # If there is a special command for inserting characters, then
- # use that first to open up the space.
- @@ -8558,7 +8554,7 @@ module RbReadline
- # if an invalid multibyte sequence was encountered. It returns (size_t)(-2)
- # if it couldn't parse a complete multibyte character.
- def _rl_get_char_len(src)
- - return 0 if src[0,1] == ?\0 || src.length==0
- + return 0 if src[0,1] == 0.chr || src.length==0
- case @encoding
- when 'E'
- len = src.scan(/./me)[0].to_s.length
- commit 0251f21dc99d6199e8eba4edd5918b2cabeec3cb
- Author: HD Moore <[email protected]>
- Date: Mon Nov 16 18:30:07 2009 +0000
- See #509
- git-svn-id: file:///home/svn/framework3/trunk@7536 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index 8d5af6a..fad8644 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -2102,12 +2102,8 @@ module RbReadline
- # otherwise errno is returned.
- def rl_read_init_file(filename)
- - #
- - # This code is too problematic at the moment
- - # Just hardcode things and move on
- - #
- - return 0
- +=begin
- # Default the filename.
- filename ||= @last_readline_init_file
- filename ||= ENV["INPUTRC"]
- @@ -2124,7 +2120,13 @@ module RbReadline
- return 0 if (_rl_read_init_file(filename, 0) == 0)
- filename = "~/_inputrc"
- end
- - return (_rl_read_init_file(filename, 0))
- + return (_rl_read_init_file(filename, 0))
- +=end
- + #
- + # This code is too problematic at the moment
- + # Just hardcode things and move on
- + #
- + return 0
- end
- def _rl_read_init_file(filename, include_level)
- commit 500eb85a58d6d54de0a2f3a0ac12ad77074c4754
- Author: HD Moore <[email protected]>
- Date: Thu Nov 12 06:31:50 2009 +0000
- Fix a typo in ^L support
- git-svn-id: file:///home/svn/framework3/trunk@7476 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index c135415..8d5af6a 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -4575,7 +4575,7 @@ module RbReadline
- def _rl_clear_screen()
- if (@_rl_term_clrpag)
- - @rl_outstream.write(@_rl_tirberm_clrpag)
- + @rl_outstream.write(@_rl_term_clrpag)
- else
- rl_crlf()
- end
- commit 48fb44560901b9ae9896ee0cf16cb3f91fcd487c
- Author: HD Moore <[email protected]>
- Date: Fri Nov 6 15:27:13 2009 +0000
- 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
- git-svn-id: file:///home/svn/framework3/trunk@7374 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index bdc8fb9..c135415 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -9,10 +9,10 @@
- =begin
- Copyright (c) 2009, Park Heesob
- All rights reserved.
- -
- +
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- -
- +
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice
- @@ -21,7 +21,7 @@ modification, are permitted provided that the following conditions are met:
- * Neither the name of Park Heesob nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
- -
- +
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- @@ -1877,7 +1877,7 @@ module RbReadline
- @_rl_screenwidth = wc
- @_rl_screenheight = wr
- else
- - wr,wc = `stty size 2>/dev/null`.split(' ').map{|x| x.to_i}
- + wr,wc = `stty size `.split(' ').map{|x| x.to_i}
- @_rl_screenwidth = wc
- @_rl_screenheight = wr
- if ignore_env==0 && ENV['LINES']
- @@ -2070,7 +2070,7 @@ module RbReadline
- # New public way to set the system default editing chars to their readline
- # equivalents.
- def rl_tty_set_default_bindings(kmap)
- - h = Hash[*`stty -a 2>/dev/null`.scan(/(\w+) = ([^;]+);/).flatten]
- + h = Hash[*`stty -a `.scan(/(\w+) = ([^;]+);/).flatten]
- h.each {|k,v| v.gsub!(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
- kmap[h['erase']] = :rl_rubout
- kmap[h['kill']] = :rl_unix_line_discard
- @@ -2101,13 +2101,13 @@ module RbReadline
- # If the file existed and could be opened and read, 0 is returned,
- # otherwise errno is returned.
- def rl_read_init_file(filename)
- -
- +
- #
- # This code is too problematic at the moment
- # Just hardcode things and move on
- #
- return 0
- -
- +
- # Default the filename.
- filename ||= @last_readline_init_file
- filename ||= ENV["INPUTRC"]
- @@ -2187,7 +2187,7 @@ module RbReadline
- if args[5..-1] == "emacs"
- mode = @emacs_mode
- elsif args[5..-1] == "vi"
- - $stderr.puts "*** Warning: vi-mode not supported, switching back to emacs mode"
- + $stderr.puts "*** Warning: vi-mode not supported, switching back to emacs mode"
- mode = @emacs_mode
- else
- mode = @no_mode
- @@ -2338,7 +2338,7 @@ module RbReadline
- when "editing-mode"
- case value
- when "vi"
- - $stderr.puts "*** Warning: vi editing-mode not supported, switching back to emacs"
- + $stderr.puts "*** Warning: vi editing-mode not supported, switching back to emacs"
- #@_rl_keymap = @vi_insertion_keymap
- #@rl_editing_mode = @vi_mode
- @_rl_keymap = @emacs_standard_keymap
- @@ -2442,7 +2442,7 @@ module RbReadline
- rl_bind_key(key, rl_named_function(funname))
- rescue ::Exception => e
- $stderr.puts "[-] RbReadline error parsing inputrc: #{e} '#{key}'"
- - end
- + end
- 0
- end
- @@ -4039,7 +4039,7 @@ module RbReadline
- when -1
- if (cxt.search_string_index == 0)
- # XXX: This variable is not defined
- - # if (last_isearch_string)
- + # if (last_isearch_string)
- if(false)
- cxt.search_string_size = 64 + last_isearch_string_len
- cxt.search_string = last_isearch_string.dup
- @@ -6854,7 +6854,7 @@ module RbReadline
- def save_tty_chars()
- @_rl_last_tty_chars = @_rl_tty_chars
- - h = Hash[*`stty -a 2>/dev/null`.scan(/(\w+) = ([^;]+);/).flatten]
- + h = Hash[*`stty -a `.scan(/(\w+) = ([^;]+);/).flatten]
- h.each {|k,v| v.gsub!(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
- @_rl_tty_chars.t_erase = h['erase']
- @_rl_tty_chars.t_kill = h['kill']
- @@ -6872,7 +6872,7 @@ module RbReadline
- @_rl_tty_chars.t_werase = h['werase']
- @_rl_tty_chars.t_lnext = h['lnext']
- @_rl_tty_chars.t_status = -1
- - @otio = `stty -g 2>/dev/null`
- + @otio = `stty -g `
- end
- def _rl_bind_tty_special_chars(kmap)
- @@ -6883,7 +6883,7 @@ module RbReadline
- end
- def prepare_terminal_settings(meta_flag)
- - @readline_echoing_p = (`stty -a 2>/dev/null`.scan(/-*echo\b/).first == 'echo')
- + @readline_echoing_p = (`stty -a `.scan(/-*echo\b/).first == 'echo')
- # First, the basic settings to put us into character-at-a-time, no-echo
- # input mode.
- @@ -6892,7 +6892,7 @@ module RbReadline
- # If this terminal doesn't care how the 8th bit is used, then we can
- # use it for the meta-key. If only one of even or odd parity is
- # specified, then the terminal is using parity, and we cannot.
- - if (`stty -a 2>/dev/null`.scan(/-parenb\b/).first == '-parenb')
- + if (`stty -a `.scan(/-parenb\b/).first == '-parenb')
- setting << " pass8"
- end
- @@ -6903,7 +6903,7 @@ module RbReadline
- #setting << " -isig"
- - `stty #{setting} 2>/dev/null`
- + `stty #{setting} `
- end
- def _rl_control_keypad(on)
- @@ -6990,7 +6990,7 @@ module RbReadline
- @rl_outstream.flush
- # restore terminal setting
- - `stty #{@otio} 2>/dev/null`
- + `stty #{@otio} `
- @terminal_prepped = false
- rl_unsetstate(RL_STATE_TERMPREPPED)
- @@ -8713,4 +8713,5 @@ module RbReadline
- end
- private :no_terminal?
- -end
- +end
- +
- commit 8377077297e46a9ca095e77b0d7bc5b4caf7951a
- Author: HD Moore <[email protected]>
- Date: Wed Oct 28 19:37:19 2009 +0000
- Huide the error output from stty execs. Fixes #426
- git-svn-id: file:///home/svn/framework3/trunk@7299 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index c4bf6d3..bdc8fb9 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -1877,7 +1877,7 @@ module RbReadline
- @_rl_screenwidth = wc
- @_rl_screenheight = wr
- else
- - wr,wc = `stty size`.split(' ').map{|x| x.to_i}
- + wr,wc = `stty size 2>/dev/null`.split(' ').map{|x| x.to_i}
- @_rl_screenwidth = wc
- @_rl_screenheight = wr
- if ignore_env==0 && ENV['LINES']
- @@ -2070,7 +2070,7 @@ module RbReadline
- # New public way to set the system default editing chars to their readline
- # equivalents.
- def rl_tty_set_default_bindings(kmap)
- - h = Hash[*`stty -a`.scan(/(\w+) = ([^;]+);/).flatten]
- + h = Hash[*`stty -a 2>/dev/null`.scan(/(\w+) = ([^;]+);/).flatten]
- h.each {|k,v| v.gsub!(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
- kmap[h['erase']] = :rl_rubout
- kmap[h['kill']] = :rl_unix_line_discard
- @@ -6854,7 +6854,7 @@ module RbReadline
- def save_tty_chars()
- @_rl_last_tty_chars = @_rl_tty_chars
- - h = Hash[*`stty -a`.scan(/(\w+) = ([^;]+);/).flatten]
- + h = Hash[*`stty -a 2>/dev/null`.scan(/(\w+) = ([^;]+);/).flatten]
- h.each {|k,v| v.gsub!(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
- @_rl_tty_chars.t_erase = h['erase']
- @_rl_tty_chars.t_kill = h['kill']
- @@ -6872,7 +6872,7 @@ module RbReadline
- @_rl_tty_chars.t_werase = h['werase']
- @_rl_tty_chars.t_lnext = h['lnext']
- @_rl_tty_chars.t_status = -1
- - @otio = `stty -g`
- + @otio = `stty -g 2>/dev/null`
- end
- def _rl_bind_tty_special_chars(kmap)
- @@ -6883,7 +6883,7 @@ module RbReadline
- end
- def prepare_terminal_settings(meta_flag)
- - @readline_echoing_p = (`stty -a`.scan(/-*echo\b/).first == 'echo')
- + @readline_echoing_p = (`stty -a 2>/dev/null`.scan(/-*echo\b/).first == 'echo')
- # First, the basic settings to put us into character-at-a-time, no-echo
- # input mode.
- @@ -6892,7 +6892,7 @@ module RbReadline
- # If this terminal doesn't care how the 8th bit is used, then we can
- # use it for the meta-key. If only one of even or odd parity is
- # specified, then the terminal is using parity, and we cannot.
- - if (`stty -a`.scan(/-parenb\b/).first == '-parenb')
- + if (`stty -a 2>/dev/null`.scan(/-parenb\b/).first == '-parenb')
- setting << " pass8"
- end
- @@ -6903,7 +6903,7 @@ module RbReadline
- #setting << " -isig"
- - `stty #{setting}`
- + `stty #{setting} 2>/dev/null`
- end
- def _rl_control_keypad(on)
- @@ -6990,7 +6990,7 @@ module RbReadline
- @rl_outstream.flush
- # restore terminal setting
- - `stty #{@otio}`
- + `stty #{@otio} 2>/dev/null`
- @terminal_prepped = false
- rl_unsetstate(RL_STATE_TERMPREPPED)
- commit 54437321eb9ee083a5da9c7f0e5dea8f8f0b5f53
- Author: HD Moore <[email protected]>
- Date: Fri Oct 2 00:03:55 2009 +0000
- Disable inputrc processing, its not deterministic and will be impossible to support as implemented.
- git-svn-id: file:///home/svn/framework3/trunk@7111 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index 8d301a5..c4bf6d3 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -2101,6 +2101,13 @@ module RbReadline
- # If the file existed and could be opened and read, 0 is returned,
- # otherwise errno is returned.
- def rl_read_init_file(filename)
- +
- + #
- + # This code is too problematic at the moment
- + # Just hardcode things and move on
- + #
- + return 0
- +
- # Default the filename.
- filename ||= @last_readline_init_file
- filename ||= ENV["INPUTRC"]
- commit 4e244d654d7be556ac7df88e519e7cce33cd9470
- Author: HD Moore <[email protected]>
- Date: Thu Oct 1 21:02:50 2009 +0000
- Catch parsing errors in the inputrc file
- git-svn-id: file:///home/svn/framework3/trunk@7110 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index 2f849b8..8d301a5 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -2429,8 +2429,13 @@ module RbReadline
- end
- key,funname = string.split(/\s*:\s*/)
- - key = instance_eval(key)
- - rl_bind_key(key, rl_named_function(funname))
- +
- + begin
- + key = instance_eval(key)
- + rl_bind_key(key, rl_named_function(funname))
- + rescue ::Exception => e
- + $stderr.puts "[-] RbReadline error parsing inputrc: #{e} '#{key}'"
- + end
- 0
- end
- commit b4d6ba117033bd8bd841c5f0aa0e637fa204eaf8
- Author: HD Moore <[email protected]>
- Date: Thu Oct 1 16:47:48 2009 +0000
- Check for nil before trying to replace a line
- git-svn-id: file:///home/svn/framework3/trunk@7108 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index f8774c2..2f849b8 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -4184,7 +4184,9 @@ module RbReadline
- # the location.
- if (cxt.sflags & SF_FOUND)!=0
- cxt.prev_line_found = cxt.lines[cxt.history_pos]
- - rl_replace_line(cxt.lines[cxt.history_pos], false)
- + if (cxt.prev_line_found)
- + rl_replace_line(cxt.lines[cxt.history_pos], false)
- + end
- @rl_point = cxt.sline_index
- cxt.last_found_line = cxt.history_pos
- rl_display_search(cxt.search_string, (cxt.sflags & SF_REVERSE)!=0, (cxt.history_pos == cxt.save_line) ? -1 : cxt.history_pos)
- commit 92359fecc542504c2456566bb52a9cca6c98ef3c
- Author: HD Moore <[email protected]>
- Date: Thu Oct 1 16:27:18 2009 +0000
- Fix some 1.9 compat issues, wrap missing methods, extend to the cxt structure to include mb (used elsewhere)
- git-svn-id: file:///home/svn/framework3/trunk@7107 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index 792fc55..f8774c2 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -2414,7 +2414,7 @@ module RbReadline
- def rl_parse_and_bind(string)
- # If this is a parser directive, act on it.
- - if (string[0] == ?$)
- + if (string[0,1] == ?$)
- handle_parser_directive(string[1..-1])
- return 0
- end
- @@ -3000,7 +3000,7 @@ module RbReadline
- # _rl_horizontal_scroll_mode == 1, inserting the characters with
- # _rl_term_IC or _rl_term_ic will screw up the screen because of the
- # invisible characters. We need to just draw them.
- - if (old[ostart+ols] != ?\0 && (!@_rl_horizontal_scroll_mode || @_rl_last_c_pos > 0 ||
- + if (old[ostart+ols,1] != ?\0 && (!@_rl_horizontal_scroll_mode || @_rl_last_c_pos > 0 ||
- lendiff <= @prompt_visible_length || current_invis_chars==0))
- insert_some_chars(new[nfd..-1], lendiff, col_lendiff)
- @@ -3119,7 +3119,7 @@ module RbReadline
- # If someone thought that the redisplay was handled, but the currently
- # visible line has a different modification state than the one about
- # to become visible, then correct the caller's misconception.
- - if (@visible_line[0] != @invisible_line[0])
- + if (@visible_line[0,1] != @invisible_line[0,1])
- @rl_display_fixed = false
- end
- @@ -3277,7 +3277,7 @@ module RbReadline
- wc = @rl_line_buffer[0,@rl_end].scan(/./mu)[0]
- wc_bytes = wc ? wc.length : 1
- when 'X'
- - wc = @rl_line_buffer[0,@rl_end].force_encoding(@encoding_name)[0]
- + wc = @rl_line_buffer[0,@rl_end].force_encoding(@encoding_name)[0,1]
- wc_bytes = wc ? wc.bytesize : 1
- end
- else
- @@ -3445,7 +3445,7 @@ module RbReadline
- wc = @rl_line_buffer[_in,@rl_end - _in].scan(/./mu)[0]
- wc_bytes = wc ? wc.length : 1
- when 'X'
- - wc = @rl_line_buffer[_in,@rl_end - _in].force_encoding(@encoding_name)[0]
- + wc = @rl_line_buffer[_in,@rl_end - _in].force_encoding(@encoding_name)[0,1]
- wc_bytes = wc ? wc.bytesize : 1
- end
- @@ -3812,7 +3812,9 @@ module RbReadline
- when 'E'
- str[start ... _end].scan(/./me).each {|s| width += s.length }
- when 'X'
- - str[start ... _end].force_encoding(@encoding_name).codepoints.each {|s| width += s > 0x1000 ? 2 : 1 }
- + tmp = str[start ... _end]
- + return 0 if not tmp
- + tmp.force_encoding(@encoding_name).codepoints.each {|s| width += s > 0x1000 ? 2 : 1 }
- end
- width
- end
- @@ -3987,7 +3989,7 @@ module RbReadline
- # variable isearch-terminators) are used to terminate the search but
- # not subsequently execute the character as a command. The default
- # value is "\033\012" (ESC and C-J).
- - if (cxt.search_terminators.include?(cxt.lastc))
- + if (cxt.lastc.class == ::String and cxt.search_terminators.include?(cxt.lastc))
- # ESC still terminates the search, but if there is pending
- #input or if input arrives within 0.1 seconds (on systems
- #with select(2)) it is used as a prefix character
- @@ -4024,8 +4026,10 @@ module RbReadline
- # search again
- when -1
- if (cxt.search_string_index == 0)
- - if (last_isearch_string)
- - cxt.search_string_size = 64 + last_isearch_string_len
- + # XXX: This variable is not defined
- + # if (last_isearch_string)
- + if(false)
- + cxt.search_string_size = 64 + last_isearch_string_len
- cxt.search_string = last_isearch_string.dup
- cxt.search_string_index = last_isearch_string_len
- rl_display_search(cxt.search_string, (cxt.sflags & SF_REVERSE)!=0, -1)
- @@ -7089,7 +7093,7 @@ module RbReadline
- def _rl_scxt_alloc(type, flags)
- cxt = Struct.new(:type,:sflags,:search_string,:search_string_index,:search_string_size,:lines,:allocated_line,
- :hlen,:hindex,:save_point,:save_mark,:save_line,:last_found_line,:prev_line_found,:save_undo_list,:history_pos,
- - :direction,:lastc,:sline,:sline_len,:sline_index,:search_terminators).new
- + :direction,:lastc,:sline,:sline_len,:sline_index,:search_terminators, :mb).new
- cxt.type = type
- cxt.sflags = flags
- @@ -8538,7 +8542,7 @@ module RbReadline
- # if an invalid multibyte sequence was encountered. It returns (size_t)(-2)
- # if it couldn't parse a complete multibyte character.
- def _rl_get_char_len(src)
- - return 0 if src[0] == ?\0 || src.length==0
- + return 0 if src[0,1] == ?\0 || src.length==0
- case @encoding
- when 'E'
- len = src.scan(/./me)[0].to_s.length
- @@ -8548,7 +8552,7 @@ module RbReadline
- len = src.scan(/./mu)[0].to_s.length
- when 'X'
- src = src.dup.force_encoding(@encoding_name)
- - len = src.valid_encoding? ? src[0].bytesize : 0
- + len = src.valid_encoding? ? src[0,1].bytesize : 0
- else
- len = 1
- end
- commit 3c79917fb0e9dd38baf5303c560a5c1a0aca514f
- Author: HD Moore <[email protected]>
- Date: Wed Sep 30 20:36:04 2009 +0000
- Disable vi editing-mode, as its not completely implemented
- git-svn-id: file:///home/svn/framework3/trunk@7097 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index a4dd790..792fc55 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -624,7 +624,8 @@ module RbReadline
- "\C-x" => :rl_insert ,
- "\C-y" => :rl_yank ,
- "\C-z" => :rl_insert ,
- - "\C-[" => :rl_vi_movement_mode ,
- +# "\C-[" => :rl_vi_movement_mode,
- +# XXX: NOT IMPLEMENTED
- "\C-\\" => :rl_insert ,
- "\C-]" => :rl_insert ,
- "\C-^" => :rl_insert ,
- @@ -2179,7 +2180,8 @@ module RbReadline
- if args[5..-1] == "emacs"
- mode = @emacs_mode
- elsif args[5..-1] == "vi"
- - mode = @vi_mode
- + $stderr.puts "*** Warning: vi-mode not supported, switching back to emacs mode"
- + mode = @emacs_mode
- else
- mode = @no_mode
- end
- @@ -2329,8 +2331,11 @@ module RbReadline
- when "editing-mode"
- case value
- when "vi"
- - @_rl_keymap = @vi_insertion_keymap
- - @rl_editing_mode = @vi_mode
- + $stderr.puts "*** Warning: vi editing-mode not supported, switching back to emacs"
- + #@_rl_keymap = @vi_insertion_keymap
- + #@rl_editing_mode = @vi_mode
- + @_rl_keymap = @emacs_standard_keymap
- + @rl_editing_mode = @emacs_mode
- when "emacs"
- @_rl_keymap = @emacs_standard_keymap
- @rl_editing_mode = @emacs_mode
- commit 0c802ea3e1544e1783ca9a7bafd30343f36214bb
- Author: HD Moore <[email protected]>
- Date: Wed Sep 30 03:25:39 2009 +0000
- Fixes #345. Adds a more stringent check for ::Encoding class being defined, should work around false positives with getbyte
- git-svn-id: file:///home/svn/framework3/trunk@7095 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index b96cee5..a4dd790 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -4428,7 +4428,7 @@ module RbReadline
- end
- end
- - if defined? ''.getbyte
- + if(Object.const_defined?('Encoding') and Encoding.respond_to?('default_external'))
- @encoding = "X" # ruby 1.9.x or greater
- @encoding_name = Encoding.default_external.to_s
- end
- commit 3500745d70535b3d0141a59476c0b49c33eec6da
- Author: HD Moore <[email protected]>
- Date: Tue Sep 29 03:42:26 2009 +0000
- Revert previous changes, easier to just include infocmp and terminfo
- git-svn-id: file:///home/svn/framework3/trunk@7092 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index 2231c81..b96cee5 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -1822,10 +1822,7 @@ module RbReadline
- def get_term_capabilities(buffer)
- hash = {}
- - buff = IO.popen('infocmp -C 2>/dev/null').read
- - if(buff and not buff.empty? and buff !~ /couldn't open terminfo/)
- - buff.split(':').select{|x| x =~ /(.*)=(.*)/ and hash[$1]=$2.gsub('\\E',"\e").gsub(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
- - end
- + `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}}
- @_rl_term_at7 = hash["@7"]
- @_rl_term_DC = hash["DC"]
- @_rl_term_IC = hash["IC"]
- commit 7b28cdacd833891635486de8ec801b27eab7d349
- Author: HD Moore <[email protected]>
- Date: Tue Sep 29 03:30:15 2009 +0000
- Handle lacking infocmp a little smoother
- git-svn-id: file:///home/svn/framework3/trunk@7091 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index 7660bc4..2231c81 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -1822,7 +1822,10 @@ module RbReadline
- def get_term_capabilities(buffer)
- hash = {}
- - 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}}
- + buff = IO.popen('infocmp -C 2>/dev/null').read
- + if(buff and not buff.empty? and buff !~ /couldn't open terminfo/)
- + buff.split(':').select{|x| x =~ /(.*)=(.*)/ and hash[$1]=$2.gsub('\\E',"\e").gsub(/\^(.)/){($1[0].ord ^ ((?a..?z).include?($1[0]) ? 0x60 : 0x40)).chr}}
- + end
- @_rl_term_at7 = hash["@7"]
- @_rl_term_DC = hash["DC"]
- @_rl_term_IC = hash["IC"]
- commit 542b3de249c2d7fd71114d837e8cb9bd1090c526
- Author: HD Moore <[email protected]>
- Date: Tue Sep 29 03:26:23 2009 +0000
- Handle the case where there is no infocmp
- git-svn-id: file:///home/svn/framework3/trunk@7090 4d416f70-5f16-0410-b530-b9f4589650da
- diff --git a/lib/rbreadline.rb b/lib/rbreadline.rb
- index b96cee5..7660bc4 100644
- --- a/lib/rbreadline.rb
- +++ b/lib/rbreadline.rb
- @@ -1822,7 +1822,7 @@ module RbReadline
- def get_term_capabilities(buffer)
- hash = {}
- - `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}}
- + 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}}
- @_rl_term_at7 = hash["@7"]
- @_rl_term_DC = hash["DC"]
- @_rl_term_IC = hash["IC"]
Advertisement
Add Comment
Please, Sign In to add comment