[A] Added test style
This commit is contained in:
19
src/fort.c
19
src/fort.c
@@ -379,19 +379,30 @@ int ft_set_table_options(FTABLE * FORT_RESTRICT table, const fort_table_options_
|
||||
{
|
||||
assert(table);
|
||||
if (options == NULL) {
|
||||
F_FREE(table->options);
|
||||
destroy_table_options(table->options);
|
||||
table->options = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
fort_table_options_t *new_options = F_CALLOC(sizeof(fort_table_options_t), 1);
|
||||
|
||||
|
||||
fort_table_options_t *new_options = copy_table_options(options);
|
||||
if (new_options == NULL) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(new_options, options, sizeof(fort_table_options_t));
|
||||
F_FREE(table->options);
|
||||
destroy_table_options(table->options);
|
||||
table->options = new_options;
|
||||
return 0;
|
||||
|
||||
|
||||
// fort_table_options_t *new_options = F_CALLOC(sizeof(fort_table_options_t), 1);
|
||||
// if (new_options == NULL) {
|
||||
// return -1;
|
||||
// }
|
||||
// memcpy(new_options, options, sizeof(fort_table_options_t));
|
||||
// F_FREE(table->options);
|
||||
// table->options = new_options;
|
||||
// return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -64,6 +64,19 @@ fort_table_options_t* create_table_options()
|
||||
return options;
|
||||
}
|
||||
|
||||
fort_table_options_t* copy_table_options(const fort_table_options_t *option)
|
||||
{
|
||||
/* todo: normal implementation, do deep copy of col options */
|
||||
|
||||
fort_table_options_t* new_opt = create_table_options();
|
||||
if (new_opt == NULL)
|
||||
return NULL;
|
||||
|
||||
memcpy(new_opt, option, sizeof(fort_table_options_t));
|
||||
return new_opt;
|
||||
}
|
||||
|
||||
|
||||
void destroy_table_options(fort_table_options_t* options)
|
||||
{
|
||||
if (options == NULL)
|
||||
|
@@ -96,6 +96,7 @@ extern fort_table_options_t g_table_options;
|
||||
|
||||
|
||||
fort_table_options_t* create_table_options();
|
||||
fort_table_options_t* copy_table_options(const fort_table_options_t *option);
|
||||
void destroy_table_options(fort_table_options_t* options);
|
||||
fort_status_t fort_options_set_column_min_width(fort_table_options_t *options, size_t column, size_t width);
|
||||
fort_status_t fort_options_set_column_alignment(fort_table_options_t *options, size_t column, enum TextAlignment al);
|
||||
|
Reference in New Issue
Block a user