Fix missing execve; add .* printf support for s
This commit is contained in:
parent
bc104fe5d9
commit
03ab5b9f78
@ -18,6 +18,7 @@ extern int execle(const char *path, const char *arg, ...);
|
||||
extern int execv(const char *path, char *const argv[]);
|
||||
extern int execvp(const char *file, char *const argv[]);
|
||||
extern int execvpe(const char *file, char *const argv[], char *const envp[]);
|
||||
extern int execve(const char *name, char * const argv[], char * const envp[]);
|
||||
extern void _exit(int status);
|
||||
|
||||
extern int setuid(uid_t uid);
|
||||
|
@ -100,7 +100,7 @@ size_t xvasprintf(char * buf, const char * fmt, va_list args) {
|
||||
int i = 0;
|
||||
char * s;
|
||||
char * b = buf;
|
||||
int precision = 0;
|
||||
int precision = -1;
|
||||
for (const char *f = fmt; *f; f++) {
|
||||
if (*f != '%') {
|
||||
*b++ = *f;
|
||||
@ -131,10 +131,15 @@ size_t xvasprintf(char * buf, const char * fmt, va_list args) {
|
||||
if (*f == '.') {
|
||||
++f;
|
||||
precision = 0;
|
||||
while (*f >= '0' && *f <= '9') {
|
||||
precision *= 10;
|
||||
precision += *f - '0';
|
||||
if (*f == '*') {
|
||||
precision = (int)va_arg(args, int);
|
||||
++f;
|
||||
} else {
|
||||
while (*f >= '0' && *f <= '9') {
|
||||
precision *= 10;
|
||||
precision += *f - '0';
|
||||
++f;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (*f == 'l') {
|
||||
@ -162,7 +167,7 @@ size_t xvasprintf(char * buf, const char * fmt, va_list args) {
|
||||
if (s == NULL) {
|
||||
s = "(null)";
|
||||
}
|
||||
if (precision > 0) {
|
||||
if (precision >= 0) {
|
||||
while (*s && precision > 0) {
|
||||
*b++ = *s++;
|
||||
count++;
|
||||
|
Loading…
Reference in New Issue
Block a user