diff --git a/src/dosbox.cpp b/src/dosbox.cpp index 4a31477c..f67995e3 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -148,7 +148,7 @@ void DOSBOX_Init(void) { secprop=control->AddSection_prop("DOSBOX",&DOSBOX_RealInit); - secprop->Add_string("LANGUAGE","dosbox.lang"); + secprop->Add_string("LANGUAGE",""); secprop->Add_int("WARNINGS",0); control->AddSection ("MEMORY",&MEM_Init); diff --git a/src/dosbox.lang b/src/dosbox.lang deleted file mode 100644 index f2ff667b..00000000 --- a/src/dosbox.lang +++ /dev/null @@ -1,74 +0,0 @@ -:SHELL_CMD_HELP -supported commands are: -. -:SHELL_ILLEGAL_SWITCH -Illegal switch: %s -. -:SHELL_CMD_ECHO_ON -ECHO is on -. -:SHELL_CMD_ECHO_OFF -ECHO is off -. -:SHELL_CMD_CHDIR_ERROR -Unable to change to: %s -. -:SHELL_CMD_MKDIR_ERROR -Unable to make: %s -. -:SHELL_CMD_RMDIR_ERROR -Unable to remove: %s -. -:SHELL_SYNTAXERROR -The syntax of the command is incorrect -. -:SHELL_CMD_SET_NOT_SET -Environment variable %s not defined -. -:SHELL_CMD_SET_OUT_OF_SPACE -Not enough environment space left -. -:SHELL_CMD_IF_EXIST_MISSING_FILENAME -IF EXIST: Missing filename -. -:SHELL_CMD_IF_ERRORLEVEL_MISSING_NUMBER -IF ERRORLEVEL: Missing number -. -:SHELL_CMD_IF_ERRORLEVEL_INVALID_NUMBER -IF ERRORLEVEL: Invalid number -. -:SHELL_CMD_GOTO_MISSING_LABEL -No label supplied to GOTO command -. -:SHELL_CMD_GOTO_LABEL_NOT_FOUND -Label %s not found -. -:SHELL_CMD_FILE_NOT_FOUND -File %s not found -. -:SHELL_CMD_DIR_INTRO -Directory of %s -. -:SHELL_CMD_DIR_PATH_ERROR -Illegal Path -. -:SHELL_CMD_DIR_BYTES_USED -%16d File(s) %16s Bytes -. -:SHELL_CMD_DIR_BYTES_FREE -%16d Dir(s) %16s Bytes free -. -:SHELL_STARTUP -DOSBox Shell v0.35 -For Help and supported commands type: HELP - -HAVE FUN! -The DOSBox Team - -. -:SHELL_EXECUTE_DRIVE_NOT_FOUND -Drive %c does not exist! -. -:SHELL_EXECUTE_ILLEGAL_COMMAND -Illegal command: %s -. diff --git a/src/misc/messages.cpp b/src/misc/messages.cpp index 38ccb700..3ec32ef1 100644 --- a/src/misc/messages.cpp +++ b/src/misc/messages.cpp @@ -23,6 +23,9 @@ #include "cross.h" #include "support.h" #include "setup.h" +#include +#include +using namespace std; @@ -30,15 +33,39 @@ struct MessageBlock { - char * name; - char * string; - MessageBlock * next; + string name; + string val; + MessageBlock(const char* _name, const char* _val): + name(_name),val(_val) + {} }; -static MessageBlock * first_message; +static list Lang; +typedef list::iterator itmb; +void AddMessage(const char * _name, const char* _val) +{ + Lang.push_back(MessageBlock(_name,_val)); +} + +void ReplaceMessage(const char * _name, const char* _val) +{ + //find the message + for(itmb tel=Lang.begin();tel!=Lang.end();tel++) + { + if((*tel).name==_name) + { itmb teln=tel; + teln++; + Lang.erase(tel,teln); + break; + } + } + //even if the message doesn't exist add it + AddMessage(_name,_val); +} static void LoadMessageFile(const char * fname) { - FILE * mfile=fopen(fname,"rb"); + if(*fname=='\0') return;//empty string=no languagefile + FILE * mfile=fopen(fname,"rb"); /* This should never happen and since other modules depend on this use a normal printf */ if (!mfile) { E_Exit("MSG:Can't load messages: %s",fname); @@ -66,15 +93,8 @@ static void LoadMessageFile(const char * fname) { strcpy(name,linein+1); /* End of string marker */ } else if (linein[0]=='.') { - /* Save the string internally */ - size_t total=sizeof(MessageBlock)+strlen(name)+1+strlen(string)+1; - MessageBlock * newblock=(MessageBlock *)malloc(total); - newblock->name=((char *)newblock)+sizeof(MessageBlock); - newblock->string=newblock->name+strlen(name)+1; - strcpy(newblock->name,name); - strcpy(newblock->string,string); - newblock->next=first_message; - first_message=newblock; + /* Replace/Add the string to the internal langaugefile */ + ReplaceMessage(name,string); } else { /* Normal string to be added */ strcat(string,linein); @@ -83,19 +103,20 @@ static void LoadMessageFile(const char * fname) { } fclose(mfile); } - -char * MSG_Get(char * msg) { - MessageBlock * index=first_message; - while (index) { - if (!strcmp(msg,index->name)) return index->string; - index=index->next; - } - return "Message not found"; +const char * MSG_Get(char const * msg) { + for(itmb tel=Lang.begin();tel!=Lang.end();tel++) + { + + if((*tel).name==msg) + { + return (*tel).val.c_str(); + } + } + return "Message not Found!"; } void MSG_Init(Section_prop * section) { /* Load the messages from "dosbox.lang file" */ - first_message=0; std::string file_name; if (control->cmdline->FindString("-lang",file_name)) { LoadMessageFile(file_name.c_str()); diff --git a/src/misc/programs.cpp b/src/misc/programs.cpp index 85be35a0..aea3fdb8 100644 --- a/src/misc/programs.cpp +++ b/src/misc/programs.cpp @@ -92,7 +92,7 @@ Program::Program() { cmd = new CommandLine(envscan,tail.buffer); } -void Program::WriteOut(char * format,...) { +void Program::WriteOut(const char * format,...) { char buf[1024]; va_list msg; diff --git a/src/misc/support.cpp b/src/misc/support.cpp index 349b151a..1aeb55e9 100644 --- a/src/misc/support.cpp +++ b/src/misc/support.cpp @@ -214,7 +214,7 @@ void S_Warn(char * format,...) { GFX_ShowMsg(buf); #endif } -char buf[1024]; //global as else it doesn't always gets thrown right (linux/gcc2.95) +static char buf[1024]; //greater scope as else it doesn't always gets thrown right (linux/gcc2.95) void E_Exit(char * format,...) { // char buf[1024]; //see above diff --git a/src/shell/shell.cpp b/src/shell/shell.cpp index 4ae9f881..3375d388 100644 --- a/src/shell/shell.cpp +++ b/src/shell/shell.cpp @@ -175,10 +175,33 @@ 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"; - void SHELL_Init() { - - call_shellstop=CALLBACK_Allocate(); +//add messages: + AddMessage("SHELL_CMD_HELP","supported commands are:\n"); + AddMessage("SHELL_CMD_ECHO_ON","ECHO is on\n"); + AddMessage("SHELL_CMD_ECHO_OFF","ECHO is off\n"); + AddMessage("SHELL_ILLEGAL_SWITCH","Illegal switch: %s"); + AddMessage("SHELL_CMD_CHDIR_ERROR","Unable to change to: %s\n"); + AddMessage("SHELL_CMD_MKDIR_ERROR","Unable to make: %s\n"); + AddMessage("SHELL_CMD_RMDIR_ERROR","Unable to remove: %\n"); + AddMessage("SHELL_SYNTAXERROR","The syntax of the command is incorrect.\n"); + AddMessage("SHELL_CMD_SET_NOT_SET","Environment variable %s not defined\n"); + AddMessage("SHELL_CMD_SET_OUT_OF_SPACE","Not enough environment space left.\n"); + AddMessage("SHELL_CMD_IF_EXIST_MISSING_FILENAME","IF EXIST: Missing filename.\n"); + AddMessage("SHELL_CMD_IF_ERRORLEVEL_MISSING_NUMBER","IF ERRORLEVEL: Missing number.\n"); + AddMessage("SHELL_CMD_IF_ERRORLEVEL_INVALID_NUMBER","IF ERRORLEVEL: Invalid number.\n"); + AddMessage("SHELL_CMD_GOTO_MISSING_LABEL","No label supplied to GOTO command.\n"); + AddMessage("SHELL_CMD_GOTO_LABEL_NOT_FOUND","GOTO: Label %s not found.\n"); + AddMessage("SHELL_CMD_FILE_NOT_FOUND","File %s not found.\n"); + AddMessage("SHELL_CMD_DIR_INTRO","Directory of %s.\n"); + AddMessage("SHELL_CMD_DIR_PATH_ERROR","Illegal Path\n"); + AddMessage("SHELL_CMD_DIR_BYTES_USED","%5d File(s) %17s Bytes\n"); + AddMessage("SHELL_CMD_DIR_BYTES_FREE","%5d Dir(s) %17s Bytes free"); + AddMessage("SHELL_EXECUTE_DRIVE_NOT_FOUND","Drive %c does not exist!\n"); + AddMessage("SHELL_EXECUTE_ILLEGAL_COMMAND","Illegal command: %s.\n"); + AddMessage("SHELL_STARTUP","DOSBox Shell v0.40\nFor Help and supported commands type: HELP\n\nHAVE FUN!\nThe DOSBox Team\n\n"); +//regular startup + call_shellstop=CALLBACK_Allocate(); CALLBACK_Setup(call_shellstop,shellstop_handler,CB_IRET); PROGRAMS_MakeFile("COMMAND.COM",SHELL_ProgramStart);