diff --git a/terminal/src/main/java/org/jline/utils/InfoCmp.java b/terminal/src/main/java/org/jline/utils/InfoCmp.java index 8ba47198d..eb567b972 100644 --- a/terminal/src/main/java/org/jline/utils/InfoCmp.java +++ b/terminal/src/main/java/org/jline/utils/InfoCmp.java @@ -576,7 +576,9 @@ public static void parseInfoCmp( String key = cap.substring(0, index); String val = cap.substring(index + 1); int iVal; - if (val.startsWith("0x")) { + if ("0".equals(val)) { + iVal = 0; + } else if (val.startsWith("0x")) { iVal = Integer.parseInt(val.substring(2), 16); } else if (val.startsWith("0")) { iVal = Integer.parseInt(val.substring(1), 8); diff --git a/terminal/src/test/java/org/jline/utils/InfoCmpTest.java b/terminal/src/test/java/org/jline/utils/InfoCmpTest.java index 8cf71544a..84861edad 100644 --- a/terminal/src/test/java/org/jline/utils/InfoCmpTest.java +++ b/terminal/src/test/java/org/jline/utils/InfoCmpTest.java @@ -59,10 +59,11 @@ public void testInfoCmpWithHexa() { Map strings = new HashMap<>(); String infocmp = "xterm-256color|xterm with 256 colors,\n" + "\tam, bce, ccc, km, mc5i, mir, msgr, npc, xenl,\n" + - "\tcolors#0x100, cols#80, it#8, lines#24, pairs#0x7fff,\n" + + "\tcolors#0x100, cols#010, it#0, lines#24, pairs#0x7fff,\n" + "\tacsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,\n" + "\tbel=^G, blink=\\E[5m, bold=\\E[1m, cbt=\\E[Z, civis=\\E[?25l\n"; InfoCmp.parseInfoCmp(infocmp, bools, ints, strings); + assertEquals(8, (int) ints.get(Capability.columns)); assertEquals(0x100, (int) ints.get(Capability.max_colors)); assertEquals(0x7fff, (int) ints.get(Capability.max_pairs)); }