diff --git a/app/localize/help.h b/app/localize/help.h index 68a74d39..cda18fef 100644 --- a/app/localize/help.h +++ b/app/localize/help.h @@ -24,7 +24,7 @@ * * Generated with FlexCat. For more information, see: * http://sourceforge.net/projects/flexcat/ - * + * */ #ifndef AMATH_LOCALIZE_HELP_H @@ -33,7 +33,7 @@ /** * @file help.h * @brief Localized help text definitions. - * + * */ #include "clib.h" diff --git a/app/localize/ident.h b/app/localize/ident.h index d33cecf3..56273a66 100644 --- a/app/localize/ident.h +++ b/app/localize/ident.h @@ -24,7 +24,7 @@ * * Generated with FlexCat. For more information, see: * http://sourceforge.net/projects/flexcat/ - * + * */ #ifndef AMATH_LOCALIZE_IDENT_HELP_H @@ -33,7 +33,7 @@ /** * @file ident.h * @brief Localized help text definitions. - * + * */ #include "clib.h" diff --git a/app/localize/text.h b/app/localize/text.h index 6fd2203d..a662ea83 100644 --- a/app/localize/text.h +++ b/app/localize/text.h @@ -24,7 +24,7 @@ * * Generated with FlexCat. For more information, see: * http://sourceforge.net/projects/flexcat/ - * + * */ #ifndef AMATH_LOCALIZE_TEXT_H @@ -33,7 +33,7 @@ /** * @file text.h * @brief Localized text definitions. - * + * */ #include "clib.h" diff --git a/app/main.cpp b/app/main.cpp index 33ef0328..715560dd 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -31,6 +31,7 @@ int main(int argc, char **argv) { Program = CreateProgram(argc, argv); + Program->Initialize(argc, argv); Program->Run(); delete Program; FreeAllSafe(); diff --git a/app/main/statements.cpp b/app/main/statements.cpp index 753ce972..9b8adf68 100644 --- a/app/main/statements.cpp +++ b/app/main/statements.cpp @@ -104,10 +104,7 @@ char* PromptStatement::Execute() buf->ClearAndCopy(prompt); while(buf->RemoveTrailing(' ')); buf->Append(' '); - - Program->Console->SetPrompt(buf->GetString()); - Program->Preferences->SetPrompt(buf->GetString()); - + Program->SetPrompt(buf->GetString()); delete buf; return (char*)EMPTYSTRING; } diff --git a/app/system/base/io.cpp b/app/system/base/io.cpp index 302f7d6d..54b864aa 100644 --- a/app/system/base/io.cpp +++ b/app/system/base/io.cpp @@ -98,7 +98,6 @@ class Program* CreateProgram(int argc, char **argv) { out = new StandardProgram(); #endif } - out->Initialize(argc, argv); return out; } diff --git a/app/system/console_amiga.cpp b/app/system/console_amiga.cpp index ce6fe911..5b9a70e4 100755 --- a/app/system/console_amiga.cpp +++ b/app/system/console_amiga.cpp @@ -27,10 +27,9 @@ #include "clib.h" #include "main/nodes.h" #include "main/evaluator.h" +#include "system/console_amiga.h" #ifdef AMIGA -#include -#include "system/console_amiga.h" AmigaShellConsole::AmigaShellConsole(const char *prompt) : ConsoleBase(prompt) diff --git a/app/system/console_stdc.cpp b/app/system/console_stdc.cpp index 8ab5e5e5..52102de7 100755 --- a/app/system/console_stdc.cpp +++ b/app/system/console_stdc.cpp @@ -91,7 +91,7 @@ void StandardConsole::ReadLine() line = proc->GetLine(); #ifdef UNIX - tcsetattr(STDIN_FILENO, TCSANOW, &old_tio); + tcsetattr(STDIN_FILENO, TCSANOW, &old_tio); #endif } diff --git a/app/system/filesystem_amiga.cpp b/app/system/filesystem_amiga.cpp index 0313a263..a81286ee 100755 --- a/app/system/filesystem_amiga.cpp +++ b/app/system/filesystem_amiga.cpp @@ -31,12 +31,6 @@ #include "system/filesystem_amiga.h" #ifdef AMIGA -#include -#include -#include -#include -#include -#include /** * @brief diff --git a/app/system/filesystem_stdc.cpp b/app/system/filesystem_stdc.cpp index 548287a6..e7c4515a 100755 --- a/app/system/filesystem_stdc.cpp +++ b/app/system/filesystem_stdc.cpp @@ -39,7 +39,7 @@ CharBuffer* StandardFilesystem::ListDirectory(const char *path) { #ifdef UNIX - CharBuffer *pathbuf = new CharBuffer(); + CharBuffer *pathbuf = new CharBuffer(); pathbuf->Empty(); if (path == NOMEM) { pathbuf->Append("."); @@ -108,9 +108,9 @@ CharBuffer* StandardFilesystem::ListDirectory(const char *path) delete pathbuf; return lines; #else - CharBuffer *lines = new CharBuffer(); - lines->Empty(); - return lines; + CharBuffer *lines = new CharBuffer(); + lines->Empty(); + return lines; #endif } diff --git a/app/system/language_amiga.cpp b/app/system/language_amiga.cpp index 5821d166..76471ac4 100644 --- a/app/system/language_amiga.cpp +++ b/app/system/language_amiga.cpp @@ -34,9 +34,7 @@ #include "system/language_amiga.h" #ifdef AMIGA -#include "clib/locale_protos.h" -//#include -#include +#include AmigaLanguage::AmigaLanguage() { diff --git a/app/system/language_stdc.cpp b/app/system/language_stdc.cpp index a93f9715..68534909 100644 --- a/app/system/language_stdc.cpp +++ b/app/system/language_stdc.cpp @@ -118,7 +118,7 @@ bool StandardLanguage::CharIsSpace(long unsigned int character) bool StandardLanguage::CharIsCntrl(long unsigned int character) { - return (character <= 32 || character >= 126); + return (character < 32 || character > 125); } bool StandardLanguage::StrIsEqualLoc(const char* s1, const char* s2) diff --git a/app/system/preferences.cpp b/app/system/preferences.cpp index 4cdc1061..99b9fdaf 100644 --- a/app/system/preferences.cpp +++ b/app/system/preferences.cpp @@ -47,15 +47,16 @@ PreferencesBase::~PreferencesBase() void PreferencesBase::SetDefaults() { - AllocAndCopy(&this->prompt, ">>> "); + AllocAndCopy(&this->prompt, "> "); digits = 9; } char* PreferencesBase::GetDescription() { - static const char *promptq = "\""; - static const char *sprompt = "prompt"; + static const char promptq = '"'; + static const char *sprompt = "prompt"; static const char *sdigits = "digits"; + static const char delimitor = ';'; Number *d = new RealNumber(GetDigits()); NumeralSystem *ns = new DecimalSystem(2); @@ -64,20 +65,22 @@ char* PreferencesBase::GetDescription() buf->Empty(); buf->EnsureSize( - StrLen(sprompt) + StrLen(SPACE) + StrLen(promptq) + - StrLen(prompt) + StrLen(promptq) + StrLen(NEWLINE) + - StrLen(sdigits) + StrLen(SPACE) + StrLen(dtext) + - StrLen(NEWLINE) + 1); + sizeof(sprompt) + sizeof(SPACE) + sizeof(promptq) + StrLen(prompt) + + sizeof(promptq) + sizeof(delimitor) + sizeof(NEWLINE) + + sizeof(sdigits) + sizeof(SPACE) + StrLen(dtext) + sizeof(delimitor) + + sizeof(NEWLINE) + 1); buf->Append(sprompt); buf->Append(SPACE); buf->Append(promptq); buf->Append(prompt); buf->Append(promptq); + buf->Append(delimitor); buf->Append(NEWLINE); buf->Append(sdigits); buf->Append(SPACE); buf->Append(dtext); + buf->Append(delimitor); buf->Append(NEWLINE); delete ns; @@ -86,6 +89,10 @@ char* PreferencesBase::GetDescription() void PreferencesBase::SetPrefs(char* prefs) { + if (prefs == NOMEM) { + return; + } + Parser *parser = new Parser(prefs); SyntaxNode *node = parser->Parse(); delete parser; diff --git a/app/system/preferences_amiga.cpp b/app/system/preferences_amiga.cpp index 71c4d129..be4d8a3f 100644 --- a/app/system/preferences_amiga.cpp +++ b/app/system/preferences_amiga.cpp @@ -30,12 +30,6 @@ #include "system/preferences_amiga.h" #ifdef AMIGA -#include -#include -#include -#include -#include -#include static const char *tempname = "ENV:amath.prefs"; static const char *permname = "ENVARC:amath.prefs"; @@ -53,10 +47,12 @@ bool AmigaPreferences::Load() const int bufsize = 64; char* buf = new char[bufsize]; char* c; + int s = 1; do { c = FGets(file, buf, bufsize); if (c != NULL) { + text->EnsureSize(s++); text->Append(c); } } while (c != NULL); diff --git a/app/system/preferences_stdc.cpp b/app/system/preferences_stdc.cpp index 21fb81d2..854d8e64 100644 --- a/app/system/preferences_stdc.cpp +++ b/app/system/preferences_stdc.cpp @@ -38,6 +38,7 @@ static const char *permname = "/usr/local/etc/amath.conf"; bool StandardPreferences::Load() { +#ifdef UNIX FILE *file = fopen(tempname, "r"); if (!file) { return false; @@ -49,10 +50,12 @@ bool StandardPreferences::Load() const int bufsize = 64; char* buf = new char[bufsize]; char* c; + int s = 1; do { c = fgets(buf, bufsize, file); if (c != NULL) { + text->EnsureSize(s++); text->Append(c); } } while (c != NULL); @@ -61,6 +64,7 @@ bool StandardPreferences::Load() fclose(file); SetPrefs(text->GetString()); delete text; +#endif return true; } @@ -76,6 +80,7 @@ bool StandardPreferences::Save() bool StandardPreferences::SavePrefs(const char* name) { +#ifdef UNIX FILE *file = fopen(name, "w"); if (!file) { return false; @@ -84,6 +89,7 @@ bool StandardPreferences::SavePrefs(const char* name) char *out = GetDescription(); fputs(out, file); fclose(file); +#endif return true; } diff --git a/app/system/proc_amiga.h b/app/system/proc_amiga.h index 066bfb5e..fa160cb2 100755 --- a/app/system/proc_amiga.h +++ b/app/system/proc_amiga.h @@ -37,7 +37,6 @@ #include "system/task.h" #include "system/base/thread.h" -#ifdef WITHTEST // Still under development #ifdef AMIGA #include #include @@ -70,4 +69,3 @@ private: #endif #endif -#endif diff --git a/app/system/program.cpp b/app/system/program.cpp index 6df39591..7b66238d 100644 --- a/app/system/program.cpp +++ b/app/system/program.cpp @@ -38,14 +38,11 @@ Program::Program() Functions = new FunctionList(); Graphs = new GraphList(); ins = new RealNumber(); - - Preferences = CreatePreferences(); -// Preferences->Load(); - Language = CreateLanguage(); + Filesystem = CreateFilesystem(); + Preferences = CreatePreferences(); Input = new DecimalSystem(Preferences->GetDigits(), Language->GetFractionPoint()); Output = new DecimalSystem(Preferences->GetDigits(), Language->GetFractionPoint()); - Filesystem = CreateFilesystem(); } Program::~Program() @@ -59,9 +56,8 @@ Program::~Program() delete Language; delete ins; -// Preferences->Keep(); + Preferences->Keep(); delete Preferences; - } void Program::NewPositionalInput(short unsigned int base, short unsigned int digits) @@ -90,6 +86,14 @@ void Program::NewPositionalOutput(short unsigned int base, short unsigned int di } } +void Program::SetPrompt(const char* text) +{ + if (Console != NOMEM) { + Console->SetPrompt(text); + } + Preferences->SetPrompt(text); +} + Number* Program::GetLastResult() { return ins; diff --git a/app/system/program.h b/app/system/program.h index c6356902..6e2a5832 100644 --- a/app/system/program.h +++ b/app/system/program.h @@ -63,7 +63,8 @@ public: void NewPositionalInput(short unsigned int base, short unsigned int digits); void NewPositionalOutput(short unsigned int base, short unsigned int digits); void SetLastResult(Number *number); - struct Number* GetLastResult(); + void SetPrompt(const char *text); + struct Number* GetLastResult(); class Language *Language; class ConsoleBase *Console; class PreferencesBase *Preferences; @@ -75,7 +76,7 @@ public: class GraphList *Graphs; private: - struct Number* ins; + struct Number* ins; }; #endif diff --git a/app/system/program_amiga.cpp b/app/system/program_amiga.cpp index 059e4307..84e946d4 100644 --- a/app/system/program_amiga.cpp +++ b/app/system/program_amiga.cpp @@ -25,7 +25,6 @@ */ #include "clib.h" -#include "platform.h" #include "lib/charbuf.h" #include "main/graphlist.h" #include "main/evaluator.h" @@ -40,11 +39,6 @@ #include "system/base/io.h" #ifdef AMIGA -#include -#include -#include -#include - #define ARGS_FORMAT "SHELL/S,INPUT/F" AmigaProgram::AmigaProgram() @@ -88,6 +82,8 @@ void AmigaProgram::Initialize(int argc, char **argv) void AmigaProgram::Run() { + Preferences->Load(); + if (Console != NULL) { Console->Run(); } else if (args.input != NULL) { @@ -106,3 +102,4 @@ void AmigaProgram::Exit() #endif + diff --git a/app/system/program_stdc.cpp b/app/system/program_stdc.cpp index 7558128e..b62cc4d2 100644 --- a/app/system/program_stdc.cpp +++ b/app/system/program_stdc.cpp @@ -79,6 +79,8 @@ void StandardProgram::Initialize(int argc, char **argv) void StandardProgram::Run() { + Preferences->Load(); + if (Console != NOMEM) { Console->Run(); return; diff --git a/app/system/program_test.cpp b/app/system/program_test.cpp index 5486df4d..35f886cc 100644 --- a/app/system/program_test.cpp +++ b/app/system/program_test.cpp @@ -56,7 +56,9 @@ void TestProgram::Run() } void TestProgram::Initialize(int argc, char** argv) -{ } +{ + Preferences->Load(); +} void TestProgram::Exit() { } diff --git a/app/system/task_amiga.cpp b/app/system/task_amiga.cpp index 21c7fadf..7bc393fe 100644 --- a/app/system/task_amiga.cpp +++ b/app/system/task_amiga.cpp @@ -29,7 +29,6 @@ #include "system/task_amiga.h" #ifdef AMIGA -#ifdef DEVNOTFINISH // Still under development #include #include #include @@ -86,4 +85,3 @@ void AmigaTask::WaitExit() } #endif -#endif diff --git a/app/system/task_amiga.h b/app/system/task_amiga.h index 639ef02b..406e16f2 100755 --- a/app/system/task_amiga.h +++ b/app/system/task_amiga.h @@ -34,11 +34,11 @@ */ #include "clib.h" +#include "system/task.h" #include "system/task_amiga.h" #include "system/base/thread.h" #ifdef AMIGA -#ifdef DEVNOTFINISH // Still under development #include #include #include @@ -76,4 +76,3 @@ private: #endif #endif -#endif diff --git a/lib/platform.h b/lib/platform.h index 354f53a8..49caedbc 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -75,11 +75,15 @@ typedef int bool; # ifndef ANSICONSOLE # define ANSICONSOLE # endif +# include +# include # include # include # include # include +# include # include +# include #endif // Check weather an POSIX compatible API is available