From: Bastian Dehn Date: Fri, 10 Oct 2025 07:28:36 +0000 (+0200) Subject: fix compare issues X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=a72a82b3a26a4375e6f37d75c5bbcca69261d480;p=mv_none_space.git fix compare issues --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2eeb492..cd12487 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.25.1) IF ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") - SET(CMAKE_C_FLAGS "-std=c99 -Werror") + SET(CMAKE_C_FLAGS "-std=c99 -Werror -Wextra -pedantic") ELSE() - SET(CMAKE_C_FLAGS "-std=c99 -g -Wall -fsanitize=address") + SET(CMAKE_C_FLAGS "-std=c99 -g -Wall -Wextra -pedantic -fsanitize=address") ENDIF() MESSAGE(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") diff --git a/src/main.c b/src/main.c index 3fd4b37..3ffa764 100644 --- a/src/main.c +++ b/src/main.c @@ -48,7 +48,7 @@ void rename_files(const char* dir_path, rename_ptr renamefunc) char* dirname = NULL; glob_t* files = get_files(dir_path); - for (int i = 0; i < files->gl_pathc; i++) { + for (size_t i = 0; i < files->gl_pathc; i++) { output = renamefunc(files->gl_pathv[i]); rename_file(files->gl_pathv[i], output); diff --git a/src/rename.c b/src/rename.c index 7fe12a0..dcfad4e 100644 --- a/src/rename.c +++ b/src/rename.c @@ -9,7 +9,7 @@ char* escape(const char* src) char* dest = malloc(sizeof(char) * STR_MAX_LENGTH); int destcounter = 0; - for (int i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { switch(src[i]) { case SPACE: case ROUND_BRACKET_OPEN: @@ -40,7 +40,7 @@ char* rename_point(const char* src) size_t length = strlen(dest); int point_count = 0; - for (int i = length - 1; i > -1; i--) { + for (size_t i = length - 1; i > 0; i--) { if (dest[i] == POINT) point_count++; @@ -58,7 +58,7 @@ char* rename_lower(const char* src) { char* dest = rename_string(src); size_t length = strlen(dest); - for (int i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { if (dest[i] >= A && dest[i] <= Z) dest[i] += SPACE; } @@ -72,7 +72,7 @@ char* rename_string(const char* src) int dest_count = 0; char* dest = malloc(sizeof(char) * STR_MAX_LENGTH); - for (int i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { if (src[i] == SPACE) { dest[dest_count++] = '_'; } else if (src[i] == WIDE_CHAR_PREFIX && src[i + 1] == WIDE_CHAR_a) { diff --git a/src/rename.h b/src/rename.h index 490324a..1378b53 100644 --- a/src/rename.h +++ b/src/rename.h @@ -3,32 +3,32 @@ #define STR_MAX_LENGTH 1024 -#define SPACE 0x20 -#define ROUND_BRACKET_OPEN 0x28 -#define ROUND_BRACKET_CLOSE 0x29 -#define BRACKET_OPEN 0x5b -#define BRACKET_CLOSE 0x5d -#define BRACE_OPEN 0x7b -#define BRACE_CLOSE 0x7d -#define POINT 0x2e -#define A 0x41 -#define Z 0x5a -#define WIDE_CHAR_PREFIX 0xffffffc3 -#define WIDE_CHAR_a 0xffffffa4 -#define WIDE_CHAR_A 0xffffff84 -#define WIDE_CHAR_o 0xffffffb6 -#define WIDE_CHAR_O 0xffffff96 -#define WIDE_CHAR_u 0xffffffbc -#define WIDE_CHAR_U 0xffffff9c -#define WIDE_CHAR_SS 0xffffff9f -#define WIDE_CHAR_SHORT_PREFIX 0xc3 -#define WIDE_CHAR_SHORT_a 0xa4 -#define WIDE_CHAR_SHORT_A 0x84 -#define WIDE_CHAR_SHORT_o 0xb6 -#define WIDE_CHAR_SHORT_O 0x96 -#define WIDE_CHAR_SHORT_u 0xbc -#define WIDE_CHAR_SHORT_U 0x9c -#define WIDE_CHAR_SHORT_SS 0x9f +#define SPACE (char) 0x20 +#define ROUND_BRACKET_OPEN (char) 0x28 +#define ROUND_BRACKET_CLOSE (char) 0x29 +#define BRACKET_OPEN (char) 0x5b +#define BRACKET_CLOSE (char) 0x5d +#define BRACE_OPEN (char) 0x7b +#define BRACE_CLOSE (char) 0x7d +#define POINT (char) 0x2e +#define A (char) 0x41 +#define Z (char) 0x5a +#define WIDE_CHAR_PREFIX (char) 0xc3 +#define WIDE_CHAR_a (char) 0xa4 +#define WIDE_CHAR_A (char) 0x84 +#define WIDE_CHAR_o (char) 0xb6 +#define WIDE_CHAR_O (char) 0x96 +#define WIDE_CHAR_u (char) 0xbc +#define WIDE_CHAR_U (char) 0x9c +#define WIDE_CHAR_SS (char) 0x9f +#define WIDE_CHAR_SHORT_PREFIX (char) 0xc3 +#define WIDE_CHAR_SHORT_a (char) 0xa4 +#define WIDE_CHAR_SHORT_A (char) 0x84 +#define WIDE_CHAR_SHORT_o (char) 0xb6 +#define WIDE_CHAR_SHORT_O (char) 0x96 +#define WIDE_CHAR_SHORT_u (char) 0xbc +#define WIDE_CHAR_SHORT_U (char) 0x9c +#define WIDE_CHAR_SHORT_SS (char) 0x9f typedef char* (*rename_ptr)(const char* src);