some reformatting for utf8map.c

and a few omitted 'const's for some constant pointers to constant
characters.

utf8map.c is missing date, branch, and revision tags on its first line.
This commit is contained in:
PatR
2024-01-25 11:22:01 -08:00
parent cc599cb6cd
commit 4be4f55ccf

View File

@@ -260,7 +260,7 @@ glyph_find_core(const char *id, struct find_struct *findwhat)
if (parse_id(id, findwhat)) { if (parse_id(id, findwhat)) {
if (findwhat->findtype == find_glyph) { if (findwhat->findtype == find_glyph) {
(findwhat->callback)(findwhat->val, findwhat); (*findwhat->callback)(findwhat->val, findwhat);
} else { } else {
for (glyph = 0; glyph < MAX_GLYPH; ++glyph) { for (glyph = 0; glyph < MAX_GLYPH; ++glyph) {
do_callback = FALSE; do_callback = FALSE;
@@ -570,6 +570,7 @@ int
glyphrep(const char *op) glyphrep(const char *op)
{ {
int reslt = 0, glyph = NO_GLYPH; int reslt = 0, glyph = NO_GLYPH;
if (!glyphid_cache) if (!glyphid_cache)
reslt = 1; /* for debugger use only; no cache available */ reslt = 1; /* for debugger use only; no cache available */
reslt = glyphrep_to_custom_map_entries(op, &glyph); reslt = glyphrep_to_custom_map_entries(op, &glyph);
@@ -646,7 +647,8 @@ static int
parse_id(const char *id, struct find_struct *findwhat) parse_id(const char *id, struct find_struct *findwhat)
{ {
FILE *fp = (FILE *) 0; FILE *fp = (FILE *) 0;
int i = 0, j, mnum, glyph, pm_offset = 0, oc_offset = 0, cmap_offset = 0, int i = 0, j, mnum, glyph,
pm_offset = 0, oc_offset = 0, cmap_offset = 0,
pm_count = 0, oc_count = 0, cmap_count = 0; pm_count = 0, oc_count = 0, cmap_count = 0;
boolean skip_base = FALSE, skip_this_one, dump_ids = FALSE, boolean skip_base = FALSE, skip_this_one, dump_ids = FALSE,
filling_cache = FALSE, is_S = FALSE, is_G = FALSE; filling_cache = FALSE, is_S = FALSE, is_G = FALSE;
@@ -703,6 +705,8 @@ parse_id(const char *id, struct find_struct *findwhat)
return 0; return 0;
} }
} else { } else {
const char *buf2, *buf3, *buf4;
/* individual matching glyph entries */ /* individual matching glyph entries */
for (glyph = 0; glyph < MAX_GLYPH; ++glyph) { for (glyph = 0; glyph < MAX_GLYPH; ++glyph) {
skip_base = FALSE; skip_base = FALSE;
@@ -711,8 +715,9 @@ parse_id(const char *id, struct find_struct *findwhat)
if (glyph_is_monster(glyph)) { if (glyph_is_monster(glyph)) {
/* buf2 will hold the distinguishing prefix */ /* buf2 will hold the distinguishing prefix */
/* buf3 will hold the base name */ /* buf3 will hold the base name */
const char *buf2 = ""; buf2 = "";
const char *buf3 = monsdump[glyph_to_mon(glyph)].nm; buf3 = monsdump[glyph_to_mon(glyph)].nm;
if (glyph_is_normal_male_monster(glyph)) { if (glyph_is_normal_male_monster(glyph)) {
buf2 = "male_"; buf2 = "male_";
} else if (glyph_is_normal_female_monster(glyph)) { } else if (glyph_is_normal_female_monster(glyph)) {
@@ -736,8 +741,8 @@ parse_id(const char *id, struct find_struct *findwhat)
} else if (glyph_is_body(glyph)) { } else if (glyph_is_body(glyph)) {
/* buf2 will hold the distinguishing prefix */ /* buf2 will hold the distinguishing prefix */
/* buf3 will hold the base name */ /* buf3 will hold the base name */
const char *buf2 = ""; buf2 = ""; /* superflous */
const char *buf3 = monsdump[glyph_to_body_corpsenm(glyph)].nm; buf3 = monsdump[glyph_to_body_corpsenm(glyph)].nm;
if (glyph_is_body_piletop(glyph)) { if (glyph_is_body_piletop(glyph)) {
buf2 = "piletop_body_"; buf2 = "piletop_body_";
} else { } else {
@@ -749,8 +754,8 @@ parse_id(const char *id, struct find_struct *findwhat)
} else if (glyph_is_statue(glyph)) { } else if (glyph_is_statue(glyph)) {
/* buf2 will hold the distinguishing prefix */ /* buf2 will hold the distinguishing prefix */
/* buf3 will hold the base name */ /* buf3 will hold the base name */
const char *buf2 = ""; buf2 = "";
const char *buf3 = monsdump[glyph_to_statue_corpsenm(glyph)].nm; buf3 = monsdump[glyph_to_statue_corpsenm(glyph)].nm;
if (glyph_is_fem_statue_piletop(glyph)) { if (glyph_is_fem_statue_piletop(glyph)) {
buf2 = "piletop_statue_of_female_"; buf2 = "piletop_statue_of_female_";
} else if (glyph_is_fem_statue(glyph)) { } else if (glyph_is_fem_statue(glyph)) {
@@ -767,8 +772,8 @@ parse_id(const char *id, struct find_struct *findwhat)
i = glyph_to_obj(glyph); i = glyph_to_obj(glyph);
/* buf2 will hold the distinguishing prefix */ /* buf2 will hold the distinguishing prefix */
/* buf3 will hold the base name */ /* buf3 will hold the base name */
const char *buf2 = ""; buf2 = "";
const char *buf3 = ""; buf3 = "";
if (((i > SCR_STINKING_CLOUD) && (i < SCR_MAIL)) if (((i > SCR_STINKING_CLOUD) && (i < SCR_MAIL))
|| ((i > WAN_LIGHTNING) && (i < GOLD_PIECE))) || ((i > WAN_LIGHTNING) && (i < GOLD_PIECE)))
skip_this_one = TRUE; skip_this_one = TRUE;
@@ -808,9 +813,9 @@ parse_id(const char *id, struct find_struct *findwhat)
/* buf2 will hold the distinguishing prefix */ /* buf2 will hold the distinguishing prefix */
/* buf3 will hold the base name */ /* buf3 will hold the base name */
/* buf4 will hold the distinguishing suffix */ /* buf4 will hold the distinguishing suffix */
const char *buf2 = ""; buf2 = "";
const char *buf3 = ""; buf3 = "";
const char *buf4 = ""; buf4 = "";
if (glyph == GLYPH_CMAP_OFF) { if (glyph == GLYPH_CMAP_OFF) {
cmap = S_stone; cmap = S_stone;
buf3 = "stone substrate"; buf3 = "stone substrate";
@@ -833,10 +838,11 @@ parse_id(const char *id, struct find_struct *findwhat)
} else if (glyph_is_cmap_a(glyph)) { } else if (glyph_is_cmap_a(glyph)) {
cmap = (glyph - GLYPH_CMAP_A_OFF) + S_ndoor; cmap = (glyph - GLYPH_CMAP_A_OFF) + S_ndoor;
} else if (glyph_is_cmap_altar(glyph)) { } else if (glyph_is_cmap_altar(glyph)) {
const char *altar_text[] = { static const char *const altar_text[] = {
"unaligned", "chaotic", "neutral", "unaligned", "chaotic", "neutral",
"lawful", "other", "lawful", "other",
}; };
j = (glyph - GLYPH_ALTAR_OFF); j = (glyph - GLYPH_ALTAR_OFF);
cmap = S_altar; cmap = S_altar;
if (j != altar_other) { if (j != altar_other) {
@@ -850,10 +856,11 @@ parse_id(const char *id, struct find_struct *findwhat)
} else if (glyph_is_cmap_b(glyph)) { } else if (glyph_is_cmap_b(glyph)) {
cmap = (glyph - GLYPH_CMAP_B_OFF) + S_grave; cmap = (glyph - GLYPH_CMAP_B_OFF) + S_grave;
} else if (glyph_is_cmap_zap(glyph)) { } else if (glyph_is_cmap_zap(glyph)) {
static const char *zap_texts[] = { static const char *const zap_texts[] = {
"missile", "fire", "frost", "sleep", "missile", "fire", "frost", "sleep",
"death", "lightning", "poison gas", "acid" "death", "lightning", "poison gas", "acid"
}; };
j = (glyph - GLYPH_ZAP_OFF); j = (glyph - GLYPH_ZAP_OFF);
cmap = (j % 4) + S_vbeam; cmap = (j % 4) + S_vbeam;
Snprintf(buf[2], sizeof buf[2], "%s", Snprintf(buf[2], sizeof buf[2], "%s",
@@ -866,11 +873,12 @@ parse_id(const char *id, struct find_struct *findwhat)
} else if (glyph_is_cmap_c(glyph)) { } else if (glyph_is_cmap_c(glyph)) {
cmap = (glyph - GLYPH_CMAP_C_OFF) + S_digbeam; cmap = (glyph - GLYPH_CMAP_C_OFF) + S_digbeam;
} else if (glyph_is_swallow(glyph)) { } else if (glyph_is_swallow(glyph)) {
static const char *swallow_texts[] = { static const char *const swallow_texts[] = {
"top left", "top center", "top right", "top left", "top center", "top right",
"middle left", "middle right", "bottom left", "middle left", "middle right", "bottom left",
"bottom center", "bottom right", "bottom center", "bottom right",
}; };
j = glyph - GLYPH_SWALLOW_OFF; j = glyph - GLYPH_SWALLOW_OFF;
cmap = glyph_to_swallow(glyph); cmap = glyph_to_swallow(glyph);
mnum = j / ((S_sw_br - S_sw_tl) + 1); mnum = j / ((S_sw_br - S_sw_tl) + 1);
@@ -882,20 +890,20 @@ parse_id(const char *id, struct find_struct *findwhat)
buf3 = buf[3]; buf3 = buf[3];
skip_base = TRUE; skip_base = TRUE;
} else if (glyph_is_explosion(glyph)) { } else if (glyph_is_explosion(glyph)) {
int expl; static const char *const expl_type_texts[] = {
static const char *expl_type_texts[] = {
"dark", "noxious", "muddy", "wet", "dark", "noxious", "muddy", "wet",
"magical", "fiery", "frosty", "magical", "fiery", "frosty",
}; };
static const char *expl_texts[] = { static const char *const expl_texts[] = {
"tl", "tc", "tr", "ml", "mc", "tl", "tc", "tr", "ml", "mc",
"mr", "bl", "bc", "br", "mr", "bl", "bc", "br",
}; };
int expl;
j = glyph - GLYPH_EXPLODE_OFF; j = glyph - GLYPH_EXPLODE_OFF;
expl = j / ((S_expl_br - S_expl_tl) + 1); expl = j / ((S_expl_br - S_expl_tl) + 1);
cmap = cmap = (j % ((S_expl_br - S_expl_tl) + 1))
(j % ((S_expl_br - S_expl_tl) + 1)) + S_expl_tl; + S_expl_tl;
i = cmap - S_expl_tl; i = cmap - S_expl_tl;
Snprintf(buf[2], sizeof buf[2], "%s ", Snprintf(buf[2], sizeof buf[2], "%s ",
expl_type_texts[expl]); expl_type_texts[expl]);