[F] Fixed warnings with -Wpedantic option
This commit is contained in:
		@@ -48,7 +48,7 @@ if("${FORT_COMPILER}" STREQUAL "MSVC")
 | 
				
			|||||||
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W4")
 | 
					    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W4")
 | 
				
			||||||
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W4")
 | 
					    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W4")
 | 
				
			||||||
else("${FORT_COMPILER}" STREQUAL "MSVC")
 | 
					else("${FORT_COMPILER}" STREQUAL "MSVC")
 | 
				
			||||||
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -Wextra")
 | 
					    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -Wextra -std=c99 -Wpedantic")
 | 
				
			||||||
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -Wextra")
 | 
					    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -Wextra")
 | 
				
			||||||
endif("${FORT_COMPILER}" STREQUAL "MSVC")
 | 
					endif("${FORT_COMPILER}" STREQUAL "MSVC")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										24
									
								
								lib/fort.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								lib/fort.c
									
									
									
									
									
								
							@@ -129,7 +129,7 @@ typedef struct vector vector_t;
 | 
				
			|||||||
typedef struct fort_cell fort_cell_t;
 | 
					typedef struct fort_cell fort_cell_t;
 | 
				
			||||||
typedef struct string_buffer string_buffer_t;
 | 
					typedef struct string_buffer string_buffer_t;
 | 
				
			||||||
typedef struct fort_row fort_row_t;
 | 
					typedef struct fort_row fort_row_t;
 | 
				
			||||||
typedef struct ft_table ft_table_t;
 | 
					/*typedef struct ft_table ft_table_t;*/
 | 
				
			||||||
typedef struct separator separator_t;
 | 
					typedef struct separator separator_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -157,8 +157,8 @@ char *fort_strdup(const char *str);
 | 
				
			|||||||
wchar_t *fort_wcsdup(const wchar_t *str);
 | 
					wchar_t *fort_wcsdup(const wchar_t *str);
 | 
				
			||||||
size_t number_of_columns_in_format_string(const char *fmt);
 | 
					size_t number_of_columns_in_format_string(const char *fmt);
 | 
				
			||||||
size_t number_of_columns_in_format_wstring(const wchar_t *fmt);
 | 
					size_t number_of_columns_in_format_wstring(const wchar_t *fmt);
 | 
				
			||||||
//int snprint_n_chars(char *buf, size_t length, size_t n, char ch);
 | 
					/*int snprint_n_chars(char *buf, size_t length, size_t n, char ch);*/
 | 
				
			||||||
//int wsnprint_n_chars(wchar_t *buf, size_t length, size_t n, wchar_t ch);
 | 
					/*int wsnprint_n_chars(wchar_t *buf, size_t length, size_t n, wchar_t ch);*/
 | 
				
			||||||
int snprint_n_strings(char *buf, size_t length, size_t n, const char *str);
 | 
					int snprint_n_strings(char *buf, size_t length, size_t n, const char *str);
 | 
				
			||||||
int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str);
 | 
					int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -197,9 +197,6 @@ int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str);
 | 
				
			|||||||
 *               VECTOR
 | 
					 *               VECTOR
 | 
				
			||||||
 * ***************************************************************************/
 | 
					 * ***************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct vector;
 | 
					 | 
				
			||||||
typedef struct vector vector_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define INVALID_VEC_INDEX ((size_t) -1)
 | 
					#define INVALID_VEC_INDEX ((size_t) -1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern vector_t *create_vector(size_t item_size, size_t capacity);
 | 
					extern vector_t *create_vector(size_t item_size, size_t capacity);
 | 
				
			||||||
