1
0
Fork 0

Some more const stuff. Silences a few warnings and removes a few casts. Update description of dss.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2886
This commit is contained in:
Peter Veenstra 2007-06-14 08:23:46 +00:00
parent df0f8ee9d6
commit a5ac3216ba
26 changed files with 312 additions and 288 deletions

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: shell.cpp,v 1.84 2007-02-22 08:34:10 qbix79 Exp $ */
/* $Id: shell.cpp,v 1.85 2007-06-14 08:23:46 qbix79 Exp $ */
#include <stdlib.h>
#include <stdarg.h>
@ -420,10 +420,10 @@ void AUTOEXEC_Init(Section * sec) {
test = new AUTOEXEC(sec);
}
static char * path_string="PATH=Z:\\";
static char * comspec_string="COMSPEC=Z:\\COMMAND.COM";
static char * full_name="Z:\\COMMAND.COM";
static char * init_line="/INIT AUTOEXEC.BAT";
static char const * const path_string="PATH=Z:\\";
static char const * const comspec_string="COMSPEC=Z:\\COMMAND.COM";
static char const * const full_name="Z:\\COMMAND.COM";
static char const * const init_line="/INIT AUTOEXEC.BAT";
void SHELL_Init() {
/* Add messages */

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: shell_cmds.cpp,v 1.75 2007-06-12 20:22:09 c2woody Exp $ */
/* $Id: shell_cmds.cpp,v 1.76 2007-06-14 08:23:46 qbix79 Exp $ */
#include <string.h>
#include <ctype.h>
@ -62,18 +62,22 @@ static SHELL_Cmd cmd_list[]={
{ "PATH", 1, &DOS_Shell::CMD_PATH, "SHELL_CMD_PATH_HELP"},
{ "VER", 0, &DOS_Shell::CMD_VER, "SHELL_CMD_VER_HELP"},
{0,0,0,0}
};
bool DOS_Shell::CheckConfig(char* cmd,char*line) {
Section* test = control->GetSectionFromProperty(cmd);
};
static char empty_char = 0;
static char* empty_string = &empty_char;
bool DOS_Shell::CheckConfig(char* cmd_in,char*line) {
Section* test = control->GetSectionFromProperty(cmd_in);
if(!test) return false;
if(line && !line[0]) {
char const* val = test->GetPropValue(cmd);
char const* val = test->GetPropValue(cmd_in);
if(val) WriteOut("%s\n",val);
return true;
}
char newcom[1024]; newcom[0] = 0; strcpy(newcom,"z:\\config ");
strcat(newcom,test->GetName()); strcat(newcom," ");
strcat(newcom,cmd);strcat(newcom,line);
strcat(newcom,cmd_in);strcat(newcom,line);
DoCommand(newcom);
return true;
}
@ -81,8 +85,8 @@ bool DOS_Shell::CheckConfig(char* cmd,char*line) {
void DOS_Shell::DoCommand(char * line) {
/* First split the line into command and arguments */
line=trim(line);
char cmd[CMD_MAXLINE];
char * cmd_write=cmd;
char cmd_buffer[CMD_MAXLINE];
char * cmd_write=cmd_buffer;
while (*line) {
if (*line==32) break;
if (*line=='/') break;
@ -92,7 +96,7 @@ void DOS_Shell::DoCommand(char * line) {
*cmd_write=0;
Bit32u cmd_index=0;
while (cmd_list[cmd_index].name) {
if (strcasecmp(cmd_list[cmd_index].name,cmd)==0) {
if (strcasecmp(cmd_list[cmd_index].name,cmd_buffer)==0) {
(this->*(cmd_list[cmd_index].handler))(line);
return;
}
@ -102,20 +106,20 @@ void DOS_Shell::DoCommand(char * line) {
*cmd_write++=*line++;
}
*cmd_write=0;
if (strlen(cmd)==0) return;
if (strlen(cmd_buffer)==0) return;
/* Check the internal list */
Bit32u cmd_index=0;
while (cmd_list[cmd_index].name) {
if (strcasecmp(cmd_list[cmd_index].name,cmd)==0) {
if (strcasecmp(cmd_list[cmd_index].name,cmd_buffer)==0) {
(this->*(cmd_list[cmd_index].handler))(line);
return;
}
cmd_index++;
}
/* This isn't an internal command execute it */
if(Execute(cmd,line)) return;
if(CheckConfig(cmd,line)) return;
WriteOut(MSG_Get("SHELL_EXECUTE_ILLEGAL_COMMAND"),cmd);
if(Execute(cmd_buffer,line)) return;
if(CheckConfig(cmd_buffer,line)) return;
WriteOut(MSG_Get("SHELL_EXECUTE_ILLEGAL_COMMAND"),cmd_buffer);
}
#define HELP(command) \
@ -183,7 +187,7 @@ void DOS_Shell::CMD_HELP(char * args){
while (cmd_list[cmd_index].name) {
if (optall || !cmd_list[cmd_index].flags) {
WriteOut("<\033[34;1m%-8s\033[0m> %s",cmd_list[cmd_index].name,MSG_Get(cmd_list[cmd_index].help));
if(!(++write_count%22)) CMD_PAUSE("");
if(!(++write_count%22)) CMD_PAUSE(empty_string);
}
cmd_index++;
}
@ -198,8 +202,9 @@ void DOS_Shell::CMD_RENAME(char * args){
char* slash = strrchr(arg1,'\\');
if(slash) {
slash++;
//If directory specified (crystal caves installer)
// rename from c:\X : rename c:\abc.exe abc.shr. File must appear in C:\
/* If directory specified (crystal caves installer)
* rename from c:\X : rename c:\abc.exe abc.shr.
* File must appear in C:\ */
char dir_source[DOS_PATHLENGTH]={0};
//Copy first and then modify, makes GCC happy
@ -331,7 +336,7 @@ void DOS_Shell::CMD_DIR(char * args) {
}
bool optW=ScanCMDBool(args,"W");
bool optS=ScanCMDBool(args,"S");
ScanCMDBool(args,"S");
bool optP=ScanCMDBool(args,"P");
bool optAD=ScanCMDBool(args,"AD");
char * rem=ScanCMDRemain(args);
@ -398,12 +403,12 @@ void DOS_Shell::CMD_DIR(char * args) {
/* Skip non-directories if option AD is present */
if(optAD && !(attr&DOS_ATTR_DIRECTORY) ) continue;
char * ext="";
char * ext = empty_string;
if (!optW && (name[0] != '.')) {
ext = strrchr(name, '.');
if (!ext) ext = "";
else *ext++ = '\0';
if (!ext) ext = empty_string;
else *ext++ = 0;
}
Bit8u day = (Bit8u)(date & 0x001f);
Bit8u month = (Bit8u)((date >> 5) & 0x000f);
@ -435,7 +440,7 @@ void DOS_Shell::CMD_DIR(char * args) {
}
if(optP) {
if(!(++p_count%(22*w_size))) {
CMD_PAUSE("");
CMD_PAUSE(empty_string);
}
}
} while ( (ret=DOS_FindNext()) );