From a1ffd31ae3a5b5de75ff939ca1f18194ce944899 Mon Sep 17 00:00:00 2001 From: seleznevae Date: Sat, 17 Nov 2018 23:55:05 +0300 Subject: [PATCH] [D] Removed redundant comments --- lib/fort.c | 97 ++++++++++----------------------------------- src/fort_impl.c | 40 +++++-------------- src/fort_utils.c | 4 +- src/properties.c | 19 --------- src/properties.h | 12 +++--- src/row.c | 4 -- src/string_buffer.c | 2 + src/vector.c | 16 ++------ 8 files changed, 44 insertions(+), 150 deletions(-) diff --git a/lib/fort.c b/lib/fort.c index e79b1bf..60d7497 100644 --- a/lib/fort.c +++ b/lib/fort.c @@ -446,11 +446,10 @@ int get_cell_property_value_hierarcial(const fort_table_properties_t *properties FT_INTERNAL fort_status_t set_default_cell_property(uint32_t property, int value); -/***************************************************************************** - * TABLE BORDER - *****************************************************************************/ -/* +/* TABLE BORDER DESRIPTION + * + * * TL TT TT TT TV TT TT TT TT TT TT TT TR * LL IV RR * LL IV RR @@ -467,8 +466,9 @@ fort_status_t set_default_cell_property(uint32_t property, int value); */ - -/* +/* HORIZONTAL SEPARATOR DESCRIPTION + * + * * TL TT TT TT TV TT TT TT TV TT TT TT TR <----- TopSeparator * LL IV IV RR * LH IH IH IH II IH IH IH II IH IH IH RH <----- InsideSeparator @@ -1066,9 +1066,6 @@ error: return; } -/***************************************************************************** - * COLUMN PROPERTIES - * ***************************************************************************/ struct fort_cell_props g_default_cell_properties = { FT_ANY_ROW, /* cell_row */ @@ -1221,15 +1218,6 @@ int get_cell_property_value_hierarcial(const fort_table_properties_t *properties continue; } -// if (row != FT_ANY_ROW) { -// row = FT_ANY_ROW; -// continue; -// } -// if (column != FT_ANY_COLUMN) { -// column = FT_ANY_COLUMN; -// continue; -// } - opt = NULL; break; } @@ -1322,10 +1310,6 @@ fort_status_t set_default_cell_property(uint32_t property, int value) return set_cell_property_impl(&g_default_cell_properties, property, value); } -/***************************************************************************** - * PROPERTIESS - * ***************************************************************************/ - #define BASIC_STYLE { \ /* border_chars */ \ @@ -1835,9 +1819,6 @@ fort_table_properties_t *copy_table_properties(const fort_table_properties_t *pr return new_opt; } - - - /******************************************************** End of file "properties.c" ********************************************************/ @@ -2629,7 +2610,9 @@ int ft_row_wwrite(ft_table_t *table, size_t cols, const wchar_t *cells[]) for (i = 0; i < cols; ++i) { int status = ft_wwrite_impl(table, cells[i]); if (FT_IS_ERROR(status)) { - /* todo: maybe current pos in case of error should be equal to the one before function call? */ + /* todo: maybe current pos in case of error should be equal + * to the one before function call? + */ return status; } } @@ -2656,7 +2639,9 @@ int ft_table_write(ft_table_t *table, size_t rows, size_t cols, const char *tabl for (i = 0; i < rows; ++i) { int status = ft_row_write(table, cols, (const char **)&table_cells[i * cols]); if (FT_IS_ERROR(status)) { - /* todo: maybe current pos in case of error should be equal to the one before function call? */ + /* todo: maybe current pos in case of error should be equal + * to the one before function call? + */ return status; } if (i != rows - 1) @@ -2684,7 +2669,9 @@ int ft_table_wwrite(ft_table_t *table, size_t rows, size_t cols, const wchar_t * for (i = 0; i < rows; ++i) { int status = ft_row_wwrite(table, cols, (const wchar_t **)&table_cells[i * cols]); if (FT_IS_ERROR(status)) { - /* todo: maybe current pos in case of error should be equal to the one before function call? */ + /* todo: maybe current pos in case of error should be equal + * to the one before function call? + */ return status; } if (i != rows - 1) @@ -2912,30 +2899,6 @@ clear: #endif -/* - * TMP - */ -//static int dummy_function(void) -//#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER) -//__attribute__ ((unused)) -//#endif -//; - -//static int dummy_function(void) -//{ -// if (0) { -// vector_t *v = create_vector(1, DEFAULT_VECTOR_CAPACITY); -// vector_clear(v); -// vector_erase(v, 0); -// vector_index_of(v, NULL); -// vector_capacity(v); -// } -// return 0; -//} - - - - int ft_add_separator(ft_table_t *table) { assert(table); @@ -2963,10 +2926,6 @@ int ft_add_separator(ft_table_t *table) - -/* ******************************************************************************* */ - - struct ft_border_style *FT_BASIC_STYLE = (struct ft_border_style *) &FORT_BASIC_STYLE; struct ft_border_style *FT_BASIC2_STYLE = (struct ft_border_style *) &FORT_BASIC2_STYLE; struct ft_border_style *FT_SIMPLE_STYLE = (struct ft_border_style *) &FORT_SIMPLE_STYLE; @@ -3176,10 +3135,6 @@ int ft_set_cell_span(ft_table_t *table, size_t row, size_t col, size_t hor_span) #include #include -/***************************************************************************** - * VECTOR IMPLEMENTATIONS - * ***************************************************************************/ - struct vector { size_t m_size; void *m_data; @@ -3187,6 +3142,7 @@ struct vector { size_t m_item_size; }; + static int vector_reallocate_(vector_t *vector, size_t new_capacity) { assert(vector); @@ -3199,7 +3155,7 @@ static int vector_reallocate_(vector_t *vector, size_t new_capacity) return 0; } -/* ------------ Constructors & Destructors ----------------------------- */ + FT_INTERNAL vector_t *create_vector(size_t item_size, size_t capacity) { @@ -3234,13 +3190,6 @@ void destroy_vector(vector_t *vector) } -/* -FT_INTERNAL - -*/ - - -/* ----------- Nonmodifying functions --------------------------------- */ FT_INTERNAL size_t vector_size(const vector_t *vector) { @@ -3256,7 +3205,7 @@ size_t vector_capacity(const vector_t *vector) return vector->m_capacity; } -/* ----------- Modifying functions ------------------------------------- */ + FT_INTERNAL int vector_push(vector_t *vector, const void *item) { @@ -3506,6 +3455,7 @@ const char *str_n_substring_beg(const char *str, char ch_separator, size_t n) return str ? (str + 1) : NULL; } + #ifdef FT_HAVE_WCHAR FT_INTERNAL const wchar_t *wstr_n_substring_beg(const wchar_t *str, wchar_t ch_separator, size_t n) @@ -3550,6 +3500,7 @@ void str_n_substring(const char *str, char ch_separator, size_t n, const char ** return; } + #ifdef FT_HAVE_WCHAR FT_INTERNAL void wstr_n_substring(const wchar_t *str, wchar_t ch_separator, size_t n, const wchar_t **begin, const wchar_t **end) @@ -4224,8 +4175,8 @@ int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str) { size_t str_len = strlen(str); - /* note: baybe it's, better to return -1 in case of multibyte character strings - * (not sure this case is done correctly). + /* note: baybe it's, better to return -1 in case of multibyte character + * strings (not sure this case is done correctly). */ if (str_len > 1) { const unsigned char *p = (const unsigned char *)str; @@ -5232,11 +5183,9 @@ FT_INTERNAL int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, size_t row_height, const context_t *context) { -// int (*snprint_n_chars_)(char *, size_t, size_t, char) = snprint_n_chars; int (*snprint_n_strings_)(char *, size_t, size_t, const char *) = snprint_n_strings; int (*cell_printf_)(fort_cell_t *, size_t, char *, size_t, const context_t *) = cell_printf; - assert(context); const char *space_char = " "; const char *new_line_char = "\n"; @@ -5322,11 +5271,9 @@ FT_INTERNAL int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, size_t row_height, const context_t *context) { -// int (*snprint_n_chars_)(wchar_t *, size_t, size_t, wchar_t) = wsnprint_n_chars; int (*snprint_n_strings_)(wchar_t *, size_t, size_t, const char *) = wsnprint_n_string; int (*cell_printf_)(fort_cell_t *, size_t, wchar_t *, size_t, const context_t *) = cell_wprintf; - assert(context); const char *space_char = " "; const char *new_line_char = "\n"; diff --git a/src/fort_impl.c b/src/fort_impl.c index 92bb7a7..1937c2b 100644 --- a/src/fort_impl.c +++ b/src/fort_impl.c @@ -490,7 +490,9 @@ int ft_row_wwrite(ft_table_t *table, size_t cols, const wchar_t *cells[]) for (i = 0; i < cols; ++i) { int status = ft_wwrite_impl(table, cells[i]); if (FT_IS_ERROR(status)) { - /* todo: maybe current pos in case of error should be equal to the one before function call? */ + /* todo: maybe current pos in case of error should be equal + * to the one before function call? + */ return status; } } @@ -517,7 +519,9 @@ int ft_table_write(ft_table_t *table, size_t rows, size_t cols, const char *tabl for (i = 0; i < rows; ++i) { int status = ft_row_write(table, cols, (const char **)&table_cells[i * cols]); if (FT_IS_ERROR(status)) { - /* todo: maybe current pos in case of error should be equal to the one before function call? */ + /* todo: maybe current pos in case of error should be equal + * to the one before function call? + */ return status; } if (i != rows - 1) @@ -545,7 +549,9 @@ int ft_table_wwrite(ft_table_t *table, size_t rows, size_t cols, const wchar_t * for (i = 0; i < rows; ++i) { int status = ft_row_wwrite(table, cols, (const wchar_t **)&table_cells[i * cols]); if (FT_IS_ERROR(status)) { - /* todo: maybe current pos in case of error should be equal to the one before function call? */ + /* todo: maybe current pos in case of error should be equal + * to the one before function call? + */ return status; } if (i != rows - 1) @@ -773,30 +779,6 @@ clear: #endif -/* - * TMP - */ -//static int dummy_function(void) -//#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER) -//__attribute__ ((unused)) -//#endif -//; - -//static int dummy_function(void) -//{ -// if (0) { -// vector_t *v = create_vector(1, DEFAULT_VECTOR_CAPACITY); -// vector_clear(v); -// vector_erase(v, 0); -// vector_index_of(v, NULL); -// vector_capacity(v); -// } -// return 0; -//} - - - - int ft_add_separator(ft_table_t *table) { assert(table); @@ -824,10 +806,6 @@ int ft_add_separator(ft_table_t *table) - -/* ******************************************************************************* */ - - struct ft_border_style *FT_BASIC_STYLE = (struct ft_border_style *) &FORT_BASIC_STYLE; struct ft_border_style *FT_BASIC2_STYLE = (struct ft_border_style *) &FORT_BASIC2_STYLE; struct ft_border_style *FT_SIMPLE_STYLE = (struct ft_border_style *) &FORT_SIMPLE_STYLE; diff --git a/src/fort_utils.c b/src/fort_utils.c index 18d207a..5e59aa6 100644 --- a/src/fort_utils.c +++ b/src/fort_utils.c @@ -249,8 +249,8 @@ int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str) { size_t str_len = strlen(str); - /* note: baybe it's, better to return -1 in case of multibyte character strings - * (not sure this case is done correctly). + /* note: baybe it's, better to return -1 in case of multibyte character + * strings (not sure this case is done correctly). */ if (str_len > 1) { const unsigned char *p = (const unsigned char *)str; diff --git a/src/properties.c b/src/properties.c index 934b899..2060bca 100644 --- a/src/properties.c +++ b/src/properties.c @@ -268,9 +268,6 @@ error: return; } -/***************************************************************************** - * COLUMN PROPERTIES - * ***************************************************************************/ struct fort_cell_props g_default_cell_properties = { FT_ANY_ROW, /* cell_row */ @@ -423,15 +420,6 @@ int get_cell_property_value_hierarcial(const fort_table_properties_t *properties continue; } -// if (row != FT_ANY_ROW) { -// row = FT_ANY_ROW; -// continue; -// } -// if (column != FT_ANY_COLUMN) { -// column = FT_ANY_COLUMN; -// continue; -// } - opt = NULL; break; } @@ -524,10 +512,6 @@ fort_status_t set_default_cell_property(uint32_t property, int value) return set_cell_property_impl(&g_default_cell_properties, property, value); } -/***************************************************************************** - * PROPERTIESS - * ***************************************************************************/ - #define BASIC_STYLE { \ /* border_chars */ \ @@ -1036,6 +1020,3 @@ fort_table_properties_t *copy_table_properties(const fort_table_properties_t *pr return new_opt; } - - - diff --git a/src/properties.h b/src/properties.h index a20bf10..4bc7db3 100644 --- a/src/properties.h +++ b/src/properties.h @@ -71,11 +71,10 @@ int get_cell_property_value_hierarcial(const fort_table_properties_t *properties FT_INTERNAL fort_status_t set_default_cell_property(uint32_t property, int value); -/***************************************************************************** - * TABLE BORDER - *****************************************************************************/ -/* +/* TABLE BORDER DESRIPTION + * + * * TL TT TT TT TV TT TT TT TT TT TT TT TR * LL IV RR * LL IV RR @@ -92,8 +91,9 @@ fort_status_t set_default_cell_property(uint32_t property, int value); */ - -/* +/* HORIZONTAL SEPARATOR DESCRIPTION + * + * * TL TT TT TT TV TT TT TT TV TT TT TT TR <----- TopSeparator * LL IV IV RR * LH IH IH IH II IH IH IH II IH IH IH RH <----- InsideSeparator diff --git a/src/row.c b/src/row.c index ccfa9b4..dd7550d 100644 --- a/src/row.c +++ b/src/row.c @@ -939,11 +939,9 @@ FT_INTERNAL int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, size_t row_height, const context_t *context) { -// int (*snprint_n_chars_)(char *, size_t, size_t, char) = snprint_n_chars; int (*snprint_n_strings_)(char *, size_t, size_t, const char *) = snprint_n_strings; int (*cell_printf_)(fort_cell_t *, size_t, char *, size_t, const context_t *) = cell_printf; - assert(context); const char *space_char = " "; const char *new_line_char = "\n"; @@ -1029,11 +1027,9 @@ FT_INTERNAL int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, size_t row_height, const context_t *context) { -// int (*snprint_n_chars_)(wchar_t *, size_t, size_t, wchar_t) = wsnprint_n_chars; int (*snprint_n_strings_)(wchar_t *, size_t, size_t, const char *) = wsnprint_n_string; int (*cell_printf_)(fort_cell_t *, size_t, wchar_t *, size_t, const context_t *) = cell_wprintf; - assert(context); const char *space_char = " "; const char *new_line_char = "\n"; diff --git a/src/string_buffer.c b/src/string_buffer.c index 8888fff..64dc103 100644 --- a/src/string_buffer.c +++ b/src/string_buffer.c @@ -88,6 +88,7 @@ const char *str_n_substring_beg(const char *str, char ch_separator, size_t n) return str ? (str + 1) : NULL; } + #ifdef FT_HAVE_WCHAR FT_INTERNAL const wchar_t *wstr_n_substring_beg(const wchar_t *str, wchar_t ch_separator, size_t n) @@ -132,6 +133,7 @@ void str_n_substring(const char *str, char ch_separator, size_t n, const char ** return; } + #ifdef FT_HAVE_WCHAR FT_INTERNAL void wstr_n_substring(const wchar_t *str, wchar_t ch_separator, size_t n, const wchar_t **begin, const wchar_t **end) diff --git a/src/vector.c b/src/vector.c index 9c6e8e2..7dd810c 100644 --- a/src/vector.c +++ b/src/vector.c @@ -2,10 +2,6 @@ #include #include -/***************************************************************************** - * VECTOR IMPLEMENTATIONS - * ***************************************************************************/ - struct vector { size_t m_size; void *m_data; @@ -13,6 +9,7 @@ struct vector { size_t m_item_size; }; + static int vector_reallocate_(vector_t *vector, size_t new_capacity) { assert(vector); @@ -25,7 +22,7 @@ static int vector_reallocate_(vector_t *vector, size_t new_capacity) return 0; } -/* ------------ Constructors & Destructors ----------------------------- */ + FT_INTERNAL vector_t *create_vector(size_t item_size, size_t capacity) { @@ -60,13 +57,6 @@ void destroy_vector(vector_t *vector) } -/* -FT_INTERNAL - -*/ - - -/* ----------- Nonmodifying functions --------------------------------- */ FT_INTERNAL size_t vector_size(const vector_t *vector) { @@ -82,7 +72,7 @@ size_t vector_capacity(const vector_t *vector) return vector->m_capacity; } -/* ----------- Modifying functions ------------------------------------- */ + FT_INTERNAL int vector_push(vector_t *vector, const void *item) {