Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c99aa51

Browse files
committed
Merge remote-tracking branch 'upstream/master' into from-tfs
Conflicts: src/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj src/System.Threading.Tasks/tests/project.lock.json
2 parents d8781a0 + fd08a1e commit c99aa51

File tree

70 files changed

+25578
-504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+25578
-504
lines changed

src/Common/src/Interop/Unix/libcoreclr/Interop.OpenSemaphore.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Common/src/Interop/Unix/libcurl/Interop.libcurl.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,8 @@ public static extern IntPtr curl_slist_append(
140140
[DllImport(Interop.Libraries.LibCurl)]
141141
public static extern void curl_slist_free_all(
142142
IntPtr curl_slist);
143+
144+
[DllImport(Interop.Libraries.LibCurl)]
145+
public static extern IntPtr curl_version_info(int curlVersionStamp);
143146
}
144147
}

src/Common/src/Interop/Unix/libcurl/Interop.libcurl_types.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,30 @@ internal static partial class CURLMSG
125125
internal const int CURLMSG_DONE = 1;
126126
}
127127

128+
internal static partial class CURL_VERSION_Features
129+
{
130+
internal const int CURL_VERSION_IPV6 = (1<<0);
131+
internal const int CURL_VERSION_KERBEROS4 = (1<<1);
132+
internal const int CURL_VERSION_SSL = (1<<2);
133+
internal const int CURL_VERSION_LIBZ = (1<<3);
134+
internal const int CURL_VERSION_NTLM = (1<<4);
135+
internal const int CURL_VERSION_GSSNEGOTIATE = (1<<5);
136+
internal const int CURL_VERSION_DEBUG = (1<<6);
137+
internal const int CURL_VERSION_ASYNCHDNS = (1<<7);
138+
internal const int CURL_VERSION_SPNEGO = (1<<8);
139+
internal const int CURL_VERSION_LARGEFILE = (1<<9);
140+
internal const int CURL_VERSION_IDN = (1<<10);
141+
internal const int CURL_VERSION_SSPI = (1<<11);
142+
internal const int CURL_VERSION_CONV = (1<<12);
143+
internal const int CURL_VERSION_CURLDEBUG = (1<<13);
144+
internal const int CURL_VERSION_TLSAUTH_SRP = (1<<14);
145+
internal const int CURL_VERSION_NTLM_WB = (1<<15);
146+
internal const int CURL_VERSION_HTTP2 = (1<<16);
147+
internal const int CURL_VERSION_GSSAPI = (1<<17);
148+
internal const int CURL_VERSION_KERBEROS5 = (1<<18);
149+
internal const int CURL_VERSION_UNIX_SOCKETS = (1<<19);
150+
}
151+
128152
// Type definition of CURLMsg from multi.h
129153
[StructLayout(LayoutKind.Explicit)]
130154
internal struct CURLMsg
@@ -139,6 +163,19 @@ internal struct CURLMsg
139163
internal int result;
140164
}
141165

