ref: 7bd3cc1436b996798a53a948eafea98971d17f8e
parent: dfd2077c64673869adf02ad26c8d39cb124dab00
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Feb 18 01:49:42 EST 2017
[libc] Protect va_list functions in stdio.h These function should be declared only if stdarg was included before including stdio.h. This patch also split long lines.
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -16,51 +16,61 @@
extern int rename(const char *old, const char *new);
extern FILE *tmpfile(void);
extern char *tmpnam(char *s);
-extern int fclose(FILE *stream);
-extern int fflush(FILE *stream);
-extern FILE *fopen(const char * restrict filename, const char * restrict mode);
-extern FILE *freopen(const char * restrict filename, const char * restrict mode,
- FILE * restrict stream);
-extern void setbuf(FILE * restrict stream, char * restrict buf);
-extern int setvbuf(FILE * restrict stream, char * restrict buf, int mode, size_t size);
-extern int fprintf(FILE * restrict stream, const char * restrict format, ...);
-extern int fscanf(FILE * restrict stream, const char * restrict format, ...);
-extern int printf(const char * restrict format, ...);
-extern int scanf(const char * restrict format, ...);
-extern int snprintf(char * restrict s, size_t n, const char * restrict format, ...);
-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 arg);
-extern int vfscanf(FILE * restrict stream, const char * restrict format, va_list arg);
-extern int vprintf(const char * restrict format, va_list arg);
-extern int vscanf(const char * restrict format, va_list arg);
-extern int vsnprintf(char * restrict s, size_t n, const char * restrict format,
- va_list arg);
-extern int vsprintf(char * restrict s, const char * restrict format, va_list arg);
-extern int vsscanf(const char * restrict s, const char * restrict format, va_list arg);
-extern int fgetc(FILE *stream);
-extern char *fgets(char * restrict s, int n, FILE * restrict stream);
-extern int fputc(int c, FILE *stream);
-extern int fputs(const char * restrict s, FILE * restrict stream);
-extern int getc(FILE *stream);
+extern int fclose(FILE *fp);
+extern int fflush(FILE *fp);
+extern FILE *fopen(const char * restrict fname, const char * restrict mode);
+extern FILE *freopen(const char * restrict fname, const char * restrict mode,
+ FILE * restrict fp);
+extern void setbuf(FILE * restrict fp, char * restrict buf);
+extern int setvbuf(FILE * restrict fp,
+ char * restrict buf, int mode, size_t size);
+extern int fprintf(FILE * restrict fp, const char * restrict fmt, ...);
+extern int fscanf(FILE * restrict fp, const char * restrict fmt, ...);
+extern int printf(const char * restrict fmt, ...);
+extern int scanf(const char * restrict fmt, ...);
+extern int snprintf(char * restrict s,
+ size_t n, const char * restrict fmt, ...);
+extern int sprintf(char * restrict s, const char * restrict fmt, ...);
+extern int sscanf(const char * restrict s, const char * restrict fmt, ...);
+
+#ifdef _STDARG_H
+extern int vfprintf(FILE * restrict fp,
+ const char * restrict fmt, va_list arg);
+extern int vfscanf(FILE * restrict fp,
+ const char * restrict fmt, va_list arg);
+extern int vprintf(const char * restrict fmt, va_list arg);
+extern int vscanf(const char * restrict fmt, va_list arg);
+extern int vsnprintf(char * restrict s, size_t n, const char * restrict fmt,
+ va_list arg);
+extern int vsprintf(char * restrict s,
+ const char * restrict fmt, va_list arg);
+extern int vsscanf(const char * restrict s,
+ const char * restrict fmt, va_list arg);
+#endif
+
+extern int fgetc(FILE *fp);
+extern char *fgets(char * restrict s, int n, FILE * restrict fp);
+extern int fputc(int c, FILE *fp);
+extern int fputs(const char * restrict s, FILE * restrict fp);
+extern int getc(FILE *fp);
extern int getchar(void);
extern char *gets(char *s);
-extern int putc(int c, FILE *stream);
+extern int putc(int c, FILE *fp);
extern int putchar(int c);
extern int puts(const char *s);
-extern int ungetc(int c, FILE *stream);
+extern int ungetc(int c, FILE *fp);
extern size_t fread(void * restrict ptr, size_t size, size_t nmemb,
- FILE * restrict stream);
+ FILE * restrict fp);
extern size_t fwrite(const void * restrict ptr, size_t size, size_t nmemb,
- FILE * restrict stream);
-extern int fgetpos(FILE * restrict stream, fpos_t * restrict pos);
-extern int fseek(FILE *stream, long int offset, int whence);
-extern int fsetpos(FILE *stream, const fpos_t *pos);
-extern long int ftell(FILE *stream);
-extern void rewind(FILE *stream);
-extern void clearerr(FILE *stream);
-extern int feof(FILE *stream);
-extern int ferror(FILE *stream);
+ FILE * restrict fp);
+extern int fgetpos(FILE * restrict fp, fpos_t * restrict pos);
+extern int fseek(FILE *fp, long int offset, int whence);
+extern int fsetpos(FILE *fp, const fpos_t *pos);
+extern long int ftell(FILE *fp);
+extern void rewind(FILE *fp);
+extern void clearerr(FILE *fp);
+extern int feof(FILE *fp);
+extern int ferror(FILE *fp);
extern void perror(const char *s);
#endif