From 5949f9b9cd7d6e416716b51c2cae0f4336cd82c5 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Tue, 7 Jan 2020 21:54:31 -0500 Subject: put small functions together and cleaned up float exporting --- str.c | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 str.c (limited to 'str.c') diff --git a/str.c b/str.c deleted file mode 100644 index 62dfd70..0000000 --- a/str.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2019, 2020 Leo Tenenbaum. - This file is part of toc. toc is distributed under version 3 of the GNU General Public License, without any warranty whatsoever. - You should have received a copy of the GNU General Public License along with toc. If not, see . -*/ -/* -A better alternative to strncpy. dest is guaranteed to be a null-terminated string -after this function is run. -Returns the number of characters copied to dest, not including the null character. -destsz must be greater than 0. -*/ -size_t str_copy(char *dest, size_t destsz, const char *src) { - assert(destsz); - if (!*src) { - *dest = 0; - return 0; - } - for (size_t i = 0; i < destsz-1; ++i) { - *dest = *src; - if (!*src) { - *dest = 0; - return i; - } - ++src; ++dest; - } - dest[destsz-1] = 0; - return destsz-1; -} -- cgit v1.2.3