From 5bf39e2e67ed258de26e03f5393e9d1f03487c2d Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 6 Oct 2016 14:01:14 +0200 Subject: [PATCH] Fix xamarin_log to not treat % as format specifiers. Fixes #45046. --- runtime/xamarin-support.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runtime/xamarin-support.m b/runtime/xamarin-support.m index 62186ad637ca..295b366d1c04 100644 --- a/runtime/xamarin-support.m +++ b/runtime/xamarin-support.m @@ -21,13 +21,22 @@ xamarin_log (const unsigned short *unicodeMessage) { // COOP: no managed memory access: any mode. +#if TARGET_OS_WATCH && defined (__arm__) // maybe make this configurable somehow? int length = 0; const unsigned short *ptr = unicodeMessage; while (*ptr++) length += sizeof (unsigned short); NSString *msg = [[NSString alloc] initWithBytes: unicodeMessage length: length encoding: NSUTF16LittleEndianStringEncoding]; - xamarin_printf ([msg UTF8String]); + const char *utf8 = [msg UTF8String]; + int len = strlen (utf8); + fwrite (utf8, 1, len, stdout); + if (len == 0 || utf8 [len - 1] != '\n') + fwrite ("\n", 1, 1, stdout); + fflush (stdout); [msg release]; +#else + NSLog (@"%S", unicodeMessage); +#endif } void*