files.c cleanup and/or trashing (trunk only)

I started out changing some bar=strcpy(alloc(strlen(foo)+1),foo)
sequences to bar=dupstr(foo), then decided to try to clean up the lint
From a bug report.  I'm not sure
whether the final result is worth it, and the MICRO configurations need
to test configuration file processing for LEVELS and RAMDISK.  There were
three different sets of conditionals being used for that.

Declaration             Parsing                          Assignment
#if MICRO || WIN32      #if MICRO && !NOCWD_ASSUMPTIONS  #if MICRO && !NOCWD_
 char tmp_levels[]       read LEVELS into tmp_levels     # if MFLOPPY
# if MFLOPPY && !AMIGA  # if MFLOPPY && !AMIGA            handle tmp_levels
 char tmp_ramdisk[]      read RAMDISK into tmp_ramdisk   #  if !AMIGA
# endif                 # endif                           handle tmp_ramdisk
#endif                  #endif                           #  endif x 3

The revised code uses the middle set; the other two are gone.  This means
that MICRO+!MFLOPPY will use LEVELS instead of silently ignoring it, which
might need to be changed.
This commit is contained in:
nethack.rankin
2012-02-21 04:05:45 +00:00
parent 6a9217d568
commit e8e62b561e
+155 -180
View File
@@ -158,6 +158,10 @@ static int lockptr;
# define unlink macunlink # define unlink macunlink
#endif #endif
#if (defined(macintosh) && (defined(__SC__) || defined(__MRC__))) || defined(__MWERKS__)
# define PRAGMA_UNUSED
#endif
#ifdef USER_SOUNDS #ifdef USER_SOUNDS
extern char *sounddir; extern char *sounddir;
#endif #endif
@@ -184,8 +188,9 @@ STATIC_DCL boolean FDECL(make_compressed_name, (const char *, char *));
#endif #endif
STATIC_DCL char *FDECL(make_lockname, (const char *,char *)); STATIC_DCL char *FDECL(make_lockname, (const char *,char *));
STATIC_DCL FILE *FDECL(fopen_config_file, (const char *, int)); STATIC_DCL FILE *FDECL(fopen_config_file, (const char *, int));
STATIC_DCL int FDECL(get_uchars, (FILE *,char *,char *,uchar *,BOOLEAN_P,int,const char *)); STATIC_DCL int FDECL(get_uchars,
int FDECL(parse_config_line, (FILE *,char *,char *,char *,int)); (FILE *,char *,char *,uchar *,BOOLEAN_P,int,const char *));
int FDECL(parse_config_line, (FILE *,char *,int));
#ifdef LOADSYMSETS #ifdef LOADSYMSETS
STATIC_DCL FILE *NDECL(fopen_sym_file); STATIC_DCL FILE *NDECL(fopen_sym_file);
STATIC_DCL void FDECL(set_symhandling, (char *,int)); STATIC_DCL void FDECL(set_symhandling, (char *,int));
@@ -306,13 +311,18 @@ int bufsz;
return callerbuf; return callerbuf;
} }
#ifndef PREFIXES_IN_USE #ifdef PREFIXES_IN_USE
/*ARGSUSED*/ # define UNUSED_if_not_PREFIXES_IN_USE /*empty*/
#else
# define UNUSED_if_not_PREFIXES_IN_USE UNUSED
#endif #endif
/*ARGSUSED*/
const char * const char *
fqname(basenam, whichprefix, buffnum) fqname(basenam, whichprefix, buffnum)
const char *basenam; const char *basenam;
int whichprefix, buffnum; int whichprefix UNUSED_if_not_PREFIXES_IN_USE;
int buffnum UNUSED_if_not_PREFIXES_IN_USE;
{ {
#ifndef PREFIXES_IN_USE #ifndef PREFIXES_IN_USE
return basenam; return basenam;
@@ -337,19 +347,20 @@ int whichprefix, buffnum;
#endif #endif
} }
/* reasonbuf must be at least BUFSZ, supplied by caller */
/*ARGSUSED*/
int int
validate_prefix_locations(reasonbuf) validate_prefix_locations(reasonbuf)
char *reasonbuf; char *reasonbuf; /* reasonbuf must be at least BUFSZ, supplied by caller */
{ {
#if defined(NOCWD_ASSUMPTIONS) #if defined(NOCWD_ASSUMPTIONS)
FILE *fp; FILE *fp;
const char *filename; const char *filename;
int prefcnt, failcount = 0; int prefcnt, failcount = 0;
char panicbuf1[BUFSZ], panicbuf2[BUFSZ], *details; char panicbuf1[BUFSZ], panicbuf2[BUFSZ];
const char *details;
#endif
if (reasonbuf) reasonbuf[0] = '\0'; if (reasonbuf) reasonbuf[0] = '\0';
#if defined(NOCWD_ASSUMPTIONS)
for (prefcnt = 1; prefcnt < PREFIX_COUNT; prefcnt++) { for (prefcnt = 1; prefcnt < PREFIX_COUNT; prefcnt++) {
/* don't test writing to configdir or datadir; they're readonly */ /* don't test writing to configdir or datadir; they're readonly */
if (prefcnt == CONFIGPREFIX || prefcnt == DATAPREFIX) continue; if (prefcnt == CONFIGPREFIX || prefcnt == DATAPREFIX) continue;
@@ -1332,15 +1343,21 @@ boolean uncomp;
} }
#endif /* COMPRESS */ #endif /* COMPRESS */
#if defined(COMPRESS) || defined(ZLIB_COMP)
# define UNUSED_if_not_COMPRESS /*empty*/
#else
# define UNUSED_if_not_COMPRESS UNUSED
#endif
/* compress file */ /* compress file */
void void
nh_compress(filename) nh_compress(filename)
const char *filename; const char *filename UNUSED_if_not_COMPRESS;
{ {
#if !defined(COMPRESS) && !defined(ZLIB_COMP) #if !defined(COMPRESS) && !defined(ZLIB_COMP)
#if (defined(macintosh) && (defined(__SC__) || defined(__MRC__))) || defined(__MWERKS__) # ifdef PRAGMA_UNUSED
# pragma unused(filename) # pragma unused(filename)
#endif # endif
#else #else
docompress_file(filename, FALSE); docompress_file(filename, FALSE);
#endif #endif
@@ -1350,12 +1367,12 @@ const char *filename;
/* uncompress file if it exists */ /* uncompress file if it exists */
void void
nh_uncompress(filename) nh_uncompress(filename)
const char *filename; const char *filename UNUSED_if_not_COMPRESS;
{ {
#if !defined(COMPRESS) && !defined(ZLIB_COMP) #if !defined(COMPRESS) && !defined(ZLIB_COMP)
#if (defined(macintosh) && (defined(__SC__) || defined(__MRC__))) || defined(__MWERKS__) # ifdef PRAGMA_UNUSED
# pragma unused(filename) # pragma unused(filename)
#endif # endif
#else #else
docompress_file(filename, TRUE); docompress_file(filename, TRUE);
#endif #endif
@@ -1538,36 +1555,33 @@ make_lockname(filename, lockname)
const char *filename; const char *filename;
char *lockname; char *lockname;
{ {
#if (defined(macintosh) && (defined(__SC__) || defined(__MRC__))) || defined(__MWERKS__) #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(WIN32) || defined(MSDOS)
# pragma unused(filename,lockname) # ifdef NO_FILE_LINKS
return (char*)0;
#else
# if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(WIN32) || defined(MSDOS)
# ifdef NO_FILE_LINKS
Strcpy(lockname, LOCKDIR); Strcpy(lockname, LOCKDIR);
Strcat(lockname, "/"); Strcat(lockname, "/");
Strcat(lockname, filename); Strcat(lockname, filename);
# else # else
Strcpy(lockname, filename); Strcpy(lockname, filename);
# endif # endif
# ifdef VMS # ifdef VMS
{ {
char *semi_colon = rindex(lockname, ';'); char *semi_colon = rindex(lockname, ';');
if (semi_colon) *semi_colon = '\0'; if (semi_colon) *semi_colon = '\0';
} }
Strcat(lockname, ".lock;1"); Strcat(lockname, ".lock;1");
# else
Strcat(lockname, "_lock");
# endif
return lockname;
# else # else
Strcat(lockname, "_lock");
# endif
return lockname;
#else /* !(UNIX || VMS || AMIGA || WIN32 || MSDOS) */
# ifdef PRAGMA_UNUSED
# pragma unused(filename)
# endif
lockname[0] = '\0'; lockname[0] = '\0';
return (char*)0; return (char*)0;
# endif /* UNIX || VMS || AMIGA || WIN32 || MSDOS */
#endif #endif
} }
/* lock a file */ /* lock a file */
boolean boolean
lock_file(filename, whichprefix, retryct) lock_file(filename, whichprefix, retryct)
@@ -1575,8 +1589,8 @@ const char *filename;
int whichprefix; int whichprefix;
int retryct; int retryct;
{ {
#if (defined(macintosh) && (defined(__SC__) || defined(__MRC__))) || defined(__MWERKS__) #if defined(PRAGMA_UNUSED) && !(defined(UNIX) || defined(VMS)) && !(defined(AMIGA) || defined(WIN32) || defined(MSDOS))
# pragma unused(filename, retryct) # pragma unused(retryct)
#endif #endif
char locknambuf[BUFSZ]; char locknambuf[BUFSZ];
const char *lockname; const char *lockname;
@@ -1605,8 +1619,8 @@ int retryct;
case EEXIST: case EEXIST:
if (retryct--) { if (retryct--) {
HUP raw_printf( HUP raw_printf(
"Waiting for access to %s. (%d retries left).", "Waiting for access to %s. (%d retries left).",
filename, retryct); filename, retryct);
# if defined(SYSV) || defined(ULTRIX) || defined(VMS) # if defined(SYSV) || defined(ULTRIX) || defined(VMS)
(void) (void)
# endif # endif
@@ -1614,7 +1628,7 @@ int retryct;
} else { } else {
HUP (void) raw_print("I give up. Sorry."); HUP (void) raw_print("I give up. Sorry.");
HUP raw_printf("Perhaps there is an old %s around?", HUP raw_printf("Perhaps there is an old %s around?",
lockname); lockname);
nesting--; nesting--;
return FALSE; return FALSE;
} }
@@ -1641,7 +1655,7 @@ int retryct;
HUP perror(lockname); HUP perror(lockname);
HUP raw_printf("Cannot lock %s.", filename); HUP raw_printf("Cannot lock %s.", filename);
HUP raw_printf( HUP raw_printf(
"(Perhaps you are running NetHack from inside the distribution package?)." "(Perhaps you are running NetHack from inside the distribution package?)."
); );
nesting--; nesting--;
return FALSE; return FALSE;
@@ -1703,9 +1717,6 @@ int retryct;
void void
unlock_file(filename) unlock_file(filename)
const char *filename; const char *filename;
#if defined(macintosh) && (defined(__SC__) || defined(__MRC__))
# pragma unused(filename)
#endif
{ {
char locknambuf[BUFSZ]; char locknambuf[BUFSZ];
const char *lockname; const char *lockname;
@@ -1852,35 +1863,36 @@ int src;
Sprintf(tmp_config, "%s/%s", envp, ".nethackrc"); Sprintf(tmp_config, "%s/%s", envp, ".nethackrc");
if ((fp = fopenp(tmp_config, "r")) != (FILE *)0) if ((fp = fopenp(tmp_config, "r")) != (FILE *)0)
return(fp); return(fp);
# if defined(__APPLE__) # if defined(__APPLE__)
/* try an alternative */ /* try an alternative */
if (envp) { if (envp) {
Sprintf(tmp_config, "%s/%s", envp, "Library/Preferences/NetHack Defaults"); Sprintf(tmp_config, "%s/%s", envp,
"Library/Preferences/NetHack Defaults");
if ((fp = fopenp(tmp_config, "r")) != (FILE *)0) if ((fp = fopenp(tmp_config, "r")) != (FILE *)0)
return(fp); return(fp);
Sprintf(tmp_config, "%s/%s", envp, "Library/Preferences/NetHack Defaults.txt"); Sprintf(tmp_config, "%s/%s", envp,
"Library/Preferences/NetHack Defaults.txt");
if ((fp = fopenp(tmp_config, "r")) != (FILE *)0) if ((fp = fopenp(tmp_config, "r")) != (FILE *)0)
return(fp); return(fp);
} }
# endif # endif
if (errno != ENOENT) { if (errno != ENOENT) {
char *details; const char *details;
/* e.g., problems when setuid NetHack can't search home /* e.g., problems when setuid NetHack can't search home
* directory restricted to user */ * directory restricted to user */
#if defined (NHSTDC) && !defined(NOTSTDC) # if defined (NHSTDC) && !defined(NOTSTDC)
if ((details = strerror(errno)) == 0) if ((details = strerror(errno)) == 0)
#endif # endif
details = ""; details = "";
raw_printf("Couldn't open default config file %s %s(%d).", raw_printf("Couldn't open default config file %s %s(%d).",
tmp_config, details, errno); tmp_config, details, errno);
wait_synch(); wait_synch();
} }
# endif # endif /* Unix */
#endif #endif
return (FILE *)0; return (FILE *)0;
} }
@@ -1967,22 +1979,20 @@ int prefixid;
#define match_varname(INP,NAM,LEN) match_optname(INP, NAM, LEN, TRUE) #define match_varname(INP,NAM,LEN) match_optname(INP, NAM, LEN, TRUE)
/*ARGSUSED*/
int int
parse_config_line(fp, buf, tmp_ramdisk, tmp_levels, src) parse_config_line(fp, buf, src)
FILE *fp; FILE *fp;
char *buf; char *buf;
char *tmp_ramdisk;
char *tmp_levels;
int src; int src;
{ {
#if (defined(macintosh) && (defined(__SC__) || defined(__MRC__))) || defined(__MWERKS__) #if defined(MICRO) && !defined(NOCWD_ASSUMPTIONS)
# pragma unused(tmp_ramdisk,tmp_levels) static boolean ramdisk_specified = FALSE;
#endif #endif
char *bufp, *altp; char *bufp, *altp;
uchar translate[MAXPCHARS]; uchar translate[MAXPCHARS];
int len; int len, n;
/* lines beginning with '#' are comments */
if (*buf == '#') if (*buf == '#')
return 1; return 1;
@@ -2047,17 +2057,23 @@ int src;
* place. For now, we accept and silently * place. For now, we accept and silently
* ignore RAMDISK */ * ignore RAMDISK */
# ifndef AMIGA # ifndef AMIGA
(void) strncpy(tmp_ramdisk, bufp, PATHLEN-1); if (strlen(bufp) >= PATHLEN) bufp[PATHLEN-1] = '\0';
Strcpy(levels, bufp);
ramdisk = (strcmp(permbones, levels) != 0);
ramdisk_specified = TRUE;
# endif # endif
# endif # endif
} else if (match_varname(buf, "LEVELS", 4)) { } else if (match_varname(buf, "LEVELS", 4)) {
(void) strncpy(tmp_levels, bufp, PATHLEN-1); if (strlen(bufp) >= PATHLEN) bufp[PATHLEN-1] = '\0';
Strcpy(permbones, bufp);
if (!ramdisk_specified || !*levels) Strcpy(levels, bufp);
ramdisk = (strcmp(permbones, levels) != 0);
} else if (match_varname(buf, "SAVE", 4)) { } else if (match_varname(buf, "SAVE", 4)) {
# ifdef MFLOPPY # ifdef MFLOPPY
extern int saveprompt; extern int saveprompt;
# endif # endif
char *ptr; char *ptr;
if ((ptr = index(bufp, ';')) != 0) { if ((ptr = index(bufp, ';')) != 0) {
*ptr = '\0'; *ptr = '\0';
# ifdef MFLOPPY # ifdef MFLOPPY
@@ -2088,103 +2104,96 @@ int src;
} else if (match_varname(buf, "CATNAME", 3)) { } else if (match_varname(buf, "CATNAME", 3)) {
(void) strncpy(catname, bufp, PL_PSIZ-1); (void) strncpy(catname, bufp, PL_PSIZ-1);
#ifdef SYSCF #ifdef SYSCF
} else if ( (src==SET_IN_SYS) && match_varname(buf, "WIZARDS", 7)) { } else if (src == SET_IN_SYS && match_varname(buf, "WIZARDS", 7)) {
if(sysopt.wizards) free(sysopt.wizards); if (sysopt.wizards) free(sysopt.wizards);
sysopt.wizards = (char*)alloc(strlen(bufp)+1); sysopt.wizards = dupstr(bufp);
Strcpy(sysopt.wizards, bufp); } else if (src == SET_IN_SYS && match_varname(buf, "SHELLERS", 8)) {
} else if ( (src==SET_IN_SYS) && match_varname(buf, "SHELLERS", 8)) { if (sysopt.shellers) free(sysopt.shellers);
if(sysopt.shellers) free(sysopt.shellers); sysopt.shellers = dupstr(bufp);
sysopt.shellers = (char*)alloc(strlen(bufp)+1); } else if (src == SET_IN_SYS && match_varname(buf, "SUPPORT", 7)) {
Strcpy(sysopt.shellers, bufp); if (sysopt.support) free(sysopt.support);
} else if ( (src==SET_IN_SYS) && match_varname(buf, "SUPPORT", 7)) { sysopt.support = dupstr(bufp);
if(sysopt.support) free(sysopt.support); } else if (src == SET_IN_SYS && match_varname(buf, "RECOVER", 7)) {
sysopt.support = (char*)alloc(strlen(bufp)+1); if (sysopt.recover) free(sysopt.recover);
Strcpy(sysopt.support, bufp); sysopt.recover = dupstr(bufp);
} else if ( (src==SET_IN_SYS) && match_varname(buf, "RECOVER", 7)) { } else if (match_varname(buf, "SEDUCE", 6)) {
if(sysopt.recover) free(sysopt.recover); n = !!atoi(bufp); /* XXX this could be tighter */
sysopt.recover = (char*)alloc(strlen(bufp)+1); /* allow anyone to turn it off, but only sysconf to turn it on*/
Strcpy(sysopt.recover, bufp); if (src != SET_IN_SYS && n != 0) {
} else if ( match_varname(buf, "SEDUCE", 6)) {
int temp = !!atoi(bufp); /* XXX this could be tighter */
/* allow anyone to turn it off, but only sysconf to turn it on*/
if(src!=SET_IN_SYS && temp!=0){
raw_printf("Illegal value in SEDUCE"); raw_printf("Illegal value in SEDUCE");
return 0; return 0;
} }
sysopt.seduce = temp; sysopt.seduce = n;
sysopt_seduce_set(temp); sysopt_seduce_set(sysopt.seduce);
} else if ( (src==SET_IN_SYS) && match_varname(buf, "MAXPLAYERS", 10)) { } else if (src == SET_IN_SYS && match_varname(buf, "MAXPLAYERS", 10)) {
int temp = atoi(bufp); n = atoi(bufp);
/* XXX to get more than 25, need to rewrite all lock code */ /* XXX to get more than 25, need to rewrite all lock code */
if(temp > 0 && temp <= 25){ if (n < 1 || n > 25) {
sysopt.maxplayers = temp; raw_printf("Illegal value in MAXPLAYERS (maximum is 25).");
} else {
raw_printf("Illegal value in MAXPLAYERS.");
return 0; return 0;
} }
} else if ( (src==SET_IN_SYS) && match_varname(buf, "PERSMAX", 7)) { sysopt.maxplayers = n;
int temp = atoi(bufp); } else if (src == SET_IN_SYS && match_varname(buf, "PERSMAX", 7)) {
if(temp < 1){ n = atoi(bufp);
if (n < 1) {
raw_printf("Illegal value in PERSMAX (minimum is 1)."); raw_printf("Illegal value in PERSMAX (minimum is 1).");
return 0; return 0;
} }
sysopt.persmax = temp; sysopt.persmax = n;
} else if ( (src==SET_IN_SYS) && match_varname(buf, "PERS_IS_UID", 11)) { } else if (src == SET_IN_SYS && match_varname(buf, "PERS_IS_UID", 11)) {
int temp = atoi(bufp); n = atoi(bufp);
if(temp != 0 && temp != 1){ if (n != 0 && n != 1) {
raw_printf("Illegal value in PERS_IS_UID (must be 0 or 1)."); raw_printf("Illegal value in PERS_IS_UID (must be 0 or 1).");
return 0; return 0;
} }
sysopt.pers_is_uid = temp; sysopt.pers_is_uid = n;
} else if ( (src==SET_IN_SYS) && match_varname(buf, "ENTRYMAX", 8)) { } else if (src == SET_IN_SYS && match_varname(buf, "ENTRYMAX", 8)) {
int temp = atoi(bufp); n = atoi(bufp);
if(temp < 10){ if (n < 10) {
raw_printf("Illegal value in ENTRYMAX (minimum is 10)."); raw_printf("Illegal value in ENTRYMAX (minimum is 10).");
return 0; return 0;
} }
sysopt.entrymax = temp; sysopt.entrymax = n;
} else if ( (src==SET_IN_SYS) && match_varname(buf, "POINTSMIN", 9)) { } else if ( (src==SET_IN_SYS) && match_varname(buf, "POINTSMIN", 9)) {
int temp = atoi(bufp); n = atoi(bufp);
if(temp < 1){ if (n < 1) {
raw_printf("Illegal value in POINTSMIN (minimum is 1)."); raw_printf("Illegal value in POINTSMIN (minimum is 1).");
return 0; return 0;
} }
sysopt.pointsmin = temp; sysopt.pointsmin = n;
# ifdef PANICTRACE # ifdef PANICTRACE
# ifdef PANICTRACE_LIBC
} else if (src == SET_IN_SYS && } else if (src == SET_IN_SYS &&
match_varname(buf, "PANICTRACE_LIBC", 15)) { match_varname(buf, "PANICTRACE_LIBC", 15)) {
int temp = atoi(bufp); # ifdef PANICTRACE_LIBC
if (temp < 0 || temp > 2) { n = atoi(bufp);
if (n < 0 || n > 2) {
raw_printf("Illegal value in PANICTRACE_LIBC (not 0,1,2)."); raw_printf("Illegal value in PANICTRACE_LIBC (not 0,1,2).");
return 0; return 0;
} }
sysopt.panictrace_libc = temp; sysopt.panictrace_libc = n;
# endif /* PANICTRACE_LIBC */ # endif /* PANICTRACE_LIBC */
} else if (src == SET_IN_SYS && } else if (src == SET_IN_SYS &&
match_varname(buf, "PANICTRACE_GDB", 14)) { match_varname(buf, "PANICTRACE_GDB", 14)) {
int temp = atoi(bufp); n = atoi(bufp);
if (temp < 0 || temp > 2) { if (n < 0 || n > 2) {
raw_printf("Illegal value in PANICTRACE_GDB (not 0,1,2)."); raw_printf("Illegal value in PANICTRACE_GDB (not 0,1,2).");
return 0; return 0;
} }
sysopt.panictrace_gdb = temp; sysopt.panictrace_gdb = n;
} else if ( (src==SET_IN_SYS) && match_varname(buf, "GDBPATH", 7)) { } else if (src == SET_IN_SYS && match_varname(buf, "GDBPATH", 7)) {
if(!file_exists(bufp)){ if (!file_exists(bufp)) {
raw_printf("File specified in GDBPATH does not exist."); raw_printf("File specified in GDBPATH does not exist.");
return 0; return 0;
} }
if(sysopt.gdbpath) free(sysopt.gdbpath); if (sysopt.gdbpath) free(sysopt.gdbpath);
sysopt.gdbpath = (char*)alloc(strlen(bufp)+1); sysopt.gdbpath = dupstr(bufp);
Strcpy(sysopt.gdbpath, bufp); } else if (src == SET_IN_SYS && match_varname(buf, "GREPPATH", 7)) {
} else if ( (src==SET_IN_SYS) && match_varname(buf, "GREPPATH", 7)) { if (!file_exists(bufp)) {
if(!file_exists(bufp)){
raw_printf("File specified in GREPPATH does not exist."); raw_printf("File specified in GREPPATH does not exist.");
return 0; return 0;
} }
if(sysopt.greppath) free(sysopt.greppath); if (sysopt.greppath) free(sysopt.greppath);
sysopt.greppath = (char*)alloc(strlen(bufp)+1); sysopt.greppath = dupstr(bufp);
Strcpy(sysopt.greppath, bufp);
# endif /* PANICTRACE */ # endif /* PANICTRACE */
#endif /* SYSCF */ #endif /* SYSCF */
} else if (match_varname(buf, "BOULDER", 3)) { } else if (match_varname(buf, "BOULDER", 3)) {
@@ -2393,37 +2402,16 @@ read_config_file(filename, src)
const char *filename; const char *filename;
int src; int src;
{ {
#define tmp_levels (char *)0
#define tmp_ramdisk (char *)0
#if defined(MICRO) || defined(WIN32)
#undef tmp_levels
char tmp_levels[PATHLEN];
# ifdef MFLOPPY
# ifndef AMIGA
#undef tmp_ramdisk
char tmp_ramdisk[PATHLEN];
# endif
# endif
#endif
char buf[4*BUFSZ]; char buf[4*BUFSZ];
FILE *fp; FILE *fp;
boolean rv = TRUE; /* assume successful parse */ boolean rv = TRUE; /* assume successful parse */
if (!(fp = fopen_config_file(filename, src))) return FALSE; if (!(fp = fopen_config_file(filename, src))) return FALSE;
#if defined(MICRO) || defined(WIN32)
# ifdef MFLOPPY
# ifndef AMIGA
tmp_ramdisk[0] = 0;
# endif
# endif
tmp_levels[0] = 0;
#endif
/* begin detection of duplicate configfile options */ /* begin detection of duplicate configfile options */
set_duplicate_opt_detection(1); set_duplicate_opt_detection(1);
while (fgets(buf, 4*BUFSZ, fp)) { while (fgets(buf, sizeof buf, fp)) {
#ifdef notyet #ifdef notyet
/* /*
XXX Don't call read() in parse_config_line, read as callback or reassemble line XXX Don't call read() in parse_config_line, read as callback or reassemble line
@@ -2431,33 +2419,16 @@ at this level.
OR: Forbid multiline stuff for alternate config sources. OR: Forbid multiline stuff for alternate config sources.
*/ */
#endif #endif
if (!parse_config_line(fp, buf, tmp_ramdisk, tmp_levels, src)) { if (!parse_config_line(fp, buf, src)) {
raw_printf("Bad option line: \"%.50s\"", buf); raw_printf("Bad option line: \"%.50s\"", buf);
wait_synch(); wait_synch();
rv = FALSE; rv = FALSE;
} }
} }
(void) fclose(fp); (void) fclose(fp);
/* turn off detection of duplicate configfile options */ /* turn off detection of duplicate configfile options */
set_duplicate_opt_detection(0); set_duplicate_opt_detection(0);
#if defined(MICRO) && !defined(NOCWD_ASSUMPTIONS)
/* should be superseded by fqn_prefix[] */
# ifdef MFLOPPY
Strcpy(permbones, tmp_levels);
# ifndef AMIGA
if (tmp_ramdisk[0]) {
Strcpy(levels, tmp_ramdisk);
if (strcmp(permbones, levels)) /* if not identical */
ramdisk = TRUE;
} else
# endif /* AMIGA */
Strcpy(levels, tmp_levels);
Strcpy(bones, levels);
# endif /* MFLOPPY */
#endif /* MICRO */
return rv; return rv;
} }
@@ -2723,8 +2694,7 @@ int which_set;
symset_list = tmpsp; symset_list = tmpsp;
} }
tmpsp->idx = symset_count; tmpsp->idx = symset_count;
tmpsp->name = (char *)alloc(strlen(bufp)+1); tmpsp->name = dupstr(bufp);
Strcpy(tmpsp->name, bufp);
tmpsp->desc = (char *)0; tmpsp->desc = (char *)0;
tmpsp->nocolor = 0; tmpsp->nocolor = 0;
/* initialize restriction bits */ /* initialize restriction bits */
@@ -2747,10 +2717,8 @@ int which_set;
break; break;
case 3: /* description:something */ case 3: /* description:something */
tmpsp = symset_list; /* most recent symset */ tmpsp = symset_list; /* most recent symset */
if (tmpsp && !tmpsp->desc) { if (tmpsp && !tmpsp->desc)
tmpsp->desc = (char *)alloc(strlen(bufp)+1); tmpsp->desc = dupstr(bufp);
Strcpy(tmpsp->desc, bufp);
}
break; break;
case 5: case 5:
/* restrictions: xxxx*/ /* restrictions: xxxx*/
@@ -2951,12 +2919,19 @@ const char *cp;
/* ---------- BEGIN SCOREBOARD CREATION ----------- */ /* ---------- BEGIN SCOREBOARD CREATION ----------- */
/* verify that we can write to the scoreboard file; if not, try to create one */ #ifdef OS2_CODEVIEW
# define UNUSED_if_not_OS2_CODEVIEW /*empty*/
#else
# define UNUSED_if_not_OS2_CODEVIEW UNUSED
#endif
/* verify that we can write to scoreboard file; if not, try to create one */
/*ARGUSED*/
void void
check_recordfile(dir) check_recordfile(dir)
const char *dir; const char *dir UNUSED_if_not_OS2_CODEVIEW;
{ {
#if (defined(macintosh) && (defined(__SC__) || defined(__MRC__))) || defined(__MWERKS__) #if defined(PRAGMA_UNUSED) && !defined(OS2_CODEVIEW)
# pragma unused(dir) # pragma unused(dir)
#endif #endif
const char *fq_record; const char *fq_record;
@@ -2967,12 +2942,12 @@ const char *dir;
fd = open(fq_record, O_RDWR, 0); fd = open(fq_record, O_RDWR, 0);
if (fd >= 0) { if (fd >= 0) {
# ifdef VMS /* must be stream-lf to use UPDATE_RECORD_IN_PLACE */ # ifdef VMS /* must be stream-lf to use UPDATE_RECORD_IN_PLACE */
if (!file_is_stmlf(fd)) { if (!file_is_stmlf(fd)) {
raw_printf( raw_printf(
"Warning: scoreboard file %s is not in stream_lf format", "Warning: scoreboard file %s is not in stream_lf format",
fq_record); fq_record);
wait_synch(); wait_synch();
} }
# endif # endif
(void) close(fd); /* RECORD is accessible */ (void) close(fd); /* RECORD is accessible */
} else if ((fd = open(fq_record, O_CREAT|O_RDWR, FCMASK)) >= 0) { } else if ((fd = open(fq_record, O_CREAT|O_RDWR, FCMASK)) >= 0) {