diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/mem.c | 4 | ||||
-rw-r--r-- | src/strings.c | 2 | ||||
-rw-r--r-- | test/test.c | 20 |
4 files changed, 17 insertions, 13 deletions
@@ -653,3 +653,7 @@ Some small fixes suggested by Charlie Gordon <gmane@chqrlie.org>. Minor build tweaks...updated to new release number. ---------------------------------------------------------------------- +Tue Jun 29 17:23:34 2004 Michael Jennings (mej) + +Oops, forgot some re-ordering. +---------------------------------------------------------------------- @@ -156,7 +156,7 @@ memrec_add_var(memrec_t *memrec, const char *filename, unsigned long line, void D_MEM(("Storing as pointer #%lu at %10p (from %10p).\n", memrec->cnt, p, memrec->ptrs)); p->ptr = ptr; p->size = size; - spiftool_safe_strncpy(p->file, filename, LIBAST_FNAME_LEN); + spiftool_safe_strncpy(p->file, SPIF_CONST_CAST(charptr) filename, LIBAST_FNAME_LEN); p->file[LIBAST_FNAME_LEN] = 0; p->line = line; } @@ -267,7 +267,7 @@ memrec_chg_var(memrec_t *memrec, const char *var, const char *filename, unsigned D_MEM(("Changing variable %s (%10p, %lu -> %10p, %lu)\n", var, oldp, p->size, newp, size)); p->ptr = newp; p->size = size; - spiftool_safe_strncpy(p->file, filename, LIBAST_FNAME_LEN); + spiftool_safe_strncpy(p->file, SPIF_CONST_CAST(charptr) filename, LIBAST_FNAME_LEN); p->line = line; } diff --git a/src/strings.c b/src/strings.c index 4081c06..24ae00f 100644 --- a/src/strings.c +++ b/src/strings.c @@ -232,7 +232,7 @@ spiftool_safe_strncat(spif_charptr_t dest, const spif_charptr_t src, spif_int32_ if ((len < 0) || (len >= size)) { return FALSE; } else { - return spiftool_safe_strncpy(dest + len, size - len, src); + return spiftool_safe_strncpy(dest + len, src, size - len); } } diff --git a/test/test.c b/test/test.c index 097243e..2d60380 100644 --- a/test/test.c +++ b/test/test.c @@ -125,13 +125,13 @@ test_strings(void) TEST_BEGIN("spiftool_safe_strncpy() function"); s1 = MALLOC(20); - TEST_FAIL_IF(spiftool_safe_strncpy(s1, 20, "pneumonoultramicroscopicsilicovolcanoconiosis")); + TEST_FAIL_IF(spiftool_safe_strncpy(s1, "pneumonoultramicroscopicsilicovolcanoconiosis", 20)); TEST_FAIL_IF(strncmp(s1, "pneumonoultramicros", 20)); - TEST_FAIL_IF(!spiftool_safe_strncpy(s1, 20, "abc")); + TEST_FAIL_IF(!spiftool_safe_strncpy(s1, "abc", 20)); TEST_FAIL_IF(strcmp(s1, "abc")); - TEST_FAIL_IF(!spiftool_safe_strncpy(s1, 20, "")); + TEST_FAIL_IF(!spiftool_safe_strncpy(s1, "", 20)); TEST_FAIL_IF(*s1); - TEST_FAIL_IF(!spiftool_safe_strncpy(s1, 20, "0123456789012345678")); + TEST_FAIL_IF(!spiftool_safe_strncpy(s1, "0123456789012345678", 20)); TEST_FAIL_IF(strncmp(s1, "0123456789012345678", 20)); FREE(s1); TEST_PASS(); @@ -139,15 +139,15 @@ test_strings(void) TEST_BEGIN("spiftool_safe_strncat() function"); s1 = MALLOC(20); *s1 = 0; - TEST_FAIL_IF(spiftool_safe_strncat(s1, 20, "pneumonoultramicroscopicsilicovolcanoconiosis")); + TEST_FAIL_IF(spiftool_safe_strncat(s1, "pneumonoultramicroscopicsilicovolcanoconiosis", 20)); TEST_FAIL_IF(strncmp(s1, "pneumonoultramicros", 20)); - TEST_FAIL_IF(!spiftool_safe_strncpy(s1, 20, "abc")); - TEST_FAIL_IF(!spiftool_safe_strncat(s1, 20, "defg")); + TEST_FAIL_IF(!spiftool_safe_strncpy(s1, "abc", 20)); + TEST_FAIL_IF(!spiftool_safe_strncat(s1, "defg", 20)); TEST_FAIL_IF(strcmp(s1, "abcdefg")); - TEST_FAIL_IF(!spiftool_safe_strncat(s1, 20, "")); + TEST_FAIL_IF(!spiftool_safe_strncat(s1, "", 20)); TEST_FAIL_IF(strcmp(s1, "abcdefg")); - TEST_FAIL_IF(!spiftool_safe_strncpy(s1, 20, "0123456789")); - TEST_FAIL_IF(!spiftool_safe_strncat(s1, 20, "012345678")); + TEST_FAIL_IF(!spiftool_safe_strncpy(s1, "0123456789", 20)); + TEST_FAIL_IF(!spiftool_safe_strncat(s1, "012345678", 20)); TEST_FAIL_IF(strncmp(s1, "0123456789012345678", 20)); FREE(s1); TEST_PASS(); |