From 60245f9da027d5e5c721664aff33ba5d87b9ce68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9=20=D0=9F=D1=83?= =?UTF-8?q?=D0=B7=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 13 Dec 2020 11:29:15 +0300 Subject: [PATCH] Fix for C89 compatibility --- Makefile | 2 +- uprintf.c | 6 +++--- uprintf.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index ab107bc..7fa9752 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ all: test test: test.c uprintf.c uprintf.h - gcc -std=c99 -Os -o test test.c uprintf.c + gcc -std=c89 -Os -o test test.c uprintf.c clean: rm -rf test diff --git a/uprintf.c b/uprintf.c index c1ac216..82da79a 100644 --- a/uprintf.c +++ b/uprintf.c @@ -66,12 +66,12 @@ static int l_strlen(const char *str) /* Helper functions for p() */ static void print_string(put_char_func pc, const char *str, int width, char wchr) { - int sl; + int sl, w; if (width < 0) { sl = l_strlen(str); - for (int w = -width; w > sl; w --) + for (w = -width; w > sl; w --) pc(wchr); } @@ -80,7 +80,7 @@ static void print_string(put_char_func pc, const char *str, int width, char wchr if (width > 0) { - for (int w = width; w > sl; w --) + for (w = width; w > sl; w --) pc(wchr); } } diff --git a/uprintf.h b/uprintf.h index 1104de5..5e0662e 100644 --- a/uprintf.h +++ b/uprintf.h @@ -12,4 +12,4 @@ void pp(put_char_func pc, const char *fmt, ...); void p(const char *fmt, ...); int psn(char *str, int size, const char *fmt, ...); -#endif // _UPRINTF +#endif /* _UPRINTF */