From 45ebd05cb682b8a38f21487cb2e871d4d7b31b59 Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Tue, 9 Jan 2024 21:16:32 -0500 Subject: [PATCH] Minor tweaks. --- src/utils.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils.c b/src/utils.c index de9edd31..f64c8f62 100644 --- a/src/utils.c +++ b/src/utils.c @@ -36,6 +36,11 @@ char *StrnCpy(char *dest, char const *source, int n) { char *odest = dest; + if (n <= 0) { + *dest = 0; + return dest; + } + while (n-- && (*dest++ = *source++)) ; if (*(dest-1)) *dest = 0; return odest; @@ -108,7 +113,7 @@ int DateOK(int y, int m, int d) m > 11 || y > BASE + YR_RANGE || d > DaysInMonth(m, y) ) return 0; - else return 1; + return 1; } /* Functions designed to defeat gcc optimizer */