[hackers] [scc] [libc] Protect va_list functions in stdio.h || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 18 Feb 2017 06:50:59 +0100 (CET)

commit d801303c0a5a2af35f3ffb570f3d19e75f85e5b4
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Feb 18 06:49:42 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sat Feb 18 06:49:42 2017 +0100

    [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.

diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index 594d20c..8e59d0d 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
_AT_@ -16,51 +16,61 @@ extern int remove(const char *filename);
 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
Received on Sat Feb 18 2017 - 06:50:59 CET

This archive was generated by hypermail 2.3.0 : Sat Feb 18 2017 - 07:00:22 CET