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