From 0b990e46abfc753bb94cae63741fe8fa069f7254 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 7 Mar 2015 11:39:11 -0800 Subject: [PATCH] Remove scpack. --- sourcepawn/compiler/AMBuilder | 39 -- sourcepawn/compiler/sc5-in.scp | 653 ++++++++----------------- sourcepawn/compiler/sc5.cpp | 2 +- sourcepawn/compiler/sc7-in.scp | 811 +------------------------------ sourcepawn/compiler/sc7.cpp | 84 +--- sourcepawn/compiler/scexpand.cpp | 68 --- sourcepawn/compiler/scpack.c | 450 ----------------- 7 files changed, 225 insertions(+), 1882 deletions(-) delete mode 100644 sourcepawn/compiler/scexpand.cpp delete mode 100644 sourcepawn/compiler/scpack.c diff --git a/sourcepawn/compiler/AMBuilder b/sourcepawn/compiler/AMBuilder index 3d468c99..2612536a 100644 --- a/sourcepawn/compiler/AMBuilder +++ b/sourcepawn/compiler/AMBuilder @@ -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', diff --git a/sourcepawn/compiler/sc5-in.scp b/sourcepawn/compiler/sc5-in.scp index 27739fa7..7bed79f8 100644 --- a/sourcepawn/compiler/sc5-in.scp +++ b/sourcepawn/compiler/sc5-in.scp @@ -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 \"\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 \"\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 +}; diff --git a/sourcepawn/compiler/sc5.cpp b/sourcepawn/compiler/sc5.cpp index 7adebb6f..6520a8cf 100644 --- a/sourcepawn/compiler/sc5.cpp +++ b/sourcepawn/compiler/sc5.cpp @@ -43,7 +43,7 @@ #pragma warning(disable:4125) /* decimal digit terminates octal escape sequence */ #endif -#include +#include "sc5-in.scp" #if defined _MSC_VER #pragma warning(pop) diff --git a/sourcepawn/compiler/sc7-in.scp b/sourcepawn/compiler/sc7-in.scp index 7cd69b54..3f7c3e34 100644 --- a/sourcepawn/compiler/sc7-in.scp +++ b/sourcepawn/compiler/sc7-in.scp @@ -22,36 +22,17 @@ * Version: $Id$ */ -size_t strexpand(char *dest, unsigned char *source, size_t maxlen, unsigned char pairtable[128][2]); - #define SCPACK_TERMINATOR , /* end each section with a comma */ #define SCPACK_TABLE sequences_table -/*-*SCPACK start of pair table, do not change or remove this line */ -unsigned char sequences_table[][2] = { - {49,33}, {37,128}, {32,129}, {32,37}, {114,105}, {112,132}, {46,133}, {97,100}, {46,97}, {136,108}, {137,116}, {115,104}, {111,135}, {117,139}, {112,141}, {108,140}, - {131,50}, {144,33}, {46,115}, {138,33}, {59,36}, {134,130}, {143,146}, {115,116}, {134,145}, {110,151}, {111,153}, {99,154}, {112,147}, {135,100}, {134,33}, {114,33}, - {111,156}, {112,160}, {46,99}, {138,130}, {142,158}, {131,51}, {150,152}, {112,33}, {120,167}, {101,168}, {148,169}, {97,159}, {112,171}, {148,172}, {165,33}, {173,142}, - {122,101}, {176,114}, {101,113}, {110,100}, {149,164}, {157,114}, {33,161}, {131,49}, {103,33}, {157,33}, {104,184}, {99,186}, {120,187}, {98,111}, {118,101}, {111,190}, - {109,191}, {130,170}, {131,52}, {106,177}, {138,145}, {180,166}, {192,147}, {108,162}, {163,166}, {143,149}, {115,174}, {117,179}, {139,199}, {203,202}, {189,205}, {105,100}, - {115,103}, {115,108}, {207,120}, {195,130}, {46,135}, {178,33}, {212,114}, {204,134}, {155,149}, {142,162}, {183,145}, {150,149}, {143,152}, {194,33}, {130,175}, {97,179}, - {177,111}, {182,185}, {143,46}, {183,144}, {155,152}, {145,175}, {114,101}, {230,102}, {108,231}, {101,115}, {233,115}, {114,116}, {142,147}, {105,33}, {155,163}, {178,130}, - {215,32}, {240,50}, {143,196}, {155,197}, {181,197}, {181,200}, {108,210}, {46,98}, {241,225}, {208,235}, {209,234}, {224,158}, {143,163}, {150,163}, {155,200} -}; -/*-*SCPACK end of pair table, do not change or remove this line */ #define seqsize(o,p) (opcodes(o)+opargs(p)) typedef struct { const char *find; const char *replace; int savesize; /* number of bytes saved (in bytecode) */ -} SETUP_SEQUENCE; -typedef struct { - char *find; - char *replace; - int savesize; /* number of bytes saved (in bytecode) */ } SEQUENCE; -static SETUP_SEQUENCE sequences_cmp[] = { +static SEQUENCE sequences_cmp[] = { /* A very common sequence in four varieties * load.s.pri n1 load.s.pri n2 * push.pri load.s.alt n1 @@ -74,109 +55,59 @@ static SETUP_SEQUENCE sequences_cmp[] = { * pop.alt - */ { - #ifdef SCPACK "load.s.pri %1!push.pri!load.s.pri %2!pop.alt!", "load.s.pri %2!load.s.alt %1!", - #else - "\226\305\241", - "\246\375", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!push.pri!load.s.pri %2!pop.alt!", "load.s.pri %2!load.alt %1!", - #else - "\217\305\241", - "\246\374", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.s.pri %1!push.pri!load.pri %2!pop.alt!", "load.pri %2!load.s.alt %1!", - #else - "\226\264\334\241", - "\334\375", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!push.pri!load.pri %2!pop.alt!", "load.pri %2!load.alt %1!", - #else - "\217\264\334\241", - "\334\374", - #endif seqsize(4,2) - seqsize(2,2) }, /* (#1#) The above also occurs with "addr.pri" (array * indexing) as the first line; so that adds 2 cases. */ { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!pop.alt!", "addr.alt %1!load.s.pri %2!", - #else - "\364\241", - "\365", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "addr.pri %1!push.pri!load.pri %2!pop.alt!", "addr.alt %1!load.pri %2!", - #else - "\265\264\334\241", - "\265\243\334", - #endif seqsize(4,2) - seqsize(2,2) }, /* And the same sequence with const.pri as either the first * or the second load instruction: four more cases. */ { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!pop.alt!", "load.s.pri %2!const.alt %1!", - #else - "\363\241", - "\246\356", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.pri %2!pop.alt!", "load.pri %2!const.alt %1!", - #else - "\233\264\334\241", - "\334\356", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.s.pri %1!push.pri!const.pri %2!pop.alt!", "const.pri %2!load.s.alt %1!", - #else - "\226\264\344\241", - "\344\375", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!push.pri!const.pri %2!pop.alt!", "const.pri %2!load.alt %1!", - #else - "\217\264\344\241", - "\344\374", - #endif seqsize(4,2) - seqsize(2,2) }, /* The same as above, but now with "addr.pri" (array @@ -184,23 +115,13 @@ static SETUP_SEQUENCE sequences_cmp[] = { * the second. */ { - #ifdef SCPACK "addr.pri %1!push.pri!const.pri %2!pop.alt!", "addr.alt %1!const.pri %2!", - #else - "\265\264\344\241", - "\265\243\344", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "addr.pri %1!push.pri!zero.pri!pop.alt!", "addr.alt %1!zero.pri!", - #else - "\265\264\373\241", - "\265\243\373", - #endif seqsize(4,1) - seqsize(2,1) }, /* ??? add references */ @@ -213,33 +134,18 @@ static SETUP_SEQUENCE sequences_cmp[] = { * so add another two cases. */ { - #ifdef SCPACK "move.pri!push.pri!load.s.pri %1!pop.alt!", "load.s.pri %1!", - #else - "\300\236\244\333\241", - "\333", - #endif seqsize(4,1) - seqsize(1,1) }, { - #ifdef SCPACK "move.pri!push.pri!load.pri %1!pop.alt!", "load.pri %1!", - #else - "\300\236\244\311\241", - "\311", - #endif seqsize(4,1) - seqsize(1,1) }, { - #ifdef SCPACK "move.pri!push.pri!const.pri %1!pop.alt!", "const.pri %1!", - #else - "\300\236\244\330\241", - "\330", - #endif seqsize(4,1) - seqsize(1,1) }, /* More optimizations for chained relational operators; the @@ -269,163 +175,83 @@ static SETUP_SEQUENCE sequences_cmp[] = { * ;$exp - */ { - #ifdef SCPACK "xchg!sgrtr!swap.alt!and!pop.alt!;$exp!", "sless!pop.alt!and!;$exp!", - #else - "\274\371\237swa\234\337\266\252", - "\372\266\337!\252", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sless!swap.alt!and!pop.alt!;$exp!", "sgrtr!pop.alt!and!;$exp!", - #else - "\274\372!swa\234\337\266\252", - "\371\237\241\337!\252", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sgeq!swap.alt!and!pop.alt!;$exp!", "sleq!pop.alt!and!;$exp!", - #else - "\274\320\325swa\234\337\266\252", - "\321\262\266\337!\252", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sleq!swap.alt!and!pop.alt!;$exp!", "sgeq!pop.alt!and!;$exp!", - #else - "\274\321\325swa\234\337\266\252", - "\320\262\266\337!\252", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sgrtr!swap.alt!and!pop.alt!jzer %1!", "sless!pop.alt!and!jzer %1!", - #else - "\274\371\237swa\234\337\266\323", - "\372\266\337!\323", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sless!swap.alt!and!pop.alt!jzer %1!", "sgrtr!pop.alt!and!jzer %1!", - #else - "\274\372!swa\234\337\266\323", - "\371\237\241\337!\323", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sgeq!swap.alt!and!pop.alt!jzer %1!", "sleq!pop.alt!and!jzer %1!", - #else - "\274\320\325swa\234\337\266\323", - "\321\262\266\337!\323", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sleq!swap.alt!and!pop.alt!jzer %1!", "sgeq!pop.alt!and!jzer %1!", - #else - "\274\321\325swa\234\337\266\323", - "\320\262\266\337!\323", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sgrtr!jzer %1!;$exp!", "jsgeq %1!;$exp!", - #else - "\274\371\237\303\301", - "j\320\262\301", - #endif seqsize(3,1) - seqsize(1,1) }, { - #ifdef SCPACK "xchg!sless!jzer %1!;$exp!", "jsleq %1!;$exp!", - #else - "\274\372!\303\301", - "j\321\262\301", - #endif seqsize(3,1) - seqsize(1,1) }, { - #ifdef SCPACK "xchg!sgeq!jzer %1!;$exp!", "jsgrtr %1!;$exp!", - #else - "\274\320\325\303\301", - "j\371r\301", - #endif seqsize(3,1) - seqsize(1,1) }, { - #ifdef SCPACK "xchg!sleq!jzer %1!;$exp!", "jsless %1!;$exp!", - #else - "\274\321\325\303\301", - "j\372\301", - #endif seqsize(3,1) - seqsize(1,1) }, { - #ifdef SCPACK "xchg!sgrtr!;$exp!", "sless!;$exp!", - #else - "\274\371\237\252", - "\372!\252", - #endif seqsize(2,0) - seqsize(1,0) }, { - #ifdef SCPACK "xchg!sless!;$exp!", "sgrtr!;$exp!", - #else - "\274\372!\252", - "\371\237\252", - #endif seqsize(2,0) - seqsize(1,0) }, { - #ifdef SCPACK "xchg!sgeq!;$exp!", "sleq!;$exp!", - #else - "\274\320\325\252", - "\321\325\252", - #endif seqsize(2,0) - seqsize(1,0) }, { - #ifdef SCPACK "xchg!sleq!;$exp!", "sgeq!;$exp!", - #else - "\274\321\325\252", - "\320\325\252", - #endif seqsize(2,0) - seqsize(1,0) }, /* The entry to chained operators is also opt to optimization @@ -444,83 +270,43 @@ static SETUP_SEQUENCE sequences_cmp[] = { * and all permutations... */ { - #ifdef SCPACK "load.s.pri %1!load.s.alt %2!xchg!", "load.s.pri %2!load.s.alt %1!", - #else - "\333\226\304\274", - "\246\375", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.s.pri %1!load.alt %2!xchg!", "load.pri %2!load.s.alt %1!", - #else - "\333\362\274", - "\334\375", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.s.pri %1!const.alt %2!xchg!", "const.pri %2!load.s.alt %1!", - #else - "\333\233\304\274", - "\344\375", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!load.s.alt %2!xchg!", "load.s.pri %2!load.alt %1!", - #else - "\311\226\304\274", - "\246\374", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!load.alt %2!xchg!", "load.pri %2!load.alt %1!", - #else - "\311\362\274", - "\334\374", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!const.alt %2!xchg!", "const.pri %2!load.alt %1!", - #else - "\311\233\304\274", - "\344\374", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!load.s.alt %2!xchg!", "load.s.pri %2!const.alt %1!", - #else - "\330\226\304\274", - "\246\356", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!load.alt %2!xchg!", "load.pri %2!const.alt %1!", - #else - "\330\362\274", - "\334\356", - #endif seqsize(3,2) - seqsize(2,2) }, /* some sequences where PRI is moved to ALT can be optimized @@ -536,94 +322,49 @@ static SETUP_SEQUENCE sequences_cmp[] = { * (where [load.pri %2] may also be another operatrion loading PRI) */ { - #ifdef SCPACK "move.alt!const.pri %1!xchg!", "const.alt %1!", - #else - "\306\330\274", - "\356", - #endif seqsize(3,1) - seqsize(1,1) }, { - #ifdef SCPACK "move.alt!load.pri %1!xchg!", "load.alt %1!", - #else - "\306\311\274", - "\374", - #endif seqsize(3,1) - seqsize(1,1) }, { - #ifdef SCPACK "move.alt!load.s.pri %1!xchg!", "load.s.alt %1!", - #else - "\306\333\274", - "\375", - #endif seqsize(3,1) - seqsize(1,1) }, /* ----- */ { - #ifdef SCPACK "lref.pri %1!move.alt!load.pri %2!", "lref.alt %1!load.pri %2!", - #else - "\350\225\306\334", - "\350\243\334", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "lref.pri %1!move.alt!load.s.pri %2!", "lref.alt %1!load.s.pri %2!", - #else - "\350\225\306\246", - "\350\310", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "lref.pri %1!move.alt!const.pri %2!", "lref.alt %1!const.pri %2!", - #else - "\350\225\306\344", - "\350\243\344", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "lref.s.pri %1!move.alt!load.pri %2!", "lref.s.alt %1!load.pri %2!", - #else - "\350\222\225\306\334", - "\350\222\243\334", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "lref.s.pri %1!move.alt!load.s.pri %2!", "lref.s.alt %1!load.s.pri %2!", - #else - "\350\222\225\306\246", - "\350\222\310", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "lref.s.pri %1!move.alt!const.pri %2!", "lref.s.alt %1!const.pri %2!", - #else - "\350\222\225\306\344", - "\350\222\243\344", - #endif seqsize(3,2) - seqsize(2,2) }, /* Array indexing can merit from special instructions. @@ -668,212 +409,112 @@ static SETUP_SEQUENCE sequences_cmp[] = { #if !defined BIT16 /* loading from array, "cell" shifted */ { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri 2!pop.alt!add!load.i!", "addr.alt %1!load.s.pri %2!bounds %3!lidx!", - #else - "\364\316\370\342\355", - "\365\316\366!", - #endif seqsize(8,4) - seqsize(4,3) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri 2!pop.alt!add!load.i!", "const.alt %1!load.s.pri %2!bounds %3!lidx!", - #else - "\363\316\370\342\355", - "\376\316\366!", - #endif seqsize(8,4) - seqsize(4,3) }, { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!shl.c.pri 2!pop.alt!add!load.i!", "addr.alt %1!load.s.pri %2!lidx!", - #else - "\364\370\342\355", - "\365\366!", - #endif seqsize(7,3) - seqsize(3,2) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!shl.c.pri 2!pop.alt!add!load.i!", "const.alt %1!load.s.pri %2!lidx!", - #else - "\363\370\342\355", - "\376\366!", - #endif seqsize(7,3) - seqsize(3,2) }, #endif /* loading from array, not "cell" shifted */ { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri %4!pop.alt!add!load.i!", "addr.alt %1!load.s.pri %2!bounds %3!lidx.b %4!", - #else - "\364\316\327\302\341\342\355", - "\365\316\366\367\335", - #endif seqsize(8,4) - seqsize(4,4) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri %4!pop.alt!add!load.i!", "const.alt %1!load.s.pri %2!bounds %3!lidx.b %4!", - #else - "\363\316\327\302\341\342\355", - "\376\316\366\367\335", - #endif seqsize(8,4) - seqsize(4,4) }, { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!shl.c.pri %3!pop.alt!add!load.i!", "addr.alt %1!load.s.pri %2!lidx.b %3!", - #else - "\364\327\256\241\271\342\355", - "\365\366\367\256", - #endif seqsize(7,3) - seqsize(3,3) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!shl.c.pri %3!pop.alt!add!load.i!", "const.alt %1!load.s.pri %2!lidx.b %3!", - #else - "\363\327\256\241\271\342\355", - "\376\366\367\256", - #endif seqsize(7,3) - seqsize(3,3) }, #if !defined BIT16 /* array index calculation for storing a value, "cell" aligned */ { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri 2!pop.alt!add!", "addr.alt %1!load.s.pri %2!bounds %3!idxaddr!", - #else - "\364\316\370", - "\365\316\322\235\237", - #endif seqsize(7,4) - seqsize(4,3) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri 2!pop.alt!add!", "const.alt %1!load.s.pri %2!bounds %3!idxaddr!", - #else - "\363\316\370", - "\376\316\322\235\237", - #endif seqsize(7,4) - seqsize(4,3) }, { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!shl.c.pri 2!pop.alt!add!", "addr.alt %1!load.s.pri %2!idxaddr!", - #else - "\364\370", - "\365\322\235\237", - #endif seqsize(6,3) - seqsize(3,2) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!shl.c.pri 2!pop.alt!add!", "const.alt %1!load.s.pri %2!idxaddr!", - #else - "\363\370", - "\376\322\235\237", - #endif seqsize(6,3) - seqsize(3,2) }, #endif /* array index calculation for storing a value, not "cell" packed */ { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri %4!pop.alt!add!", "addr.alt %1!load.s.pri %2!bounds %3!idxaddr.b %4!", - #else - "\364\316\327\302\341", - "\365\316\322\265\367\335", - #endif seqsize(7,4) - seqsize(4,4) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri %4!pop.alt!add!", "const.alt %1!load.s.pri %2!bounds %3!idxaddr.b %4!", - #else - "\363\316\327\302\341", - "\376\316\322\265\367\335", - #endif seqsize(7,4) - seqsize(4,4) }, { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!shl.c.pri %3!pop.alt!add!", "addr.alt %1!load.s.pri %2!idxaddr.b %3!", - #else - "\364\327\256\241\271", - "\365\322\265\367\256", - #endif seqsize(6,3) - seqsize(3,3) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!shl.c.pri %3!pop.alt!add!", "const.alt %1!load.s.pri %2!idxaddr.b %3!", - #else - "\363\327\256\241\271", - "\376\322\265\367\256", - #endif seqsize(6,3) - seqsize(3,3) }, #if !defined BIT16 /* the shorter array indexing sequences, see above for comments */ { - #ifdef SCPACK "shl.c.pri 2!pop.alt!add!loadi!", "pop.alt!lidx!", - #else - "\370\217\355", - "\241\366!", - #endif seqsize(4,1) - seqsize(2,0) }, { - #ifdef SCPACK "shl.c.pri 2!pop.alt!add!", "pop.alt!idxaddr!", - #else - "\370", - "\241\322\235\237", - #endif seqsize(3,1) - seqsize(2,0) }, #endif { - #ifdef SCPACK "shl.c.pri %1!pop.alt!add!loadi!", "pop.alt!lidx.b %1!", - #else - "\314\225\241\271\217\355", - "\241\366\367\202", - #endif seqsize(4,1) - seqsize(2,1) }, { - #ifdef SCPACK "shl.c.pri %1!pop.alt!add!", "pop.alt!idxaddr.b %1!", - #else - "\314\225\241\271", - "\241\322\265\367\202", - #endif seqsize(3,1) - seqsize(2,1) }, /* For packed arrays, there is another case (packed arrays @@ -891,23 +532,13 @@ static SETUP_SEQUENCE sequences_cmp[] = { * case is already handled (see #1#) */ { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!bounds %3!pop.alt!", "addr.alt %1!load.s.pri %2!bounds %3!", - #else - "\364\316\241", - "\365\316", - #endif seqsize(5,3) - seqsize(3,3) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!bounds %3!pop.alt!", "const.alt %1!load.s.pri %2!bounds %3!", - #else - "\363\316\241", - "\376\316", - #endif seqsize(5,3) - seqsize(3,3) }, /* Declaration of simple variables often follows the sequence: @@ -918,23 +549,13 @@ static SETUP_SEQUENCE sequences_cmp[] = { * ;$exp - */ { - #ifdef SCPACK ";$lcl %1 %2!stack -4!const.pri %3!stor.s.pri %2!;$exp!", ";$lcl %1 %2!push.c %3!;$exp!", - #else - "\224lcl\332\227ack -4!\233\206\256\227or\222\230\252", - "\224lcl\332\331\256\252", - #endif seqsize(3,3) - seqsize(1,1) }, { - #ifdef SCPACK ";$lcl %1 %2!stack -4!zero.pri!stor.s.pri %2!;$exp!", ";$lcl %1 %2!push.c 0!;$exp!", - #else - "\224lcl\332\227ack -4!\373\227or\222\230\252", - "\224lcl\332\331 0!\252", - #endif seqsize(3,2) - seqsize(1,1) }, /* During a calculation, the intermediate result must sometimes @@ -947,56 +568,31 @@ static SETUP_SEQUENCE sequences_cmp[] = { * so add another two cases. */ { - #ifdef SCPACK "push.pri!load.s.pri %1!pop.alt!", "move.alt!load.s.pri %1!", - #else - "\244\333\241", - "\306\333", - #endif seqsize(3,1) - seqsize(2,1) }, { - #ifdef SCPACK "push.pri!load.pri %1!pop.alt!", "move.alt!load.pri %1!", - #else - "\244\311\241", - "\306\311", - #endif seqsize(3,1) - seqsize(2,1) }, { - #ifdef SCPACK "push.pri!const.pri %1!pop.alt!", "move.alt!const.pri %1!", - #else - "\244\330\241", - "\306\330", - #endif seqsize(3,1) - seqsize(2,1) }, { - #ifdef SCPACK "push.pri!zero.pri!pop.alt!", "move.alt!zero.pri!", - #else - "\244\373\241", - "\306\373", - #endif seqsize(3,0) - seqsize(2,0) }, /* saving PRI and then loading from its address * occurs when indexing a multi-dimensional array */ { - #ifdef SCPACK "push.pri!load.i!pop.alt!", "move.alt!load.i!", - #else - "\244\342i\266", - "\306\342\355", - #endif seqsize(3,0) - seqsize(2,0) }, /* An even simpler PUSH/POP optimization (occurs in @@ -1005,75 +601,40 @@ static SETUP_SEQUENCE sequences_cmp[] = { * pop.alt - */ { - #ifdef SCPACK "push.pri!pop.alt!", "move.alt!", - #else - "\244\241", - "\306", - #endif seqsize(2,0) - seqsize(1,0) }, /* Some simple arithmetic sequences */ { - #ifdef SCPACK "move.alt!load.s.pri %1!add!", "load.s.alt %1!add!", - #else - "\306\333\271", - "\375\271", - #endif seqsize(3,1) - seqsize(2,1) }, { - #ifdef SCPACK "move.alt!load.pri %1!add!", "load.alt %1!add!", - #else - "\306\311\271", - "\374\271", - #endif seqsize(3,1) - seqsize(2,1) }, { - #ifdef SCPACK "move.alt!const.pri %1!add!", "const.alt %1!add!", - #else - "\306\330\271", - "\356\271", - #endif seqsize(3,1) - seqsize(2,1) }, { - #ifdef SCPACK "move.alt!load.s.pri %1!sub.alt!", "load.s.alt %1!sub!", - #else - "\306\333sub\223", - "\375sub!", - #endif seqsize(3,1) - seqsize(2,1) }, { - #ifdef SCPACK "move.alt!load.pri %1!sub.alt!", "load.alt %1!sub!", - #else - "\306\311sub\223", - "\374sub!", - #endif seqsize(3,1) - seqsize(2,1) }, { - #ifdef SCPACK "move.alt!const.pri %1!sub.alt!", "const.alt %1!sub!", - #else - "\306\330sub\223", - "\356sub!", - #endif seqsize(3,1) - seqsize(2,1) }, /* User-defined operators first load the operands into registers and @@ -1089,83 +650,43 @@ static SETUP_SEQUENCE sequences_cmp[] = { * This gives 2 x 4 cases. */ { - #ifdef SCPACK "const.pri %1!const.alt %2!push.pri!push.alt!", "push.c %1!push.c %2!", - #else - "\330\233\304\244\354", - "\331\202\331\221", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!const.alt %2!push.alt!push.pri!", "push.c %2!push.c %1!", - #else - "\330\233\304\354\244", - "\331\221\331\202", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!load.alt %2!push.pri!push.alt!", "push.c %1!push %2!", - #else - "\330\362\244\354", - "\331\202\216\221", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!load.alt %2!push.alt!push.pri!", "push %2!push.c %1!", - #else - "\330\362\354\244", - "\216\221\331\202", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!const.alt %2!push.pri!push.alt!", "push %1!push.c %2!", - #else - "\311\233\304\244\354", - "\216\202\331\221", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!const.alt %2!push.alt!push.pri!", "push.c %2!push %1!", - #else - "\311\233\304\354\244", - "\331\221\216\202", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!load.alt %2!push.pri!push.alt!", "push %1!push %2!", - #else - "\311\362\244\354", - "\216\202\216\221", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!load.alt %2!push.alt!push.pri!", "push %2!push %1!", - #else - "\311\362\354\244", - "\216\221\216\202", - #endif seqsize(4,2) - seqsize(2,2) }, /* Function calls (parameters are passed on the stack) @@ -1188,53 +709,28 @@ static SETUP_SEQUENCE sequences_cmp[] = { * if this shortcut is used. Check for the ;$par comment. */ { - #ifdef SCPACK "load.s.pri %1!push.pri!;$par!", "push.s %1!;$par!", - #else - "\226\264\255", - "\216\222\202\255", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "load.pri %1!push.pri!;$par!", "push %1!;$par!", - #else - "\217\264\255", - "\216\202\255", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "const.pri %1!push.pri!;$par!", "push.c %1!;$par!", - #else - "\233\264\255", - "\331\202\255", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "zero.pri!push.pri!;$par!", "push.c 0!;$par!", - #else - "\373\244\255", - "\331 0!\255", - #endif seqsize(2,0) - seqsize(1,1) }, { - #ifdef SCPACK "addr.pri %1!push.pri!;$par!", "push.adr %1!;$par!", - #else - "\265\264\255", - "\216\326\202\255", - #endif seqsize(2,1) - seqsize(1,1) }, /* References with a default value generate new cells on the heap @@ -1243,13 +739,8 @@ static SETUP_SEQUENCE sequences_cmp[] = { * push.pri - */ { - #ifdef SCPACK "move.pri!push.pri!", "push.alt!", - #else - "\300\236\244", - "\354", - #endif seqsize(2,0) - seqsize(1,0) }, /* Simple arithmetic operations on constants. Noteworthy is the @@ -1268,43 +759,23 @@ static SETUP_SEQUENCE sequences_cmp[] = { * eq - */ { - #ifdef SCPACK "const.alt %1!add!", "add.c %1!", - #else - "\356\271", - "\235\242\202", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "const.alt %1!sub!", "add.c -%1!", - #else - "\356sub!", - "\235\242 -\201", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "const.alt %1!smul!", "smul.c %1!", - #else - "\356smul!", - "smu\307\202", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "const.alt %1!eq!", "eq.c.pri %1!", - #else - "\356\325", - "\262\242\225", - #endif seqsize(2,1) - seqsize(1,1) }, /* Some operations use the alternative subtraction operation --these @@ -1318,23 +789,13 @@ static SETUP_SEQUENCE sequences_cmp[] = { * sub.alt - */ { - #ifdef SCPACK "const.pri %1!load.s.alt %2!sub.alt!", "load.s.pri %2!add.c -%1!", - #else - "\330\226\304sub\223", - "\246\235\242 -\201", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!load.alt %2!sub.alt!", "load.pri %2!add.c -%1!", - #else - "\330\362sub\223", - "\334\235\242 -\201", - #endif seqsize(3,2) - seqsize(2,2) }, /* With arrays indexed with constants that come from enumerations, it happens @@ -1343,13 +804,8 @@ static SETUP_SEQUENCE sequences_cmp[] = { * add.c n2 - */ { - #ifdef SCPACK "add.c %1!add.c %2!", "add.c %1+%2!", - #else - "\235\242\202\235\242\221", - "\235\242\267+%2!", - #endif seqsize(2,2) - seqsize(1,1) }, /* Compare and jump @@ -1392,123 +848,63 @@ static SETUP_SEQUENCE sequences_cmp[] = { * jzer n1 - */ { - #ifdef SCPACK "eq!jzer %1!", "jneq %1!", - #else - "\325\323", - "jn\357", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "eq!jnz %1!", "jeq %1!", - #else - "\325jnz\202", - "j\357", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "neq!jzer %1!", "jeq %1!", - #else - "n\325\323", - "j\357", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "neq!jnz %1!", "jneq %1!", - #else - "n\325jnz\202", - "jn\357", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "less!jzer %1!", "jgeq %1!", - #else - "l\352!\323", - "jg\357", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "leq!jzer %1!", "jgrtr %1!", - #else - "l\325\323", - "jg\353r\202", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "grtr!jzer %1!", "jleq %1!", - #else - "g\353\237\323", - "jl\357", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "geq!jzer %1!", "jless %1!", - #else - "g\325\323", - "jl\352\202", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "sless!jzer %1!", "jsgeq %1!", - #else - "\372!\323", - "j\320\357", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "sleq!jzer %1!", "jsgrtr %1!", - #else - "\321\325\323", - "j\371r\202", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "sgrtr!jzer %1!", "jsleq %1!", - #else - "\371\237\323", - "j\321\357", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "sgeq!jzer %1!", "jsless %1!", - #else - "\320\325\323", - "j\372\202", - #endif seqsize(2,1) - seqsize(1,1) }, /* Test for zero (common case, especially for strings) @@ -1521,23 +917,13 @@ static SETUP_SEQUENCE sequences_cmp[] = { * jneq n1 - */ { - #ifdef SCPACK "zero.alt!jeq %1!", "jzer %1!", - #else - "\340\223j\357", - "\323", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "zero.alt!jneq %1!", "jnz %1!", - #else - "\340\223jn\357", - "jnz\202", - #endif seqsize(2,1) - seqsize(1,1) }, /* Incrementing and decrementing leaves a value in @@ -1554,83 +940,43 @@ static SETUP_SEQUENCE sequences_cmp[] = { * and decrements. */ { - #ifdef SCPACK "inc %1!load.pri %1!;$exp!", "inc %1!;$exp!", - #else - "inc\202\311\252", - "inc\301", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "load.pri %1!inc %1!;$exp!", "inc %1!;$exp!", - #else - "\311inc\301", - "inc\301", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "inc.s %1!load.s.pri %1!;$exp!", "inc.s %1!;$exp!", - #else - "inc\222\202\333\252", - "inc\222\301", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "load.s.pri %1!inc.s %1!;$exp!", "inc.s %1!;$exp!", - #else - "\333inc\222\301", - "inc\222\301", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "dec %1!load.pri %1!;$exp!", "dec %1!;$exp!", - #else - "dec\202\311\252", - "dec\301", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "load.pri %1!dec %1!;$exp!", "dec %1!;$exp!", - #else - "\311dec\301", - "dec\301", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "dec.s %1!load.s.pri %1!;$exp!", "dec.s %1!;$exp!", - #else - "dec\222\202\333\252", - "dec\222\301", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "load.s.pri %1!dec.s %1!;$exp!", "dec.s %1!;$exp!", - #else - "\333dec\222\301", - "dec\222\301", - #endif seqsize(2,2) - seqsize(1,1) }, /* ??? the same (increments and decrements) for references */ @@ -1659,63 +1005,33 @@ static SETUP_SEQUENCE sequences_cmp[] = { * time, but anyway... */ { - #ifdef SCPACK "const.pri 0!stor.pri %1!;$exp!", "zero %1!;$exp!", - #else - "\233\206 0!\227or\225\252", - "\340\301", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "const.pri 0!stor.s.pri %1!;$exp!", "zero.s %1!;$exp!", - #else - "\233\206 0!\227or\222\225\252", - "\340\222\301", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "zero.pri!stor.pri %1!;$exp!", "zero %1!;$exp!", - #else - "\373\227or\225\252", - "\340\301", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "zero.pri!stor.s.pri %1!;$exp!", "zero.s %1!;$exp!", - #else - "\373\227or\222\225\252", - "\340\222\301", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "const.pri 0!", "zero.pri!", - #else - "\233\206 0!", - "\373", - #endif seqsize(1,1) - seqsize(1,0) }, { - #ifdef SCPACK "const.alt 0!", "zero.alt!", - #else - "\233\212 0!", - "\340\223", - #endif seqsize(1,1) - seqsize(1,0) }, @@ -1729,13 +1045,8 @@ static SETUP_SEQUENCE sequences_cmp[] = { * count pushed before, and the stack pointer restored afterwards */ { - #ifdef SCPACK "push.c %1!sysreq.c %2!stack %3!", //note: %3 == %1 + 4 "sysreq.n %2 %1!", - #else - "\331\202sysr\262\242\221\227ack\256", - "sysr\262.n\220\202", - #endif seqsize(3,3) - seqsize(1,2) }, /* ----- */ @@ -1751,166 +1062,86 @@ static SETUP_SEQUENCE sequences_cmp[] = { * Similar sequences occur with PUSH, PUSH.s and PUSHADDR */ { - #ifdef SCPACK "push.c %1!;$par!push.c %2!;$par!push.c %3!;$par!push.c %4!;$par!push.c %5!", "push5.c %1 %2 %3 %4 %5!", - #else - "\331\336\242\345\242\256\257\242\335\257\242\2035!", - "\2165\242\343\245\302\2035!", - #endif seqsize(5,5) - seqsize(1,5) }, { - #ifdef SCPACK "push.c %1!;$par!push.c %2!;$par!push.c %3!;$par!push.c %4!", "push4.c %1 %2 %3 %4!", - #else - "\331\336\242\345\242\256\257\242\335", - "\2164\242\343\245\335", - #endif seqsize(4,4) - seqsize(1,4) }, { - #ifdef SCPACK "push.c %1!;$par!push.c %2!;$par!push.c %3!", "push3.c %1 %2 %3!", - #else - "\331\336\242\345\242\256", - "\2163\242\343\256", - #endif seqsize(3,3) - seqsize(1,3) }, { - #ifdef SCPACK "push.c %1!;$par!push.c %2!", "push2.c %1 %2!", - #else - "\331\336\242\221", - "\2162\242\332", - #endif seqsize(2,2) - seqsize(1,2) }, /* ----- */ { - #ifdef SCPACK "push %1!;$par!push %2!;$par!push %3!;$par!push %4!;$par!push %5!", "push5 %1 %2 %3 %4 %5!", - #else - "\216\336\345\256\257\335\257\2035!", - "\2165\343\245\302\2035!", - #endif seqsize(5,5) - seqsize(1,5) }, { - #ifdef SCPACK "push %1!;$par!push %2!;$par!push %3!;$par!push %4!", "push4 %1 %2 %3 %4!", - #else - "\216\336\345\256\257\335", - "\2164\343\245\335", - #endif seqsize(4,4) - seqsize(1,4) }, { - #ifdef SCPACK "push %1!;$par!push %2!;$par!push %3!", "push3 %1 %2 %3!", - #else - "\216\336\345\256", - "\2163\343\256", - #endif seqsize(3,3) - seqsize(1,3) }, { - #ifdef SCPACK "push %1!;$par!push %2!", "push2 %1 %2!", - #else - "\216\336\221", - "\2162\332", - #endif seqsize(2,2) - seqsize(1,2) }, /* ----- */ { - #ifdef SCPACK "push.s %1!;$par!push.s %2!;$par!push.s %3!;$par!push.s %4!;$par!push.s %5!", "push5.s %1 %2 %3 %4 %5!", - #else - "\216\222\336\222\345\222\256\257\222\335\257\222\2035!", - "\2165\222\343\245\302\2035!", - #endif seqsize(5,5) - seqsize(1,5) }, { - #ifdef SCPACK "push.s %1!;$par!push.s %2!;$par!push.s %3!;$par!push.s %4!", "push4.s %1 %2 %3 %4!", - #else - "\216\222\336\222\345\222\256\257\222\335", - "\2164\222\343\245\335", - #endif seqsize(4,4) - seqsize(1,4) }, { - #ifdef SCPACK "push.s %1!;$par!push.s %2!;$par!push.s %3!", "push3.s %1 %2 %3!", - #else - "\216\222\336\222\345\222\256", - "\2163\222\343\256", - #endif seqsize(3,3) - seqsize(1,3) }, { - #ifdef SCPACK "push.s %1!;$par!push.s %2!", "push2.s %1 %2!", - #else - "\216\222\336\222\221", - "\2162\222\332", - #endif seqsize(2,2) - seqsize(1,2) }, /* ----- */ { - #ifdef SCPACK "push.adr %1!;$par!push.adr %2!;$par!push.adr %3!;$par!push.adr %4!;$par!push.adr %5!", "push5.adr %1 %2 %3 %4 %5!", - #else - "\216\326\336\326\345\326\256\257\326\335\257\326\2035!", - "\2165\326\343\245\302\2035!", - #endif seqsize(5,5) - seqsize(1,5) }, { - #ifdef SCPACK "push.adr %1!;$par!push.adr %2!;$par!push.adr %3!;$par!push.adr %4!", "push4.adr %1 %2 %3 %4!", - #else - "\216\326\336\326\345\326\256\257\326\335", - "\2164\326\343\245\335", - #endif seqsize(4,4) - seqsize(1,4) }, { - #ifdef SCPACK "push.adr %1!;$par!push.adr %2!;$par!push.adr %3!", "push3.adr %1 %2 %3!", - #else - "\216\326\336\326\345\326\256", - "\2163\326\343\256", - #endif seqsize(3,3) - seqsize(1,3) }, { - #ifdef SCPACK "push.adr %1!;$par!push.adr %2!", "push2.adr %1 %2!", - #else - "\216\326\336\326\221", - "\2162\326\332", - #endif seqsize(2,2) - seqsize(1,2) }, /* Loading two registers at a time @@ -1927,43 +1158,23 @@ static SETUP_SEQUENCE sequences_cmp[] = { * load.s.pri n1 - */ { - #ifdef SCPACK "load.pri %1!load.alt %2!", "load.both %1 %2!", - #else - "\311\362", - "\342\275th\332", - #endif seqsize(2,2) - seqsize(1,2) }, { - #ifdef SCPACK "load.alt %2!load.pri %1!", "load.both %1 %2!", - #else - "\362\311", - "\342\275th\332", - #endif seqsize(2,2) - seqsize(1,2) }, { - #ifdef SCPACK "load.s.pri %1!load.s.alt %2!", "load.s.both %1 %2!", - #else - "\333\226\304", - "\226.\275th\332", - #endif seqsize(2,2) - seqsize(1,2) }, { - #ifdef SCPACK "load.s.alt %2!load.s.pri %1!", "load.s.both %1 %2!", - #else - "\226\304\333", - "\226.\275th\332", - #endif seqsize(2,2) - seqsize(1,2) }, /* Loading two registers and then pushing them occurs with user operators @@ -1976,23 +1187,13 @@ static SETUP_SEQUENCE sequences_cmp[] = { * push.alt - */ { - #ifdef SCPACK "load.both %1 %2!push.pri!push.alt!", "push2 %1 %2!", - #else - "\342\275th\332\244\354", - "\2162\332", - #endif seqsize(3,2) - seqsize(1,2) }, { - #ifdef SCPACK "load.s.both %1 %2!push.pri!push.alt!", "push2.s %1 %2!", - #else - "\226.\275th\332\244\354", - "\2162\222\332", - #endif seqsize(3,2) - seqsize(1,2) }, /* Load a constant in a variable @@ -2003,23 +1204,13 @@ static SETUP_SEQUENCE sequences_cmp[] = { * stor.s.pri n2 - */ { - #ifdef SCPACK "const.pri %1!stor.pri %2!", "const %2 %1!", - #else - "\330\227or\230", - "\233\220\202", - #endif seqsize(2,2) - seqsize(1,2) }, { - #ifdef SCPACK "const.pri %1!stor.s.pri %2!", "const.s %2 %1!", - #else - "\330\227or\222\230", - "\233\222\220\202", - #endif seqsize(2,2) - seqsize(1,2) }, /* ----- */ diff --git a/sourcepawn/compiler/sc7.cpp b/sourcepawn/compiler/sc7.cpp index 8b417eee..fd474523 100644 --- a/sourcepawn/compiler/sc7.cpp +++ b/sourcepawn/compiler/sc7.cpp @@ -62,7 +62,7 @@ #pragma warning(disable:4125) /* decimal digit terminates octal escape sequence */ #endif -#include +#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=0 && var -#include -#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 - diff --git a/sourcepawn/compiler/scpack.c b/sourcepawn/compiler/scpack.c deleted file mode 100644 index 37d553c8..00000000 --- a/sourcepawn/compiler/scpack.c +++ /dev/null @@ -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 -#include -#include -#include -#include - -#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 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 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= 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 [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; -}