Cleanup defines

このコミットが含まれているのは:
Carsten Larsen 2017-04-15 20:36:40 +02:00
コミット 3374eebd4d
33個のファイルの変更69行の追加301行の削除

3
configure vendored
ファイルの表示

@ -278,13 +278,12 @@ SYSSRCS='
console.cpp
console_amiga.cpp
console_stdc.cpp
console_posix.cpp
console_termios.cpp
console_windows.cpp
filesystem_amiga.cpp
filesystem_stdc.cpp
language.cpp
language_amiga.cpp
language_posix.cpp
language_stdc.cpp
preferences.cpp
preferences_amiga.cpp

ファイルの表示

@ -84,28 +84,23 @@
# endif
#endif
/******************************************************************************/
#if defined(HAIKU) || defined(UNIX) || defined(APPLE) || defined(_POSIX_VERSION)
# ifndef POSIX
# define POSIX
#if defined(HAIKU) || defined(UNIX) || defined(APPLE)
# ifndef TERMIOS
# define TERMIOS
# endif
#endif
/******************************************************************************/
#if !defined(AMIGA) && !defined(POSIX) && !defined(WINDOWS)
# ifndef STDC_CONSOLE
# define STDC_CONSOLE
# endif
#endif
/******************************************************************************/
#if defined(POSIX)
# include <stdint.h>
# include <unistd.h>
# include <dirent.h>
#endif
/******************************************************************************/
#if defined(WINDOWS)
# include <stdint.h>
#endif
/******************************************************************************/
#if defined(AROS) || defined(MORPHOS) || defined(AOS4)
# include <stdint.h>
# include <sys/types.h>
#endif
/******************************************************************************/
#if defined(AOS3)
# include <sys/types.h>
# define IPTR LONG*
@ -116,11 +111,6 @@ typedef u_int32_t uint32_t;
typedef u_int64_t uint64_t;
#endif
/******************************************************************************/
#if defined(AROS) || defined(MORPHOS) || defined(AOS4) || defined(APPLE)
# include <stdint.h>
# include <sys/types.h>
#endif
/******************************************************************************/
#if (__cplusplus <= 199711L && !defined(WINDOWS)) || !defined(__cplusplus)
#ifndef nullptr
#define nullptr 0

ファイルの表示

@ -29,7 +29,7 @@
#include "amathc.h"
#ifdef AMIGA
#if defined(AMIGA)
#include <clib/exec_protos.h>
#endif
@ -58,7 +58,7 @@ unsigned int AllocAndCopy(char** destination, const char* source)
*destination = AllocMemSafe(size);
d = *destination;
#ifdef AMIGA // Take advantage of exec
#if defined(AMIGA) // Take advantage of exec
CopyMem(s, d, n);
#else
while (n--)

ファイルの表示

@ -29,7 +29,7 @@
#include "amathc.h"
#ifdef AMIGA
#if defined(AMIGA)
#include <stddef.h>
#include <exec/types.h>
#include <exec/memory.h>

ファイルの表示

