mescc: Tinycc support: vsnprintf.

* module/language/c99/compiler.mes (ast-type->type): Support *p++ in test.
* mlibc/libc-mes+tcc.c (vsnprintf): Implement.
This commit is contained in:
Jan Nieuwenhuizen 2017-08-01 13:24:23 +02:00
parent 0b60a58809
commit 4fbd16aaac
2 changed files with 23 additions and 2 deletions

View File

@ -335,8 +335,27 @@ time_t time (time_t *tloc)
int
vsnprintf (char *str, size_t size, char const *format, va_list ap)
{
eputs ("vsnprintf stub\n");
return 0;
char const *p = format;
while (*p)
if (*p != '%')
*str++ = *p++;
else
{
p++;
char c = *p;
switch (c)
{
case '%': {*str++ = *p; break;}
case 'c': {char c; c = va_arg (ap, char); *str++=c; break;}
case 'd': {int d; d = va_arg (ap, int); strcpy (str, itoa (d)); break;}
case 's': {char *s; s = va_arg (ap, char *); strcpy (str, s); break;}
default: {*str++ = *p; break;}
}
p++;
}
va_end (ap);
*str = 0;
return strlen (str);
}
void *

View File

@ -1283,6 +1283,8 @@
(define (ast-type->type info o)
(pmatch o
((p-expr ,expr) (ast-type->type info (p-expr->type info o)))
((pre-inc ,expr) (ast-type->type info expr))
((post-inc ,expr) (ast-type->type info expr))
((decl-spec-list ,type-spec)
(ast-type->type info type-spec))
((decl-spec-list (type-qual ,qual) (type-spec (fixed-type ,type)))