@@ -267,8 +264,6 @@ enum str_buf_type {
 | 
				
			|||||||
    WCharBuf
 | 
					    WCharBuf
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct string_buffer;
 | 
					 | 
				
			||||||
typedef struct string_buffer string_buffer_t;
 | 
					 | 
				
			||||||
struct string_buffer {
 | 
					struct string_buffer {
 | 
				
			||||||
    union {
 | 
					    union {
 | 
				
			||||||
        char *cstr;
 | 
					        char *cstr;
 | 
				
			||||||
@@ -318,16 +313,10 @@ struct fort_column_options {
 | 
				
			|||||||
    int col_min_width;
 | 
					    int col_min_width;
 | 
				
			||||||
    enum ft_text_alignment align;
 | 
					    enum ft_text_alignment align;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
typedef struct fort_column_options fort_column_options_t;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern fort_column_options_t g_column_options;
 | 
					extern fort_column_options_t g_column_options;
 | 
				
			||||||
fort_column_options_t create_column_options(void);
 | 
					fort_column_options_t create_column_options(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct vector;
 | 
					 | 
				
			||||||
typedef struct vector vector_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define OPTION_IS_SET(ft_opts, option) ((ft_opts) & (option))
 | 
					#define OPTION_IS_SET(ft_opts, option) ((ft_opts) & (option))
 | 
				
			||||||
#define OPTION_SET(ft_opts, option) ((ft_opts) |=(option))
 | 
					#define OPTION_SET(ft_opts, option) ((ft_opts) |=(option))
 | 
				
			||||||
#define OPTION_UNSET(ft_opts, option) ((ft_opts) &= ~((uint32_t)option))
 | 
					#define OPTION_UNSET(ft_opts, option) ((ft_opts) &= ~((uint32_t)option))
 | 
				
			||||||
@@ -450,7 +439,6 @@ struct fort_table_options {
 | 
				
			|||||||
    fort_cell_opt_container_t *cell_options;
 | 
					    fort_cell_opt_container_t *cell_options;
 | 
				
			||||||
    fort_entire_table_options_t entire_table_options;
 | 
					    fort_entire_table_options_t entire_table_options;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
typedef struct fort_table_options fort_table_options_t;
 | 
					 | 
				
			||||||
extern fort_table_options_t g_table_options;
 | 
					extern fort_table_options_t g_table_options;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t max_border_elem_strlen(struct fort_table_options *);
 | 
					size_t max_border_elem_strlen(struct fort_table_options *);
 | 
				
			||||||
@@ -533,10 +521,6 @@ string_buffer_t *cell_get_string_buffer(fort_cell_t *cell);
 | 
				
			|||||||
#include <wchar.h>
 | 
					#include <wchar.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct fort_row;
 | 
					 | 
				
			||||||
typedef struct fort_row fort_row_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
fort_row_t *create_row(void);
 | 
					fort_row_t *create_row(void);
 | 
				
			||||||
void destroy_row(fort_row_t *row);
 | 
					void destroy_row(fort_row_t *row);
 | 
				
			||||||
fort_row_t *create_row_from_string(const char *str);
 | 
					fort_row_t *create_row_from_string(const char *str);
 | 
				
			||||||
@@ -600,8 +584,6 @@ int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* #include "fort_utils.h" */ /* Commented by amalgamation script */
 | 
					/* #include "fort_utils.h" */ /* Commented by amalgamation script */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct ft_table;
 | 
					 | 
				
			||||||
typedef struct ft_table ft_table_t;
 | 
					 | 
				
			||||||
struct ft_table {
 | 
					struct ft_table {
 | 
				
			||||||
    vector_t *rows;
 | 
					    vector_t *rows;
 | 
				
			||||||
    fort_table_options_t *options;
 | 
					    fort_table_options_t *options;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -94,7 +94,7 @@ typedef struct vector vector_t;
 | 
				
			|||||||
typedef struct fort_cell fort_cell_t;
 | 
					typedef struct fort_cell fort_cell_t;
 | 
				
			||||||
typedef struct string_buffer string_buffer_t;
 | 
					typedef struct string_buffer string_buffer_t;
 | 
				
			||||||
typedef struct fort_row fort_row_t;
 | 
					typedef struct fort_row fort_row_t;
 | 
				
			||||||
typedef struct ft_table ft_table_t;
 | 
					/*typedef struct ft_table ft_table_t;*/
 | 
				
			||||||
typedef struct separator separator_t;
 | 
					typedef struct separator separator_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -122,8 +122,8 @@ char *fort_strdup(const char *str);
 | 
				
			|||||||
wchar_t *fort_wcsdup(const wchar_t *str);
 | 
					wchar_t *fort_wcsdup(const wchar_t *str);
 | 
				
			||||||
size_t number_of_columns_in_format_string(const char *fmt);
 | 
					size_t number_of_columns_in_format_string(const char *fmt);
 | 
				
			||||||
size_t number_of_columns_in_format_wstring(const wchar_t *fmt);
 | 
					size_t number_of_columns_in_format_wstring(const wchar_t *fmt);
 | 
				
			||||||
//int snprint_n_chars(char *buf, size_t length, size_t n, char ch);
 | 
					/*int snprint_n_chars(char *buf, size_t length, size_t n, char ch);*/
 | 
				
			||||||
//int wsnprint_n_chars(wchar_t *buf, size_t length, size_t n, wchar_t ch);
 | 
					/*int wsnprint_n_chars(wchar_t *buf, size_t length, size_t n, wchar_t ch);*/
 | 
				
			||||||
int snprint_n_strings(char *buf, size_t length, size_t n, const char *str);
 | 
					int snprint_n_strings(char *buf, size_t length, size_t n, const char *str);
 | 
				
			||||||
int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str);
 | 
					int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,16 +9,10 @@ struct fort_column_options {
 | 
				
			|||||||
    int col_min_width;
 | 
					    int col_min_width;
 | 
				
			||||||
    enum ft_text_alignment align;
 | 
					    enum ft_text_alignment align;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
typedef struct fort_column_options fort_column_options_t;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern fort_column_options_t g_column_options;
 | 
					extern fort_column_options_t g_column_options;
 | 
				
			||||||
fort_column_options_t create_column_options(void);
 | 
					fort_column_options_t create_column_options(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct vector;
 | 
					 | 
				
			||||||
typedef struct vector vector_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define OPTION_IS_SET(ft_opts, option) ((ft_opts) & (option))
 | 
					#define OPTION_IS_SET(ft_opts, option) ((ft_opts) & (option))
 | 
				
			||||||
#define OPTION_SET(ft_opts, option) ((ft_opts) |=(option))
 | 
					#define OPTION_SET(ft_opts, option) ((ft_opts) |=(option))
 | 
				
			||||||
#define OPTION_UNSET(ft_opts, option) ((ft_opts) &= ~((uint32_t)option))
 | 
					#define OPTION_UNSET(ft_opts, option) ((ft_opts) &= ~((uint32_t)option))
 | 
				
			||||||
@@ -141,7 +135,6 @@ struct fort_table_options {
 | 
				
			|||||||
    fort_cell_opt_container_t *cell_options;
 | 
					    fort_cell_opt_container_t *cell_options;
 | 
				
			||||||
    fort_entire_table_options_t entire_table_options;
 | 
					    fort_entire_table_options_t entire_table_options;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
typedef struct fort_table_options fort_table_options_t;
 | 
					 | 
				
			||||||
extern fort_table_options_t g_table_options;
 | 
					extern fort_table_options_t g_table_options;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t max_border_elem_strlen(struct fort_table_options *);
 | 
					size_t max_border_elem_strlen(struct fort_table_options *);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,10 +9,6 @@
 | 
				
			|||||||
#include <wchar.h>
 | 
					#include <wchar.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct fort_row;
 | 
					 | 
				
			||||||
typedef struct fort_row fort_row_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
fort_row_t *create_row(void);
 | 
					fort_row_t *create_row(void);
 | 
				
			||||||
void destroy_row(fort_row_t *row);
 | 
					void destroy_row(fort_row_t *row);
 | 
				
			||||||
fort_row_t *create_row_from_string(const char *str);
 | 
					fort_row_t *create_row_from_string(const char *str);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,8 +12,6 @@ enum str_buf_type {
 | 
				
			|||||||
    WCharBuf
 | 
					    WCharBuf
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct string_buffer;
 | 
					 | 
				
			||||||
typedef struct string_buffer string_buffer_t;
 | 
					 | 
				
			||||||
struct string_buffer {
 | 
					struct string_buffer {
 | 
				
			||||||
    union {
 | 
					    union {
 | 
				
			||||||
        char *cstr;
 | 
					        char *cstr;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,8 +3,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "fort_utils.h"
 | 
					#include "fort_utils.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct ft_table;
 | 
					 | 
				
			||||||
typedef struct ft_table ft_table_t;
 | 
					 | 
				
			||||||
struct ft_table {
 | 
					struct ft_table {
 | 
				
			||||||
    vector_t *rows;
 | 
					    vector_t *rows;
 | 
				
			||||||
    fort_table_options_t *options;
 | 
					    fort_table_options_t *options;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,9 +8,6 @@
 | 
				
			|||||||
 *               VECTOR
 | 
					 *               VECTOR
 | 
				
			||||||
 * ***************************************************************************/
 | 
					 * ***************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct vector;
 | 
					 | 
				
			||||||
typedef struct vector vector_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define INVALID_VEC_INDEX ((size_t) -1)
 | 
					#define INVALID_VEC_INDEX ((size_t) -1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern vector_t *create_vector(size_t item_size, size_t capacity);
 | 
					extern vector_t *create_vector(size_t item_size, size_t capacity);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,8 +34,10 @@ static int create_simple_table_and_show(void)
 | 
				
			|||||||
        result = 1;
 | 
					        result = 1;
 | 
				
			||||||
        goto exit;
 | 
					        goto exit;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
//    if (set_test_options_for_table(table) != FT_SUCCESS)
 | 
					    /*
 | 
				
			||||||
//        return 2;
 | 
					    if (set_test_options_for_table(table) != FT_SUCCESS)
 | 
				
			||||||
 | 
					        return 2;
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER) != FT_SUCCESS) {
 | 
					    if (ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER) != FT_SUCCESS) {
 | 
				
			||||||
        result = 3;
 | 
					        result = 3;
 | 
				
			||||||
@@ -73,7 +75,7 @@ static int create_simple_table_and_show(void)
 | 
				
			|||||||
        "| 3 | c | 234 | 3.140000 |\n"
 | 
					        "| 3 | c | 234 | 3.140000 |\n"
 | 
				
			||||||
        "|   |   |     |          |\n"
 | 
					        "|   |   |     |          |\n"
 | 
				
			||||||
        "+---+---+-----+----------+\n";
 | 
					        "+---+---+-----+----------+\n";
 | 
				
			||||||
//    assert_str_equal(table_str, table_str_etalon);
 | 
					    /*assert_str_equal(table_str, table_str_etalon);*/
 | 
				
			||||||
    if (strcmp(table_str, table_str_etalon) != 0) {
 | 
					    if (strcmp(table_str, table_str_etalon) != 0) {
 | 
				
			||||||
        result = 8;
 | 
					        result = 8;
 | 
				
			||||||
        goto exit;
 | 
					        goto exit;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -84,7 +84,6 @@ struct ft_table *create_test_int_table(int set_test_opts)
 | 
				
			|||||||
    assert_true(table != NULL);
 | 
					    assert_true(table != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
 | 
					    ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
 | 
				
			||||||
//    int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
 | 
					 | 
				
			||||||
    int n = ft_write_ln(table, "3", "4", "55", "67");
 | 
					    int n = ft_write_ln(table, "3", "4", "55", "67");
 | 
				
			||||||
    assert(n == FT_SUCCESS);
 | 
					    assert(n == FT_SUCCESS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -115,7 +114,6 @@ struct ft_table *create_test_int_wtable(int set_test_opts)
 | 
				
			|||||||
    assert_true(table != NULL);
 | 
					    assert_true(table != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
 | 
					    ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
 | 
				
			||||||
//    int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
 | 
					 | 
				
			||||||
    int n = ft_wwrite_ln(table, L"3", L"4", L"55", L"67");
 | 
					    int n = ft_wwrite_ln(table, L"3", L"4", L"55", L"67");
 | 
				
			||||||
    assert(n == FT_SUCCESS);
 | 
					    assert(n == FT_SUCCESS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,7 +49,7 @@ struct test_case {
 | 
				
			|||||||
#define assert_str_equal(str1, str2) \
 | 
					#define assert_str_equal(str1, str2) \
 | 
				
			||||||
    if (strcmp(str1, str2) != 0) \
 | 
					    if (strcmp(str1, str2) != 0) \
 | 
				
			||||||
    { \
 | 
					    { \
 | 
				
			||||||
        fprintf(stderr, "%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __FUNCTION__); \
 | 
					        fprintf(stderr, "%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __func__); \
 | 
				
			||||||
        fprintf(stderr, "Left string:\n%s\n", str1); \
 | 
					        fprintf(stderr, "Left string:\n%s\n", str1); \
 | 
				
			||||||
        fprintf(stderr, "Right string:\n%s\n", str2); \
 | 
					        fprintf(stderr, "Right string:\n%s\n", str2); \
 | 
				
			||||||
        exit(EXIT_FAILURE); \
 | 
					        exit(EXIT_FAILURE); \
 | 
				
			||||||
@@ -58,7 +58,7 @@ struct test_case {
 | 
				
			|||||||
#define assert_wcs_equal(str1, str2) \
 | 
					#define assert_wcs_equal(str1, str2) \
 | 
				
			||||||
    if (wcscmp(str1, str2) != 0) \
 | 
					    if (wcscmp(str1, str2) != 0) \
 | 
				
			||||||
    { \
 | 
					    { \
 | 
				
			||||||
        fprintf(stderr, "%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __FUNCTION__); \
 | 
					        fprintf(stderr, "%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __func__); \
 | 
				
			||||||
        setlocale(LC_CTYPE, ""); \
 | 
					        setlocale(LC_CTYPE, ""); \
 | 
				
			||||||
        fwprintf(stdout, L"Left string:\n%ls\n", str1); \
 | 
					        fwprintf(stdout, L"Left string:\n%ls\n", str1); \
 | 
				
			||||||
        fwprintf(stdout, L"Right string:\n%ls\n", str2); \
 | 
					        fwprintf(stdout, L"Right string:\n%ls\n", str2); \
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user