166+
// NOTE: The definition of this structure in Curl/curl.h is larger than
167+
// than what is defined below. This definition is only valid for use with
168+
// Marshal.PtrToStructure and not for general use in P/Invoke signatures.
169+
[StructLayout(LayoutKind.Sequential)]
170+
internal struct curl_version_info_data
171+
{
172+
internal int age;
173+
private unsafe char *version;
174+
private int versionNum;
175+
private unsafe char *host;
176+
internal int features;
177+
}
178+
142179
public delegate int curl_socket_callback(
143180
IntPtr handle,
144181
curl_socket_t sockfd,

src/System.Console/src/System/ConsolePal.Unix.cs

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ namespace System
1818
// e.g. for reading/writing /dev/stdin, /dev/stdout, and /dev/stderr,
1919
// for getting environment variables for accessing charset information for encodings,
2020
// and terminfo databases / strings for manipulating the terminal.
21+
// NOTE: The test class reflects over this class to run the tests due to limitations in
22+
// the test infrastructure that prevent OS-specific builds of test binaries. If you
23+
// change any of the class / struct / function names, parameters, etc then you need
24+
// to also change the test class.
2125
internal static class ConsolePal
2226
{
2327
public static Stream OpenStandardInput()
@@ -251,26 +255,27 @@ private struct TerminalColorInfo
251255
/// <summary>The cached instance.</summary>
252256
public static TerminalColorInfo Instance { get { return _instance.Value; } }
253257

258+
private TerminalColorInfo(TermInfo.Database db)
259+
{
260+
ForegroundFormat = db != null ? db.GetString(TermInfo.Database.SetAnsiForegroundIndex) : string.Empty;
261+
BackgroundFormat = db != null ? db.GetString(TermInfo.Database.SetAnsiBackgroundIndex) : string.Empty;
262+
ResetFormat = db != null ?
263+
db.GetString(TermInfo.Database.OrigPairsIndex) ??
264+
db.GetString(TermInfo.Database.OrigColorsIndex)
265+
: string.Empty;
266+
267+
int maxColors = db != null ? db.GetNumber(TermInfo.Database.MaxColorsIndex) : 0;
268+
MaxColors = // normalize to either the full range of all ANSI colors, just the dark ones, or none
269+
maxColors >= 16 ? 16 :
270+
maxColors >= 8 ? 8 :
271+
0;
272+
}
273+
254274
/// <summary>Lazy initialization of the terminal color information.</summary>
255275
private static Lazy<TerminalColorInfo> _instance = new Lazy<TerminalColorInfo>(() =>
256276
{
257-
TermInfo.Database db = TermInfo.Database.Instance;
258-
TerminalColorInfo tci = new TerminalColorInfo();
259-
if (db != null)
260-
{
261-
tci.ForegroundFormat = db.GetString(TermInfo.Database.SetAnsiForegroundIndex);
262-
tci.BackgroundFormat = db.GetString(TermInfo.Database.SetAnsiBackgroundIndex);
263-
tci.ResetFormat =
264-
db.GetString(TermInfo.Database.OrigPairsIndex) ??
265-
db.GetString(TermInfo.Database.OrigColorsIndex);
266-
267-
int maxColors = db.GetNumber(TermInfo.Database.MaxColorsIndex);
268-
tci.MaxColors = // normalize to either the full range of all ANSI colors, just the dark ones, or none
269-
maxColors >= 16 ? 16 :
270-
maxColors >= 8 ? 8 :
271-
0;
272-
}
273-
return tci;
277+
TermInfo.Database db = TermInfo.Database.Instance; // Could be null if TERM is set to a file that doesn't exist
278+
return new TerminalColorInfo(db);
274279
}, isThreadSafe: true);
275280
}
276281

@@ -902,10 +907,16 @@ private static string EvaluateInternal(
902907
~value);
903908
break;
904909

905-
// Augment first two parameters by 1
910+
// Some terminfo files appear to have a fairly liberal interpretation of %i. The spec states that %i increments the first two arguments,
911+
// but some uses occur when there's only a single argument. To make sure we accomodate these files, we increment the values
912+
// of up to (but not requiring) two arguments.
906913
case 'i':
907-
args[0] = 1 + args[0].Int32;
908-
args[1] = 1 + args[1].Int32;
914+
if (args.Length > 0)
915+
{
916+
args[0] = 1 + args[0].Int32;
917+
if (args.Length > 1)
918+
args[1] = 1 + args[1].Int32;
919+
}
909920
break;
910921

911922
// Conditional of the form %? if-part %t then-part %e else-part %;

src/System.Console/tests/System.Console.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<Compile Include="Timeout.cs" />
2727
<Compile Include="ThreadSafety.cs" />
2828
<Compile Include="XunitAssemblyAttributes.cs" />
29+
<Compile Include="TermInfo.cs" />
2930
</ItemGroup>
3031
<ItemGroup>
3132
<ProjectReference Include="..\src\System.Console.csproj">

0 commit comments

Comments
 (0)