options.c cleanup

Replace several 'foo = alloc(strlen(bar)+1), strcpy(foo,bar)' sequences
  with 'foo = dupstr(bar)' calls.
Change 'free(foo)' into 'free((genericptr_t) foo)' to possibly pacify
  'lint' and/or really old compilers.
Add braces around 'if something;' when 'else { otherwise; }' has braces.
Simplify option value formatting for 'sortloot'.
This commit is contained in:
PatR
2015-11-09 19:20:19 -08:00
parent 85b234e1fc
commit 2e3ef24762

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 options.c $NHDT-Date: 1447124657 2015/11/10 03:04:17 $ $NHDT-Branch: master $:$NHDT-Revision: 1.238 $ */ /* NetHack 3.6 options.c $NHDT-Date: 1447125615 2015/11/10 03:20:15 $ $NHDT-Branch: master $:$NHDT-Revision: 1.239 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -710,8 +710,10 @@ initoptions_init()
#if defined(UNIX) || defined(VMS) #if defined(UNIX) || defined(VMS)
#ifdef TTY_GRAPHICS #ifdef TTY_GRAPHICS
/* detect whether a "vt" terminal can handle alternate charsets */ /* detect whether a "vt" terminal can handle alternate charsets */
if ((opts = nh_getenv("TERM")) && !strncmpi(opts, "vt", 2) && AS && AE if ((opts = nh_getenv("TERM"))
&& index(AS, '\016') && index(AE, '\017')) { /* [could also check "xterm" which emulates vtXXX by default] */
&& !strncmpi(opts, "vt", 2)
&& AS && AE && index(AS, '\016') && index(AE, '\017')) {
if (!symset[PRIMARY].name) if (!symset[PRIMARY].name)
load_symset("DECGraphics", PRIMARY); load_symset("DECGraphics", PRIMARY);
switch_symbols(TRUE); switch_symbols(TRUE);
@@ -1057,9 +1059,9 @@ const char *optn;
else else
flags.suppress_alert = fnv; flags.suppress_alert = fnv;
if (rejectver) { if (rejectver) {
if (!initial) if (!initial) {
You_cant("disable new feature alerts for future versions."); You_cant("disable new feature alerts for future versions.");
else { } else {
Sprintf(buf, Sprintf(buf,
"\n%s=%s Invalid reference to a future version ignored", "\n%s=%s Invalid reference to a future version ignored",
optn, op); optn, op);
@@ -1372,7 +1374,7 @@ int typ;
char *pattern; char *pattern;
{ {
struct plinemsg_type *tmp struct plinemsg_type *tmp
= (struct plinemsg_type *) alloc(sizeof (struct plinemsg_type)); = (struct plinemsg_type *) alloc(sizeof (struct plinemsg_type));
if (!tmp) if (!tmp)
return FALSE; return FALSE;
@@ -1387,7 +1389,7 @@ char *pattern;
pline("%s: %s", re_error, regex_error_desc(tmp->regex)); pline("%s: %s", re_error, regex_error_desc(tmp->regex));
wait_synch(); wait_synch();
regex_free(tmp->regex); regex_free(tmp->regex);
free(tmp); free((genericptr_t) tmp);
return FALSE; return FALSE;
} }
tmp->pattern = dupstr(pattern); tmp->pattern = dupstr(pattern);
@@ -1655,7 +1657,7 @@ boolean tinitial, tfrom_file;
{ {
register char *op; register char *op;
unsigned num; unsigned num;
boolean negated, duplicate; boolean negated, val_negated, duplicate;
int i; int i;
const char *fullname; const char *fullname;
@@ -1730,10 +1732,10 @@ boolean tinitial, tfrom_file;
/* align:string */ /* align:string */
fullname = "align"; fullname = "align";
if (match_optname(opts, fullname, sizeof("align") - 1, TRUE)) { if (match_optname(opts, fullname, sizeof("align") - 1, TRUE)) {
if (negated) if (negated) {
bad_negation(fullname, FALSE); bad_negation(fullname, FALSE);
else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
boolean val_negated = FALSE; val_negated = FALSE;
while ((*op == '!') || !strncmpi(op, "no", 2)) { while ((*op == '!') || !strncmpi(op, "no", 2)) {
if (*op == '!') if (*op == '!')
op++; op++;
@@ -1758,10 +1760,10 @@ boolean tinitial, tfrom_file;
fullname = "role"; fullname = "role";
if (match_optname(opts, fullname, 4, TRUE) if (match_optname(opts, fullname, 4, TRUE)
|| match_optname(opts, (fullname = "character"), 4, TRUE)) { || match_optname(opts, (fullname = "character"), 4, TRUE)) {
if (negated) if (negated) {
bad_negation(fullname, FALSE); bad_negation(fullname, FALSE);
else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
boolean val_negated = FALSE; val_negated = FALSE;
while ((*op == '!') || !strncmpi(op, "no", 2)) { while ((*op == '!') || !strncmpi(op, "no", 2)) {
if (*op == '!') if (*op == '!')
op++; op++;
@@ -1787,10 +1789,10 @@ boolean tinitial, tfrom_file;
/* race:string */ /* race:string */
fullname = "race"; fullname = "race";
if (match_optname(opts, fullname, 4, TRUE)) { if (match_optname(opts, fullname, 4, TRUE)) {
if (negated) if (negated) {
bad_negation(fullname, FALSE); bad_negation(fullname, FALSE);
else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
boolean val_negated = FALSE; val_negated = FALSE;
while ((*op == '!') || !strncmpi(op, "no", 2)) { while ((*op == '!') || !strncmpi(op, "no", 2)) {
if (*op == '!') if (*op == '!')
op++; op++;
@@ -1816,10 +1818,10 @@ boolean tinitial, tfrom_file;
/* gender:string */ /* gender:string */
fullname = "gender"; fullname = "gender";
if (match_optname(opts, fullname, 4, TRUE)) { if (match_optname(opts, fullname, 4, TRUE)) {
if (negated) if (negated) {
bad_negation(fullname, FALSE); bad_negation(fullname, FALSE);
else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
boolean val_negated = FALSE; val_negated = FALSE;
while ((*op == '!') || !strncmpi(op, "no", 2)) { while ((*op == '!') || !strncmpi(op, "no", 2)) {
if (*op == '!') if (*op == '!')
op++; op++;
@@ -1968,11 +1970,10 @@ boolean tinitial, tfrom_file;
if (match_optname(opts, fullname, 7, TRUE)) { if (match_optname(opts, fullname, 7, TRUE)) {
if (duplicate) if (duplicate)
complain_about_duplicate(opts, 1); complain_about_duplicate(opts, 1);
if (negated) if (negated) {
bad_negation(fullname, FALSE); bad_negation(fullname, FALSE);
else if ((op = string_for_opt(opts, FALSE)) != 0) { } else if ((op = string_for_opt(opts, FALSE)) != 0) {
symset[ROGUESET].name = (char *) alloc(strlen(op) + 1); symset[ROGUESET].name = dupstr(op);
Strcpy(symset[ROGUESET].name, op);
if (!read_sym_file(ROGUESET)) { if (!read_sym_file(ROGUESET)) {
clear_symsetentry(ROGUESET, TRUE); clear_symsetentry(ROGUESET, TRUE);
raw_printf("Unable to load symbol set \"%s\" from \"%s\".", raw_printf("Unable to load symbol set \"%s\" from \"%s\".",
@@ -1991,11 +1992,10 @@ boolean tinitial, tfrom_file;
if (match_optname(opts, fullname, 6, TRUE)) { if (match_optname(opts, fullname, 6, TRUE)) {
if (duplicate) if (duplicate)
complain_about_duplicate(opts, 1); complain_about_duplicate(opts, 1);
if (negated) if (negated) {
bad_negation(fullname, FALSE); bad_negation(fullname, FALSE);
else if ((op = string_for_opt(opts, FALSE)) != 0) { } else if ((op = string_for_opt(opts, FALSE)) != 0) {
symset[PRIMARY].name = (char *) alloc(strlen(op) + 1); symset[PRIMARY].name = dupstr(op);
Strcpy(symset[PRIMARY].name, op);
if (!read_sym_file(PRIMARY)) { if (!read_sym_file(PRIMARY)) {
clear_symsetentry(PRIMARY, TRUE); clear_symsetentry(PRIMARY, TRUE);
raw_printf("Unable to load symbol set \"%s\" from \"%s\".", raw_printf("Unable to load symbol set \"%s\" from \"%s\".",
@@ -2370,9 +2370,9 @@ boolean tinitial, tfrom_file;
if (match_optname(opts, fullname, 4, TRUE)) { if (match_optname(opts, fullname, 4, TRUE)) {
if (duplicate) if (duplicate)
complain_about_duplicate(opts, 1); complain_about_duplicate(opts, 1);
if (negated) if (negated) {
bad_negation(fullname, FALSE); bad_negation(fullname, FALSE);
else if ((op = string_for_opt(opts, negated))) { } else if ((op = string_for_opt(opts, negated)) != 0) {
#ifdef WIN32 #ifdef WIN32
(void) strncpy(iflags.altkeyhandler, op, MAX_ALTKEYHANDLER - 5); (void) strncpy(iflags.altkeyhandler, op, MAX_ALTKEYHANDLER - 5);
load_keyboard_handler(); load_keyboard_handler();
@@ -2973,9 +2973,9 @@ boolean tinitial, tfrom_file;
fullname = "subkeyvalue"; fullname = "subkeyvalue";
if (match_optname(opts, fullname, 5, TRUE)) { if (match_optname(opts, fullname, 5, TRUE)) {
/* no duplicate complaint here */ /* no duplicate complaint here */
if (negated) if (negated) {
bad_negation(fullname, FALSE); bad_negation(fullname, FALSE);
else { } else {
#if defined(WIN32) #if defined(WIN32)
op = string_for_opt(opts, 0); op = string_for_opt(opts, 0);
map_subkeyvalue(op); map_subkeyvalue(op);
@@ -3140,9 +3140,9 @@ boolean tinitial, tfrom_file;
if (duplicate) if (duplicate)
complain_about_duplicate(opts, 1); complain_about_duplicate(opts, 1);
if (match_optname(opts, fullname, (int) strlen(fullname), TRUE)) { if (match_optname(opts, fullname, (int) strlen(fullname), TRUE)) {
if (negated) if (negated) {
bad_negation(fullname, FALSE); bad_negation(fullname, FALSE);
else if ((op = string_for_opt(opts, FALSE)) != 0) { } else if ((op = string_for_opt(opts, FALSE)) != 0) {
int j; int j;
char c, op_buf[BUFSZ]; char c, op_buf[BUFSZ];
boolean isbad = FALSE; boolean isbad = FALSE;
@@ -3197,11 +3197,10 @@ boolean tinitial, tfrom_file;
complain_about_duplicate(opts, 1); complain_about_duplicate(opts, 1);
if (!negated) { if (!negated) {
/* There is no rogue level DECgraphics-specific set */ /* There is no rogue level DECgraphics-specific set */
if (symset[PRIMARY].name) if (symset[PRIMARY].name) {
badflag = TRUE; badflag = TRUE;
else { } else {
symset[PRIMARY].name = (char *) alloc(strlen(fullname) + 1); symset[PRIMARY].name = dupstr(fullname);
Strcpy(symset[PRIMARY].name, fullname);
if (!read_sym_file(PRIMARY)) { if (!read_sym_file(PRIMARY)) {
badflag = TRUE; badflag = TRUE;
clear_symsetentry(PRIMARY, TRUE); clear_symsetentry(PRIMARY, TRUE);
@@ -3224,13 +3223,12 @@ boolean tinitial, tfrom_file;
complain_about_duplicate(opts, 1); complain_about_duplicate(opts, 1);
if (!negated) { if (!negated) {
for (i = 0; i < NUM_GRAPHICS; ++i) { for (i = 0; i < NUM_GRAPHICS; ++i) {
if (symset[i].name) if (symset[i].name) {
badflag = TRUE; badflag = TRUE;
else { } else {
if (i == ROGUESET) if (i == ROGUESET)
sym_name = "RogueIBM"; sym_name = "RogueIBM";
symset[i].name = (char *) alloc(strlen(sym_name) + 1); symset[i].name = dupstr(sym_name);
Strcpy(symset[i].name, sym_name);
if (!read_sym_file(i)) { if (!read_sym_file(i)) {
badflag = TRUE; badflag = TRUE;
clear_symsetentry(i, TRUE); clear_symsetentry(i, TRUE);
@@ -3258,11 +3256,10 @@ boolean tinitial, tfrom_file;
if (duplicate) if (duplicate)
complain_about_duplicate(opts, 1); complain_about_duplicate(opts, 1);
if (!negated) { if (!negated) {
if (symset[PRIMARY].name) if (symset[PRIMARY].name) {
badflag = TRUE; badflag = TRUE;
else { } else {
symset[PRIMARY].name = (char *) alloc(strlen(fullname) + 1); symset[PRIMARY].name = dupstr(fullname);
Strcpy(symset[PRIMARY].name, fullname);
if (!read_sym_file(PRIMARY)) { if (!read_sym_file(PRIMARY)) {
badflag = TRUE; badflag = TRUE;
clear_symsetentry(PRIMARY, TRUE); clear_symsetentry(PRIMARY, TRUE);
@@ -3355,9 +3352,8 @@ boolean tinitial, tfrom_file;
|| (boolopt[i].addr) == &flags.showrace || (boolopt[i].addr) == &flags.showrace
|| (boolopt[i].addr) == &iflags.hilite_pet) { || (boolopt[i].addr) == &iflags.hilite_pet) {
need_redraw = TRUE; need_redraw = TRUE;
}
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
else if ((boolopt[i].addr) == &iflags.use_color) { } else if ((boolopt[i].addr) == &iflags.use_color) {
need_redraw = TRUE; need_redraw = TRUE;
#ifdef TOS #ifdef TOS
if ((boolopt[i].addr) == &iflags.use_color && iflags.BIOS) { if ((boolopt[i].addr) == &iflags.use_color && iflags.BIOS) {
@@ -3367,9 +3363,8 @@ boolean tinitial, tfrom_file;
set_colors(); set_colors();
} }
#endif #endif
#endif /* TEXTCOLOR */
} }
#endif
return; return;
} }
} }
@@ -3417,9 +3412,9 @@ void
add_menu_cmd_alias(from_ch, to_ch) add_menu_cmd_alias(from_ch, to_ch)
char from_ch, to_ch; char from_ch, to_ch;
{ {
if (n_menu_mapped >= MAX_MENU_MAPPED_CMDS) if (n_menu_mapped >= MAX_MENU_MAPPED_CMDS) {
pline("out of menu map space."); pline("out of menu map space.");
else { } else {
mapped_menu_cmds[n_menu_mapped] = from_ch; mapped_menu_cmds[n_menu_mapped] = from_ch;
mapped_menu_op[n_menu_mapped] = to_ch; mapped_menu_op[n_menu_mapped] = to_ch;
n_menu_mapped++; n_menu_mapped++;
@@ -3604,19 +3599,20 @@ doset()
} }
any.a_int = -4; any.a_int = -4;
Sprintf(buf2, n_currently_set, msgtype_count()); Sprintf(buf2, n_currently_set, msgtype_count());
Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : " ", "message types", Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : " ",
buf2); "message types", buf2);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED); add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
any.a_int = -3; any.a_int = -3;
Sprintf(buf2, n_currently_set, count_menucolors()); Sprintf(buf2, n_currently_set, count_menucolors());
Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : " ", "menucolors", Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : " ",
buf2); "menucolors", buf2);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED); add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
#ifdef STATUS_VIA_WINDOWPORT #ifdef STATUS_VIA_WINDOWPORT
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
any.a_int = -2; any.a_int = -2;
get_status_hilites(buf2, 60); get_status_hilites(buf2, 60);
if (!*buf2) Sprintf(buf2, "%s", "(none)"); if (!*buf2)
Sprintf(buf2, "%s", "(none)");
if (!iflags.menu_tab_sep) if (!iflags.menu_tab_sep)
Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : " ", Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : " ",
"status_hilites", buf2); "status_hilites", buf2);
@@ -3966,6 +3962,7 @@ boolean setinitial, setfromfile;
} else if (!strcmp("sortloot", optname)) { } else if (!strcmp("sortloot", optname)) {
const char *sortl_name; const char *sortl_name;
menu_item *sortl_pick = (menu_item *) 0; menu_item *sortl_pick = (menu_item *) 0;
tmpwin = create_nhwindow(NHW_MENU); tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin); start_menu(tmpwin);
any = zeroany; any = zeroany;
@@ -4258,13 +4255,12 @@ boolean setinitial, setfromfile;
|| !strcmp("roguesymset", optname)) { || !strcmp("roguesymset", optname)) {
menu_item *symset_pick = (menu_item *) 0; menu_item *symset_pick = (menu_item *) 0;
boolean primaryflag = (*optname == 's'), boolean primaryflag = (*optname == 's'),
rogueflag = (*optname == 'r'), ready_to_switch = FALSE, rogueflag = (*optname == 'r'),
ready_to_switch = FALSE,
nothing_to_do = FALSE; nothing_to_do = FALSE;
int res;
char *symset_name, fmtstr[20]; char *symset_name, fmtstr[20];
struct symsetentry *sl; struct symsetentry *sl;
int setcount = 0; int res, which_set, setcount = 0, chosen = -2;
int chosen = -2, which_set;
if (rogueflag) if (rogueflag)
which_set = ROGUESET; which_set = ROGUESET;
@@ -4359,14 +4355,13 @@ boolean setinitial, setfromfile;
} }
sl = sl->next; sl = sl->next;
} }
} } else if (chosen == -1) {
else if (chosen == -1) {
/* explicit selection of defaults */ /* explicit selection of defaults */
/* free the now stale symset attributes */ /* free the now stale symset attributes */
if (symset_name) if (symset_name) {
free((genericptr_t) symset_name); free((genericptr_t) symset_name);
symset_name = (char *) 0; symset_name = (char *) 0;
}
clear_symsetentry(which_set, TRUE); clear_symsetentry(which_set, TRUE);
} else } else
nothing_to_do = TRUE; nothing_to_do = TRUE;
@@ -4399,7 +4394,7 @@ boolean setinitial, setfromfile;
return TRUE; return TRUE;
if (!symset[which_set].name && symset_name) if (!symset[which_set].name && symset_name)
symset[which_set].name = symset_name; symset[which_set].name = symset_name; /* not dupstr() here */
/* Set default symbols and clear the handling value */ /* Set default symbols and clear the handling value */
if (rogueflag) if (rogueflag)
@@ -4408,9 +4403,9 @@ boolean setinitial, setfromfile;
init_l_symbols(); init_l_symbols();
if (symset[which_set].name) { if (symset[which_set].name) {
if (read_sym_file(which_set)) if (read_sym_file(which_set)) {
ready_to_switch = TRUE; ready_to_switch = TRUE;
else { } else {
clear_symsetentry(which_set, TRUE); clear_symsetentry(which_set, TRUE);
return TRUE; return TRUE;
} }
@@ -4586,9 +4581,9 @@ char *buf;
Sprintf(buf, "%s", to_be_done); Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "menu_invert_all")) else if (!strcmp(optname, "menu_invert_all"))
Sprintf(buf, "%s", to_be_done); Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "menu_headings")) { else if (!strcmp(optname, "menu_headings"))
Sprintf(buf, "%s", attr2attrname(iflags.menu_headings)); Sprintf(buf, "%s", attr2attrname(iflags.menu_headings));
} else if (!strcmp(optname, "menu_invert_page")) else if (!strcmp(optname, "menu_invert_page"))
Sprintf(buf, "%s", to_be_done); Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "menu_last_page")) else if (!strcmp(optname, "menu_last_page"))
Sprintf(buf, "%s", to_be_done); Sprintf(buf, "%s", to_be_done);
@@ -4602,12 +4597,12 @@ char *buf;
Sprintf(buf, "%s", to_be_done); Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "menu_select_page")) else if (!strcmp(optname, "menu_select_page"))
Sprintf(buf, "%s", to_be_done); Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "monsters")) else if (!strcmp(optname, "monsters")) {
Sprintf(buf, "%s", to_be_done); Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "msghistory")) } else if (!strcmp(optname, "msghistory")) {
Sprintf(buf, "%u", iflags.msg_history); Sprintf(buf, "%u", iflags.msg_history);
#ifdef TTY_GRAPHICS #ifdef TTY_GRAPHICS
else if (!strcmp(optname, "msg_window")) } else if (!strcmp(optname, "msg_window")) {
Sprintf(buf, "%s", (iflags.prevmsg_window == 's') Sprintf(buf, "%s", (iflags.prevmsg_window == 's')
? "single" ? "single"
: (iflags.prevmsg_window == 'c') : (iflags.prevmsg_window == 'c')
@@ -4616,9 +4611,9 @@ char *buf;
? "full" ? "full"
: "reversed"); : "reversed");
#endif #endif
else if (!strcmp(optname, "name")) } else if (!strcmp(optname, "name")) {
Sprintf(buf, "%s", plname); Sprintf(buf, "%s", plname);
else if (!strcmp(optname, "number_pad")) { } else if (!strcmp(optname, "number_pad")) {
static const char *numpadmodes[] = { static const char *numpadmodes[] = {
"0=off", "1=on", "2=on, MSDOS compatible", "0=off", "1=on", "2=on, MSDOS compatible",
"3=on, phone-style layout", "3=on, phone-style layout",
@@ -4699,14 +4694,11 @@ char *buf;
else else
Strcpy(buf, defopt); Strcpy(buf, defopt);
} else if (!strcmp(optname, "sortloot")) { } else if (!strcmp(optname, "sortloot")) {
char *sortname = (char *) NULL; for (i = 0; i < SIZE(sortltype); i++)
if (flags.sortloot == sortltype[i][0]) {
for (i = 0; i < SIZE(sortltype) && sortname == (char *) NULL; i++) { Strcpy(buf, sortltype[i]);
if (flags.sortloot == sortltype[i][0]) break;
sortname = (char *) sortltype[i]; }
}
if (sortname != (char *) NULL)
Sprintf(buf, "%s", sortname);
} else if (!strcmp(optname, "player_selection")) { } else if (!strcmp(optname, "player_selection")) {
Sprintf(buf, "%s", iflags.wc_player_selection ? "prompts" : "dialog"); Sprintf(buf, "%s", iflags.wc_player_selection ? "prompts" : "dialog");
#ifdef MSDOS #ifdef MSDOS
@@ -4831,15 +4823,15 @@ const char *mapping;
apehead = (grab) ? &iflags.autopickup_exceptions[AP_GRAB] apehead = (grab) ? &iflags.autopickup_exceptions[AP_GRAB]
: &iflags.autopickup_exceptions[AP_LEAVE]; : &iflags.autopickup_exceptions[AP_LEAVE];
ape = (struct autopickup_exception *) alloc( ape = (struct autopickup_exception *) alloc(
sizeof(struct autopickup_exception)); sizeof (struct autopickup_exception));
ape->regex = regex_init(); ape->regex = regex_init();
if (!regex_compile(text2, ape->regex)) { if (!regex_compile(text2, ape->regex)) {
raw_print("regex error in AUTOPICKUP_EXCEPTION"); raw_print("regex error in AUTOPICKUP_EXCEPTION");
regex_free(ape->regex); regex_free(ape->regex);
free(ape); free((genericptr_t) ape);
return 0; return 0;
} }
ape->pattern = (char *)alloc(strlen(text2) + 1); ape->pattern = (char *) alloc(strlen(text2) + 1);
strcpy(ape->pattern, text2); strcpy(ape->pattern, text2);
ape->grab = grab; ape->grab = grab;
ape->next = *apehead; ape->next = *apehead;
@@ -4861,14 +4853,15 @@ struct autopickup_exception *whichape;
for (ape = iflags.autopickup_exceptions[chain]; ape;) { for (ape = iflags.autopickup_exceptions[chain]; ape;) {
if (ape == whichape) { if (ape == whichape) {
struct autopickup_exception *freeape = ape; struct autopickup_exception *freeape = ape;
ape = ape->next; ape = ape->next;
if (prev) if (prev)
prev->next = ape; prev->next = ape;
else else
iflags.autopickup_exceptions[chain] = ape; iflags.autopickup_exceptions[chain] = ape;
regex_free(freeape->regex); regex_free(freeape->regex);
free(freeape->pattern); free((genericptr_t) freeape->pattern);
free(freeape); free((genericptr_t) freeape);
} else { } else {
prev = ape; prev = ape;
ape = ape->next; ape = ape->next;
@@ -4907,9 +4900,9 @@ free_autopickup_exceptions()
for (pass = AP_LEAVE; pass <= AP_GRAB; ++pass) { for (pass = AP_LEAVE; pass <= AP_GRAB; ++pass) {
while ((ape = iflags.autopickup_exceptions[pass]) != 0) { while ((ape = iflags.autopickup_exceptions[pass]) != 0) {
regex_free(ape->regex); regex_free(ape->regex);
free(ape->pattern); free((genericptr_t) ape->pattern);
iflags.autopickup_exceptions[pass] = ape->next; iflags.autopickup_exceptions[pass] = ape->next;
free(ape); free((genericptr_t) ape);
} }
} }
} }
@@ -4922,11 +4915,13 @@ int which_set;
{ {
clear_symsetentry(which_set, TRUE); clear_symsetentry(which_set, TRUE);
symset[which_set].name = (char *) alloc(strlen(s) + 1); if (symset[which_set].name)
Strcpy(symset[which_set].name, s); free((genericptr_t) symset[which_set].name);
if (read_sym_file(which_set)) symset[which_set].name = dupstr(s);
if (read_sym_file(which_set)) {
switch_symbols(TRUE); switch_symbols(TRUE);
else { } else {
clear_symsetentry(which_set, TRUE); clear_symsetentry(which_set, TRUE);
return 0; return 0;
} }
@@ -5115,7 +5110,7 @@ const char *str;
Strcat(buf, ", "); Strcat(buf, ", ");
} else { } else {
putstr(datawin, 0, str); putstr(datawin, 0, str);
free(buf), buf = 0; free((genericptr_t) buf), buf = 0;
} }
return; return;
} }
@@ -5561,9 +5556,8 @@ char *fontname;
} }
if (fn) { if (fn) {
if (*fn) if (*fn)
free(*fn); free((genericptr_t) *fn);
*fn = (char *) alloc(strlen(fontname) + 1); *fn = dupstr(fontname);
Strcpy(*fn, fontname);
} }
return; return;
} }
@@ -5649,15 +5643,13 @@ char *op;
if (!strcmpi(wn, wnames[j]) || !strcmpi(wn, shortnames[j])) { if (!strcmpi(wn, wnames[j]) || !strcmpi(wn, shortnames[j])) {
if (tfg && !strstri(tfg, " ")) { if (tfg && !strstri(tfg, " ")) {
if (*fgp[j]) if (*fgp[j])
free(*fgp[j]); free((genericptr_t) *fgp[j]);
*fgp[j] = (char *) alloc(strlen(tfg) + 1); *fgp[j] = dupstr(tfg);
Strcpy(*fgp[j], tfg);
} }
if (tbg && !strstri(tbg, " ")) { if (tbg && !strstri(tbg, " ")) {
if (*bgp[j]) if (*bgp[j])
free(*bgp[j]); free((genericptr_t) *bgp[j]);
*bgp[j] = (char *) alloc(strlen(tbg) + 1); *bgp[j] = dupstr(tbg);
Strcpy(*bgp[j], tbg);
} }
break; break;
} }