symbols tweaks

Mostly formatting but a couple of minor code changes too.
This commit is contained in:
PatR
2022-11-23 13:06:05 -08:00
parent ccec83e8ce
commit 47ace5d10a
4 changed files with 61 additions and 36 deletions

View File

@@ -3475,8 +3475,8 @@ read_wizkit(void)
/* ---------- BEGIN SYMSET FILE HANDLING ----------- */
extern const char *known_handling[]; /* symbols.c */
extern const char *known_restrictions[]; /* symbols.c */
extern const char *const known_handling[]; /* symbols.c */
extern const char *const known_restrictions[]; /* symbols.c */
static
FILE *

View File

@@ -3455,12 +3455,16 @@ optfn_suppress_alert(int optidx, int req, boolean negated,
return optn_ok;
}
extern const char *known_handling[]; /* symbols.c */
extern const char *known_restrictions[]; /* symbols.c */
extern const char *const known_handling[]; /* symbols.c */
extern const char *const known_restrictions[]; /* symbols.c */
static int
optfn_symset(int optidx UNUSED, int req, boolean negated UNUSED, char *opts,
char *op)
optfn_symset(
int optidx UNUSED,
int req,
boolean negated UNUSED,
char *opts,
char *op)
{
if (req == do_init) {
return optn_ok;
@@ -3478,7 +3482,8 @@ optfn_symset(int optidx UNUSED, int req, boolean negated UNUSED, char *opts,
if (g.symset[PRIMARYSET].handling) {
#ifndef ENHANCED_SYMBOLS
if (g.symset[PRIMARYSET].handling == H_UTF8) {
config_error_add("Unavailable symset handler \"%s\" for %s",
config_error_add(
"Unavailable symset handler \"%s\" for %s",
known_handling[H_UTF8], op);
load_symset("default", PRIMARYSET);
}
@@ -3495,7 +3500,8 @@ optfn_symset(int optidx UNUSED, int req, boolean negated UNUSED, char *opts,
if (!opts)
return optn_err;
Sprintf(opts, "%s",
g.symset[PRIMARYSET].name ? g.symset[PRIMARYSET].name : "default");
g.symset[PRIMARYSET].name ? g.symset[PRIMARYSET].name
: "default");
if (g.currentgraphics == PRIMARYSET && g.symset[PRIMARYSET].name)
Strcat(opts, ", active");
if (g.symset[PRIMARYSET].handling) {
@@ -3508,7 +3514,8 @@ optfn_symset(int optidx UNUSED, int req, boolean negated UNUSED, char *opts,
if (!opts)
return optn_err;
Sprintf(opts, "%s",
g.symset[PRIMARYSET].name ? g.symset[PRIMARYSET].name : "default");
g.symset[PRIMARYSET].name ? g.symset[PRIMARYSET].name
: "default");
return optn_ok;
}
if (req == do_handler) {

View File

@@ -7,7 +7,9 @@
static void savedsym_add(const char *, const char *, int);
static struct _savedsym *savedsym_find(const char *, int);
void purge_custom_entries(enum graphics_sets which_set);
#ifdef ENHANCED_SYMBOLS
static void purge_custom_entries(enum graphics_sets which_set);
#endif
extern const uchar def_r_oc_syms[MAXOCLASSES]; /* drawing.c */
@@ -27,10 +29,10 @@ void (*ibmgraphics_mode_callback)(void) = 0;
#endif
#ifdef ENHANCED_SYMBOLS
void (*utf8graphics_mode_callback)(void) = 0; /* set in tty_start_screen and
found in unixtty, windtty, etc */
* found in unixtty,windtty,&c */
#endif
/*
/*
* Explanations of the functions found below:
*
* init_symbols()
@@ -136,10 +138,10 @@ get_othersym(int idx, int which_set)
if (which_set == ROGUESET)
sym = g.ov_rogue_syms[oidx] ? g.ov_rogue_syms[oidx]
: g.rogue_syms[oidx];
: g.rogue_syms[oidx];
else
sym = g.ov_primary_syms[oidx] ? g.ov_primary_syms[oidx]
: g.primary_syms[oidx];
: g.primary_syms[oidx];
if (!sym) {
switch(idx) {
case SYM_NOTHING:
@@ -194,7 +196,8 @@ init_rogue_symbols(void)
for (i = 0; i < MAXPCHARS; i++)
g.rogue_syms[i + SYM_OFF_P] = defsyms[i].sym;
g.rogue_syms[S_vodoor] = g.rogue_syms[S_hodoor] = g.rogue_syms[S_ndoor] = '+';
g.rogue_syms[S_vodoor] = g.rogue_syms[S_hodoor]
= g.rogue_syms[S_ndoor] = '+';
g.rogue_syms[S_upstair] = g.rogue_syms[S_dnstair] = '%';
for (i = 0; i < MAXOCLASSES; i++)
@@ -257,7 +260,7 @@ switch_symbols(int nondefault)
if (nondefault) {
for (i = 0; i < SYM_MAX; i++)
g.showsyms[i] = g.ov_primary_syms[i] ? g.ov_primary_syms[i]
: g.primary_syms[i];
: g.primary_syms[i];
#ifdef PC9800
if (SYMHANDLING(H_IBM) && ibmgraphics_mode_callback)
(*ibmgraphics_mode_callback)();
@@ -339,26 +342,31 @@ clear_symsetentry(int which_set, boolean name_too)
#endif
}
boolean symset_is_compatible(enum symset_handling_types handling, unsigned long wincap2)
/* called from windmain.c */
boolean
symset_is_compatible(
enum symset_handling_types handling,
unsigned long wincap2)
{
#ifdef ENHANCED_SYMBOLS
if ((handling == H_UTF8) &&
(((wincap2 & WC2_U_UTF8STR) == 0)
|| ((wincap2 & WC2_U_24BITCOLOR) == 0)))
#define WC2_utf8_bits (WC2_U_UTF8STR | WC2_U_24BITCOLOR)
if (handling == H_UTF8 && ((wincap2 & WC2_utf8_bits) != WC2_utf8_bits))
return FALSE;
#undef WC2_bits
#else
nhUse(handling);
nhUse(wincap2);
#endif
return TRUE;
}
/*
/*
* If you are adding code somewhere to be able to recognize
* particular types of symset "handling", define a
* H_XXX macro in include/sym.h and add the name
* to this array at the matching offset.
*/
const char *known_handling[] = {
const char *const known_handling[] = {
"UNKNOWN", /* H_UNK */
"IBM", /* H_IBM */
"DEC", /* H_DEC */
@@ -381,7 +389,7 @@ const char *known_handling[] = {
* under the case 5 sections of the same SYM_CONTROL idx switches.
* - add the field to clear_symsetentry()
*/
const char *known_restrictions[] = {
const char *const known_restrictions[] = {
"primary", "rogue", (const char *) 0,
};
@@ -1057,7 +1065,8 @@ struct customization_detail *find_matching_symset_customization(
const char *customization_name, int custtype,
enum graphics_sets which_set);
struct customization_detail *find_display_urep_customization(
const char *customization_name, int glyphidx, enum graphics_sets which_set);
const char *customization_name, int glyphidx,
enum graphics_sets which_set);
extern glyph_map glyphmap[MAX_GLYPH];
static void shuffle_customizations(void);
@@ -1114,10 +1123,12 @@ shuffle_customizations(void)
/* Current structure already appears in tmp_u */
struct unicode_representation *other = tmp_u[duplicate[idx]];
tmp_u[i] = (struct unicode_representation *) alloc(sizeof *tmp_u[i]);
tmp_u[i] = (struct unicode_representation *)
alloc(sizeof *tmp_u[i]);
*tmp_u[i] = *other;
if (other->utf8str != NULL) {
tmp_u[i]->utf8str = (uint8 *) dupstr((const char *) other->utf8str);
tmp_u[i]->utf8str = (uint8 *)
dupstr((const char *) other->utf8str);
}
} else {
tmp_u[i] = obj_glyphs[idx].u;
@@ -1139,9 +1150,10 @@ shuffle_customizations(void)
}
struct customization_detail *
find_matching_symset_customization(const char *customization_name,
int custtype,
enum graphics_sets which_set)
find_matching_symset_customization(
const char *customization_name,
int custtype,
enum graphics_sets which_set)
{
struct symset_customization *gdc = &g.sym_customizations[which_set];
if ((gdc->custtype == custtype)
@@ -1150,11 +1162,12 @@ find_matching_symset_customization(const char *customization_name,
return (struct customization_detail *) 0;
}
void
static void
purge_custom_entries(enum graphics_sets which_set)
{
struct symset_customization *gdc = &g.sym_customizations[which_set];
struct customization_detail *details = gdc->details, *next;
while (details) {
next = details->next;
if (gdc->custtype == custom_ureps) {
@@ -1179,12 +1192,14 @@ purge_custom_entries(enum graphics_sets which_set)
}
struct customization_detail *
find_display_sym_customization(const char *customization_name,
const struct symparse *symparse,
enum graphics_sets which_set)
find_display_sym_customization(
const char *customization_name,
const struct symparse *symparse,
enum graphics_sets which_set)
{
struct symset_customization *gdc = &g.sym_customizations[which_set];
struct customization_detail *symdetails;
if ((gdc->custtype == custom_symbols)
&& (strcmp(customization_name, gdc->customization_name) == 0)) {
symdetails = gdc->details;

View File

@@ -10,7 +10,7 @@ extern const struct symparse loadsyms[];
extern struct enum_dump monsdump[];
extern struct enum_dump objdump[];
extern glyph_map glyphmap[MAX_GLYPH];
extern const char *known_handling[]; /* symbols.c */
extern const char *const known_handling[]; /* symbols.c */
#ifdef ENHANCED_SYMBOLS
@@ -65,7 +65,8 @@ to_custom_symset_entry_callback(int glyph, struct find_struct *findwhat)
(findwhat->color != 0L) ? findwhat->color : 0L);
#endif
add_custom_urep_entry(known_handling[H_UTF8], glyph,
uval, utf8str, findwhat->color, g.symset_which_set);
uval, utf8str, findwhat->color,
g.symset_which_set);
}
}
@@ -1053,8 +1054,9 @@ test_glyphnames(void)
static void
just_find_callback(int glyph UNUSED, struct find_struct *findwhat UNUSED)
{
/* nothing */
return;
}
static int
find_glyphs(const char *id)
{
@@ -1086,6 +1088,7 @@ to_unicode_callback(int glyph UNUSED, struct find_struct *findwhat)
#endif
}
}
int
glyphs_to_unicode(const char *id, const char *unicode_val, long clr)
{