Support %.*s in exception formatter
This commit is contained in:
parent
0a9eeca62e
commit
d89b023752
@ -453,11 +453,19 @@ KrkValue krk_runtimeError(KrkClass * type, const char * fmt, ...) {
|
||||
++f;
|
||||
|
||||
int size = ' ';
|
||||
int len = -1;
|
||||
|
||||
if (*f == 'z') size = *f++;
|
||||
else if (*f == 'l') size = *f++;
|
||||
else if (*f == 'L') size = *f++;
|
||||
|
||||
if (*f == '.') {
|
||||
if (f[1] == '*') {
|
||||
len = va_arg(args, int);
|
||||
f += 2;
|
||||
}
|
||||
}
|
||||
|
||||
switch (*f) {
|
||||
case 0: break;
|
||||
case '%':
|
||||
@ -472,7 +480,7 @@ KrkValue krk_runtimeError(KrkClass * type, const char * fmt, ...) {
|
||||
|
||||
case 's': {
|
||||
const char * c = va_arg(args, const char *);
|
||||
pushStringBuilderStr(&sb, c, strlen(c));
|
||||
pushStringBuilderStr(&sb, c, len == -1 ? strlen(c) : (size_t)len);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user