vcscanf: change buf type to unsigned char *

The data it points to will be accessed directly.
Also remove casts which are now unnecessary.
This commit is contained in:
Matheus Afonso Martins Moreira 2023-11-02 06:05:37 -03:00
parent 64c883a320
commit 3403b6c604

View file

@ -60,7 +60,7 @@ int __vcscanf(int callback(void *), //
struct FreeMe *next; struct FreeMe *next;
void *ptr; void *ptr;
} *freeme = NULL; } *freeme = NULL;
void *buf = NULL; unsigned char *buf = NULL;
size_t bufsize; size_t bufsize;
const unsigned char *p = (const unsigned char *)fmt; const unsigned char *p = (const unsigned char *)fmt;
int *n_ptr; int *n_ptr;
@ -321,7 +321,7 @@ int __vcscanf(int callback(void *), //
} }
if (c != -1 && j + !rawmode < bufsize && (rawmode || !isspace(c))) { if (c != -1 && j + !rawmode < bufsize && (rawmode || !isspace(c))) {
if (charbytes == 1) { if (charbytes == 1) {
((unsigned char *)buf)[j++] = (unsigned char)c; buf[j++] = (unsigned char)c;
c = READ; c = READ;
} else if (tpdecodecb((wint_t *)&c, c, (void *)callback, arg) != } else if (tpdecodecb((wint_t *)&c, c, (void *)callback, arg) !=
-1) { -1) {
@ -343,7 +343,7 @@ int __vcscanf(int callback(void *), //
goto Done; goto Done;
} else if (!rawmode && j < bufsize) { } else if (!rawmode && j < bufsize) {
if (charbytes == sizeof(char)) { if (charbytes == sizeof(char)) {
((unsigned char *)buf)[j] = '\0'; buf[j] = '\0';
} else if (charbytes == sizeof(char16_t)) { } else if (charbytes == sizeof(char16_t)) {
((char16_t *)buf)[j] = u'\0'; ((char16_t *)buf)[j] = u'\0';
} else if (charbytes == sizeof(wchar_t)) { } else if (charbytes == sizeof(wchar_t)) {
@ -355,7 +355,7 @@ int __vcscanf(int callback(void *), //
} }
++items; ++items;
if (ismalloc) { if (ismalloc) {
*va_arg(va, char **) = buf; *va_arg(va, char **) = (void *) buf;
} }
} else { } else {
do { do {