Skip to content
Snippets Groups Projects
Commit fd882edc authored by Mark Somerville's avatar Mark Somerville
Browse files

Fix problem when reading terminal capabilities


An update to the terminfo entry for xterm-256color made between
ncurses-6.0+20170128-1 and ncurses-6.0+20170429-1 on Arch highlights a
problem with how terminal capabilities were being read and affects all
users of rb-readline on Arch.

The particular terminfo change was to alter the cr (carriage return)
capability from:

  ^M

to:

  \r

The rb-readline code that parses the capabilities was mistakenly storing
this capability as:

  \\r

causing "\r" to be displayed when entering a line of input into an
rb-readline program.

While I am reasonably confident that this change is sound, I am
concerned that there are other problems around the way terminal
capabilities are parsed because this patch fixes only this specific
case. Unfortunately, the `infocmp` line is a maze of regexes and escape
characters and checking and reworking it requires more time than I have
available just now.

Fixes #138.

Tested-by: Mark Somerville <mark@scottishclimbs.com> [Arch, MRI 2.4.1]
Signed-off-by: default avatarMark Somerville <mark@scottishclimbs.com>
parent 68457ded
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1812,7 +1812,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}}
`infocmp -C`.split(':').select{|x| x =~ /(.*)=(.*)/ and hash[$1]=$2.gsub("\\r", "\r").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"]
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment