parent
e44e995b7f
commit
af8fafb52c
|
@ -0,0 +1,153 @@
|
|||
From 2c1f45f3791f274855e0f5fd2fb0af71c9a756f7 Mon Sep 17 00:00:00 2001
|
||||
From: Bernhard Urban <bernhard.urban@xamarin.com>
|
||||
Date: Wed, 14 Feb 2018 05:35:11 +0100
|
||||
Subject: [PATCH] [TermInfo] support new file format terminfo2 introduced with
|
||||
ncurses6.1 (#6960)
|
||||
|
||||
See also https://github.com/mirror/ncurses/commit/1501ae2a13db0ffd2db8404c24aa5010a88ea91b#diff-2c0786db969084ba9e087d82f8275e0b
|
||||
|
||||
Fixes https://github.com/mono/mono/issues/6752
|
||||
---
|
||||
configure.ac | 2 +-
|
||||
mcs/class/corlib/System/TermInfoReader.cs | 62 +++++++++++++++++++++++--------
|
||||
2 files changed, 48 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/mcs/class/corlib/System/TermInfoReader.cs b/mcs/class/corlib/System/TermInfoReader.cs
|
||||
index a171706add61..2be4627e7910 100644
|
||||
--- mcs/class/corlib/System/TermInfoReader.cs
|
||||
+++ mcs/class/corlib/System/TermInfoReader.cs
|
||||
@@ -32,7 +32,8 @@
|
||||
using System.Text;
|
||||
namespace System {
|
||||
// This class reads data from a byte array or file containing the terminfo capabilities
|
||||
- // information for any given terminal. The maximum allowed size is 4096 bytes.
|
||||
+ // information for any given terminal. The maximum allowed size is 4096 (or
|
||||
+ // 32768 for terminfo2) bytes.
|
||||
//
|
||||
// Terminfo database files are divided in the following sections:
|
||||
//
|
||||
@@ -45,7 +46,7 @@ namespace System {
|
||||
//
|
||||
// The header is as follows:
|
||||
//
|
||||
- // Magic number (0x1 and 0x1A)
|
||||
+ // Magic number (0x11A/0432 or 0x21e/01036 for terminfo2)
|
||||
// Terminal names size
|
||||
// Boolean section size
|
||||
// Numeric section size
|
||||
@@ -58,8 +59,9 @@ namespace System {
|
||||
// The boolean capabilities section has bytes that are set to 1 if the capability is supported
|
||||
// and 0 otherwise. If the index of a capability is greater than the section size, 0 is assumed.
|
||||
//
|
||||
- // The numeric capabilities section holds 2-byte integers in little endian format. No negative
|
||||
- // values are allowed and the absence of a capability is marked as two 0xFF.
|
||||
+ // The numeric capabilities section holds 2-byte integers (4-byte integers for terminfo2) in
|
||||
+ // little endian format. No negative values are allowed and the absence of a capability is marked
|
||||
+ // as two 0xFF (four 0xFF for terminfo2).
|
||||
//
|
||||
// The string offsets section contains 2-byte integer offsets into the string capabilies section.
|
||||
// If the capability is not supported, the index will be two 0xFF bytes.
|
||||
@@ -72,17 +74,17 @@ namespace System {
|
||||
//
|
||||
|
||||
class TermInfoReader {
|
||||
- //short nameSize;
|
||||
- short boolSize;
|
||||
- short numSize;
|
||||
- short strOffsets;
|
||||
- //short strSize;
|
||||
+ int boolSize;
|
||||
+ int numSize;
|
||||
+ int strOffsets;
|
||||
|
||||
//string [] names; // Last one is the description
|
||||
byte [] buffer;
|
||||
int booleansOffset;
|
||||
//string term;
|
||||
|
||||
+ int intOffset;
|
||||
+
|
||||
public TermInfoReader (string term, string filename)
|
||||
{
|
||||
using (FileStream st = File.OpenRead (filename)) {
|
||||
@@ -114,12 +116,21 @@ public TermInfoReader (string term, byte [] buffer)
|
||||
// get { return term; }
|
||||
// }
|
||||
|
||||
+ void DetermineVersion (short magic)
|
||||
+ {
|
||||
+ if (magic == 0x11a)
|
||||
+ intOffset = 2;
|
||||
+ else if (magic == 0x21e)
|
||||
+ intOffset = 4;
|
||||
+ else
|
||||
+ throw new Exception (String.Format ("Magic number is unexpected: {0}", magic));
|
||||
+ }
|
||||
+
|
||||
void ReadHeader (byte [] buffer, ref int position)
|
||||
{
|
||||
short magic = GetInt16 (buffer, position);
|
||||
position += 2;
|
||||
- if (magic != 282)
|
||||
- throw new Exception (String.Format ("Magic number is wrong: {0}", magic));
|
||||
+ DetermineVersion (magic);
|
||||
|
||||
/*nameSize =*/ GetInt16 (buffer, position);
|
||||
position += 2;
|
||||
@@ -161,8 +172,8 @@ public int Get (TermInfoNumbers number)
|
||||
if ((offset % 2) == 1)
|
||||
offset++;
|
||||
|
||||
- offset += ((int) number) * 2;
|
||||
- return GetInt16 (buffer, offset);
|
||||
+ offset += ((int) number) * intOffset;
|
||||
+ return GetInteger (buffer, offset);
|
||||
}
|
||||
|
||||
public string Get (TermInfoStrings tstr)
|
||||
@@ -175,7 +186,7 @@ public string Get (TermInfoStrings tstr)
|
||||
if ((offset % 2) == 1)
|
||||
offset++;
|
||||
|
||||
- offset += numSize * 2;
|
||||
+ offset += numSize * intOffset;
|
||||
int off2 = GetInt16 (buffer, offset + (int) tstr * 2);
|
||||
if (off2 == -1)
|
||||
return null;
|
||||
@@ -193,7 +204,7 @@ public string Get (TermInfoStrings tstr)
|
||||
if ((offset % 2) == 1)
|
||||
offset++;
|
||||
|
||||
- offset += numSize * 2;
|
||||
+ offset += numSize * intOffset;
|
||||
int off2 = GetInt16 (buffer, offset + (int) tstr * 2);
|
||||
if (off2 == -1)
|
||||
return null;
|
||||
@@ -211,6 +222,27 @@ short GetInt16 (byte [] buffer, int offset)
|
||||
return (short) (uno + dos * 256);
|
||||
}
|
||||
|
||||
+ int GetInt32 (byte [] buffer, int offset)
|
||||
+ {
|
||||
+ int b1 = (int) buffer [offset];
|
||||
+ int b2 = (int) buffer [offset + 1];
|
||||
+ int b3 = (int) buffer [offset + 2];
|
||||
+ int b4 = (int) buffer [offset + 3];
|
||||
+ if (b1 == 255 && b2 == 255 && b3 == 255 && b4 == 255)
|
||||
+ return -1;
|
||||
+
|
||||
+ return b1 + b2 << 8 + b3 << 16 + b4 << 24;
|
||||
+ }
|
||||
+
|
||||
+ int GetInteger (byte [] buffer, int offset)
|
||||
+ {
|
||||
+ if (intOffset == 2)
|
||||
+ return GetInt16 (buffer, offset);
|
||||
+ else
|
||||
+ // intOffset == 4
|
||||
+ return GetInt32 (buffer, offset);
|
||||
+ }
|
||||
+
|
||||
string GetString (byte [] buffer, int offset)
|
||||
{
|
||||
int length = 0;
|
|
@ -1,6 +1,6 @@
|
|||
# Template file for 'mono'
|
||||
pkgname=mono
|
||||
version=5.4.1.7
|
||||
version=5.8.0.108
|
||||
revision=1
|
||||
wrksrc="mono-${version}"
|
||||
lib32disabled=yes
|
||||
|
@ -15,7 +15,7 @@ maintainer="Juan RP <xtraeme@voidlinux.eu>"
|
|||
homepage="http://www.mono-project.com"
|
||||
license="MIT, 3-clause-BSD, GPL-2, LGPL-2, MPL-1.1"
|
||||
distfiles="http://download.mono-project.com/sources/mono/$pkgname-$version.tar.bz2"
|
||||
checksum=543d9ec2ccebad9bb8425b22e10271f13d9512487c0e1578eeccdb1b8dc6a055
|
||||
checksum=ecd7c55c2f62caa65fb360ace74a45ee44bbe2de046566d90594ba66c082f39c
|
||||
|
||||
case "$XBPS_TARGET_MACHINE" in
|
||||
*-musl) configure_args+=" --disable-boehm --without-sigaltstack" ;;
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
site="http://www.mono-project.com/download/"
|
||||
site="http://www.mono-project.com/download/stable/"
|
||||
pattern="Stable \(\K[\d.]+"
|
||||
|
|
Loading…
Reference in New Issue