Skip to content
Snippets Groups Projects
Commit 5a1ab6a7 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

A second pass at: Better native vs. DOS cmd-line detection in cmdstr()

cmdstr() is often called for non-executable command-lines (e.g. for @include: file name/path arguments), so don't default to native unless a mode value was specified. Hopefully addresses issue reported by bobrob without breaking anything else (again).
parent 1c481255
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #897 passed
......@@ -226,7 +226,10 @@ static bool native_executable(scfg_t* cfg, const char* cmdline, long mode)
unsigned i;
if(mode&EX_NATIVE)
return(TRUE);
return true;
if(*cmdline == '?' || *cmdline == '*')
return true;
SAFECOPY(str,cmdline); /* Set str to program name only */
truncstr(str," ");
......@@ -1838,9 +1841,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
{
char str[MAX_PATH+1],*cmd;
int i,j,len;
if(mode == EX_UNSPECIFIED && (*instr == '?' || *instr == '*'))
mode = EX_NATIVE;
bool native = (mode == EX_UNSPECIFIED) || native_executable(&cfg, instr, mode);
if(outstr==NULL)
cmd=cmdstr_output;
......@@ -1874,8 +1875,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break;
case 'F': /* File path */
#if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE)
&& strncmp(fpath, cfg.node_dir, strlen(cfg.node_dir)) == 0) {
if(!native && strncmp(fpath, cfg.node_dir, strlen(cfg.node_dir)) == 0) {
strncat(cmd, DOSEMU_NODE_DIR, avail);
strncat(cmd, fpath + strlen(cfg.node_dir), avail);
}
......@@ -1885,7 +1885,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break;
case 'G': /* Temp directory */
#if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE))
if(!native)
strncat(cmd, DOSEMU_TEMP_DIR, avail);
else
#endif
......@@ -1899,7 +1899,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break;
case 'J':
#if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE))
if(!native)
strncat(cmd, DOSEMU_DATA_DIR, avail);
else
#endif
......@@ -1907,7 +1907,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break;
case 'K':
#if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE))
if(!native)
strncat(cmd, DOSEMU_CTRL_DIR, avail);
else
#endif
......@@ -1921,7 +1921,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break;
case 'N': /* Node Directory (same as SBBSNODE environment var) */
#if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE))
if(!native)
strncat(cmd, DOSEMU_NODE_DIR, avail);
else
#endif
......@@ -1966,7 +1966,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break;
case 'Z':
#if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE))
if(!native)
strncat(cmd, DOSEMU_TEXT_DIR, avail);
else
#endif
......@@ -1984,7 +1984,7 @@ char* sbbs_t::cmdstr(const char *instr, const char *fpath, const char *fspec, ch
break;
case '!': /* EXEC Directory */
#if defined(__linux__) && defined(USE_DOSEMU)
if(!(mode & EX_NATIVE))
if(!native)
strncat(cmd, DOSEMU_EXEC_DIR, avail);
else
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment