Created
February 18, 2025 11:26
-
-
Save pookjw/347a1fac244eea2f085308872e650b7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#import <AppKit/AppKit.h> | |
APPKIT_EXTERN size_t _NSParseWithFormat(NSString *, NSString *, ...); | |
int call_vsscanf_l(const char *tokenstring, const char *format, ...) { | |
int result; | |
va_list arglist; | |
va_start(arglist, format); | |
result = vsscanf_l(tokenstring, 0, format, arglist); | |
va_end(arglist); | |
return result; | |
} | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
float v_1; | |
float v_2; | |
float v_3; | |
float v_4; | |
int n_1; | |
float v_5; | |
float v_6; | |
float v_7; | |
float v_8; | |
int n_2; | |
size_t s_1 = call_vsscanf_l("-643 162 400 828 -2304 0 2304 1271 ", "%f %f %f %f %n%f %f %f %f %n", &v_1, &v_2, &v_3, &v_4, &n_1, &v_5, &v_6, &v_7, &v_8, &n_2); | |
assert(s_1 == 8); | |
assert(n_1 == 17); | |
assert(n_2 == 35); | |
assert(v_1 == -643.0f); | |
assert(v_2 == 162.0f); | |
assert(v_3 == 400.0f); | |
assert(v_4 == 828.0f); | |
assert(v_5 == -2304.0f); | |
assert(v_6 == 0.0f); | |
assert(v_7 == 2304.0f); | |
assert(v_8 == 1271.0f); | |
size_t s_2 = _NSParseWithFormat(@"-643 162 400 828 -2304 0 2304 1271 ", @"%f %f %f %f %n%f %f %f %f %n", &v_1, &v_2, &v_3, &v_4, &n_1, &v_5, &v_6, &v_7, &v_8, &n_2); | |
assert(s_2 == 8); | |
assert(n_1 == 17); | |
assert(n_2 == 35); | |
assert(v_1 == -643.0f); | |
assert(v_2 == 162.0f); | |
assert(v_3 == 400.0f); | |
assert(v_4 == 828.0f); | |
assert(v_5 == -2304.0f); | |
assert(v_6 == 0.0f); | |
assert(v_7 == 2304.0f); | |
assert(v_8 == 1271.0f); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment