From 7fa5b36626838b6424ed406ee108e7a850646cab Mon Sep 17 00:00:00 2001 From: Dino Date: Wed, 21 Jan 2026 22:52:39 -0500 Subject: [PATCH] ruledit & ruleup: add gt_marking _() to more output strings RM #1893 --- tools/ruleutil/rulesave.c | 122 +++++++++++++++++++++++++------------- utility/registry_ini.c | 30 +++++++--- utility/registry_ini.h | 36 +++++++---- 3 files changed, 126 insertions(+), 62 deletions(-) diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c index 3ed8624cc8..4b19cca547 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -366,7 +366,8 @@ static bool save_strvec(struct section_file *sfile, sections[i] = strvec_get(to_save, i); } - secfile_insert_str_vec(sfile, sections, sect_count, "%s.%s", path, entry); + secfile_insert_str_vec_gt_marking(sfile, sections, sect_count, + "%s.%s", path, entry); } return TRUE; @@ -688,8 +689,10 @@ static bool save_cities_ruleset(const char *filename, const char *name) save_name_translation(sfile, &(s->name), path); if (strcmp(rule_name_get(&s->name), rule_name_get(&s->abbreviation))) { - secfile_insert_str(sfile, rule_name_get(&s->abbreviation), - "%s.short_name", path); + struct entry *pentry = + secfile_insert_str(sfile, rule_name_get(&s->abbreviation), + "%s.short_name", path); + entry_str_set_gt_marking(pentry, TRUE); } save_reqs_vector(sfile, &(s->reqs), path, "reqs"); @@ -880,8 +883,10 @@ static bool save_action_ui_name(struct section_file *sfile, } if (strcmp(ui_name, action_ui_name_default(act))) { - secfile_insert_str(sfile, ui_name, - "actions.%s", entry_name); + struct entry *pentry = + secfile_insert_str(sfile, ui_name, + "actions.%s", entry_name); + entry_str_set_gt_marking(pentry, TRUE); } return TRUE; @@ -1249,6 +1254,7 @@ static bool save_game_ruleset(const char *filename, const char *name) enum trade_route_type trt; int i; bool locks; + struct entry *pentry; if (sfile == NULL) { return FALSE; @@ -1280,11 +1286,9 @@ static bool save_game_ruleset(const char *filename, const char *name) } if (game.ruleset_summary != NULL) { - struct entry *mod_entry; - - mod_entry = secfile_insert_str(sfile, game.ruleset_summary, - "about.summary"); - entry_str_set_gt_marking(mod_entry, TRUE); + pentry = secfile_insert_str(sfile, game.ruleset_summary, + "about.summary"); + entry_str_set_gt_marking(pentry, TRUE); } if (game.ruleset_description != NULL) { @@ -1618,12 +1622,14 @@ static bool save_game_ruleset(const char *filename, const char *name) } if (strcmp(game.calendar.positive_year_label, RS_DEFAULT_POS_YEAR_LABEL)) { - secfile_insert_str(sfile, game.calendar.positive_year_label, - "calendar.positive_label"); + pentry = secfile_insert_str(sfile, game.calendar.positive_year_label, + "calendar.positive_label"); + entry_str_set_gt_marking(pentry, TRUE); } if (strcmp(game.calendar.negative_year_label, RS_DEFAULT_NEG_YEAR_LABEL)) { - secfile_insert_str(sfile, game.calendar.negative_year_label, - "calendar.negative_label"); + pentry = secfile_insert_str(sfile, game.calendar.negative_year_label, + "calendar.negative_label"); + entry_str_set_gt_marking(pentry, TRUE); } if (game.plr_bg_color != NULL) { @@ -1641,9 +1647,9 @@ static bool save_game_ruleset(const char *filename, const char *name) tnames[i] = team_slot_rule_name(team_slot_by_number(i)); } - secfile_insert_str_vec(sfile, tnames, - game.server.ruledit.named_teams, - "teams.names"); + secfile_insert_str_vec_gt_marking(sfile, tnames, + game.server.ruledit.named_teams, + "teams.names"); } comment_disasters(sfile); @@ -1700,9 +1706,13 @@ static bool save_game_ruleset(const char *filename, const char *name) save_default_int(sfile, pach->culture, 0, path, "culture"); - secfile_insert_str(sfile, pach->first_msg, "%s.first_msg", path); + pentry = secfile_insert_str(sfile, pach->first_msg, + "%s.first_msg", path); + entry_str_set_gt_marking(pentry, TRUE); if (pach->cons_msg != NULL) { - secfile_insert_str(sfile, pach->cons_msg, "%s.cons_msg", path); + pentry = secfile_insert_str(sfile, pach->cons_msg, + "%s.cons_msg", path); + entry_str_set_gt_marking(pentry, TRUE); } } achievements_iterate_end; @@ -1881,6 +1891,7 @@ static bool save_governments_ruleset(const char *filename, const char *name) { struct section_file *sfile = create_ruleset_file(name, "government"); int sect_idx; + struct entry *pentry; if (sfile == NULL) { return FALSE; @@ -1919,14 +1930,16 @@ static bool save_governments_ruleset(const char *filename, const char *name) title = ruler_title_male_untranslated_name(prtitle); if (title != NULL) { - secfile_insert_str(sfile, title, - "%s.ruler_male_title", path); + pentry = secfile_insert_str(sfile, title, + "%s.ruler_male_title", path); + entry_str_set_gt_marking(pentry, TRUE); } title = ruler_title_female_untranslated_name(prtitle); if (title != NULL) { - secfile_insert_str(sfile, title, - "%s.ruler_female_title", path); + pentry = secfile_insert_str(sfile, title, + "%s.ruler_female_title", path); + entry_str_set_gt_marking(pentry, TRUE); } } @@ -2332,6 +2345,7 @@ static bool save_techs_ruleset(const char *filename, const char *name) int sect_idx; struct advance *a_none = advance_by_number(A_NONE); bool uflags_tech = FALSE; + struct entry *pentry; if (sfile == NULL) { return FALSE; @@ -2347,12 +2361,16 @@ static bool save_techs_ruleset(const char *filename, const char *name) uflags_tech = TRUE; } - secfile_insert_str(sfile, flagname, "control.flags%d.name", i); + pentry = secfile_insert_str(sfile, flagname, + "control.flags%d.name", i); + entry_str_set_gt_marking(pentry, TRUE); /* Save the user flag help text even when it is undefined. That makes * the formatting code happy. The resulting "" is ignored when the * ruleset is loaded. */ - secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i); + pentry = secfile_insert_str(sfile, helptxt, + "control.flags%d.helptxt", i); + entry_str_set_gt_marking(pentry, TRUE); } } @@ -2402,7 +2420,9 @@ static bool save_techs_ruleset(const char *filename, const char *name) secfile_insert_str(sfile, pa->graphic_alt, "%s.graphic_alt", path); } if (pa->bonus_message != NULL) { - secfile_insert_str(sfile, pa->bonus_message, "%s.bonus_message", path); + pentry = secfile_insert_str(sfile, pa->bonus_message, + "%s.bonus_message", path); + entry_str_set_gt_marking(pentry, TRUE); } set_count = 0; @@ -2438,6 +2458,7 @@ static bool save_terrain_ruleset(const char *filename, const char *name) int i; bool uflags_terr = FALSE; bool uflags_extra = FALSE; + struct entry *pentry; if (sfile == NULL) { return FALSE; @@ -2453,12 +2474,16 @@ static bool save_terrain_ruleset(const char *filename, const char *name) uflags_terr = TRUE; } - secfile_insert_str(sfile, flagname, "control.flags%d.name", i); + pentry = secfile_insert_str(sfile, flagname, + "control.flags%d.name", i); + entry_str_set_gt_marking(pentry, TRUE); /* Save the user flag help text even when it is undefined. That makes * the formatting code happy. The resulting "" is ignored when the * ruleset is loaded. */ - secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i); + pentry = secfile_insert_str(sfile, helptxt, + "control.flags%d.helptxt", i); + entry_str_set_gt_marking(pentry, TRUE); } } @@ -2475,13 +2500,16 @@ static bool save_terrain_ruleset(const char *filename, const char *name) uflags_extra = TRUE; } - secfile_insert_str(sfile, flagname, "control.extra_flags%d.name", i); + pentry = secfile_insert_str(sfile, flagname, + "control.extra_flags%d.name", i); + entry_str_set_gt_marking(pentry, TRUE); /* Save the user flag help text even when it is undefined. That makes * the formatting code happy. The resulting "" is ignored when the * ruleset is loaded. */ - secfile_insert_str(sfile, helptxt, - "control.extra_flags%d.helptxt", i); + pentry = secfile_insert_str(sfile, helptxt, + "control.extra_flags%d.helptxt", i); + entry_str_set_gt_marking(pentry, TRUE); } } @@ -2732,10 +2760,12 @@ static bool save_terrain_ruleset(const char *filename, const char *name) } } extra_type_by_cause_iterate_end; - secfile_insert_str(sfile, terrain_control.gui_type_base0, - "extraui.ui_name_base_fortress"); - secfile_insert_str(sfile, terrain_control.gui_type_base1, - "extraui.ui_name_base_airbase"); + pentry = secfile_insert_str(sfile, terrain_control.gui_type_base0, + "extraui.ui_name_base_fortress"); + entry_str_set_gt_marking(pentry, TRUE); + pentry = secfile_insert_str(sfile, terrain_control.gui_type_base1, + "extraui.ui_name_base_airbase"); + entry_str_set_gt_marking(pentry, TRUE); comment_extras(sfile); @@ -3039,8 +3069,8 @@ static bool save_veteran_system(struct section_file *sfile, const char *path, vlist_move[i] = vsystem->definitions[i].move_bonus; } - secfile_insert_str_vec(sfile, vlist_name, vsystem->levels, - "%s.veteran_names", path); + secfile_insert_str_vec_gt_marking(sfile, vlist_name, vsystem->levels, + "%s.veteran_names", path); secfile_insert_int_vec(sfile, vlist_power, vsystem->levels, "%s.veteran_power_fact", path); secfile_insert_int_vec(sfile, vlist_raise, vsystem->levels, @@ -3100,6 +3130,7 @@ static bool save_units_ruleset(const char *filename, const char *name) int sect_idx; bool uflags_utype = FALSE; bool uflags_uclass = FALSE; + struct entry *pentry; if (sfile == NULL) { return FALSE; @@ -3115,12 +3146,16 @@ static bool save_units_ruleset(const char *filename, const char *name) uflags_utype = TRUE; } - secfile_insert_str(sfile, flagname, "control.flags%d.name", i); + pentry = secfile_insert_str(sfile, flagname, + "control.flags%d.name", i); + entry_str_set_gt_marking(pentry, TRUE); /* Save the user flag help text even when it is undefined. That makes * the formatting code happy. The resulting "" is ignored when the * ruleset is loaded. */ - secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i); + pentry = secfile_insert_str(sfile, helptxt, + "control.flags%d.helptxt", i); + entry_str_set_gt_marking(pentry, TRUE); } } @@ -3137,13 +3172,16 @@ static bool save_units_ruleset(const char *filename, const char *name) uflags_uclass = TRUE; } - secfile_insert_str(sfile, flagname, "control.class_flags%d.name", i); + pentry = secfile_insert_str(sfile, flagname, + "control.class_flags%d.name", i); + entry_str_set_gt_marking(pentry, TRUE); /* Save the user flag help text even when it is undefined. That makes * the formatting code happy. The resulting "" is ignored when the * ruleset is loaded. */ - secfile_insert_str(sfile, helptxt, - "control.class_flags%d.helptxt", i); + pentry = secfile_insert_str(sfile, helptxt, + "control.class_flags%d.helptxt", i); + entry_str_set_gt_marking(pentry, TRUE); } } diff --git a/utility/registry_ini.c b/utility/registry_ini.c index 9a5f21591b..83bf65f474 100644 --- a/utility/registry_ini.c +++ b/utility/registry_ini.c @@ -1573,11 +1573,13 @@ struct entry *secfile_insert_comment(struct section_file *secfile, size_t secfile_insert_str_vec_full(struct section_file *secfile, const char *const *strings, size_t dim, const char *comment, bool allow_replace, - bool no_escape, const char *path, ...) + bool no_escape, bool gt_marking, + const char *path, ...) { char fullpath[MAX_LEN_SECPATH]; size_t i, ret = 0; va_list args; + struct entry *pentry; SECFILE_RETURN_VAL_IF_FAIL(secfile, NULL, NULL != secfile, 0); @@ -1587,17 +1589,27 @@ size_t secfile_insert_str_vec_full(struct section_file *secfile, /* NB: 'path,0' is actually 'path'. See comment in the head * of the file. */ - if (dim > 0 - && NULL != secfile_insert_str_full(secfile, strings[0], comment, - allow_replace, no_escape, FALSE, - "%s", fullpath)) { - ret++; + if (dim > 0) { + pentry = secfile_insert_str_full(secfile, strings[0], comment, + allow_replace, no_escape, FALSE, + "%s", fullpath); + if (NULL != pentry) { + ret++; + if (gt_marking) { + entry_str_set_gt_marking(pentry, TRUE); + } + } } + for (i = 1; i < dim; i++) { - if (NULL != secfile_insert_str_full(secfile, strings[i], comment, - allow_replace, no_escape, FALSE, - "%s,%d", fullpath, (int) i)) { + pentry = secfile_insert_str_full(secfile, strings[i], comment, + allow_replace, no_escape, FALSE, + "%s,%d", fullpath, (int) i); + if (NULL != pentry) { ret++; + if (gt_marking) { + entry_str_set_gt_marking(pentry, TRUE); + } } } diff --git a/utility/registry_ini.h b/utility/registry_ini.h index 400ce4fcc7..4a68076f04 100644 --- a/utility/registry_ini.h +++ b/utility/registry_ini.h @@ -193,38 +193,52 @@ struct entry *secfile_insert_str_full(struct section_file *secfile, comment, path, ...) \ secfile_insert_str_full(secfile, string, comment, TRUE, TRUE, FALSE, \ path, ## __VA_ARGS__) + size_t secfile_insert_str_vec_full(struct section_file *secfile, const char *const *strings, size_t dim, const char *comment, bool allow_replace, - bool no_escape, const char *path, ...) - fc__attribute((__format__(__printf__, 7, 8))); + bool no_escape, bool gt_marking, + const char *path, ...) + fc__attribute((__format__(__printf__, 8, 9))); #define secfile_insert_str_vec(secfile, strings, dim, path, ...) \ - secfile_insert_str_vec_full(secfile, strings, dim, NULL, FALSE, FALSE, \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + NULL, FALSE, FALSE, FALSE, \ + path, ## __VA_ARGS__) +#define secfile_insert_str_vec_gt_marking(secfile, strings, dim, path, ...) \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + NULL, FALSE, FALSE, TRUE, \ path, ## __VA_ARGS__) #define secfile_insert_str_vec_noescape(secfile, strings, dim, path, ...) \ - secfile_insert_str_vec_full(secfile, strings, dim, NULL, FALSE, TRUE, \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + NULL, FALSE, TRUE, FALSE, \ path, ## __VA_ARGS__) #define secfile_insert_str_vec_comment(secfile, strings, dim, \ comment, path, ...) \ - secfile_insert_str_vec_full(secfile, strings, dim, comment, FALSE, TRUE, \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + comment, FALSE, TRUE, FALSE, \ path, ## __VA_ARGS__) #define secfile_insert_str_vec_noescape_comment(secfile, strings, dim, \ comment, path, ...) \ - secfile_insert_str_vec_full(secfile, strings, dim, comment, FALSE, TRUE, \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + comment, FALSE, TRUE, FALSE \ path, ## __VA_ARGS__) #define secfile_replace_str_vec(secfile, strings, dim, path, ...) \ - secfile_insert_str_vec_full(secfile, strings, dim, NULL, TRUE, FALSE, \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + NULL, TRUE, FALSE, FALSE, \ path, ## __VA_ARGS__) #define secfile_replace_str_vec_noescape(secfile, strings, dim, path, ...) \ - secfile_insert_str_vec_full(secfile, strings, dim, NULL, TRUE, TRUE, \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + NULL, TRUE, TRUE, FALSE, \ path, ## __VA_ARGS__) #define secfile_replace_str_vec_comment(secfile, strings, dim, \ comment, path, ...) \ - secfile_insert_str_vec_full(secfile, strings, dim, comment, TRUE, TRUE, \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + comment, TRUE, TRUE, FALSE, \ path, ## __VA_ARGS__) #define secfile_replace_str_vec_noescape_comment(secfile, strings, dim, \ comment, path, ...) \ - secfile_insert_str_vec_full(secfile, strings, dim, comment, TRUE, TRUE, \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + comment, TRUE, TRUE, FALSE, \ path, ## __VA_ARGS__) struct entry *secfile_insert_plain_enum_full(struct section_file *secfile, @@ -583,7 +597,7 @@ int *secfile_lookup_enum_vec_data(const struct section_file *secfile, secfile_data_t data, const char *path, ...) fc__warn_unused_result fc__attribute((__format__ (__printf__, 6, 7))); - + /* Sections functions. */ struct section *secfile_section_by_name(const struct section_file *secfile, const char *section_name); -- 2.31.0