From b2a1aa9b884ebe2b1283ba54a7864335539b66d7 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 21 Jun 2020 11:59:24 +0100 Subject: improvements from review --- utils/split-messages.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'utils') diff --git a/utils/split-messages.c b/utils/split-messages.c index fa384feb2..581151485 100644 --- a/utils/split-messages.c +++ b/utils/split-messages.c @@ -172,8 +172,13 @@ static nserror process_cmdline(int argc, char **argv, struct param *param) return NSERROR_OK; } -/*** - * extract key/value from a line + +/** + * extract key/value from a line of input + * + * \retun NSERROR_OK and key_out and value_out updated + * NSERROR_NOT_FOUND if not a key/value input line + * NSERROR_INVALID if the line is and invalid format (missing colon) */ static nserror get_key_value(char *line, ssize_t linelen, char **key_out, char **value_out) @@ -223,6 +228,10 @@ get_key_value(char *line, ssize_t linelen, char **key_out, char **value_out) return NSERROR_OK; } + +/** + * extract language, platform and token elements from a string + */ static nserror get_lang_plat_tok(char *str, char **lang_out, char **plat_out, char **tok_out) { @@ -259,6 +268,9 @@ get_lang_plat_tok(char *str, char **lang_out, char **plat_out, char **tok_out) } +/** + * reverse order of entries in a translation list + */ static nserror translation_list_reverse(struct trnsltn_entry **tlist) { @@ -281,6 +293,7 @@ translation_list_reverse(struct trnsltn_entry **tlist) return NSERROR_OK; } + /** * find a translation entry from a key * @@ -312,6 +325,9 @@ translation_from_key(struct trnsltn_entry *tlist, } +/** + * create and link an entry into translation list + */ static nserror translation_add(struct trnsltn_entry **tlist, const char *lang, @@ -334,6 +350,9 @@ translation_add(struct trnsltn_entry **tlist, } +/** + * replace key and value on a translation entry + */ static nserror translation_replace(struct trnsltn_entry *tran, const char *lang, @@ -350,6 +369,7 @@ translation_replace(struct trnsltn_entry *tran, return NSERROR_OK; } + /** * process a line of the input file * @@ -395,7 +415,8 @@ messageline(struct param *param, * new entry is in selected language and * current entry is not */ - res = translation_replace(tran, lang, tok, value); } else if ((strcmp(lang, param->fallback) != 0) && + res = translation_replace(tran, lang, tok, value); + } else if ((strcmp(lang, param->fallback) != 0) && (strcmp(tran->lang, param->fallback) != 0)) { /* * new entry is in fallback language and @@ -417,6 +438,9 @@ messageline(struct param *param, } +/** + * read fatmessages file and create a translation entry list + */ static nserror fatmessages_read(struct param *param, struct trnsltn_entry **tlist) { @@ -454,6 +478,10 @@ fatmessages_read(struct param *param, struct trnsltn_entry **tlist) return res; } + +/** + * write output in NetSurf messages format + */ static nserror message_write(struct param *param, struct trnsltn_entry *tlist) { -- cgit v1.2.3