mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Added a stub for sscanf(3).
This stub implements an ugly hack to help port binutils. Hopefully we'll get a real scanf family of functions soon.
This commit is contained in:
parent
f089a030b4
commit
c03738a9f3
2 changed files with 18 additions and 1 deletions
|
@ -102,6 +102,7 @@ extern int snprintf(char* restrict s, size_t n, const char* restrict format, ...
|
|||
extern char* sortix_gets(void);
|
||||
extern int sortix_puts(const char* str);
|
||||
extern int sprintf(char* restrict s, const char* restrict format, ...);
|
||||
extern int sscanf(const char* restrict s, const char* restrict format, ...);
|
||||
extern int vfprintf(FILE* restrict stream, const char* restrict format, va_list ap);
|
||||
extern int vprintf(const char* restrict format, va_list ap);
|
||||
extern int vsnprintf(char* restrict, size_t, const char* restrict, va_list);
|
||||
|
@ -131,7 +132,6 @@ extern int rename(const char* oldname, const char* newname);
|
|||
extern int renameat(int oldfd, const char* oldname, int newfd, const char* newname);
|
||||
extern int scanf(const char* restrict format, ...);
|
||||
extern int setvbuf(FILE* restrict stream, char* restrict buf, int type, size_t size);
|
||||
extern int sscanf(const char* restrict s, const char* restrict format, ...);
|
||||
extern int ungetc(int c, FILE* stream);
|
||||
extern int vdprintf(int fildes, const char* restrict format, va_list ap);
|
||||
extern int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg);
|
||||
|
|
|
@ -119,6 +119,23 @@ namespace Maxsi
|
|||
return (int) result;
|
||||
}
|
||||
|
||||
// TODO: This is an ugly hack to help build binutils.
|
||||
#warning Ugly sscanf hack to help build binutils
|
||||
extern int sscanf(const char* s, const char* format, ...)
|
||||
{
|
||||
if ( strcmp(format, "%x") != 0 )
|
||||
{
|
||||
fprintf(stderr, "sscanf hack doesn't implement: '%s'\n", format);
|
||||
abort();
|
||||
}
|
||||
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
unsigned* dec = va_arg(list, unsigned*);
|
||||
*dec = strtol(s, NULL, 16);
|
||||
return strlen(s);
|
||||
}
|
||||
|
||||
typedef struct vsnprintf_struct
|
||||
{
|
||||
char* str;
|
||||
|
|
Loading…
Add table
Reference in a new issue