1
mirror of https://github.com/mpv-player/mpv synced 2024-07-19 20:54:13 +02:00

macosx_application: refactor psn matching code

Objective-C is shorter / more readable than snprintf.
This commit is contained in:
Stefano Pigozzi 2013-05-29 23:57:55 +02:00
parent 8b40494e93
commit a31422bbfe

View File

@ -363,15 +363,13 @@ static void macosx_redirect_output_to_logfile(const char *filename)
static bool psn_matches_current_process(char *psn_arg_to_check)
{
ProcessSerialNumber psn;
size_t psn_length = 5+10+1+10;
char psn_arg[psn_length+1];
GetCurrentProcess(&psn);
snprintf(psn_arg, 5+10+1+10+1, "-psn_%u_%u",
psn.highLongOfPSN, psn.lowLongOfPSN);
psn_arg[psn_length]=0;
return strcmp(psn_arg, psn_arg_to_check) == 0;
NSString *in_psn = [NSString stringWithUTF8String:psn_arg_to_check];
NSString *real_psn = [NSString stringWithFormat:@"-psn_%u_%u",
psn.highLongOfPSN, psn.lowLongOfPSN];
return [real_psn isEqualToString:in_psn];
}
void macosx_finder_args_preinit(int *argc, char ***argv)