@ -47,7 +47,7 @@
#pragma GCC diagnostic ignored "-Wcast-align"
#endif
#ifdef AMIGA
#if defined(AMIGA)
#include <clib/exec_protos.h>
#endif
@ -84,7 +84,7 @@ void MemCopy(void* destination, const void* source, unsigned int length)
if ((mem_ptr)dst < (mem_ptr)src)
{
// Copy forward
#ifdef AMIGA // Take advantage of exec
#if defined(AMIGA) // Take advantage of exec
CopyMem((void*)source, destination, length);
#else
t = (mem_ptr)src; // only need low bits

ファイルの表示

@ -39,7 +39,7 @@ const char* vers = TXTDOSVERSION;
class Program* Program = nullptr;
#ifdef AMIGA
#if defined(AMIGA)
#include <clib/exec_protos.h>
static struct DosBase *DosBase = nullptr;
static struct GfxBase *GfxBase = nullptr;

ファイルの表示

@ -55,7 +55,7 @@ void Evaluator::Evaluate() const
SyntaxNode* node = parser->Parse();
delete parser;
#ifdef DEBUGTREE
#if defined(DEBUGTREE)
Viewer* viewer = new Viewer(node);
const char* vout = viewer->GetTree();
output->EnsureGrowth(StrLen(vout));
@ -68,7 +68,7 @@ void Evaluator::Evaluate() const
node = optimizer->GetRoot();
delete optimizer;
#ifdef DEBUGTREE
#if defined(DEBUGTREE)
viewer = new Viewer(node);
vout = viewer->GetTree();
output->EnsureGrowth(StrLen(vout));

ファイルの表示

@ -209,7 +209,7 @@ SyntaxNode* Parser::ParseStatement()
case symexit:
res = new ExitStatement();
break;
#if !defined(STDC_CONSOLE)
#if !defined(AMIGA) && !defined(TERMIOS) && !defined(WINDOWS)
case symclear:
res = new ClearStatement();
break;

ファイルの表示

@ -90,7 +90,7 @@ char* HelpStatement::StatementHelp() const
output->ClearBuffer();
APPENDHELP(STATEMENTLINE)
#if !defined(STDC_CONSOLE)
#if !defined(AMIGA) && !defined(TERMIOS) && !defined(WINDOWS)
APPENDHELP(STATEMENTCLEAR)
#endif
APPENDHELP(STATEMENTDEF)

ファイルの表示

@ -32,7 +32,7 @@
#include "viewer.h"
#include "lib/charbuf.h"
#ifdef DEBUGTREE
#if defined(DEBUGTREE)
Viewer::Viewer(SyntaxNode* root)
{

ファイルの表示

@ -39,13 +39,12 @@
#include "nodes.h"
#include "lib/charbuf.h"
#ifdef DEBUGTREE
#if defined(DEBUGTREE)
/**
* @brief Control class displaying a syntax tree
* @details
* Define DEBUGTREE to enable the tree viewer.
*
*/
class Viewer
{

ファイルの表示

@ -31,7 +31,7 @@
#include "console_stdc.h"
#include "main/evaluator.h"
#if defined(STDC_CONSOLE)
#if !defined(AMIGA) && !defined(TERMIOS) && !defined(WINDOWS)
#include <stdio.h>
StandardConsole::StandardConsole(const char* prompt) :

ファイルの表示

@ -39,7 +39,7 @@
#include "amath.h"
#include "console.h"
#if defined(STDC_CONSOLE)
#if !defined(AMIGA) && !defined(TERMIOS) && !defined(WINDOWS)
/**
* @brief Encapsulates the IO of a Standard C console.

ファイルの表示

@ -30,27 +30,27 @@
#include "amath.h"
#include "amathc.h"
#include "console.h"
#include "console_posix.h"
#include "console_termios.h"
#include "lib/charval.h"
#include "lib/aengine.h"
#include "main/evaluator.h"
#if defined(POSIX)
#if defined(TERMIOS)
#include <stdio.h>
#include <termios.h>
PosixConsole::PosixConsole(const char* prompt, CharValidator* validator) :
TermiosConsole::TermiosConsole(const char* prompt, CharValidator* validator) :
ConsoleBase(prompt), line(nullptr), exit(false)
{
proc = new AnsiConoleEngine(prompt, validator);
}
PosixConsole::~PosixConsole()
TermiosConsole::~TermiosConsole()
{
delete proc;
}
bool PosixConsole::Open()
bool TermiosConsole::Open()
{
if (tcgetattr(STDIN_FILENO, &oldAttr) != 0)
{
@ -66,7 +66,7 @@ bool PosixConsole::Open()
return (tcsetattr(STDIN_FILENO, TCSANOW, &newAttr) != -1);
}
void PosixConsole::Close()
void TermiosConsole::Close()
{
if (!termError)
{
@ -74,7 +74,7 @@ void PosixConsole::Close()
}
}
void PosixConsole::Start()
void TermiosConsole::Start()
{
exit = false;
StartMessage();
@ -91,12 +91,12 @@ void PosixConsole::Start()
}
}
void PosixConsole::Exit()
void TermiosConsole::Exit()
{
exit = true;
}
void PosixConsole::ReadLine()
void TermiosConsole::ReadLine()
{
char c;
proc->StartInput();
@ -116,12 +116,12 @@ void PosixConsole::ReadLine()
line = proc->GetLine();
}
void PosixConsole::WriteString(const char* string)
void TermiosConsole::WriteString(const char* string)
{
Write(string, StrLen(string));
}
void PosixConsole::Write(const char* string, unsigned int length)
void TermiosConsole::Write(const char* string, unsigned int length)
{
ssize_t res = write(STDOUT_FILENO, string, length);
if (res != length)
@ -130,7 +130,7 @@ void PosixConsole::Write(const char* string, unsigned int length)
}
}
void PosixConsole::SetPrompt(const char* string)
void TermiosConsole::SetPrompt(const char* string)
{
ConsoleBase::SetPrompt(string);
proc->SetPrompt(string);

ファイルの表示

@ -27,11 +27,11 @@
*
*/
#ifndef AMATH_POSIX_CONSOLE
#define AMATH_POSIX_CONSOLE
#ifndef AMATH_TERMIOS_CONSOLE
#define AMATH_TERMIOS_CONSOLE
/**
* @file console_posix.h
* @file console_termios.h
* @brief Standard C and termios based console.
*
*/
@ -42,18 +42,18 @@
#include "lib/charval.h"
#include "lib/aengine.h"
#if defined(POSIX)
#if defined(TERMIOS)
#include <termios.h>
/**
* @brief Encapsulates the IO of a console using Standard C and termios.
*
*/
class PosixConsole : public ConsoleBase
class TermiosConsole : public ConsoleBase
{
public:
PosixConsole(const char* prompt, CharValidator* validator);
virtual ~PosixConsole();
TermiosConsole(const char* prompt, CharValidator* validator);
virtual ~TermiosConsole();
virtual bool Open();
virtual void Close();
virtual void Start();

ファイルの表示

@ -34,14 +34,12 @@
#include "lib/charbuf.h"
#include "loc/text.h"
#ifdef AMIGA
#if defined(AMIGA)
#include <clib/dos_protos.h>
/**
* @brief
*
* http://en.wikibooks.org/wiki/Aros/Developer/Docs/Libraries/DOS#Examine_Files_or_Directories
*
*/
CharBuffer* AmigaFilesystem::ListDirectory(const char* path)
{

ファイルの表示

@ -32,15 +32,14 @@
/**
* @file filesystem_amiga.h
* @brief Amiga OS specific file system calls.
*
* @brief Amiga OS specific file system calls
*/
#include "amath.h"
#include "amathc.h"
#include "filesystem.h"
#ifdef AMIGA
#if defined(AMIGA)
class AmigaFilesystem : public FilesystemBase
{

ファイルの表示

@ -40,6 +40,10 @@
#include <stdio.h>
#include <stdlib.h>
#if defined(UNIX) || defined(HAIKU)
#include <dirent.h>
#endif
CharBuffer* StandardFilesystem::ListDirectory(const char* path)
{
#if defined(UNIX) || defined(HAIKU)
@ -86,7 +90,7 @@ CharBuffer* StandardFilesystem::ListDirectory(const char* path)
const char *type;
#ifdef HAIKU
#if defined(HAIKU)
type = TXTLISTDIRTUNKNOWN;
#else
switch (entry->d_type) {

ファイルの表示

@ -32,7 +32,7 @@
/**
* @file filesystem_stdc.h
* @brief Standard C compliant file system calls.
* @brief Standard C compliant file system calls
*
*/
@ -55,5 +55,4 @@ private:
};
#endif
#endif

ファイルの表示

@ -41,7 +41,7 @@
static const texttag ansiTags[] = {
{"#HEADLINE#", "\x1B[1m"},
#ifdef UNIX
#if defined(UNIX)
{"#SYNTAXHIGHLIGHT#", "\x1B[3m\x1B[32m"},
#else
{"#SYNTAXHIGHLIGHT#", "\x1B[32m"},

ファイルの表示

@ -36,7 +36,7 @@
#include "loc/ident.h"
#include "loc/kword.h"
#ifdef AMIGA
#if defined(AMIGA)
#include <clib/locale_protos.h>
AmigaLanguage::AmigaLanguage() :

ファイルの表示

@ -30,11 +30,14 @@
#ifndef AMATH_LANGUAGE_AMIGA_H
#define AMATH_LANGUAGE_AMIGA_H
#include "amath.h"
#include "language.h"
#include "loc/help.h"
#include "loc/text.h"
#include "loc/kword.h"
#if defined(AMIGA)
class AmigaLanguage : public Language
{
public:
@ -64,3 +67,4 @@ private:
};
#endif
#endif

ファイルの表示

@ -1,126 +0,0 @@
/*-
* Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Project homepage:
* http://amath.innolan.net
*
*/
#include "amath.h"
#include "amathc.h"
#include "program.h"
#include "language_posix.h"
#include "loc/help.h"
#include "loc/text.h"
#include "loc/ident.h"
#include "loc/kword.h"
#if defined(UNIX)
#include <stdio.h>
#include <ctype.h> /* http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ctype.h.html */
#include <locale.h> /* http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/locale.h.html */
#include <nl_types.h> /* http://pubs.opengroup.org/onlinepubs/7908799/xsh/nl_types.h.html */
#include <string.h>
PosixLanguage::PosixLanguage() :
Language()
{
// locale = newlocale(LC_ALL, "da_DK.ISO8859-15", (locale_t)0);
// setlocale(LC_NUMERIC, "da_DK.ISO8859-15");
locale = newlocale(LC_ALL, "", (locale_t)0);
setlocale(LC_NUMERIC, "");
conv = localeconv();
}
PosixLanguage::~PosixLanguage()
{
freelocale(locale);
}
bool PosixLanguage::CharIsAlNum(long unsigned int character)
{
return (bool)isalnum_l((int)character, locale);
}
bool PosixLanguage::CharIsAlpha(long unsigned int character)
{
return (bool)isalpha_l((int)character, locale);
}
bool PosixLanguage::CharIsCntrl(long unsigned int character)
{
return (bool)iscntrl_l((int)character, locale);
}
bool PosixLanguage::CharIsDigit(long unsigned int character)
{
return (bool)isdigit_l((int)character, locale);
}
bool PosixLanguage::CharIsPunct(long unsigned int character)
{
return (bool)ispunct_l((int)character, locale);
}
bool PosixLanguage::CharIsSpace(long unsigned int character)
{
return (bool)isspace_l((int)character, locale);
}
char PosixLanguage::GetFractionPoint()
{
return *(conv->decimal_point);
}
bool PosixLanguage::StrIsEqualLoc(const char* s1, const char* s2)
{
size_t len = StrLen(s2) * 2;
char *tmp = new char[len];
strxfrm(tmp, s2, len);
bool res = StrIsEqual(s1, tmp);
delete [] tmp;
return res;
}
char* PosixLanguage::Translate(identhelpdef* def)
{
return (char*)def->text;
}
char* PosixLanguage::Translate(helptextdef* def)
{
return (char*)def->text;
}
char* PosixLanguage::Translate(textdef* def)
{
return (char*)def->text;
}
bool PosixLanguage::Validate(char c)
{
return (c >= 32 && c <= 126);
}
#endif

ファイルの表示

@ -1,70 +0,0 @@
/*-
* Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Project homepage:
* http://amath.innolan.net
*
*/
#ifndef _LANGUAGE_POSIX_H
#define _LANGUAGE_POSIX_H
#include "amath.h"
#include "amathc.h"
#include "language.h"
#include "loc/help.h"
#include "loc/text.h"
#include "loc/kword.h"
#ifdef UNIX
#include <ctype.h>
#include <locale.h>
#include <nl_types.h>
class PosixLanguage : public Language {
public:
PosixLanguage();
~PosixLanguage();
char GetFractionPoint();
bool CharIsAlNum(unsigned long character);
bool CharIsAlpha(unsigned long character);
bool CharIsDigit(unsigned long character);
bool CharIsPunct(unsigned long character);
bool CharIsSpace(unsigned long character);
bool CharIsCntrl(unsigned long character);
bool StrIsEqualLoc(const char *s1, const char *s2);
bool Validate(char c);
protected:
char* Translate(textdef *def);
char* Translate(helptextdef *def);
char* Translate(identhelpdef *def);
private:
locale_t locale;
struct lconv *conv;
};
#endif
#endif

ファイルの表示

@ -77,5 +77,4 @@ private:
};
#endif
#endif

ファイルの表示

@ -33,7 +33,7 @@
#include "preferences.h"
#include "preferences_amiga.h"
#ifdef AMIGA
#if defined(AMIGA)
#include <clib/dos_protos.h>
static const char *tempname = "ENV:amath.prefs";

ファイルの表示

@ -30,8 +30,11 @@
#ifndef AMATH_PREFERENCES_AMIGA_H
#define AMATH_PREFERENCES_AMIGA_H
#include "amath.h"
#include "preferences.h"
#if defined(AMIGA)
class AmigaPreferences : public PreferencesBase
{
public:
@ -44,3 +47,4 @@ private:
};
#endif
#endif

ファイルの表示

@ -33,7 +33,6 @@
#include "language.h"
#include "language_stdc.h"
#include "language_amiga.h"
#include "language_posix.h"
#include "filesystem.h"
#include "filesystem_stdc.h"
#include "filesystem_amiga.h"
@ -52,11 +51,7 @@ Program::Program() :
Variables = new VariableList();
Functions = new FunctionList();
ins = new RealNumber();
#if defined(UNIX)
Language = new PosixLanguage();
Filesystem = new StandardFilesystem();
Preferences = new StandardPreferences();
#elif defined(AMIGA)
#if defined(AMIGA)
Language = new AmigaLanguage();
Filesystem = new AmigaFilesystem();
Preferences = new AmigaPreferences();

ファイルの表示

@ -44,7 +44,7 @@
#define ARGS_FORMAT "SHELL/S,NOANSI/S,INPUT/F"
#include <clib/dos_protos.h>
#ifdef AOS3
#if defined(AOS3)
# define RDPTR LONG*
#else
# define RDPTR IPTR*

ファイルの表示

@ -33,7 +33,7 @@
#include "filesystem.h"
#include "program_haiku.h"
#include "window_haiku.h"
#include "console_posix.h"
#include "console_termios.h"
#include "lib/charbuf.h"
#include "main/evaluator.h"
@ -77,7 +77,7 @@ void HaikuProgram::Initialize(int argc, char **argv)
return;
}
Console = new PosixConsole(Preferences->GetPrompt(), Language);
Console = new TermiosConsole(Preferences->GetPrompt(), Language);
SetAnsiMode(true);
line = new CharBuffer();

ファイルの表示

@ -30,8 +30,8 @@
#include "amath.h"
#include "amathc.h"
#include "program_stdc.h"
#include "console_posix.h"
#include "console_stdc.h"
#include "console_termios.h"
#include "console_windows.h"
#include "preferences_stdc.h"
#include "lib/charbuf.h"
@ -65,8 +65,8 @@ void StandardProgram::Initialize(int argc, char** argv)
{
#if defined(WINDOWS)
Console = new WindowsConsole(Preferences->GetPrompt(), Language);
#elif defined(POSIX)
Console = new PosixConsole(Preferences->GetPrompt(), Language);
#elif defined(TERMIOS)
Console = new TermiosConsole(Preferences->GetPrompt(), Language);
#else
Console = new StandardConsole(Preferences->GetPrompt(), Language);
#endif

ファイルの表示

@ -275,28 +275,3 @@ void AmigaWindow::SetPrompt(const char* string)
}
#endif
//http://amigadev.elowar.com/read/ADCD_2.1/Libraries_Manual_guide/node046C.html#line6
//#include <devices/keymap.h>
//
//BOOL AskKeyMap(struct IOStdReq *request, struct KeyMap *keymap)
//{
// request->io_Command = CD_ASKKEYMAP;
// request->io_Length = sizeof(struct KeyMap);
// request->io_Data = (APTR)keymap; /* where to put it */
// DoIO(request);
// if(request->io_Error) return(FALSE);
// else return(TRUE); /* if no error, it worked. */
//}
//BOOL SetKeyMap(struct IOStdReq *request,struct KeyMap *keymap)
//{
// request->io_Command = CD_SETKEYMAP;
// request->io_Length = sizeof(struct KeyMap);
// request->io_Data = (APTR)keymap; /* where to get it */
// DoIO(request);
// if(request->io_Error) return(FALSE);
// else return(TRUE); /* if no error, it worked. */
//}

ファイルの表示

@ -94,4 +94,3 @@ private:
#endif
#endif