commit
8bb6f0e5c6
@ -1,43 +1,6 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
# Build the packing binary garbage.
|
||||
scpack = SM.Program(builder, 'scpack')
|
||||
if scpack.compiler.cc.behavior == 'msvc':
|
||||
scpack.compiler.linkflags.remove('/SUBSYSTEM:WINDOWS')
|
||||
scpack.compiler.linkflags.append('/SUBSYSTEM:CONSOLE')
|
||||
scpack.compiler.cxxflags.remove('/TP')
|
||||
scpack.sources = ['scpack.c']
|
||||
scpack = builder.Add(scpack)
|
||||
|
||||
# Generate pack files.
|
||||
packed_files = ['sc5', 'sc7']
|
||||
packed_includes = []
|
||||
for packed_file in packed_files:
|
||||
# The absolute path to sc5-in.scp etc.
|
||||
in_path = os.path.join(builder.currentSourcePath, '{0}-in.scp'.format(packed_file))
|
||||
|
||||
# The output file relative to the output folder, i.e. sourcepawn/compiler/sc5.scp.
|
||||
out_path = os.path.join(builder.buildFolder, '{0}.scp'.format(packed_file))
|
||||
|
||||
# The absolute path to the build folder, i.e. /Users/.../sourcepawn/compiler.
|
||||
build_folder = os.path.join(builder.buildPath, builder.buildFolder)
|
||||
|
||||
# scpack runs in ./sourcepawn/compiler/scpack/ so we build relative paths
|
||||
# from there.
|
||||
scpack_argv = [
|
||||
os.path.join(builder.buildPath, scpack.binary.path),
|
||||
os.path.relpath(in_path, build_folder),
|
||||
os.path.relpath(os.path.join(builder.buildPath, out_path), build_folder),
|
||||
]
|
||||
|
||||
_, (entry,) = builder.AddCommand(
|
||||
inputs = [scpack.binary, in_path],
|
||||
argv = scpack_argv,
|
||||
outputs = ['{0}.scp'.format(packed_file)],
|
||||
)
|
||||
packed_includes += [entry]
|
||||
|
||||
binary = SM.Program(builder, 'spcomp')
|
||||
compiler = binary.compiler
|
||||
compiler.includes += [
|
||||
@ -49,7 +12,6 @@ compiler.includes += [
|
||||
os.path.join(builder.buildPath, 'includes'),
|
||||
os.path.join(builder.buildPath, builder.buildFolder),
|
||||
]
|
||||
compiler.sourcedeps += packed_includes
|
||||
|
||||
if compiler.cc.behavior == 'gcc':
|
||||
compiler.cflags += ['-Wno-format']
|
||||
@ -90,7 +52,6 @@ binary.sources += [
|
||||
'sc5.cpp',
|
||||
'sc6.cpp',
|
||||
'sc7.cpp',
|
||||
'scexpand.cpp',
|
||||
'sci18n.cpp',
|
||||
'sclist.cpp',
|
||||
'scmemfil.cpp',
|
||||
|
@ -1,168 +1,146 @@
|
||||
/* Pawn compiler - Error message strings (plain and compressed formats)
|
||||
*
|
||||
* Copyright (c) ITB CompuPhase, 2000-2006
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software in
|
||||
* a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
size_t strexpand(char *dest, unsigned char *source, size_t maxlen, unsigned char pairtable[128][2]);
|
||||
|
||||
#ifndef SCPACK
|
||||
# define SCPACK
|
||||
# define SCPACK_PUSH
|
||||
#endif
|
||||
|
||||
#define SCPACK_TABLE errstr_table
|
||||
/*-*SCPACK start of pair table, do not change or remove this line */
|
||||
unsigned char errstr_table
[][2] = {
|
||||
{101,32}, {116,32}, {111,110}, {115,32}, {100,32}, {105,110}, {97,114}, {116,105}, {101,114}, {37,115}, {110,111}, {97,110}, {114,101}, {135,130}, {97,108}, {101,110},
|
||||
{117,110}, {111,114}, {34,137}, {146,34}, {121,32}, {138,129}, {115,105}, {101,132}, {115,116}, {97,116}, {100,101}, {109,143}, {116,104}, {32,147}, {41,10}, {109,98},
|
||||
{117,115}, {114,97}, {144,99}, {145,32}, {98,108}, {162,141}, {102,165}, {101,120}, {97,32}, {116,121}, {169,112}, {99,139}, {118,142}, {111,108}, {171,149}, {115,121},
|
||||
{115,10}, {175,159}, {136,32}, {134,161}, {177,173}, {103,32}, {116,111}, {115,150}, {103,117}, {105,132}, {184,155}, {134,186}, {101,131}, {105,131}, {160,129}, {44,32},
|
||||
{97,164}, {109,190}, {102,133}, {101,10}, {172,185}, {99,104}, {99,116}, {166,32}, {133,196}, {104,97}, {111,102}, {117,108}, {98,128}, {167,112}, {97,141}, {179,148},
|
||||
{110,32}, {109,97}, {101,100}, {99,111}, {99,130}, {37,131}, {118,134}, {180,157}, {202,32}, {105,192}, {214,217}, {109,101}, {111,112}, {137,10}, {130,32}, {99,108},
|
||||
{118,128}, {170,128}, {187,129}, {154,194}, {102,105}, {119,105}, {108,128}, {97,131}, {220,136}, {116,97}, {100,105}, {97,115}, {157,10}, {109,153}, {152,153}, {218,128},
|
||||
{139,132}, {215,158}, {133,32}, {110,97}, {201,224}, {40,241}, {116,117}, {150,122}, {156,128}, {212,152}, {34,32}, {138,32}, {139,32}, {142,32}, {156,32}
|
||||
};
|
||||
/*-*SCPACK end of pair table, do not change or remove this line */
|
||||
|
||||
static const char *errmsg[] = {
|
||||
#ifdef SCPACK
|
||||
/*001*/ "expected token: \"%s\", but found \"%s\"\n",
|
||||
/*002*/ "only a single statement (or expression) can follow each \"case\"\n",
|
||||
/*003*/ "declaration of a local variable must appear in a compound block\n",
|
||||
/*004*/ "function \"%s\" is not implemented\n",
|
||||
/*005*/ "function may not have arguments\n",
|
||||
/*006*/ "must be assigned to an array\n",
|
||||
/*007*/ "operator cannot be redefined\n",
|
||||
/*008*/ "must be a constant expression; assumed zero\n",
|
||||
/*009*/ "invalid array size (negative, zero or out of bounds)\n",
|
||||
/*010*/ "invalid function or declaration\n",
|
||||
/*011*/ "invalid outside functions\n",
|
||||
/*012*/ "invalid function call, not a valid address\n",
|
||||
/*013*/ "no entry point (no public functions)\n",
|
||||
/*014*/ "invalid statement; not in switch\n",
|
||||
/*015*/ "\"default\" case must be the last case in switch statement\n",
|
||||
/*016*/ "multiple defaults in \"switch\"\n",
|
||||
/*017*/ "undefined symbol \"%s\"\n",
|
||||
/*018*/ "initialization data exceeds declared size\n",
|
||||
/*019*/ "not a label: \"%s\"\n",
|
||||
/*020*/ "invalid symbol name \"%s\"\n",
|
||||
/*021*/ "symbol already defined: \"%s\"\n",
|
||||
/*022*/ "must be lvalue (non-constant)\n",
|
||||
/*023*/ "array assignment must be simple assignment\n",
|
||||
/*024*/ "\"break\" or \"continue\" is out of context\n",
|
||||
/*025*/ "function heading differs from prototype\n",
|
||||
/*026*/ "no matching \"#if...\"\n",
|
||||
/*027*/ "invalid character constant\n",
|
||||
/*028*/ "invalid subscript (not an array or too many subscripts): \"%s\"\n",
|
||||
/*029*/ "invalid expression, assumed zero\n",
|
||||
/*030*/ "compound statement not closed at the end of file (started at line %d)\n",
|
||||
/*031*/ "unknown directive\n",
|
||||
/*032*/ "array index out of bounds (variable \"%s\")\n",
|
||||
/*033*/ "array must be indexed (variable \"%s\")\n",
|
||||
/*034*/ "argument does not have a default value (argument %d)\n",
|
||||
/*035*/ "argument type mismatch (argument %d)\n",
|
||||
/*036*/ "empty statement\n",
|
||||
/*037*/ "invalid string (possibly non-terminated string)\n",
|
||||
/*038*/ "extra characters on line\n",
|
||||
/*039*/ "constant symbol has no size\n",
|
||||
/*040*/ "duplicate \"case\" label (value %d)\n",
|
||||
/*041*/ "invalid ellipsis, array size is not known\n",
|
||||
/*042*/ "invalid combination of class specifiers\n",
|
||||
/*043*/ "character constant exceeds range for packed string\n",
|
||||
/*044*/ "positional parameters must precede all named parameters\n",
|
||||
/*045*/ "too many function arguments\n",
|
||||
/*046*/ "unknown array size (variable \"%s\")\n",
|
||||
/*047*/ "array sizes do not match, or destination array is too small\n",
|
||||
/*048*/ "array (s do not match\n",
|
||||
/*049*/ "invalid line continuation\n",
|
||||
/*050*/ "invalid range\n",
|
||||
/*051*/ "invalid subscript, use \"[ ]\" operators on major dimensions\n",
|
||||
/*052*/ "multi-dimensional arrays must be fully initialized\n",
|
||||
/*053*/ "exceeding maximum number of dimensions\n",
|
||||
/*054*/ "unmatched closing brace (\"}\")\n",
|
||||
/*055*/ "start of function body without function header\n",
|
||||
/*056*/ "arrays, local variables and function arguments cannot be public (variable \"%s\")\n",
|
||||
/*057*/ "unfinished expression before compiler directive\n",
|
||||
/*058*/ "duplicate argument; same argument is passed twice\n",
|
||||
/*059*/ "function argument may not have a default value (variable \"%s\")\n",
|
||||
/*060*/ "multiple \"#else\" directives between \"#if ... #endif\"\n",
|
||||
/*061*/ "\"#elseif\" directive follows an \"#else\" directive\n",
|
||||
/*062*/ "number of operands does not fit the operator\n",
|
||||
/*063*/ "function result tag of operator \"%s\" must be \"%s\"\n",
|
||||
/*064*/ "cannot change predefined operators\n",
|
||||
/*065*/ "function argument may only have a single tag (argument %d)\n",
|
||||
/*066*/ "function argument may not be a reference argument or an array (argument \"%s\")\n",
|
||||
/*067*/ "variable cannot be both a reference and an array (variable \"%s\")\n",
|
||||
/*068*/ "invalid rational number precision in #pragma\n",
|
||||
/*069*/ "rational number format already defined\n",
|
||||
/*070*/ "rational number support was not enabled\n",
|
||||
/*071*/ "user-defined operator must be declared before use (function \"%s\")\n",
|
||||
/*072*/ "\"sizeof\" operator is invalid on \"function\" symbols\n",
|
||||
/*073*/ "function argument must be an array (argument \"%s\")\n",
|
||||
/*074*/ "#define pattern must start with an alphabetic character\n",
|
||||
/*075*/ "input line too long (after substitutions)\n",
|
||||
/*076*/ "syntax error in the expression, or invalid function call\n",
|
||||
/*077*/ "malformed UTF-8 encoding, or corrupted file: %s\n",
|
||||
/*078*/ "function uses both \"return\" and \"return <value>\"\n",
|
||||
/*079*/ "inconsistent return types (array & non-array)\n",
|
||||
/*080*/ "unknown symbol, or not a constant symbol (symbol \"%s\")\n",
|
||||
/*081*/ "cannot take a tag as a default value for an indexed array parameter (symbol \"%s\")\n",
|
||||
/*082*/ "user-defined operators and native functions may not have states\n",
|
||||
/*083*/ "a function or variable may only belong to a single automaton (symbol \"%s\")\n",
|
||||
/*084*/ "state conflict: one of the states is already assigned to another implementation (symbol \"%s\")\n",
|
||||
/*085*/ "no states are defined for symbol \"%s\"\n",
|
||||
/*086*/ "unknown automaton \"%s\"\n",
|
||||
/*087*/ "unknown state \"%s\" for automaton \"%s\"\n",
|
||||
/*088*/ "public variables and local variables may not have states (symbol \"%s\")\n",
|
||||
/*089*/ "state variables may not be initialized (symbol \"%s\")\n",
|
||||
/*090*/ "public functions may not return arrays (symbol \"%s\")\n",
|
||||
/*091*/ "ambiguous constant; tag override is required (symbol \"%s\")\n",
|
||||
/*092*/ "number of arguments does not match definition\n",
|
||||
/*093*/ "expected tag name identifier\n",
|
||||
/*094*/ "function enumeration requires unique tag\n",
|
||||
/*095*/ "cannot have required parameters after optional parameters\n",
|
||||
/*096*/ "could not find member \"%s\" in struct \"%s\"\n",
|
||||
/*097*/ "symbol \"%s\" does not have a matching type\n",
|
||||
/*098*/ "type \"%s\" should be \"%s\" in new-style declarations\n",
|
||||
/*099*/ "%s should not have an explicit return type\n",
|
||||
/*100*/ "function prototypes do not match\n",
|
||||
/*101*/ "specify either all dimensions or only the last dimension\n",
|
||||
/*102*/ "cannot find %s %s\n",
|
||||
/*103*/ "%s was already defined on this %s\n",
|
||||
/*104*/ "cannot find any methods for %s\n",
|
||||
/*105*/ "cannot find method or property %s.%s\n",
|
||||
/*106*/ "cannot call methods on an array\n",
|
||||
/*107*/ "cannot call methods on a function\n",
|
||||
/*108*/ "method must have a first argument compatible with the %s type (%s)\n",
|
||||
/*109*/ "%s name must start with an uppercase letter\n",
|
||||
/*110*/ "%s has already been defined (previously seen as %s)\n",
|
||||
/*111*/ "expected identifier - did you forget a type?\n",
|
||||
/*112*/ "constructor function must return tag %s\n",
|
||||
/*113*/ "constructor for \"%s\" already exists\n",
|
||||
/*114*/ "missing type, or %s must have the same name as %s \"%s\"\n",
|
||||
/*115*/ "cannot use delete, %s %s has no destructor\n",
|
||||
/*116*/ "no methodmap or class was found for %s\n",
|
||||
/*117*/ "no destructor was found for %s %s\n",
|
||||
/*118*/ "destructors must be native functions\n",
|
||||
/*119*/ "destructors cannot have extra arguments\n",
|
||||
/* Pawn compiler - Error message strings (plain and compressed formats)
|
||||
*
|
||||
* Copyright (c) ITB CompuPhase, 2000-2006
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software in
|
||||
* a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
static const char *errmsg[] = {
|
||||
/*001*/ "expected token: \"%s\", but found \"%s\"\n",
|
||||
/*002*/ "only a single statement (or expression) can follow each \"case\"\n",
|
||||
/*003*/ "declaration of a local variable must appear in a compound block\n",
|
||||
/*004*/ "function \"%s\" is not implemented\n",
|
||||
/*005*/ "function may not have arguments\n",
|
||||
/*006*/ "must be assigned to an array\n",
|
||||
/*007*/ "operator cannot be redefined\n",
|
||||
/*008*/ "must be a constant expression; assumed zero\n",
|
||||
/*009*/ "invalid array size (negative, zero or out of bounds)\n",
|
||||
/*010*/ "invalid function or declaration\n",
|
||||
/*011*/ "invalid outside functions\n",
|
||||
/*012*/ "invalid function call, not a valid address\n",
|
||||
/*013*/ "no entry point (no public functions)\n",
|
||||
/*014*/ "invalid statement; not in switch\n",
|
||||
/*015*/ "\"default\" case must be the last case in switch statement\n",
|
||||
/*016*/ "multiple defaults in \"switch\"\n",
|
||||
/*017*/ "undefined symbol \"%s\"\n",
|
||||
/*018*/ "initialization data exceeds declared size\n",
|
||||
/*019*/ "not a label: \"%s\"\n",
|
||||
/*020*/ "invalid symbol name \"%s\"\n",
|
||||
/*021*/ "symbol already defined: \"%s\"\n",
|
||||
/*022*/ "must be lvalue (non-constant)\n",
|
||||
/*023*/ "array assignment must be simple assignment\n",
|
||||
/*024*/ "\"break\" or \"continue\" is out of context\n",
|
||||
/*025*/ "function heading differs from prototype\n",
|
||||
/*026*/ "no matching \"#if...\"\n",
|
||||
/*027*/ "invalid character constant\n",
|
||||
/*028*/ "invalid subscript (not an array or too many subscripts): \"%s\"\n",
|
||||
/*029*/ "invalid expression, assumed zero\n",
|
||||
/*030*/ "compound statement not closed at the end of file (started at line %d)\n",
|
||||
/*031*/ "unknown directive\n",
|
||||
/*032*/ "array index out of bounds (variable \"%s\")\n",
|
||||
/*033*/ "array must be indexed (variable \"%s\")\n",
|
||||
/*034*/ "argument does not have a default value (argument %d)\n",
|
||||
/*035*/ "argument type mismatch (argument %d)\n",
|
||||
/*036*/ "empty statement\n",
|
||||
/*037*/ "invalid string (possibly non-terminated string)\n",
|
||||
/*038*/ "extra characters on line\n",
|
||||
/*039*/ "constant symbol has no size\n",
|
||||
/*040*/ "duplicate \"case\" label (value %d)\n",
|
||||
/*041*/ "invalid ellipsis, array size is not known\n",
|
||||
/*042*/ "invalid combination of class specifiers\n",
|
||||
/*043*/ "character constant exceeds range for packed string\n",
|
||||
/*044*/ "positional parameters must precede all named parameters\n",
|
||||
/*045*/ "too many function arguments\n",
|
||||
/*046*/ "unknown array size (variable \"%s\")\n",
|
||||
/*047*/ "array sizes do not match, or destination array is too small\n",
|
||||
/*048*/ "array (s do not match\n",
|
||||
/*049*/ "invalid line continuation\n",
|
||||
/*050*/ "invalid range\n",
|
||||
/*051*/ "invalid subscript, use \"[ ]\" operators on major dimensions\n",
|
||||
/*052*/ "multi-dimensional arrays must be fully initialized\n",
|
||||
/*053*/ "exceeding maximum number of dimensions\n",
|
||||
/*054*/ "unmatched closing brace (\"}\")\n",
|
||||
/*055*/ "start of function body without function header\n",
|
||||
/*056*/ "arrays, local variables and function arguments cannot be public (variable \"%s\")\n",
|
||||
/*057*/ "unfinished expression before compiler directive\n",
|
||||
/*058*/ "duplicate argument; same argument is passed twice\n",
|
||||
/*059*/ "function argument may not have a default value (variable \"%s\")\n",
|
||||
/*060*/ "multiple \"#else\" directives between \"#if ... #endif\"\n",
|
||||
/*061*/ "\"#elseif\" directive follows an \"#else\" directive\n",
|
||||
/*062*/ "number of operands does not fit the operator\n",
|
||||
/*063*/ "function result tag of operator \"%s\" must be \"%s\"\n",
|
||||
/*064*/ "cannot change predefined operators\n",
|
||||
/*065*/ "function argument may only have a single tag (argument %d)\n",
|
||||
/*066*/ "function argument may not be a reference argument or an array (argument \"%s\")\n",
|
||||
/*067*/ "variable cannot be both a reference and an array (variable \"%s\")\n",
|
||||
/*068*/ "invalid rational number precision in #pragma\n",
|
||||
/*069*/ "rational number format already defined\n",
|
||||
/*070*/ "rational number support was not enabled\n",
|
||||
/*071*/ "user-defined operator must be declared before use (function \"%s\")\n",
|
||||
/*072*/ "\"sizeof\" operator is invalid on \"function\" symbols\n",
|
||||
/*073*/ "function argument must be an array (argument \"%s\")\n",
|
||||
/*074*/ "#define pattern must start with an alphabetic character\n",
|
||||
/*075*/ "input line too long (after substitutions)\n",
|
||||
/*076*/ "syntax error in the expression, or invalid function call\n",
|
||||
/*077*/ "malformed UTF-8 encoding, or corrupted file: %s\n",
|
||||
/*078*/ "function uses both \"return\" and \"return <value>\"\n",
|
||||
/*079*/ "inconsistent return types (array & non-array)\n",
|
||||
/*080*/ "unknown symbol, or not a constant symbol (symbol \"%s\")\n",
|
||||
/*081*/ "cannot take a tag as a default value for an indexed array parameter (symbol \"%s\")\n",
|
||||
/*082*/ "user-defined operators and native functions may not have states\n",
|
||||
/*083*/ "a function or variable may only belong to a single automaton (symbol \"%s\")\n",
|
||||
/*084*/ "state conflict: one of the states is already assigned to another implementation (symbol \"%s\")\n",
|
||||
/*085*/ "no states are defined for symbol \"%s\"\n",
|
||||
/*086*/ "unknown automaton \"%s\"\n",
|
||||
/*087*/ "unknown state \"%s\" for automaton \"%s\"\n",
|
||||
/*088*/ "public variables and local variables may not have states (symbol \"%s\")\n",
|
||||
/*089*/ "state variables may not be initialized (symbol \"%s\")\n",
|
||||
/*090*/ "public functions may not return arrays (symbol \"%s\")\n",
|
||||
/*091*/ "ambiguous constant; tag override is required (symbol \"%s\")\n",
|
||||
/*092*/ "number of arguments does not match definition\n",
|
||||
/*093*/ "expected tag name identifier\n",
|
||||
/*094*/ "function enumeration requires unique tag\n",
|
||||
/*095*/ "cannot have required parameters after optional parameters\n",
|
||||
/*096*/ "could not find member \"%s\" in struct \"%s\"\n",
|
||||
/*097*/ "symbol \"%s\" does not have a matching type\n",
|
||||
/*098*/ "type \"%s\" should be \"%s\" in new-style declarations\n",
|
||||
/*099*/ "%s should not have an explicit return type\n",
|
||||
/*100*/ "function prototypes do not match\n",
|
||||
/*101*/ "specify either all dimensions or only the last dimension\n",
|
||||
/*102*/ "cannot find %s %s\n",
|
||||
/*103*/ "%s was already defined on this %s\n",
|
||||
/*104*/ "cannot find any methods for %s\n",
|
||||
/*105*/ "cannot find method or property %s.%s\n",
|
||||
/*106*/ "cannot call methods on an array\n",
|
||||
/*107*/ "cannot call methods on a function\n",
|
||||
/*108*/ "method must have a first argument compatible with the %s type (%s)\n",
|
||||
/*109*/ "%s name must start with an uppercase letter\n",
|
||||
/*110*/ "%s has already been defined (previously seen as %s)\n",
|
||||
/*111*/ "expected identifier - did you forget a type?\n",
|
||||
/*112*/ "constructor function must return tag %s\n",
|
||||
/*113*/ "constructor for \"%s\" already exists\n",
|
||||
/*114*/ "missing type, or %s must have the same name as %s \"%s\"\n",
|
||||
/*115*/ "cannot use delete, %s %s has no destructor\n",
|
||||
/*116*/ "no methodmap or class was found for %s\n",
|
||||
/*117*/ "no destructor was found for %s %s\n",
|
||||
/*118*/ "destructors must be native functions\n",
|
||||
/*119*/ "destructors cannot have extra arguments\n",
|
||||
/*120*/ "methodmap and class signatures must use new-style type declarations\n",
|
||||
/*121*/ "cannot specify array dimensions on both type and name\n",
|
||||
/*122*/ "expected type expression\n",
|
||||
@ -222,292 +200,73 @@ static const char *errmsg[] = {
|
||||
/*176*/ "non-static method or property '%s' must be called with a value of type '%s'\n",
|
||||
/*177*/ "static method '%s' must be invoked via its type (try '%s.%s')\n",
|
||||
/*178*/ "cannot coerce %s[] to %s[]; storage classes differ\n",
|
||||
/*179*/ "cannot assign %s[] to %s[], storage classes differ\n",
|
||||
/*180*/ "function return type differs from prototype. expected '%s', but got '%s'\n",
|
||||
/*179*/ "cannot assign %s[] to %s[], storage classes differ\n",
|
||||
/*180*/ "function return type differs from prototype. expected '%s', but got '%s'\n",
|
||||
/*181*/ "function argument named '%s' differs from prototype\n",
|
||||
/*182*/ "functions that return arrays cannot be used as callbacks\n",
|
||||
#else
|
||||
"\315e\306\227\266k\217:\235\277bu\201fo\220\204\223\012",
|
||||
"\202l\224\250s\205g\346\356e\233\201(\243\315\214\267\202) \253 f\255low ea\305 \042c\353e\042\012",
|
||||
"\232\337\206\316 \330\250loc\375\357\301appe\206 \362\250\323mpo\220\204\244ock\012",
|
||||
"\246\235 \275\225imple\233t\322\012",
|
||||
"\307\321\224\225\364\273t\260",
|
||||
"\301\314a\267gn\227\266 \374\263y\012",
|
||||
"\350\231\243\256\314\214\343\322\012",
|
||||
"\301\314\250\371\213\201\315\214\267\202; \353sum\227z\210o\012",
|
||||
"\310\317\367\200(nega\207ve\277z\210o \243ou\201\330bo\220ds\236",
|
||||
"\310\307\243\232\337\206\316\012",
|
||||
"\310out\226d\200\246\260",
|
||||
"\310\307c\216l\277\225\250\304add\214s\260",
|
||||
"\373\217tr\224po\205\201(\373pu\244ic \246s\236",
|
||||
"\310\356e\233t; \225\362s\345t\305\012",
|
||||
"\042\232fa\313t\372c\353\200\301\314\370l\353\201c\353\200\362s\345t\305 \356e\233t\012",
|
||||
"m\313\207p\346\232fa\313t\203\362\042s\345t\305\042\012",
|
||||
"\220\343\227\327\012",
|
||||
"\205i\207\216iz\316 d\231\250\247ce\322\203\232\337\206\227\367\303",
|
||||
"\225\250label:\354",
|
||||
"\310\264 \363m\200\223\012",
|
||||
"\264 \216\214ad\224\343\322:\354",
|
||||
"\301\314l\254u\200(n\202-\371\213t\236",
|
||||
"\317a\267gn\233\201\301\314\226mp\346a\267gn\233t\012",
|
||||
"\042b\214ak\372\243\042\324t\205ue\372\275ou\201\330\324t\247t\012",
|
||||
"\307head\205\265\352ff\210\203from pro\266\252\303",
|
||||
"\373\355\305\205\265\042#if...\042\012",
|
||||
"\310\305\206a\306\262\371\213t\012",
|
||||
"\310subscrip\201(\225\374\317\243\266o m\213\224subscripts):\354",
|
||||
"\310\315\214\267\202\277\353sum\227z\210o\012",
|
||||
"\323mpo\220\204\356e\233\201\225\337os\227a\201\370\217\204\330\344\346(\230\206t\227a\201l\205\200%d\236",
|
||||
"\220k\212w\320\352\214c\207v\303",
|
||||
"\317\205\232x ou\201\330bo\220d\203(\357\223\236",
|
||||
"\317\301\314\205\232x\227(\357\223\236",
|
||||
"\342do\274\225\364\250\232fa\313\201\254u\200(\342%d\236",
|
||||
"\342\341mis\355\305 (\342%d\236",
|
||||
"empt\224\356e\233t\012",
|
||||
"\310\230r\205\265(po\267\244\224n\202-t\210m\205\231\227\230r\205g\236",
|
||||
"\247t\241 \305\206a\306\210\203\336l\205\303",
|
||||
"\371\213\201\264 \311\203\373\367\303",
|
||||
"duplic\231\200\042c\353e\372label (\254u\200%d\236",
|
||||
"\310ellip\226s\277\317\367\200\275\225k\212wn\012",
|
||||
"\310\323\237\205\316 \330\337\353\203speci\344\210\260",
|
||||
"\305\206a\306\262\371\213\201\247ce\322\203r\213g\200f\243pack\227\230r\205g\012",
|
||||
"po\226\215\375p\206a\333t\210\203\301p\214c\322\200\216l \363m\227p\206a\333t\210\260",
|
||||
"\266o m\213\224\307\273t\260",
|
||||
"\220k\212w\320\317\367\200(\357\223\236",
|
||||
"\317\367\274do \225\355\305\277\243\232\230\205\316 \317\275\266o sm\216l\012",
|
||||
"\317(\203do \225\355\305\012",
|
||||
"\310l\205\200\324t\205u\316\012",
|
||||
"\310r\213g\303",
|
||||
"\310subscript\277\240\200\042[ ]\372\350\231\221\203\336\321j\243\352\233\226\202\260",
|
||||
"m\313\207-\352\233\226\202\375\263y\203\301\314f\313l\224\205i\207\216iz\322\012",
|
||||
"\247ce\322\205\265\321ximum nu\237\262\330\352\233\226\202\260",
|
||||
"\220\355\305\227\337os\205\265b\241c\200(\042}\042\236",
|
||||
"\230\206\201\330\307bod\224\345\234ou\201\307head\210\012",
|
||||
"\263ys\277loc\375\332\274\360\307\273t\203\256\314pu\244ic (\357\223\236",
|
||||
"\220\302ish\227\315\214\267\336bef\221\200\323mpil\262\352\214c\207v\303",
|
||||
"duplic\231\200\273t; sam\200\342\275p\353s\227t\345c\303",
|
||||
"\307\342\321\224\225\364\250\232fa\313\201\254u\200(\357\223\236",
|
||||
"m\313\207p\346\042#else\372\352\214c\207v\274betwe\217 \042#if ... #\217\352f\042\012",
|
||||
"\042#elseif\372\352\214c\207\340f\255low\203\374\042#else\372\352\214c\207v\303",
|
||||
"nu\237\262\330\350\213d\203do\274\225\344\201\370\350\231\221\012",
|
||||
"\307\214s\313\201\351\265\330\350\231\221\235 \301\314\223\012",
|
||||
"\256\305\213g\200p\214\343\227\350\231\221\260",
|
||||
"\307\342\321\224\202l\224\364\250s\205g\346\351\265(\342%d\236",
|
||||
"\307\342\321\224\225\314\250\214f\210\217c\200\342\243\374\317(\342\223\236",
|
||||
"\357\256\314bo\376\250\214f\210\217c\200\360\374\317(\357\223\236",
|
||||
"\310\241\215\375nu\237\262p\214ci\226\336\362#p\241g\321\012",
|
||||
"\241\215\375nu\237\262f\221\321\201\216\214ad\224\343\322\012",
|
||||
"\241\215\375nu\237\262supp\221\201w\347\225\217\300\322\012",
|
||||
"\240\210-\343\227\350\231\243\301\314\232\337\206\227bef\221\200\240\200(\246\235\236",
|
||||
"\042\367e\312\372\350\231\243\275\310\336\042\246\372\264\260",
|
||||
"\307\342\301\314\374\317(\342\223\236",
|
||||
"#\343\200p\231t\210\320\301\230\206\201\345\376\374\216p\311be\207c \305\206a\306\210\012",
|
||||
"\205pu\201l\205\200\266o l\202\265(aft\262subs\207\366\215s\236",
|
||||
"\257n\351x \210r\243\362\370\315\214\267\202\277\243\310\307c\216l\012",
|
||||
"m\216f\221m\227UTF-8 \217\323d\205g\277\243c\221rupt\227\344le: \335",
|
||||
"\307\240\274bo\376\042\214\366rn\372\360\042\214\366r\320<\254ue>\042\012",
|
||||
"\205\324\226\230\217\201\214\366r\320\252\274(\317& n\202-\263y\236",
|
||||
"\220k\212w\320\264\277\243\225\250\371\213\201\264 \365",
|
||||
"\256\351k\200\250\351\265\347\250\232fa\313\201\254u\200f\243\374\205\232x\227\317p\206a\333t\262\365",
|
||||
"\240\210-\343\227\350\231\221\203\360\363\207\340\246\203\321\224\225\364\356e\260",
|
||||
"\250\307\243\357\321\224\202l\224bel\202\265\266 \250s\205g\346au\266\355\336\365",
|
||||
"\356\200\324fli\306: \202\200\330\370\356\274\275\216\214ad\224a\267gn\227\266 a\212\234\262imple\233t\316 \365",
|
||||
"\373\356\274\206\200\343\227f\243\327\012",
|
||||
"\220k\212w\320au\266\355\202\354",
|
||||
"\220k\212w\320\356\200\223 f\243au\266\355\202\354",
|
||||
"pu\244ic \332\274\360loc\375\332\274\321\224\225\364\356\274\365",
|
||||
"\356\200\332\274\321\224\225\314\205i\207\216iz\227\365",
|
||||
"pu\244ic \246\203\321\224\225\214\366r\320\263y\203\365",
|
||||
"a\237i\270ou\203\371\213t; \351\265ov\210rid\200\275\214qui\214\204\365",
|
||||
"nu\237\262\330\273t\203do\274\225\355\305 \343i\215\012",
|
||||
"\315e\306\227\351\265\363m\200id\217\207\344\210\012",
|
||||
"\307\217um\210\316 \214qui\214\203\220iqu\200\351g\012",
|
||||
"\256\364\214qui\214\204p\206a\333t\210\203aft\262\334\215\375p\206a\333t\210\260",
|
||||
"\323\313\204\225\302\204\333\237\210\235 \362\230ruc\201\223\012",
|
||||
"\327 do\274\225\364\250\355\305\205\265\252\303",
|
||||
"\341\223 sho\313\204\314\223 \362new-\230y\346\232\337\206\316\260",
|
||||
"\325sho\313\204\225\364\374\315lici\201\214\366r\320\252\303",
|
||||
"\307pro\266\252\274do \225\355\305\012",
|
||||
"specif\224ei\234\262\216l \352\233\226\202\203\243\202l\224\370l\353\201\352\233\226\202\012",
|
||||
"\256\302\204\325\335",
|
||||
"\325w\347\216\214ad\224\343\227\336\234\275\335",
|
||||
"\256\302\204\213\224\333\234od\203f\243\335",
|
||||
"\256\302\204\333\234o\204\243pr\350t\224\211.\335",
|
||||
"\256c\216l \333\234od\203\336\374\263y\012",
|
||||
"\256c\216l \333\234od\203\336\250\246\012",
|
||||
"\333\234o\204\301\364\250\344rs\201\342\323mpa\207\244\200\345\376\370\325\341(\211\236",
|
||||
"\325\363m\200\301\230\206\201\345\376\374upp\210c\353\200lett\210\012",
|
||||
"\325\311\203\216\214ad\224be\217 \343\227(p\214vio\240l\224se\217 \347\211\236",
|
||||
"\315e\306\227id\217\207\344\262- d\271you f\221ge\201\250\252e?\012",
|
||||
"\371ru\306\243\307\301\214\366r\320\351\265\335",
|
||||
"\256\343\200\371ru\306\243f\221\235; \216\214ad\224\247i\230\203\347\250\335",
|
||||
"miss\205\265\252e\277\243\325\301\364\370sam\200\363m\200\347\325\223\012",
|
||||
"\256\240\200\232lete\277\325\325\311\203\373\232\230ru\306\221\012",
|
||||
"\373\333\234od\321p \243\337\353\203w\347fo\220\204f\243\335",
|
||||
"\373\232\230ru\306\243w\347fo\220\204f\243\325\335",
|
||||
"\232\230ru\306\221\203\301\314\363\207\340\246\260",
|
||||
"\232\230ru\306\221\203\256\364\247t\241 \273t\260",
|
||||
"\333\234od\321p \360\337\353\203\226gn\231u\214\203\301\240\200new-\230y\346\341\232\337\206\316\260",
|
||||
"\256specif\224\317\352\233\226\202\203\336bo\376\341\360\363m\303",
|
||||
"\315e\306\227\341\315\214\267\202\012",
|
||||
"f\313ly-qu\216i\344\227\363m\200\223 \275\266o l\202g\277wo\313\204\314tr\242\231\227\266\354",
|
||||
"\220\315e\306\227\266k\217\277\315e\306\227\333\234o\204\243pr\350\251\012",
|
||||
"\315e\306\227\042\363\207ve\042\277\042get\042\277\243\042set\042\012",
|
||||
"\325f\243\325\216\214ad\224\247i\230\260",
|
||||
"pr\350t\224gett\210\203\256accep\201\247t\241 \273t\260",
|
||||
"\325\301\364\370sam\200\214\366r\320\341\347pr\350t\224\325(\211\236",
|
||||
"\256mix \333\234od\321p\203\360\337\353s\274\345\376\205h\210it\213c\303",
|
||||
"\256\323\210c\200\246\203\266 \254ue\260",
|
||||
"\256\323\210c\200objec\201\341\325\266 n\202-objec\201\341\335",
|
||||
"\256\323\210c\200n\202-objec\201\341\325\266 objec\201\341\335",
|
||||
"\256\323\210c\200\220\214l\231\227objec\201\252\274\325\360\335",
|
||||
"\341mis\355\305 (\325\360\211\236",
|
||||
"\256\240\200\374objec\201\362\250m\313\207-\351\265sele\306\221\012",
|
||||
"\263y\203\206\200\225supp\221t\227\347\214\366r\320\252e\260",
|
||||
"\256mix \214f\210\217c\200\360\317\252e\260",
|
||||
"\324s\201w\347speci\344\227t\345c\303",
|
||||
"\323\313\204\225\302\204\341\223\012",
|
||||
"new-\230y\346\317\252\274\256specif\224\352\233\226\336\367\274\347p\206\201\330\234eir \252\303",
|
||||
"\363\207ves\277f\221w\206ds\277\360pu\244ic \246\203\256\214\366r\320\263y\260",
|
||||
"\310\341\232\337\206\316\012",
|
||||
"new-\230y\346\232\337\206\316\203sho\313\204\225\364\042new\042\012",
|
||||
"vo\271\256\314\240\227\347\250\357\252\303",
|
||||
"\310\341\315\214\267\202\012",
|
||||
"#p\241gm\250new\232\337\203\301\314\214qui\214\204\243\334\215\216\012",
|
||||
"new-\230y\346\232\337\206\316\203\206\200\214qui\214d\012",
|
||||
"\256a\267g\320n\313l \266 \250n\202-n\313l\300\200\252\303",
|
||||
"\373gett\262fo\220\204f\243pr\350t\224\335",
|
||||
"sett\262\301\351k\200\247a\306l\224\202\200\247t\241 \342\345\376\341\335",
|
||||
"sett\262\301\214\366r\320void\012",
|
||||
"\373sett\262fo\220\204f\243pr\350t\224\335",
|
||||
"\256\240\200n\202-pu\244ic \246\203\347c\216lback\260",
|
||||
"\256a\267g\320INVALID_FUNCTION \266 \250n\202-\307\252\303",
|
||||
"\315e\306\227newl\205e\277bu\201fo\220\204'\211'\012",
|
||||
"\370'\213y' \341\275\225\216low\227\362new-\230y\346\363\207ve\260",
|
||||
"'\211' \275\250\214s\210v\227keyw\221d\012"
|
||||
#endif
|
||||
};
|
||||
|
||||
static const char *fatalmsg[] = {
|
||||
#ifdef SCPACK
|
||||
/*182*/ "cannot read from file: \"%s\"\n",
|
||||
/*183*/ "cannot write to file: \"%s\"\n",
|
||||
/*184*/ "table overflow: \"%s\"\n",
|
||||
/* table can be: loop table
|
||||
* literal table
|
||||
* staging buffer
|
||||
* option table (response file)
|
||||
* peephole optimizer table
|
||||
*/
|
||||
/*185*/ "insufficient memory\n",
|
||||
/*186*/ "invalid assembler instruction \"%s\"\n",
|
||||
/*187*/ "numeric overflow, exceeding capacity\n",
|
||||
/*188*/ "compiled script exceeds the maximum memory size (%ld bytes)\n",
|
||||
/*189*/ "too many error messages on one line\n",
|
||||
/*190*/ "codepage mapping file not found\n",
|
||||
/*191*/ "invalid path: \"%s\"\n",
|
||||
/*192*/ "assertion failed: %s\n",
|
||||
/*193*/ "user error: %s\n",
|
||||
#else
|
||||
"\256\214a\204from \344le:\354",
|
||||
"\256writ\200\266 \344le:\354",
|
||||
"t\300\200ov\210flow:\354",
|
||||
"\205suf\344ci\217\201\333m\221y\012",
|
||||
"\310\353se\237l\262\205\230ruc\215\354",
|
||||
"num\210ic ov\210flow\277\247ce\322\205\265capaci\251\012",
|
||||
"\323mpil\227scrip\201\247ce\322\203\370\321ximum \333m\221\224\367\200(%l\204bytes\236",
|
||||
"\266o m\213\224\210r\243\333ssag\274\336\202\200l\205\303",
|
||||
"\323\232pag\200\321pp\205\265\344\346\225fo\220d\012",
|
||||
"\310p\231h:\354",
|
||||
"\353s\210\215 fail\322: \335",
|
||||
"\240\262\210r\221: \335"
|
||||
#endif
|
||||
};
|
||||
|
||||
static const char *warnmsg[] = {
|
||||
#ifdef SCPACK
|
||||
/*200*/ "symbol \"%s\" is truncated to %d characters\n",
|
||||
/*201*/ "redefinition of constant/macro (symbol \"%s\")\n",
|
||||
/*202*/ "number of arguments does not match definition\n",
|
||||
/*203*/ "symbol is never used: \"%s\"\n",
|
||||
/*204*/ "symbol is assigned a value that is never used: \"%s\"\n",
|
||||
/*205*/ "redundant code: constant expression is zero\n",
|
||||
/*206*/ "redundant test: constant expression is non-zero\n",
|
||||
/*207*/ "unknown #pragma\n",
|
||||
/*208*/ "function with tag result used before definition, forcing reparse\n",
|
||||
/*209*/ "function \"%s\" should return a value\n",
|
||||
/*210*/ "possible use of symbol before initialization: \"%s\"\n",
|
||||
/*211*/ "possibly unintended assignment\n",
|
||||
/*212*/ "possibly unintended bitwise operation\n",
|
||||
/*213*/ "tag mismatch\n",
|
||||
/*214*/ "possibly a \"const\" array argument was intended: \"%s\"\n",
|
||||
/*215*/ "expression has no effect\n",
|
||||
/*216*/ "nested comment\n",
|
||||
/*217*/ "loose indentation\n",
|
||||
/*218*/ "old style prototypes used with optional semicolumns\n",
|
||||
/*219*/ "local variable \"%s\" shadows a variable at a preceding level\n",
|
||||
/*220*/ "expression with tag override must appear between parentheses\n",
|
||||
/*221*/ "label name \"%s\" shadows tag name\n",
|
||||
/*222*/ "number of digits exceeds rational number precision\n",
|
||||
/*223*/ "redundant \"sizeof\": argument size is always 1 (symbol \"%s\")\n",
|
||||
};
|
||||
|
||||
static const char *fatalmsg[] = {
|
||||
/*182*/ "cannot read from file: \"%s\"\n",
|
||||
/*183*/ "cannot write to file: \"%s\"\n",
|
||||
/*184*/ "table overflow: \"%s\"\n",
|
||||
/* table can be: loop table
|
||||
* literal table
|
||||
* staging buffer
|
||||
* option table (response file)
|
||||
* peephole optimizer table
|
||||
*/
|
||||
/*185*/ "insufficient memory\n",
|
||||
/*186*/ "invalid assembler instruction \"%s\"\n",
|
||||
/*187*/ "numeric overflow, exceeding capacity\n",
|
||||
/*188*/ "compiled script exceeds the maximum memory size (%ld bytes)\n",
|
||||
/*189*/ "too many error messages on one line\n",
|
||||
/*190*/ "codepage mapping file not found\n",
|
||||
/*191*/ "invalid path: \"%s\"\n",
|
||||
/*192*/ "assertion failed: %s\n",
|
||||
/*193*/ "user error: %s\n",
|
||||
};
|
||||
|
||||
static const char *warnmsg[] = {
|
||||
/*200*/ "symbol \"%s\" is truncated to %d characters\n",
|
||||
/*201*/ "redefinition of constant/macro (symbol \"%s\")\n",
|
||||
/*202*/ "number of arguments does not match definition\n",
|
||||
/*203*/ "symbol is never used: \"%s\"\n",
|
||||
/*204*/ "symbol is assigned a value that is never used: \"%s\"\n",
|
||||
/*205*/ "redundant code: constant expression is zero\n",
|
||||
/*206*/ "redundant test: constant expression is non-zero\n",
|
||||
/*207*/ "unknown #pragma\n",
|
||||
/*208*/ "function with tag result used before definition, forcing reparse\n",
|
||||
/*209*/ "function \"%s\" should return a value\n",
|
||||
/*210*/ "possible use of symbol before initialization: \"%s\"\n",
|
||||
/*211*/ "possibly unintended assignment\n",
|
||||
/*212*/ "possibly unintended bitwise operation\n",
|
||||
/*213*/ "tag mismatch\n",
|
||||
/*214*/ "possibly a \"const\" array argument was intended: \"%s\"\n",
|
||||
/*215*/ "expression has no effect\n",
|
||||
/*216*/ "nested comment\n",
|
||||
/*217*/ "loose indentation\n",
|
||||
/*218*/ "old style prototypes used with optional semicolumns\n",
|
||||
/*219*/ "local variable \"%s\" shadows a variable at a preceding level\n",
|
||||
/*220*/ "expression with tag override must appear between parentheses\n",
|
||||
/*221*/ "label name \"%s\" shadows tag name\n",
|
||||
/*222*/ "number of digits exceeds rational number precision\n",
|
||||
/*223*/ "redundant \"sizeof\": argument size is always 1 (symbol \"%s\")\n",
|
||||
/*224*/ "unused\n",
|
||||
/*225*/ "unreachable code\n",
|
||||
/*226*/ "a variable is assigned to itself (symbol \"%s\")\n",
|
||||
/*227*/ "more initializers than enum fields\n",
|
||||
/*228*/ "length of initializer exceeds size of the enum field\n",
|
||||
/*229*/ "index tag mismatch (symbol \"%s\")\n",
|
||||
/*230*/ "no implementation for state \"%s\" in function \"%s\", no fall-back\n",
|
||||
/*231*/ "state specification on forward declaration is ignored\n",
|
||||
/*232*/ "output file is written, but with compact encoding disabled\n",
|
||||
/*233*/ "state variable \"%s\" shadows a global variable\n",
|
||||
/*234*/ "symbol \"%s\" is marked as deprecated: %s\n",
|
||||
/*235*/ "public function lacks forward declaration (symbol \"%s\")\n",
|
||||
/*236*/ "unknown parameter in substitution (incorrect #define pattern)\n",
|
||||
/*225*/ "unreachable code\n",
|
||||
/*226*/ "a variable is assigned to itself (symbol \"%s\")\n",
|
||||
/*227*/ "more initializers than enum fields\n",
|
||||
/*228*/ "length of initializer exceeds size of the enum field\n",
|
||||
/*229*/ "index tag mismatch (symbol \"%s\")\n",
|
||||
/*230*/ "no implementation for state \"%s\" in function \"%s\", no fall-back\n",
|
||||
/*231*/ "state specification on forward declaration is ignored\n",
|
||||
/*232*/ "output file is written, but with compact encoding disabled\n",
|
||||
/*233*/ "state variable \"%s\" shadows a global variable\n",
|
||||
/*234*/ "symbol \"%s\" is marked as deprecated: %s\n",
|
||||
/*235*/ "public function lacks forward declaration (symbol \"%s\")\n",
|
||||
/*236*/ "unknown parameter in substitution (incorrect #define pattern)\n",
|
||||
/*237*/ "coercing functions to and from primitives is unsupported and will be removed in the future\n",
|
||||
/*238*/ "'%s:' is an illegal cast; use view_as<%s>(expression)\n",
|
||||
/*239*/ "'%s' is an illegal tag; use %s as a type\n",
|
||||
/*240*/ "'%s:' is an old-style tag operation; use view_as<%s>(expression) instead\n",
|
||||
#else
|
||||
"\327 \275tr\242\231\227\266 %\204\305\206a\306\210\260",
|
||||
"\214\343i\215 \330\371\213t/\321cro \365",
|
||||
"nu\237\262\330\273t\203do\274\225\355\305 \343i\215\012",
|
||||
"\264 \275nev\262\240\322:\354",
|
||||
"\264 \275a\267gn\227\250\254u\200\234a\201\275nev\262\240\322:\354",
|
||||
"\214d\220d\213\201\323\232: \371\213\201\315\214\267\336\275z\210o\012",
|
||||
"\214d\220d\213\201te\230: \371\213\201\315\214\267\336\275n\202-z\210o\012",
|
||||
"\220k\212w\320#p\241g\321\012",
|
||||
"\307\345\376\351\265\214s\313\201\240\227bef\221\200\343i\215\277f\221c\205\265\214p\206s\303",
|
||||
"\246\235 sho\313\204\214\366r\320\250\254u\303",
|
||||
"po\267\244\200\240\200\330\264 bef\221\200\205i\207\216iz\316:\354",
|
||||
"po\267\244\224\220\205t\217d\227a\267gn\233t\012",
|
||||
"po\267\244\224\220\205t\217d\227bit\345s\200\350\316\012",
|
||||
"\351\265mis\355\305\012",
|
||||
"po\267\244\224\250\042\371\372\317\342w\347\205t\217\232d:\354",
|
||||
"\315\214\267\336\311\203\373effe\306\012",
|
||||
"ne\230\227\323m\233t\012",
|
||||
"loos\200\205d\217t\316\012",
|
||||
"\255\204\230y\346pro\266\252\274\240\227\345\376\334\215\375semic\255umn\260",
|
||||
"loc\375\357\223 s\311dow\203\250\357a\201\250p\214c\322\205\265level\012",
|
||||
"\315\214\267\336\345\376\351\265ov\210rid\200\301appe\206 betwe\217 p\206\217\234ese\260",
|
||||
"label \363m\200\223 s\311dow\203\351\265\363m\303",
|
||||
"nu\237\262\330\352git\203\247ce\322\203\241\215\375nu\237\262p\214ci\226\202\012",
|
||||
"\214d\220d\213\201\042\367e\312\042: \342\367\200\275\216way\2031 \365",
|
||||
"\205\232t\210m\205\231\200\317\367\200\362\042\367e\312\372\315\214\267\336\365",
|
||||
"\220\214a\305\300\200\323\232\012",
|
||||
"\250\357\275a\267gn\227\266 itself \365",
|
||||
"m\221\200\205i\207\216iz\210\203\234\374\217um \344eld\260",
|
||||
"l\217g\376\330\205i\207\216iz\262\247ce\322\203\367\200\330\370\217um \344eld\012",
|
||||
"\205\232x \351\265mis\355\305 \365",
|
||||
"\373imple\233t\316 f\243\356\200\223 \362\246\235\277\373f\216l-back\012",
|
||||
"\356\200speci\344c\316 \336f\221w\206\204\232\337\206\316 \275ig\212\214d\012",
|
||||
"outpu\201\344\346\275writt\217\277bu\201\345\376\323mpac\201\217\323d\205\265\352s\300\322\012",
|
||||
"\356\200\357\223 s\311dow\203\250glob\375\332\303",
|
||||
"\327 \275m\206k\227\347\232p\214c\231\322: \335",
|
||||
"pu\244ic \307lack\203f\221w\206\204\232\337\206\316 \365",
|
||||
"\220k\212w\320p\206a\333t\262\362subs\207\366\215 (\205c\221\214c\201#\343\200p\231t\210n\236",
|
||||
"\323\210c\205\265\246\203\266 \360from primi\207v\274\275\220supp\221t\227\360\345ll \314\214mov\227\362\370fu\366\214\012"
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef SCPACK_PUSH
|
||||
# undef SCPACK
|
||||
#endif
|
||||
};
|
||||
|
@ -43,7 +43,7 @@
|
||||
#pragma warning(disable:4125) /* decimal digit terminates octal escape sequence */
|
||||
#endif
|
||||
|
||||
#include <sc5.scp>
|
||||
#include "sc5-in.scp"
|
||||
|
||||
#if defined _MSC_VER
|
||||
#pragma warning(pop)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -62,7 +62,7 @@
|
||||
#pragma warning(disable:4125) /* decimal digit terminates octal escape sequence */
|
||||
#endif
|
||||
|
||||
#include <sc7.scp>
|
||||
#include "sc7-in.scp"
|
||||
|
||||
#if defined _MSC_VER
|
||||
#pragma warning(pop)
|
||||
@ -396,65 +396,15 @@ void stgset(int onoff)
|
||||
* are embedded in the .EXE file in compressed format, here we expand
|
||||
* them (and allocate memory for the sequences).
|
||||
*/
|
||||
static SEQUENCE *sequences;
|
||||
static SEQUENCE *sequences = sequences_cmp;
|
||||
|
||||
int phopt_init(void)
|
||||
{
|
||||
size_t number, i, len;
|
||||
char str[160];
|
||||
|
||||
/* count number of sequences */
|
||||
for (number=0; sequences_cmp[number].find!=NULL; number++)
|
||||
/* nothing */;
|
||||
number++; /* include an item for the NULL terminator */
|
||||
|
||||
if ((sequences=(SEQUENCE*)malloc(number * sizeof(SEQUENCE)))==NULL)
|
||||
return FALSE;
|
||||
|
||||
/* pre-initialize all to NULL (in case of failure) */
|
||||
for (i=0; i<number; i++) {
|
||||
sequences[i].find=NULL;
|
||||
sequences[i].replace=NULL;
|
||||
sequences[i].savesize=0;
|
||||
} /* for */
|
||||
|
||||
/* expand all strings */
|
||||
for (i=0; i<number-1; i++) {
|
||||
len = strexpand(str,(unsigned char*)sequences_cmp[i].find,sizeof str,SCPACK_TABLE);
|
||||
assert(len<=sizeof str);
|
||||
assert(len==strlen(str)+1);
|
||||
sequences[i].find=(char*)malloc(len);
|
||||
if (sequences[i].find!=NULL)
|
||||
strcpy(sequences[i].find,str);
|
||||
len = strexpand(str,(unsigned char*)sequences_cmp[i].replace,sizeof str,SCPACK_TABLE);
|
||||
assert(len<=sizeof str);
|
||||
assert(len==strlen(str)+1);
|
||||
sequences[i].replace=(char*)malloc(len);
|
||||
if (sequences[i].replace!=NULL)
|
||||
strcpy(sequences[i].replace,str);
|
||||
sequences[i].savesize=sequences_cmp[i].savesize;
|
||||
if (sequences[i].find==NULL || sequences[i].replace==NULL)
|
||||
return phopt_cleanup();
|
||||
} /* for */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int phopt_cleanup(void)
|
||||
{
|
||||
int i;
|
||||
if (sequences!=NULL) {
|
||||
i=0;
|
||||
while (sequences[i].find!=NULL || sequences[i].replace!=NULL) {
|
||||
if (sequences[i].find!=NULL)
|
||||
free(sequences[i].find);
|
||||
if (sequences[i].replace!=NULL)
|
||||
free(sequences[i].replace);
|
||||
i++;
|
||||
} /* while */
|
||||
free(sequences);
|
||||
sequences=NULL;
|
||||
} /* if */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -466,13 +416,13 @@ int phopt_cleanup(void)
|
||||
#define MAX_ALIAS (PAWN_CELL_SIZE/4) * MAX_OPT_CAT
|
||||
#endif
|
||||
|
||||
static int matchsequence(char *start,char *end,char *pattern,
|
||||
static int matchsequence(const char *start,const char *end,const char *pattern,
|
||||
char symbols[MAX_OPT_VARS][MAX_ALIAS+1],
|
||||
int *match_length)
|
||||
{
|
||||
int var,i;
|
||||
char str[MAX_ALIAS+1];
|
||||
char *start_org=start;
|
||||
const char *start_org=start;
|
||||
cell value;
|
||||
char *ptr;
|
||||
|
||||
@ -505,7 +455,7 @@ static int matchsequence(char *start,char *end,char *pattern,
|
||||
} /* if */
|
||||
break;
|
||||
case '-':
|
||||
value=-strtol(pattern+1,&pattern,16);
|
||||
value=-strtol(pattern+1,(char **)&pattern,16);
|
||||
ptr=itoh((ucell)value);
|
||||
while (*ptr!='\0') {
|
||||
if (tolower(*start) != tolower(*ptr))
|
||||
@ -547,9 +497,9 @@ static int matchsequence(char *start,char *end,char *pattern,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static char *replacesequence(char *pattern,char symbols[MAX_OPT_VARS][MAX_ALIAS+1],int *repl_length)
|
||||
static char *replacesequence(const char *pattern,char symbols[MAX_OPT_VARS][MAX_ALIAS+1],int *repl_length)
|
||||
{
|
||||
char *lptr;
|
||||
const char *lptr;
|
||||
int var;
|
||||
char *buffer;
|
||||
|
||||
@ -585,10 +535,10 @@ static char *replacesequence(char *pattern,char symbols[MAX_OPT_VARS][MAX_ALIAS+
|
||||
return (char*)error(103);
|
||||
|
||||
/* replace the pattern into this temporary buffer */
|
||||
lptr=buffer;
|
||||
*lptr++='\t'; /* the "replace" patterns do not have tabs */
|
||||
char *ptr=buffer;
|
||||
*ptr++='\t'; /* the "replace" patterns do not have tabs */
|
||||
while (*pattern) {
|
||||
assert((int)(lptr-buffer)<*repl_length);
|
||||
assert((int)(ptr-buffer)<*repl_length);
|
||||
switch (*pattern) {
|
||||
case '%':
|
||||
/* write out the symbol */
|
||||
@ -597,23 +547,23 @@ static char *replacesequence(char *pattern,char symbols[MAX_OPT_VARS][MAX_ALIAS+
|
||||
var=atoi(pattern) - 1;
|
||||
assert(var>=0 && var<MAX_OPT_VARS);
|
||||
assert(symbols[var][0]!='\0'); /* variable should be defined */
|
||||
strcpy(lptr,symbols[var]);
|
||||
lptr+=strlen(symbols[var]);
|
||||
strcpy(ptr,symbols[var]);
|
||||
ptr+=strlen(symbols[var]);
|
||||
break;
|
||||
case '!':
|
||||
/* finish the line, optionally start the next line with an indent */
|
||||
*lptr++='\n';
|
||||
*lptr++='\0';
|
||||
*ptr++='\n';
|
||||
*ptr++='\0';
|
||||
if (*(pattern+1)!='\0')
|
||||
*lptr++='\t';
|
||||
*ptr++='\t';
|
||||
break;
|
||||
default:
|
||||
*lptr++=*pattern;
|
||||
*ptr++=*pattern;
|
||||
} /* switch */
|
||||
pattern++;
|
||||
} /* while */
|
||||
|
||||
assert((int)(lptr-buffer)==*repl_length);
|
||||
assert((int)(ptr-buffer)==*repl_length);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -1,68 +0,0 @@
|
||||
/* expand.c -- Byte Pair Encoding decompression */
|
||||
/* Copyright 1996 Philip Gage */
|
||||
|
||||
/* Byte Pair Compression appeared in the September 1997
|
||||
* issue of C/C++ Users Journal. The original source code
|
||||
* may still be found at the web site of the magazine
|
||||
* (www.cuj.com).
|
||||
*
|
||||
* The decompressor has been modified by me (Thiadmer
|
||||
* Riemersma) to accept a string as input, instead of a
|
||||
* complete file.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "sc.h"
|
||||
|
||||
#define STACKSIZE 16
|
||||
|
||||
size_t strexpand(char *dest, unsigned char *source, size_t maxlen, unsigned char pairtable[128][2])
|
||||
{
|
||||
unsigned char stack[STACKSIZE];
|
||||
short c, top = 0;
|
||||
size_t len;
|
||||
|
||||
assert(maxlen > 0);
|
||||
len = 1; /* already 1 byte for '\0' */
|
||||
for (;;) {
|
||||
|
||||
/* Pop byte from stack or read byte from the input string */
|
||||
if (top)
|
||||
c = stack[--top];
|
||||
else if ((c = *(unsigned char *)source++) == '\0')
|
||||
break;
|
||||
|
||||
/* Push pair on stack or output byte to the output string */
|
||||
if (c > 127) {
|
||||
assert(top+2 <= STACKSIZE);
|
||||
stack[top++] = pairtable[c-128][1];
|
||||
stack[top++] = pairtable[c-128][0];
|
||||
}
|
||||
else {
|
||||
len++;
|
||||
if (maxlen > 1) { /* reserve one byte for the '\0' */
|
||||
*dest++ = (char)c;
|
||||
maxlen--;
|
||||
}
|
||||
}
|
||||
}
|
||||
*dest = '\0';
|
||||
return len; /* return number of bytes decoded */
|
||||
}
|
||||
|
||||
#if 0 /*for testing*/
|
||||
#include "sc5.scp"
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char str[128];
|
||||
|
||||
for (i=0; i<58; i++) {
|
||||
strexpand(str, errmsg[i], sizeof str, SCPACK_TABLE);
|
||||
printf("%s", str);
|
||||
} /* for */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,450 +0,0 @@
|
||||
/* compress.c -- Byte Pair Encoding compression */
|
||||
/* Copyright 1996 Philip Gage */
|
||||
|
||||
/* This program appeared in the September 1997 issue of
|
||||
* C/C++ Users Journal. The original source code may still
|
||||
* be found at the web site of the magazine (www.cuj.com).
|
||||
*
|
||||
* It has been modified by me (Thiadmer Riemersma) to
|
||||
* compress only a section of the input file and to store
|
||||
* the compressed output along with the input as "C" strings.
|
||||
*
|
||||
* Compiling instructions:
|
||||
* Borland C++ 16-bit (large memory model is required):
|
||||
* bcc -ml scpack.c
|
||||
*
|
||||
* Watcom C/C++ 32-bit:
|
||||
* wcl386 scpack.c
|
||||
*
|
||||
* GNU C (Linux), 32-bit:
|
||||
* gcc scpack.c -o scpack
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if UINT_MAX > 0xFFFFU
|
||||
#define MAXSIZE 1024*1024L
|
||||
#else
|
||||
#define MAXSIZE UINT_MAX /* Input file buffer size */
|
||||
#endif
|
||||
#define HASHSIZE 8192 /* Hash table size, power of 2 */
|
||||
#define THRESHOLD 3 /* Increase for speed, min 3 */
|
||||
|
||||
#define START_TOKEN "#ifdef SCPACK" /* start reading the buffer here */
|
||||
#define NAME_TOKEN "#define SCPACK_TABLE"
|
||||
#define SEP_TOKEN "#define SCPACK_SEPARATOR"
|
||||
#define TERM_TOKEN "#define SCPACK_TERMINATOR"
|
||||
#define TEMPFILE "~SCPACK.TMP"
|
||||
static char tablename[32+1] = "scpack_table";
|
||||
static char separator[16]=",";
|
||||
static char terminator[16]="";
|
||||
|
||||
int compress(unsigned char *buffer, unsigned buffersize, unsigned char pairtable[128][2])
|
||||
{
|
||||
unsigned char *left, *right, *count;
|
||||
unsigned char a, b, bestcount;
|
||||
unsigned i, j, index, bestindex, code=128;
|
||||
|
||||
/* Dynamically allocate buffers and check for errors */
|
||||
left = (unsigned char *)malloc(HASHSIZE);
|
||||
right = (unsigned char *)malloc(HASHSIZE);
|
||||
count = (unsigned char *)malloc(HASHSIZE);
|
||||
if (left==NULL || right==NULL || count==NULL) {
|
||||
printf("Error allocating memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Check for errors */
|
||||
for (i=0; i<buffersize; i++)
|
||||
if (buffer[i] > 127) {
|
||||
printf("This program works only on text files (7-bit ASCII)\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memset(pairtable, 0, 128*2*sizeof(char));
|
||||
|
||||
do { /* Replace frequent pairs with bytes 128..255 */
|
||||
|
||||
/* Enter counts of all byte pairs into hash table */
|
||||
memset(count,0,HASHSIZE);
|
||||
for (i=0; i<buffersize-1; i++) {
|
||||
a = buffer[i];
|
||||
b = buffer[i+1];
|
||||
/* ignore any pair with a '\0' */
|
||||
if (a == 0 || b == 0)
|
||||
continue;
|
||||
index = (a ^ (b << 6)) & (HASHSIZE-1);
|
||||
while ((left[index] != a || right[index] != b) &&
|
||||
count[index] != 0)
|
||||
index = (index + 1) & (HASHSIZE-1);
|
||||
left[index] = a;
|
||||
right[index] = b;
|
||||
if (count[index] < 255)
|
||||
count[index] += (unsigned char)1;
|
||||
}
|
||||
|
||||
/* Search hash table for most frequent pair */
|
||||
bestcount = THRESHOLD - 1;
|
||||
for (i=0; i<HASHSIZE; i++) {
|
||||
if (count[i] > bestcount) {
|
||||
bestcount = count[i];
|
||||
bestindex = i;
|
||||
}
|
||||
}
|
||||
|
||||
/* Compress if enough occurrences of pair */
|
||||
if (bestcount >= THRESHOLD) {
|
||||
|
||||
/* Add pair to table using code as index */
|
||||
a = pairtable[code-128][0] = left[bestindex];
|
||||
b = pairtable[code-128][1] = right[bestindex];
|
||||
|
||||
/* Replace all pair occurrences with unused byte */
|
||||
for (i=0, j=0; i<buffersize; i++, j++)
|
||||
if (a == buffer[i] && b == buffer[i+1]) {
|
||||
buffer[j] = (unsigned char)code;
|
||||
++i;
|
||||
}
|
||||
else
|
||||
buffer[j] = buffer[i];
|
||||
buffersize = j;
|
||||
}
|
||||
else
|
||||
break;
|
||||
} while (++code < 255);
|
||||
|
||||
/* done */
|
||||
free(left); free(right); free(count);
|
||||
return buffersize; /* return adjusted buffersize */
|
||||
}
|
||||
|
||||
static int strmatch(char *str, char *token, int *indent)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
/* skip whitespace */
|
||||
while (*str==' ' || *str=='\t') {
|
||||
str++;
|
||||
i++;
|
||||
} /* while */
|
||||
if (strncmp(str,token,strlen(token))!=0)
|
||||
return 0;
|
||||
if (indent != NULL)
|
||||
*indent = i;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void check_if(char *str,int linenr)
|
||||
{
|
||||
if (strmatch(str,"#if",NULL)) {
|
||||
printf("Error: \"#if...\" preprocessor statement should not be in SCPACK section "
|
||||
"(line %d)\n", linenr);
|
||||
exit(1);
|
||||
} /* if */
|
||||
}
|
||||
|
||||
static int check_tablename(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (strmatch(str,NAME_TOKEN,NULL)) {
|
||||
str += strlen(NAME_TOKEN);
|
||||
while (*str==' ' || *str=='\t')
|
||||
str++;
|
||||
for (i=0; i<(sizeof tablename - 1) && *str!='\0' && strchr(" \t\n",*str)==NULL; i++, str++)
|
||||
tablename[i] = *str;
|
||||
tablename[i] = '\0';
|
||||
return 1;
|
||||
} /* if */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_separator(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (strmatch(str,SEP_TOKEN,NULL)) {
|
||||
str += strlen(SEP_TOKEN);
|
||||
while (*str==' ' || *str=='\t')
|
||||
str++;
|
||||
for (i=0; i<(sizeof separator - 1) && *str!='\0' && strchr(" \t\n",*str)==NULL; i++, str++)
|
||||
separator[i] = *str;
|
||||
separator[i] = '\0';
|
||||
return 1;
|
||||
} /* if */
|
||||
|
||||
if (strmatch(str,TERM_TOKEN,NULL)) {
|
||||
str += strlen(TERM_TOKEN);
|
||||
while (*str==' ' || *str=='\t')
|
||||
str++;
|
||||
for (i=0; i<(sizeof terminator - 1) && *str!='\0' && strchr(" \t\n",*str)==NULL; i++, str++)
|
||||
terminator[i] = *str;
|
||||
terminator[i] = '\0';
|
||||
return 1;
|
||||
} /* if */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* readbuffer
|
||||
* Reads in the input file and stores all strings in the
|
||||
* section between "#ifdef SCPACK" and "#else" in a buffer.
|
||||
* Only text that is between double quotes is added to the
|
||||
* buffer; the \" escape code is handled. Multiple strings
|
||||
* on one line are handled.
|
||||
*/
|
||||
unsigned readbuffer(FILE *input, unsigned char *buffer)
|
||||
{
|
||||
char str[256];
|
||||
unsigned buffersize;
|
||||
int i,linenr;
|
||||
|
||||
linenr=0;
|
||||
buffersize=0;
|
||||
|
||||
rewind(input);
|
||||
while (!feof(input)) {
|
||||
while (fgets(str,sizeof str,input)!=NULL) {
|
||||
linenr++;
|
||||
check_tablename(str);
|
||||
check_separator(str);
|
||||
if (strmatch(str,START_TOKEN,NULL))
|
||||
break;
|
||||
} /* while */
|
||||
if (!strmatch(str,START_TOKEN,NULL))
|
||||
return buffersize; /* no (more) section found, quit */
|
||||
|
||||
while (fgets(str,sizeof str,input)!=NULL) {
|
||||
linenr++;
|
||||
check_if(str,linenr);
|
||||
if (check_tablename(str))
|
||||
printf("Error: table name definition should not be in SCPACK section (line %d)\n", linenr);
|
||||
check_separator(str);
|
||||
if (strmatch(str,"#else",NULL))
|
||||
break; /* done */
|
||||
/* add to the buffer only what is between double quotes */
|
||||
i=0;
|
||||
do {
|
||||
while (str[i]!='\0' && str[i]!='"')
|
||||
i++;
|
||||
if (str[i]=='"') {
|
||||
/* we are in a string */
|
||||
i++;
|
||||
while (str[i]!='\0' && str[i]!='"') {
|
||||
/* handle escape sequences */
|
||||
if (str[i]=='\\') {
|
||||
i++;
|
||||
switch (str[i]) {
|
||||
case 'a': /* alarm */
|
||||
buffer[buffersize++]='\a';
|
||||
i++;
|
||||
break;
|
||||
case 'b': /* backspace */
|
||||
buffer[buffersize++]='\b';
|
||||
i++;
|
||||
break;
|
||||
case 'f': /* form feed */
|
||||
buffer[buffersize++]='\f';
|
||||
i++;
|
||||
break;
|
||||
case 'n': /* newline */
|
||||
buffer[buffersize++]='\n';
|
||||
i++;
|
||||
break;
|
||||
case 'r': /* carriage return */
|
||||
buffer[buffersize++]='\n';
|
||||
i++;
|
||||
break;
|
||||
case 't': /* tab */
|
||||
buffer[buffersize++]='\t';
|
||||
i++;
|
||||
break;
|
||||
case '\'':
|
||||
buffer[buffersize++]='\'';
|
||||
i++;
|
||||
break;
|
||||
case '"':
|
||||
buffer[buffersize++]='"';
|
||||
i++;
|
||||
break;
|
||||
default:
|
||||
// ??? octal character code escapes and hexadecimal escapes
|
||||
// not supported
|
||||
printf("Unknown escape sequence '\\%c' on line %d\n",
|
||||
str[i], linenr);
|
||||
} /* switch */
|
||||
} else {
|
||||
buffer[buffersize++]=str[i++];
|
||||
} /* if */
|
||||
} /* while */
|
||||
if (str[i]=='"') {
|
||||
buffer[buffersize++]='\0'; /* terminate each string */
|
||||
i++;
|
||||
} else {
|
||||
printf("Error: unterminated string on line %d\n",linenr);
|
||||
} /* if */
|
||||
} /* if */
|
||||
} while (str[i]!='\0');
|
||||
} /* while - in SCPACK section */
|
||||
/* put in another '\0' to terminate the section */
|
||||
buffer[buffersize++]='\0';
|
||||
} /* while - !feof(input) */
|
||||
return buffersize;
|
||||
}
|
||||
|
||||
static void write_pairtable(FILE *output, unsigned char pairtable[128][2], char *tablename)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* dump the pair table */
|
||||
fprintf(output, "/*-*SCPACK start of pair table, do not change or remove this line */\n");
|
||||
fprintf(output, "unsigned char %s[][2] = {", tablename);
|
||||
for (i=0; i<128 && pairtable[i][0]!=0 && pairtable[i][1]!=0; i++) {
|
||||
if ((i % 16)==0)
|
||||
fprintf(output, "\n ");
|
||||
else
|
||||
fprintf(output, " ");
|
||||
fprintf(output, "{%d,%d}", pairtable[i][0], pairtable[i][1]);
|
||||
/* check if something follows this pair */
|
||||
if (i+1<128 && pairtable[i+1][0]!=0 && pairtable[i+1][1]!=0)
|
||||
fprintf(output, ",");
|
||||
} /* for */
|
||||
fprintf(output, "\n};\n");
|
||||
fprintf(output, "/*-*SCPACK end of pair table, do not change or remove this line */\n");
|
||||
}
|
||||
|
||||
void writefile(FILE *input, FILE *output, unsigned char *buffer, unsigned buffersize, unsigned char pairtable[128][2])
|
||||
{
|
||||
char str[256];
|
||||
int insection, indent, needseparator;
|
||||
unsigned char *bufptr;
|
||||
|
||||
bufptr = buffer;
|
||||
insection = 0;
|
||||
|
||||
rewind(input);
|
||||
while (!feof(input)) {
|
||||
while (fgets(str,sizeof str,input)!=NULL) {
|
||||
fprintf(output,"%s",str);
|
||||
if (check_tablename(str)) {
|
||||
write_pairtable(output, pairtable, tablename);
|
||||
/* strip an existing pair table from the file */
|
||||
if (fgets(str,sizeof str,input)!=NULL) {
|
||||
if (strmatch(str,"/*-*SCPACK",NULL)) {
|
||||
while (fgets(str,sizeof str,input)!=NULL)
|
||||
if (strmatch(str,"/*-*SCPACK",NULL))
|
||||
break;
|
||||
} else {
|
||||
fprintf(output,"%s",str);
|
||||
} /* if */
|
||||
} /* if */
|
||||
} /* if */
|
||||
if (strmatch(str,START_TOKEN,NULL))
|
||||
insection = 1;
|
||||
if (insection && strmatch(str,"#else",NULL))
|
||||
break;
|
||||
} /* while */
|
||||
if (!strmatch(str,"#else",&indent))
|
||||
return; /* no (more) section found, quit */
|
||||
insection=0;
|
||||
|
||||
/* dump the buffer as strings, separated with commas */
|
||||
needseparator = 0;
|
||||
while (*bufptr != '\0') {
|
||||
assert((unsigned)(bufptr-buffer) < buffersize);
|
||||
if (needseparator)
|
||||
fprintf(output, "%s\n",separator);
|
||||
fprintf(output, "%*c\"",indent+2,' ');
|
||||
/* loop over string */
|
||||
while (*bufptr != '\0') {
|
||||
if (*bufptr<' ' || *bufptr >= 128 || *bufptr == '"' || *bufptr == '\\')
|
||||
fprintf(output, "\\%03o", *bufptr);
|
||||
else
|
||||
fprintf(output, "%c", *bufptr);
|
||||
bufptr++;
|
||||
} /* while */
|
||||
fprintf(output, "\"");
|
||||
needseparator = 1;
|
||||
bufptr++; /* skip '\0' */
|
||||
} /* while */
|
||||
fprintf(output, "%s\n",terminator);
|
||||
bufptr++;
|
||||
|
||||
/* skip the input file until the #endif section */
|
||||
while (fgets(str,sizeof str,input)!=NULL) {
|
||||
if (strmatch(str,"#endif",NULL)) {
|
||||
fprintf(output,"%s",str);
|
||||
break; /* done */
|
||||
} /* if */
|
||||
} /* while */
|
||||
} /* while - !feof(input) */
|
||||
}
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
printf("Usage: scpack <filename> [output file]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
FILE *in, *out;
|
||||
unsigned char *buffer;
|
||||
unsigned buffersize, orgbuffersize;
|
||||
unsigned char pairtable[128][2];
|
||||
|
||||
if (argc < 2 || argc > 3)
|
||||
usage();
|
||||
if ((in=fopen(argv[1],"rt"))==NULL) {
|
||||
printf("SCPACK: error opening input %s\n",argv[1]);
|
||||
usage();
|
||||
} /* if */
|
||||
if (argc == 2) {
|
||||
if ((out=fopen(TEMPFILE,"wt"))==NULL) {
|
||||
printf("SCPACK: error opening temporary file %s\n",TEMPFILE);
|
||||
usage();
|
||||
} /* if */
|
||||
} else {
|
||||
if ((out=fopen(argv[2],"wt"))==NULL) {
|
||||
printf("SCPACK: error opening output file %s\n",argv[2]);
|
||||
usage();
|
||||
} /* if */
|
||||
} /* if */
|
||||
|
||||
buffer = (unsigned char *)malloc(MAXSIZE);
|
||||
if (buffer == NULL) {
|
||||
printf("SCPACK: error allocating memory\n");
|
||||
return 1;
|
||||
} /* if */
|
||||
/* 1. read the buffer
|
||||
* 2. compress the buffer
|
||||
* 3. copy the file, insert the compressed buffer
|
||||
*/
|
||||
buffersize = readbuffer(in, buffer);
|
||||
orgbuffersize = buffersize;
|
||||
if (buffersize > 0) {
|
||||
buffersize = compress(buffer, buffersize, pairtable);
|
||||
writefile(in, out, buffer, buffersize, pairtable);
|
||||
printf("SCPACK: compression ratio: %ld%% (%d -> %d)\n",
|
||||
100L-(100L*buffersize)/orgbuffersize, orgbuffersize, buffersize);
|
||||
} else {
|
||||
printf("SCPACK: no SCPACK section found, nothing to do\n");
|
||||
} /* if */
|
||||
fclose(out);
|
||||
fclose(in);
|
||||
/* let the new file replace the old file */
|
||||
if (buffersize == 0) {
|
||||
if (argc == 2)
|
||||
remove(TEMPFILE);
|
||||
else
|
||||
remove(argv[2]);
|
||||
} else if (argc == 2) {
|
||||
remove(argv[1]);
|
||||
rename(TEMPFILE,argv[1]);
|
||||
} /* if */
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user