From b0e5eb03e14daa96224fa7e7cde1112cd84cb657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20ANDR=C3=89-CHANG?= Date: Sun, 8 Dec 2019 23:33:02 +0000 Subject: [PATCH] Feedback --- src/lib_ccx/ccx_common_common.c | 6 ++++-- src/lib_ccx/ccx_decoders_structs.h | 2 +- src/lib_ccx/ccx_encoders_helpers.c | 4 ++-- src/lib_ccx/ccx_encoders_helpers.h | 4 ++-- src/lib_ccx/params.c | 11 +++++------ 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/lib_ccx/ccx_common_common.c b/src/lib_ccx/ccx_common_common.c index 6687531e..1abe0d0d 100644 --- a/src/lib_ccx/ccx_common_common.c +++ b/src/lib_ccx/ccx_common_common.c @@ -61,9 +61,11 @@ void millis_to_time(LLONG milli, unsigned *hours, unsigned *minutes, /* Frees the given pointer */ void freep(void **arg) { - if (*arg) + if (arg) + { free(*arg); - *arg = NULL; + *arg = NULL; + } } int add_cc_sub_text(struct cc_subtitle *sub, char *str, LLONG start_time, diff --git a/src/lib_ccx/ccx_decoders_structs.h b/src/lib_ccx/ccx_decoders_structs.h index 3eec6024..038a38d1 100644 --- a/src/lib_ccx/ccx_decoders_structs.h +++ b/src/lib_ccx/ccx_decoders_structs.h @@ -62,7 +62,7 @@ typedef struct eia608_screen // A CC buffer { /** format of data inside this structure */ enum ccx_eia608_format format; - char characters[15][33]; + unsigned char characters[15][33]; unsigned char colors[15][33]; unsigned char fonts[15][33]; // Extra char at the end for a 0 int row_used[15]; // Any data in row? diff --git a/src/lib_ccx/ccx_encoders_helpers.c b/src/lib_ccx/ccx_encoders_helpers.c index 17634177..df230008 100644 --- a/src/lib_ccx/ccx_encoders_helpers.c +++ b/src/lib_ccx/ccx_encoders_helpers.c @@ -454,7 +454,7 @@ int add_word(struct word_list *list, const char *word) return word_len; } -int add_builtin_capitalized_words() +int add_builtin_capitalized_words(void) { static int function_already_ran = 0; // so we don't do it twice if (!function_already_ran) @@ -470,7 +470,7 @@ int add_builtin_capitalized_words() return 0; } -int add_builtin_profane_words() +int add_builtin_profane_words(void) { static int function_already_ran = 0; // so we don't do it twice if (!function_already_ran) diff --git a/src/lib_ccx/ccx_encoders_helpers.h b/src/lib_ccx/ccx_encoders_helpers.h index 8cf3d3dd..4926e4fb 100644 --- a/src/lib_ccx/ccx_encoders_helpers.h +++ b/src/lib_ccx/ccx_encoders_helpers.h @@ -32,8 +32,8 @@ void get_sentence_borders(int *first, int *last, int line_num, struct eia608_scr int string_cmp(const void *p1, const void *p2); int string_cmp_function(const void *p1, const void *p2, void *arg); -int add_builtin_profane_words(); -int add_builtin_capitalized_words(); +int add_builtin_profane_words(void); +int add_builtin_capitalized_words(void); void fix_subtitles(struct encoder_ctx *context, int line_number, struct eia608_screen *data); unsigned encode_line (struct encoder_ctx *ctx, unsigned char *buffer, unsigned char *text); diff --git a/src/lib_ccx/params.c b/src/lib_ccx/params.c index 37706e48..5926c758 100644 --- a/src/lib_ccx/params.c +++ b/src/lib_ccx/params.c @@ -37,8 +37,6 @@ static int inputfile_capacity = 0; -#define MAX_WORD_LENGTH 50 - size_t remove_trailing_whitespace(char *line) { char *c = line + strlen(line) - 1; @@ -58,18 +56,19 @@ int process_word_file(const char *filename, struct word_list *list) return -1; } - char line[MAX_WORD_LENGTH]; // For screen width (32)+CRLF+0 + char line[CCX_DECODER_608_SCREEN_WIDTH + 3]; // For screen width (CR)LF + '\0' == 3 int num = 0; - while (fgets(line, MAX_WORD_LENGTH, fi)) + while (fgets(line, CCX_DECODER_608_SCREEN_WIDTH + 3, fi)) { num++; if (line[0] == '#') // Treat lines starting with '#' as comments continue; size_t new_len = remove_trailing_whitespace(line); - if (new_len > MAX_WORD_LENGTH - 3) + + if (new_len > CCX_DECODER_608_SCREEN_WIDTH) { - mprint("Word in line %d too long, max = %d characters.\n", num, MAX_WORD_LENGTH); + mprint("Word in line %d too long, max = %d characters.\n", num, CCX_DECODER_608_SCREEN_WIDTH); continue; }