diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-10-16 23:28:05 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-10-16 23:28:05 +0000 |
| commit | 01c93d0aad6299e7929285cbc14f95ea73917e48 (patch) | |
| tree | 73bda982e4539bd8d1473b2e6b54b6c6a2d4beeb | |
| parent | c05d37d9210769cd3f9231ef40ac1724df8c74c5 (diff) | |
| download | pcsxr-01c93d0aad6299e7929285cbc14f95ea73917e48.tar.gz | |
Fix OS X’s SysPrintf, when sent strings without a newline. Before, it used NSLog which outputs stuff sent to it one line at a time.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@87500 e17a0e51-4ae3-4d35-97c3-1a29b211df97
| -rwxr-xr-x | macosx/main.m | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/macosx/main.m b/macosx/main.m index d37bf104..ab1707fa 100755 --- a/macosx/main.m +++ b/macosx/main.m @@ -121,7 +121,7 @@ void SysReset() #ifdef EMU_LOG #ifndef LOG_STDOUT -static NSDateFormatter* debugDateFormatter() +static inline NSDateFormatter* debugDateFormatter() { static NSDateFormatter* theFormatter = nil; if (theFormatter == nil) { @@ -133,7 +133,29 @@ static NSDateFormatter* debugDateFormatter() #endif #endif -void SysPrintf(const char *fmt, ...) { +static void AddStringToLogList(const char *themsg) +{ + static NSMutableString *theStr; + NSRange newlineRange, fullLineRange; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + theStr = [[NSMutableString alloc] init]; + }); + [theStr appendString:@(themsg)]; + while ((newlineRange = [theStr rangeOfString:@"\n"]).location != NSNotFound) { + NSString *tmpStr = [theStr substringFromIndex:newlineRange.location]; + if (tmpStr && ![tmpStr isEqualToString:@""]) { + NSLog(@"%@", tmpStr); + } + fullLineRange.location = 0; + fullLineRange.length = newlineRange.location + newlineRange.length; + fullLineRange = [theStr rangeOfComposedCharacterSequencesForRange:fullLineRange]; + [theStr deleteCharactersInRange:fullLineRange]; + } +} + +void SysPrintf(const char *fmt, ...) +{ va_list list; char *msg = calloc(sizeof(char), 512); @@ -142,7 +164,7 @@ void SysPrintf(const char *fmt, ...) { va_end(list); RunOnMainThreadSync(^{ - if (Config.PsxOut) NSLog (@"%s", msg); + if (Config.PsxOut) AddStringToLogList(msg); #ifdef EMU_LOG #ifndef LOG_STDOUT if (emuLog) fprintf(emuLog, "%s %s: %s",[[debugDateFormatter() stringFromDate:[NSDate date]] UTF8String], @@ -214,7 +236,8 @@ void SysUpdate() } // Returns to the Gui -void SysRunGui() { +void SysRunGui() +{ if (powerAssertion != kIOPMNullAssertionID) { IOPMAssertionRelease(powerAssertion); powerAssertion = kIOPMNullAssertionID; @@ -222,7 +245,8 @@ void SysRunGui() { } // Close mem and plugins -void SysClose() { +void SysClose() +{ EmuShutdown(); ReleasePlugins(); |
