From 6bd9ae6be213d5fa2536b7a88606b67f9f072004 Mon Sep 17 00:00:00 2001 From: Dino Date: Thu, 22 Jan 2026 21:18:05 -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 | 34 +++++++---- 3 files changed, 125 insertions(+), 61 deletions(-) diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c index c173f09c4e..eddc50347e 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -369,7 +369,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; @@ -693,8 +694,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"); @@ -1225,8 +1228,10 @@ static bool save_actions_ruleset(const char *filename, const char *name) } if (strcmp(ui_name, action_ui_name_default(i))) { - secfile_insert_str(sfile, ui_name, - "%s.ui_name", path); + struct entry *pentry = + secfile_insert_str(sfile, ui_name, + "%s.ui_name", path); + entry_str_set_gt_marking(pentry, TRUE); } } } @@ -1274,6 +1279,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 == nullptr) { return FALSE; @@ -1311,11 +1317,9 @@ static bool save_game_ruleset(const char *filename, const char *name) } if (game.ruleset_summary != nullptr) { - 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 != nullptr) { @@ -1641,12 +1645,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 != nullptr) { @@ -1664,9 +1670,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); @@ -1723,9 +1729,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 != nullptr) { - 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; @@ -1918,6 +1928,7 @@ static bool save_governments_ruleset(const char *filename, const char *name) int sect_idx; bool uflags_government = FALSE; int i; + struct entry *pentry; if (sfile == nullptr) { return FALSE; @@ -1979,14 +1990,16 @@ static bool save_governments_ruleset(const char *filename, const char *name) title = ruler_title_male_untranslated_name(prtitle); if (title != nullptr) { - 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 != nullptr) { - 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); } } @@ -2404,6 +2417,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 == nullptr) { return FALSE; @@ -2419,12 +2433,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); } } @@ -2474,7 +2492,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 != nullptr) { - 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; @@ -2510,6 +2530,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 == nullptr) { return FALSE; @@ -2525,12 +2546,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); } } @@ -2547,13 +2572,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); } } @@ -2807,10 +2835,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); @@ -3137,8 +3167,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, @@ -3198,6 +3228,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 == nullptr) { return FALSE; @@ -3213,12 +3244,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); } } @@ -3235,13 +3270,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 a397262890..634c2ae735 100644 --- a/utility/registry_ini.c +++ b/utility/registry_ini.c @@ -1572,11 +1572,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, nullptr, secfile != nullptr, 0); @@ -1586,17 +1588,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 - && secfile_insert_str_full(secfile, strings[0], comment, - allow_replace, no_escape, FALSE, - "%s", fullpath) != nullptr) { - ret++; + if (dim > 0) { + pentry = secfile_insert_str_full(secfile, strings[0], comment, + allow_replace, no_escape, FALSE, + "%s", fullpath); + if (nullptr != pentry) { + ret++; + if (gt_marking) { + entry_str_set_gt_marking(pentry, TRUE); + } + } } + for (i = 1; i < dim; i++) { - if (secfile_insert_str_full(secfile, strings[i], comment, - allow_replace, no_escape, FALSE, - "%s,%d", fullpath, (int) i) != nullptr) { + pentry = secfile_insert_str_full(secfile, strings[i], comment, + allow_replace, no_escape, FALSE, + "%s,%d", fullpath, (int) i); + if (nullptr != 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 28ce10a51f..d7107c68a2 100644 --- a/utility/registry_ini.h +++ b/utility/registry_ini.h @@ -196,38 +196,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, nullptr, FALSE, FALSE, \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + nullptr, 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, \ + nullptr, FALSE, FALSE, TRUE, \ path, ## __VA_ARGS__) #define secfile_insert_str_vec_noescape(secfile, strings, dim, path, ...) \ - secfile_insert_str_vec_full(secfile, strings, dim, nullptr, FALSE, TRUE, \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + nullptr, 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, nullptr, TRUE, FALSE, \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + nullptr, TRUE, FALSE, FALSE, \ path, ## __VA_ARGS__) #define secfile_replace_str_vec_noescape(secfile, strings, dim, path, ...) \ - secfile_insert_str_vec_full(secfile, strings, dim, nullptr, TRUE, TRUE, \ + secfile_insert_str_vec_full(secfile, strings, dim, \ + nullptr, 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, -- 2.31.0