Fix for C89 compatibility

This commit is contained in:
Николай Пузанов 2020-12-13 11:29:15 +03:00
parent ba79eaf7f4
commit 60245f9da0
3 changed files with 5 additions and 5 deletions

View File

@ -1,7 +1,7 @@
all: test all: test
test: test.c uprintf.c uprintf.h 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: clean:
rm -rf test rm -rf test

View File

@ -66,12 +66,12 @@ static int l_strlen(const char *str)
/* Helper functions for p() */ /* Helper functions for p() */
static void print_string(put_char_func pc, const char *str, int width, char wchr) static void print_string(put_char_func pc, const char *str, int width, char wchr)
{ {
int sl; int sl, w;
if (width < 0) if (width < 0)
{ {
sl = l_strlen(str); sl = l_strlen(str);
for (int w = -width; w > sl; w --) for (w = -width; w > sl; w --)
pc(wchr); pc(wchr);
} }
@ -80,7 +80,7 @@ static void print_string(put_char_func pc, const char *str, int width, char wchr
if (width > 0) if (width > 0)
{ {
for (int w = width; w > sl; w --) for (w = width; w > sl; w --)
pc(wchr); pc(wchr);
} }
} }

View File

@ -12,4 +12,4 @@ void pp(put_char_func pc, const char *fmt, ...);
void p(const char *fmt, ...); void p(const char *fmt, ...);
int psn(char *str, int size, const char *fmt, ...); int psn(char *str, int size, const char *fmt, ...);
#endif // _UPRINTF #endif /* _UPRINTF */