From 6f49a77e5ec41c2558fec38b8dc0575526eea382 Mon Sep 17 00:00:00 2001 From: seleznevae Date: Mon, 3 Dec 2018 23:07:58 +0300 Subject: [PATCH] [F] Fixed old compiler warnings --- .travis.yml | 12 ++++++------ lib/fort.c | 23 +++++++++++++---------- src/fort_impl.c | 23 +++++++++++++---------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index d623d91..929d23e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -127,12 +127,12 @@ script: fi # basic build with old c standard - - | - if [ "${BASIC_LINUX_GCC}" = "yes" ]; then - cd lib - gcc -Wextra -Wall -Werror --std=c89 fort.c -c -o fort.o - rm fort.o - cd .. + - if [ "${BASIC_LINUX_GCC}" = "yes" ]; + then + cd lib + gcc -Wextra -Wall -Werror --std=c89 fort.c -c -o fort.o + rm fort.o + cd .. fi # cppcheck run diff --git a/lib/fort.c b/lib/fort.c index e15d912..481c6f4 100644 --- a/lib/fort.c +++ b/lib/fort.c @@ -1256,8 +1256,9 @@ ft_table_t *ft_copy_table(ft_table_t *table) if (result == NULL) return NULL; + size_t i = 0; size_t rows_n = vector_size(table->rows); - for (size_t i = 0; i < rows_n; ++i) { + for (i = 0; i < rows_n; ++i) { fort_row_t *row = *(fort_row_t **)vector_at(table->rows, i); fort_row_t *new_row = copy_row(row); if (new_row == NULL) { @@ -1268,7 +1269,7 @@ ft_table_t *ft_copy_table(ft_table_t *table) } size_t sep_sz = vector_size(table->separators); - for (size_t i = 0; i < sep_sz; ++i) { + for (i = 0; i < sep_sz; ++i) { separator_t *sep = *(separator_t **)vector_at(table->separators, i); separator_t *new_sep = copy_separator(sep); if (new_sep == NULL) { @@ -1821,7 +1822,6 @@ const char *ft_to_string(const ft_table_t *table) clear: F_FREE(col_width_arr); F_FREE(row_height_arr); -// F_FREE(buffer); return NULL; #undef EMPTY_STRING } @@ -1924,7 +1924,6 @@ const wchar_t *ft_to_wstring(const ft_table_t *table) clear: F_FREE(col_width_arr); F_FREE(row_height_arr); -// F_FREE(buffer); return NULL; #undef EMPTY_STRING } @@ -2027,9 +2026,11 @@ static void set_border_props_for_props(fort_table_properties_t *properties, cons BOR_CHARS[LI_bip] = BOR_CHARS[TI_bip] = BOR_CHARS[RI_bip] = BOR_CHARS[BI_bip] = border_chs->in_intersect_ch; -// if (border_chs->separator_ch == '\0' && border_chs->in_intersect_ch == '\0') { -// BOR_CHARS[LH_bip] = BOR_CHARS[RH_bip] = '\0'; -// } + /* + if (border_chs->separator_ch == '\0' && border_chs->in_intersect_ch == '\0') { + BOR_CHARS[LH_bip] = BOR_CHARS[RH_bip] = '\0'; + } + */ if (strlen(border_chs->separator_ch) == 0 && strlen(border_chs->in_intersect_ch) == 0) { BOR_CHARS[LH_bip] = BOR_CHARS[RH_bip] = "\0"; } @@ -2047,9 +2048,11 @@ static void set_border_props_for_props(fort_table_properties_t *properties, cons H_BOR_CHARS[LI_bip] = H_BOR_CHARS[TI_bip] = H_BOR_CHARS[RI_bip] = H_BOR_CHARS[BI_bip] = header_border_chs->in_intersect_ch; -// if (header_border_chs->separator_ch == '\0' && header_border_chs->in_intersect_ch == '\0') { -// H_BOR_CHARS[LH_bip] = H_BOR_CHARS[RH_bip] = '\0'; -// } + /* + if (header_border_chs->separator_ch == '\0' && header_border_chs->in_intersect_ch == '\0') { + H_BOR_CHARS[LH_bip] = H_BOR_CHARS[RH_bip] = '\0'; + } + */ if (strlen(header_border_chs->separator_ch) == 0 && strlen(header_border_chs->in_intersect_ch) == 0) { BOR_CHARS[LH_bip] = BOR_CHARS[RH_bip] = "\0"; } diff --git a/src/fort_impl.c b/src/fort_impl.c index 71c449c..1d14244 100644 --- a/src/fort_impl.c +++ b/src/fort_impl.c @@ -101,8 +101,9 @@ ft_table_t *ft_copy_table(ft_table_t *table) if (result == NULL) return NULL; + size_t i = 0; size_t rows_n = vector_size(table->rows); - for (size_t i = 0; i < rows_n; ++i) { + for (i = 0; i < rows_n; ++i) { fort_row_t *row = *(fort_row_t **)vector_at(table->rows, i); fort_row_t *new_row = copy_row(row); if (new_row == NULL) { @@ -113,7 +114,7 @@ ft_table_t *ft_copy_table(ft_table_t *table) } size_t sep_sz = vector_size(table->separators); - for (size_t i = 0; i < sep_sz; ++i) { + for (i = 0; i < sep_sz; ++i) { separator_t *sep = *(separator_t **)vector_at(table->separators, i); separator_t *new_sep = copy_separator(sep); if (new_sep == NULL) { @@ -666,7 +667,6 @@ const char *ft_to_string(const ft_table_t *table) clear: F_FREE(col_width_arr); F_FREE(row_height_arr); -// F_FREE(buffer); return NULL; #undef EMPTY_STRING } @@ -769,7 +769,6 @@ const wchar_t *ft_to_wstring(const ft_table_t *table) clear: F_FREE(col_width_arr); F_FREE(row_height_arr); -// F_FREE(buffer); return NULL; #undef EMPTY_STRING } @@ -872,9 +871,11 @@ static void set_border_props_for_props(fort_table_properties_t *properties, cons BOR_CHARS[LI_bip] = BOR_CHARS[TI_bip] = BOR_CHARS[RI_bip] = BOR_CHARS[BI_bip] = border_chs->in_intersect_ch; -// if (border_chs->separator_ch == '\0' && border_chs->in_intersect_ch == '\0') { -// BOR_CHARS[LH_bip] = BOR_CHARS[RH_bip] = '\0'; -// } + /* + if (border_chs->separator_ch == '\0' && border_chs->in_intersect_ch == '\0') { + BOR_CHARS[LH_bip] = BOR_CHARS[RH_bip] = '\0'; + } + */ if (strlen(border_chs->separator_ch) == 0 && strlen(border_chs->in_intersect_ch) == 0) { BOR_CHARS[LH_bip] = BOR_CHARS[RH_bip] = "\0"; } @@ -892,9 +893,11 @@ static void set_border_props_for_props(fort_table_properties_t *properties, cons H_BOR_CHARS[LI_bip] = H_BOR_CHARS[TI_bip] = H_BOR_CHARS[RI_bip] = H_BOR_CHARS[BI_bip] = header_border_chs->in_intersect_ch; -// if (header_border_chs->separator_ch == '\0' && header_border_chs->in_intersect_ch == '\0') { -// H_BOR_CHARS[LH_bip] = H_BOR_CHARS[RH_bip] = '\0'; -// } + /* + if (header_border_chs->separator_ch == '\0' && header_border_chs->in_intersect_ch == '\0') { + H_BOR_CHARS[LH_bip] = H_BOR_CHARS[RH_bip] = '\0'; + } + */ if (strlen(header_border_chs->separator_ch) == 0 && strlen(header_border_chs->in_intersect_ch) == 0) { BOR_CHARS[LH_bip] = BOR_CHARS[RH_bip] = "\0"; }