[F] Fixed code style issues
This commit is contained in:
parent
9daee298b0
commit
e870d1dc2c
@ -6,8 +6,36 @@ def comment_line(line):
|
|||||||
|
|
||||||
def amalgamate(config):
|
def amalgamate(config):
|
||||||
with open(config["output_file"], "w") as output_f:
|
with open(config["output_file"], "w") as output_f:
|
||||||
output_f.write("/* The file was GENERATED by an amalgamation script.*/\n")
|
output_f.write("""
|
||||||
output_f.write("/* DO NOT EDIT BY HAND!!! */\n\n")
|
/*
|
||||||
|
libfort
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2017 - 2018 Seleznev Anton
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The file was GENERATED by an amalgamation script.*/
|
||||||
|
/* DO NOT EDIT BY HAND!!! */\n\n
|
||||||
|
""")
|
||||||
|
|
||||||
for hdr_file in config["header_files"]:
|
for hdr_file in config["header_files"]:
|
||||||
with open(config["src_dir"] + "/" + hdr_file, "r") as input_f:
|
with open(config["src_dir"] + "/" + hdr_file, "r") as input_f:
|
||||||
@ -56,7 +84,7 @@ def is_c_source_file(file):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
config = {}
|
config = {}
|
||||||
config["output_file"] = "./include/fort.c"
|
config["output_file"] = "./lib/fort.c"
|
||||||
config["src_dir"] = "./src"
|
config["src_dir"] = "./src"
|
||||||
all_files = os.listdir(config["src_dir"])
|
all_files = os.listdir(config["src_dir"])
|
||||||
config["src_files"] = filter(is_c_source_file, all_files)
|
config["src_files"] = filter(is_c_source_file, all_files)
|
||||||
|
76
lib/fort.c
76
lib/fort.c
@ -1,7 +1,35 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
libfort
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2017 - 2018 Seleznev Anton
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
/* The file was GENERATED by an amalgamation script.*/
|
/* The file was GENERATED by an amalgamation script.*/
|
||||||
/* DO NOT EDIT BY HAND!!! */
|
/* DO NOT EDIT BY HAND!!! */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
Begin of file "fort_utils.h"
|
Begin of file "fort_utils.h"
|
||||||
********************************************************/
|
********************************************************/
|
||||||
@ -41,15 +69,13 @@
|
|||||||
#define MIN(a,b) ((a) < (b) ? (a) : b)
|
#define MIN(a,b) ((a) < (b) ? (a) : b)
|
||||||
|
|
||||||
|
|
||||||
enum PolicyOnNull
|
enum PolicyOnNull {
|
||||||
{
|
|
||||||
Create,
|
Create,
|
||||||
DoNotCreate
|
DoNotCreate
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum F_BOOL
|
enum F_BOOL {
|
||||||
{
|
|
||||||
F_FALSE = 0,
|
F_FALSE = 0,
|
||||||
F_TRUE = 1
|
F_TRUE = 1
|
||||||
};
|
};
|
||||||
@ -88,14 +114,12 @@ struct fort_row;
|
|||||||
struct vector;
|
struct vector;
|
||||||
struct fort_cell;
|
struct fort_cell;
|
||||||
struct string_buffer;
|
struct string_buffer;
|
||||||
struct separator
|
struct separator {
|
||||||
{
|
|
||||||
int enabled;
|
int enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct fort_table_options fort_table_options_t;
|
typedef struct fort_table_options fort_table_options_t;
|
||||||
struct fort_context
|
struct fort_context {
|
||||||
{
|
|
||||||
fort_table_options_t *table_options;
|
fort_table_options_t *table_options;
|
||||||
size_t row;
|
size_t row;
|
||||||
size_t column;
|
size_t column;
|
||||||
@ -112,8 +136,7 @@ typedef struct separator separator_t;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum CellType
|
enum CellType {
|
||||||
{
|
|
||||||
CommonCell,
|
CommonCell,
|
||||||
GroupMasterCell,
|
GroupMasterCell,
|
||||||
GroupSlaveCell
|
GroupSlaveCell
|
||||||
@ -240,16 +263,14 @@ int mk_wcswidth(const wchar_t *pwcs, size_t n);
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* STRING BUFFER
|
* STRING BUFFER
|
||||||
* ***************************************************************************/
|
* ***************************************************************************/
|
||||||
enum str_buf_type
|
enum str_buf_type {
|
||||||
{
|
|
||||||
CharBuf,
|
CharBuf,
|
||||||
WCharBuf
|
WCharBuf
|
||||||
};
|
};
|
||||||
|
|
||||||
struct string_buffer;
|
struct string_buffer;
|
||||||
typedef struct string_buffer string_buffer_t;
|
typedef struct string_buffer string_buffer_t;
|
||||||
struct string_buffer
|
struct string_buffer {
|
||||||
{
|
|
||||||
union {
|
union {
|
||||||
char *cstr;
|
char *cstr;
|
||||||
wchar_t *wstr;
|
wchar_t *wstr;
|
||||||
@ -294,8 +315,7 @@ int buffer_wprintf(string_buffer_t *buffer, size_t buffer_row, wchar_t *buf, siz
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
struct fort_column_options
|
struct fort_column_options {
|
||||||
{
|
|
||||||
int col_min_width;
|
int col_min_width;
|
||||||
enum ft_text_alignment align;
|
enum ft_text_alignment align;
|
||||||
};
|
};
|
||||||
@ -313,8 +333,7 @@ typedef struct vector vector_t;
|
|||||||
#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))
|
||||||
|
|
||||||
struct fort_cell_options
|
struct fort_cell_options {
|
||||||
{
|
|
||||||
size_t cell_row;
|
size_t cell_row;
|
||||||
size_t cell_col;
|
size_t cell_col;
|
||||||
uint32_t options;
|
uint32_t options;
|
||||||
@ -356,15 +375,13 @@ fort_status_t set_default_cell_option(uint32_t option, int value);
|
|||||||
* BL BB BB BB BV BB BB BB BV BB BB BB BR <----- BottomSeparator
|
* BL BB BB BB BV BB BB BB BV BB BB BB BR <----- BottomSeparator
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum HorSeparatorPos
|
enum HorSeparatorPos {
|
||||||
{
|
|
||||||
TopSeparator,
|
TopSeparator,
|
||||||
InsideSeparator,
|
InsideSeparator,
|
||||||
BottomSeparator
|
BottomSeparator
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BorderItemPos
|
enum BorderItemPos {
|
||||||
{
|
|
||||||
TL_bip = 0,
|
TL_bip = 0,
|
||||||
TT_bip = 1,
|
TT_bip = 1,
|
||||||
TV_bip = 2,
|
TV_bip = 2,
|
||||||
@ -388,8 +405,7 @@ enum BorderItemPos
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum SeparatorItemPos
|
enum SeparatorItemPos {
|
||||||
{
|
|
||||||
LH_sip = 0,
|
LH_sip = 0,
|
||||||
IH_sip = 1,
|
IH_sip = 1,
|
||||||
II_sip = 2,
|
II_sip = 2,
|
||||||
@ -399,8 +415,7 @@ enum SeparatorItemPos
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct fort_border_style
|
struct fort_border_style {
|
||||||
{
|
|
||||||
const char *border_chars[BorderItemPosSize];
|
const char *border_chars[BorderItemPosSize];
|
||||||
const char *header_border_chars[BorderItemPosSize];
|
const char *header_border_chars[BorderItemPosSize];
|
||||||
const char *separator_chars[SepratorItemPosSize];
|
const char *separator_chars[SepratorItemPosSize];
|
||||||
@ -419,8 +434,7 @@ extern struct fort_border_style FORT_BOLD2_STYLE;
|
|||||||
extern struct fort_border_style FORT_FRAME_STYLE;
|
extern struct fort_border_style FORT_FRAME_STYLE;
|
||||||
|
|
||||||
|
|
||||||
struct fort_entire_table_options
|
struct fort_entire_table_options {
|
||||||
{
|
|
||||||
unsigned int left_margin;
|
unsigned int left_margin;
|
||||||
unsigned int top_margin;
|
unsigned int top_margin;
|
||||||
unsigned int right_margin;
|
unsigned int right_margin;
|
||||||
@ -431,8 +445,7 @@ extern fort_entire_table_options_t g_entire_table_options;
|
|||||||
fort_status_t set_entire_table_option(fort_table_options_t *table_options, uint32_t option, int value);
|
fort_status_t set_entire_table_option(fort_table_options_t *table_options, uint32_t option, int value);
|
||||||
fort_status_t set_default_entire_table_option(uint32_t option, int value);
|
fort_status_t set_default_entire_table_option(uint32_t option, int value);
|
||||||
|
|
||||||
struct fort_table_options
|
struct fort_table_options {
|
||||||
{
|
|
||||||
struct fort_border_style border_style;
|
struct fort_border_style border_style;
|
||||||
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;
|
||||||
@ -589,8 +602,7 @@ int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t
|
|||||||
|
|
||||||
struct ft_table;
|
struct ft_table;
|
||||||
typedef struct ft_table ft_table_t;
|
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;
|
||||||
string_buffer_t *conv_buffer;
|
string_buffer_t *conv_buffer;
|
||||||
|
@ -33,15 +33,13 @@
|
|||||||
#define MIN(a,b) ((a) < (b) ? (a) : b)
|
#define MIN(a,b) ((a) < (b) ? (a) : b)
|
||||||
|
|
||||||
|
|
||||||
enum PolicyOnNull
|
enum PolicyOnNull {
|
||||||
{
|
|
||||||
Create,
|
Create,
|
||||||
DoNotCreate
|
DoNotCreate
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum F_BOOL
|
enum F_BOOL {
|
||||||
{
|
|
||||||
F_FALSE = 0,
|
F_FALSE = 0,
|
||||||
F_TRUE = 1
|
F_TRUE = 1
|
||||||
};
|
};
|
||||||
@ -80,14 +78,12 @@ struct fort_row;
|
|||||||
struct vector;
|
struct vector;
|
||||||
struct fort_cell;
|
struct fort_cell;
|
||||||
struct string_buffer;
|
struct string_buffer;
|
||||||
struct separator
|
struct separator {
|
||||||
{
|
|
||||||
int enabled;
|
int enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct fort_table_options fort_table_options_t;
|
typedef struct fort_table_options fort_table_options_t;
|
||||||
struct fort_context
|
struct fort_context {
|
||||||
{
|
|
||||||
fort_table_options_t *table_options;
|
fort_table_options_t *table_options;
|
||||||
size_t row;
|
size_t row;
|
||||||
size_t column;
|
size_t column;
|
||||||
@ -104,8 +100,7 @@ typedef struct separator separator_t;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum CellType
|
enum CellType {
|
||||||
{
|
|
||||||
CommonCell,
|
CommonCell,
|
||||||
GroupMasterCell,
|
GroupMasterCell,
|
||||||
GroupSlaveCell
|
GroupSlaveCell
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
struct fort_column_options
|
struct fort_column_options {
|
||||||
{
|
|
||||||
int col_min_width;
|
int col_min_width;
|
||||||
enum ft_text_alignment align;
|
enum ft_text_alignment align;
|
||||||
};
|
};
|
||||||
@ -24,8 +23,7 @@ typedef struct vector vector_t;
|
|||||||
#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))
|
||||||
|
|
||||||
struct fort_cell_options
|
struct fort_cell_options {
|
||||||
{
|
|
||||||
size_t cell_row;
|
size_t cell_row;
|
||||||
size_t cell_col;
|
size_t cell_col;
|
||||||
uint32_t options;
|
uint32_t options;
|
||||||
@ -67,15 +65,13 @@ fort_status_t set_default_cell_option(uint32_t option, int value);
|
|||||||
* BL BB BB BB BV BB BB BB BV BB BB BB BR <----- BottomSeparator
|
* BL BB BB BB BV BB BB BB BV BB BB BB BR <----- BottomSeparator
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum HorSeparatorPos
|
enum HorSeparatorPos {
|
||||||
{
|
|
||||||
TopSeparator,
|
TopSeparator,
|
||||||
InsideSeparator,
|
InsideSeparator,
|
||||||
BottomSeparator
|
BottomSeparator
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BorderItemPos
|
enum BorderItemPos {
|
||||||
{
|
|
||||||
TL_bip = 0,
|
TL_bip = 0,
|
||||||
TT_bip = 1,
|
TT_bip = 1,
|
||||||
TV_bip = 2,
|
TV_bip = 2,
|
||||||
@ -99,8 +95,7 @@ enum BorderItemPos
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum SeparatorItemPos
|
enum SeparatorItemPos {
|
||||||
{
|
|
||||||
LH_sip = 0,
|
LH_sip = 0,
|
||||||
IH_sip = 1,
|
IH_sip = 1,
|
||||||
II_sip = 2,
|
II_sip = 2,
|
||||||
@ -110,8 +105,7 @@ enum SeparatorItemPos
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct fort_border_style
|
struct fort_border_style {
|
||||||
{
|
|
||||||
const char *border_chars[BorderItemPosSize];
|
const char *border_chars[BorderItemPosSize];
|
||||||
const char *header_border_chars[BorderItemPosSize];
|
const char *header_border_chars[BorderItemPosSize];
|
||||||
const char *separator_chars[SepratorItemPosSize];
|
const char *separator_chars[SepratorItemPosSize];
|
||||||
@ -130,8 +124,7 @@ extern struct fort_border_style FORT_BOLD2_STYLE;
|
|||||||
extern struct fort_border_style FORT_FRAME_STYLE;
|
extern struct fort_border_style FORT_FRAME_STYLE;
|
||||||
|
|
||||||
|
|
||||||
struct fort_entire_table_options
|
struct fort_entire_table_options {
|
||||||
{
|
|
||||||
unsigned int left_margin;
|
unsigned int left_margin;
|
||||||
unsigned int top_margin;
|
unsigned int top_margin;
|
||||||
unsigned int right_margin;
|
unsigned int right_margin;
|
||||||
@ -142,8 +135,7 @@ extern fort_entire_table_options_t g_entire_table_options;
|
|||||||
fort_status_t set_entire_table_option(fort_table_options_t *table_options, uint32_t option, int value);
|
fort_status_t set_entire_table_option(fort_table_options_t *table_options, uint32_t option, int value);
|
||||||
fort_status_t set_default_entire_table_option(uint32_t option, int value);
|
fort_status_t set_default_entire_table_option(uint32_t option, int value);
|
||||||
|
|
||||||
struct fort_table_options
|
struct fort_table_options {
|
||||||
{
|
|
||||||
struct fort_border_style border_style;
|
struct fort_border_style border_style;
|
||||||
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;
|
||||||
|
@ -7,16 +7,14 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* STRING BUFFER
|
* STRING BUFFER
|
||||||
* ***************************************************************************/
|
* ***************************************************************************/
|
||||||
enum str_buf_type
|
enum str_buf_type {
|
||||||
{
|
|
||||||
CharBuf,
|
CharBuf,
|
||||||
WCharBuf
|
WCharBuf
|
||||||
};
|
};
|
||||||
|
|
||||||
struct string_buffer;
|
struct string_buffer;
|
||||||
typedef struct string_buffer string_buffer_t;
|
typedef struct string_buffer string_buffer_t;
|
||||||
struct string_buffer
|
struct string_buffer {
|
||||||
{
|
|
||||||
union {
|
union {
|
||||||
char *cstr;
|
char *cstr;
|
||||||
wchar_t *wstr;
|
wchar_t *wstr;
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
struct ft_table;
|
struct ft_table;
|
||||||
typedef struct ft_table ft_table_t;
|
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;
|
||||||
string_buffer_t *conv_buffer;
|
string_buffer_t *conv_buffer;
|
||||||
|
@ -34,8 +34,7 @@ void test_table_cell_options(void);
|
|||||||
void test_table_tbl_options(void);
|
void test_table_tbl_options(void);
|
||||||
void test_memory_errors(void);
|
void test_memory_errors(void);
|
||||||
|
|
||||||
struct test_case
|
struct test_case {
|
||||||
{
|
|
||||||
char name [128];
|
char name [128];
|
||||||
void (*test)(void);
|
void (*test)(void);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user