Skip to content
This repository has been archived by the owner on Feb 23, 2018. It is now read-only.

Commit

Permalink
Fix stty parsing on HP/UX
Browse files Browse the repository at this point in the history
  • Loading branch information
gertv committed May 14, 2014
1 parent 2a02a3b commit b457cf1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/jline/internal/TerminalLineSettings.java
Expand Up @@ -115,7 +115,7 @@ public int getProperty(String name) {
*/
protected static int getProperty(String name, String stty) {
// try the first kind of regex
Pattern pattern = Pattern.compile(name + "\\s+=\\s+([^;]*)[;\\n\\r]");
Pattern pattern = Pattern.compile(name + "\\s+=\\s+(.*?)[;\\n\\r]");
Matcher matcher = pattern.matcher(stty);
if (!matcher.find()) {
// try a second kind of regex
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/jline/internal/TerminalLineSettingsTest.java
Expand Up @@ -98,6 +98,20 @@ public class TerminalLineSettingsTest
" lnext = ^V; min = 1; quit = ^\\; reprint = ^R; start = ^Q;\n" +
" status = ^T; stop = ^S; susp = ^Z; time = 0; werase = ^W;";

private final String hpuxSttySample = "speed 38400 baud; line = 0;\n" +
"rows = 52; columns = 151\n" +
"min = 4; time = 0;\n" +
"intr = DEL; quit = ^\\; erase = #; kill = @\n" +
"eof = ^D; eol = ^@; eol2 <undef>; swtch = ^@\n" +
"stop = ^S; start = ^Q; susp <undef>; dsusp <undef>\n" +
"werase <undef>; lnext <undef>\n" +
"-parenb -parodd cs8 -cstopb hupcl cread -clocal -loblk -crts\n" +
"-ignbrk brkint ignpar -parmrk -inpck istrip -inlcr -igncr icrnl -iuclc\n" +
"ixon ixany -ixoff -imaxbel -rtsxoff -ctsxon -ienqak\n" +
"isig icanon -iexten -xcase echo -echoe echok -echonl -noflsh\n" +
"-echoctl -echoprt -echoke -flusho -pendin\n" +
"opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel -tostop";

@Before
public void setUp() throws Exception {
}
Expand Down Expand Up @@ -153,4 +167,11 @@ public void testFreeBsdSttyParsing() {
assertEquals(32, TerminalLineSettings.getProperty("rows", freeBsdSttySample));
}

@Test
public void testHpuxSttyParsing() {
assertEquals(0x23, TerminalLineSettings.getProperty("erase", hpuxSttySample));
assertEquals(151, TerminalLineSettings.getProperty("columns", hpuxSttySample));
assertEquals(52, TerminalLineSettings.getProperty("rows", hpuxSttySample));
}

}

0 comments on commit b457cf1

Please sign in to comment.