From b320e319dcbea9edcd5ececa6e80e08e8c6b0fbf Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Fri, 17 Jan 2025 07:08:50 +0800 Subject: [PATCH 1/2] Revert "suppress IsMenuKeyEvent: in stderr" This reverts commit c72427be7236045a110acac62f2afa8810869020. --- RController.m | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git RController.m RController.m index cf493bb..db7e366 100644 --- RController.m +++ RController.m @@ -2109,25 +2109,6 @@ issuing the newline. [consoleTextView insertText:text]; } */ - -/* A bad hack to remove output from the stream - it is used to remove - stderr output caused by buggy Apple code that we have no control over. - It is assumed that s is allocated so if a replacement is necessary, - it will be released and a new string allocated. - */ -static NSString *fixBuggyOutput(NSString *s, NSString *regExp) { - NSRange r = [s rangeOfString:regExp options:NSRegularExpressionSearch]; - if (r.location != NSNotFound) { - NSString *os = s; - NSUInteger start, end; - [s getLineStart:&start end:&end contentsEnd:0 forRange:r]; - s = [os stringByReplacingCharactersInRange:NSMakeRange(start, end-start) withString:@""]; - [s retain]; - [os release]; - } - return s; -} - /* This function is used by two threads to write stderr and/or stdout to the console length: -1 = the string is null-terminated outputType: 0 = stdout, 1 = stderr, 2 = stdout/err as root @@ -2137,14 +2118,20 @@ outputType: 0 = stdout, 1 = stderr, 2 = stdout/err as root NSColor *color=(outputType==0)?[consoleColors objectAtIndex:iStdoutColor]:((outputType==1)?[consoleColors objectAtIndex:iStderrColor]:[consoleColors objectAtIndex:iRootColor]); if (len>=0 && buf[len]!=0) buf[len]=0; /* this MAY be dangerous ... */ NSString *s = [[NSString alloc] initWithUTF8String:buf]; - if (outputType == 1) { - // FIXME horrible, horrible hack - this warning seems to be a macOS bug, because - // we never create NSPopoverTouchBarItemButton, so we suppress it in the console - // by removing a line with that content - s = fixBuggyOutput(s, @"Warning: Expected min height of view: .* to be less than or equal to "); - /* bug in Monterey and up */ - s = fixBuggyOutput(s, @"IsMenuKeyEvent: found no unichar data in event; retranslated without deadkeys to produce"); - } + if (outputType == 1) { + // FIXME horrible, horrible hack - this warning seems to be a macOS bug, because + // we never create NSPopoverTouchBarItemButton, so we suppress it in the console + // by removing a line with that content + NSRange r = [s rangeOfString:@"Warning: Expected min height of view: .* to be less than or equal to " options:NSRegularExpressionSearch]; + if (r.location != NSNotFound) { + NSString *os = s; + NSUInteger start, end; + [s getLineStart:&start end:&end contentsEnd:0 forRange:r]; + s = [os stringByReplacingCharactersInRange:NSMakeRange(start, end-start) withString:@""]; + [s retain]; + [os release]; + } + } [self flushROutput]; [self writeConsoleDirectly:s withColor:color]; [s release]; -- 2.48.0