From 759e9a363a84c5ffa573d7a56d75ae36f74302d3 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Fri, 28 Jun 2019 16:11:15 +0100 Subject: [PATCH] wmbiff: use temporary variables and remove casts. Signed-off-by: Jeremy Sowden --- wmbiff/wmbiff/regulo.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/wmbiff/wmbiff/regulo.c b/wmbiff/wmbiff/regulo.c index 507cd19..07b5268 100644 --- a/wmbiff/wmbiff/regulo.c +++ b/wmbiff/wmbiff/regulo.c @@ -16,13 +16,15 @@ /* callbacks specified by the calling function to extract substrings to values. */ -void regulo_atoi(void *dest_int, const char *source) +void regulo_atoi(void *dest, const char *source) { + int *dest_int = dest; + /* skip any leading non-digit */ while (*source != '\0' && !isdigit(*source)) source++; - *(int *) dest_int = atoi(source); + *dest_int = atoi(source); } void regulo_strcpy(void *dest, const char *source) @@ -32,16 +34,18 @@ void regulo_strcpy(void *dest, const char *source) void regulo_strcpy_tolower(void *dest, const char *source) { - unsigned int i; + char *dest_str = dest; + size_t i; + for (i = 0; i < strlen(source); i++) { - ((char *) dest)[i] = tolower(source[i]); + dest_str[i] = tolower(source[i]); } - ((char *) dest)[i] = '\0'; + dest_str[i] = '\0'; } void regulo_strcpy_skip1(void *dest, const char *source) { - strcpy((char *) dest, source + 1); + strcpy(dest, source + 1); } #ifdef USE_GNU_REGEX