Remove string compression

This removes all scpack-packed strings and moves normal strings from
.scp files to corresponding .c files. The code responding for packing
and unpacking is gone as well.

If you have enough memory to run a SA-MP server you most likely have
more than enough of it to not worry about saving a few additional KBs
of text. Besides, these strings were kind of hard to navigate / edit,
and you could easily forget to regenerate them with scpack (though it
could be automated).
This commit is contained in:
Zeex 2015-04-06 16:09:54 +06:00
parent 2e162eae9c
commit 867f6902f3
7 changed files with 1343 additions and 2922 deletions

View File

@ -56,8 +56,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
# The Pawn compiler shared library
set(PAWNC_SRCS sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c
scexpand.c sci18n.c sclist.c scmemfil.c scstate.c scvars.c
lstring.c memfile.c libpawnc.c)
sci18n.c sclist.c scmemfil.c scstate.c scvars.c
lstring.c memfile.c libpawnc.c)
set_source_files_properties(sc1.c COMPILE_FLAGS -DNO_MAIN)
if(WIN32)
set(PAWNC_SRCS ${PAWNC_SRCS} libpawnc.rc)

View File

@ -37,16 +37,161 @@
#endif
#include "sc.h"
#if defined _MSC_VER
#pragma warning(push)
#pragma warning(disable:4125) /* decimal digit terminates octal escape sequence */
#endif
static 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 dimensions 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"
};
#include "sc5.scp"
static char *fatalmsg[] = {
/*100*/ "cannot read from file: \"%s\"\n",
/*101*/ "cannot write to file: \"%s\"\n",
/*102*/ "table overflow: \"%s\"\n",
/* table can be: loop table
* literal table
* staging buffer
* option table (response file)
* peephole optimizer table
*/
/*103*/ "insufficient memory\n",
/*104*/ "invalid assembler instruction \"%s\"\n",
/*105*/ "numeric overflow, exceeding capacity\n",
/*106*/ "compiled script exceeds the maximum memory size (%ld bytes)\n",
/*107*/ "too many error messages on one line\n",
/*108*/ "codepage mapping file not found\n",
/*109*/ "invalid path: \"%s\"\n",
/*110*/ "assertion failed: %s\n",
/*111*/ "user error: %s\n"
};
#if defined _MSC_VER
#pragma warning(pop)
#endif
static 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*/ "indeterminate array size in \"sizeof\" expression (symbol \"%s\")\n",
/*225*/ "unreachable code\n",
/*226*/ "a variable is assigned to itself (symbol \"%s\")\n",
/*227*/ "more initiallers than enum fields\n",
/*228*/ "length of initialler 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*/ "function is deprecated (symbol \"%s\") %s\n",
/*235*/ "public function lacks forward declaration (symbol \"%s\")\n",
/*236*/ "unknown parameter in substitution (incorrect #define pattern)\n",
/*237*/ "user warning: %s\n"
};
#define NUM_WARNINGS (sizeof warnmsg / sizeof warnmsg[0])
static struct s_warnstack {
@ -77,7 +222,6 @@ static int lastline,errorcount;
static short lastfile;
char *msg,*pre;
va_list argptr;
char string[128];
/* errflag is reset on each semicolon.
* In a two-pass compiler, an error should not be reported twice. Therefore
@ -110,8 +254,6 @@ static short lastfile;
warnnum++;
} /* if */
strexpand(string,(unsigned char *)msg,sizeof string,SCPACK_TABLE);
assert(errstart<=fline);
if (errline>0)
errstart=errline;
@ -121,7 +263,7 @@ static short lastfile;
va_start(argptr,number);
if (strlen(errfname)==0) {
int start= (errstart==errline) ? -1 : errstart;
if (pc_error(number,string,inpfname,start,errline,argptr)) {
if (pc_error(number,msg,inpfname,start,errline,argptr)) {
if (outf!=NULL) {
pc_closeasm(outf,TRUE);
outf=NULL;
@ -135,7 +277,7 @@ static short lastfile;
fprintf(fp,"%s(%d -- %d) : %s %03d: ",inpfname,errstart,errline,pre,number);
else
fprintf(fp,"%s(%d) : %s %03d: ",inpfname,errline,pre,number);
vfprintf(fp,string,argptr);
vfprintf(fp,msg,argptr);
fclose(fp);
} /* if */
} /* if */
@ -258,4 +400,3 @@ int pc_popwarnings()
return TRUE;
}
#undef SCPACK_TABLE

View File

@ -1,344 +0,0 @@
/* 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: sc5.sch 3633 2006-08-11 16:20:18Z thiadmer $
*/
SC_FUNC int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]);
#define SCPACK_TABLE errstr_table
/*-*SCPACK start of pair table, do not change or remove this line */
unsigned char errstr_table[][2] = {
{101,32}, {111,110}, {116,32}, {105,110}, {97,114}, {116,105}, {100,32}, {115,32}, {101,114}, {37,115}, {97,108}, {101,110}, {133,129}, {34,137}, {141,34}, {117,110},
{114,101}, {110,111}, {115,105}, {121,32}, {97,116}, {111,114}, {97,110}, {32,142}, {109,98}, {115,116}, {41,10}, {100,101}, {109,139}, {101,134}, {98,108}, {140,32},
{111,108}, {114,97}, {145,130}, {118,138}, {143,99}, {102,164}, {115,121}, {166,152}, {167,160}, {117,115}, {97,32}, {115,146}, {97,158}, {149,32}, {132,161}, {105,134},
{103,32}, {136,32}, {163,175}, {103,117}, {179,156}, {131,178}, {132,180}, {111,102}, {116,104}, {101,120}, {105,135}, {165,159}, {101,100}, {99,104}, {118,132}, {168,151},
{105,172}, {190,192}, {155,102}, {174,147}, {183,32}, {109,97}, {116,111}, {99,129}, {101,135}, {112,144}, {182,130}, {98,128}, {115,10}, {153,148}, {44,32}, {40,191},
{169,130}, {151,10}, {101,10}, {207,154}, {109,208}, {116,97}, {194,131}, {193,128}, {34,32}, {129,32}, {105,99}, {132,97}, {100,105}, {146,122}, {110,32}, {138,32},
{104,97}, {101,108}, {117,108}, {99,111}, {108,111}, {109,148}, {199,153}, {58,209}, {111,112}, {97,115}, {108,128}, {232,136}, {230,150}, {150,32}, {201,171}, {131,176},
{212,203}, {102,105}, {119,105}, {185,238}, {109,112}, {116,136}, {165,140}, {197,147}, {102,149}, {111,32}, {131,32}, {213,176}, {110,117}, {115,117}, {118,128}
};
/*-*SCPACK end of pair table, do not change or remove this line */
static 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 dimensions 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"
#else
"\271pect\235\306k\213:\227\316bu\202fo\217\206\216\012",
"\201l\223\252s\203g\352\315e\234\202(\255\363\201) c\355f\240\344w ea\275 \042c\351e\042\012",
"\233cl\333\237\304\252\344c\337\327\324appe\204 \372\252\343\364o\217\206\236ock\012",
"\366\227 \272\242i\364le\234t\274\012",
"\273\367\242\340\376\266t\314",
"\360a\253gn\235\306 \355\256y\012",
"\353\224\255c\226\242\313\220\326\274\012",
"\360\252\354\202\363\201; \351\375m\235z\210o\012",
"\265\303\335\200(nega\205ve\316z\210\371\255ou\202\304bo\217ds\232",
"\265\273\255\233cl\333\214\012",
"\265out\222d\200\366\314",
"\265\273c\212l\316\242\252\262add\220s\314",
"\221 \213tr\223po\203\202(\221 pu\236\332 \366s\232",
"\265\315e\234t; \242\372s\362t\275\012",
"\042\302a\342t\330c\351\200\360\270\200l\351\202c\351\200\372s\362t\275 \315e\234t\012",
"m\342\205p\352\302a\342t\207\372\042s\362t\275\042\012",
"\217\326\235\277\012",
"\203i\205\212iza\237d\224\252\271ce\274\207\233cl\204\235\335\322",
"\242\252lab\341\347",
"\265\250 nam\200\216\012",
"\250 \212\220ad\223\326\274\347",
"\360l\243u\200(n\201-\354t\232",
"\303a\253gn\234\202\360\222\364\352a\253gn\234t\012",
"\042b\220ak\330\255\042\307t\203ue\330\272ou\202\304\307t\271t\012",
"\273head\357\334ff\210\207from pro\306typ\322",
"\221 \345\275\357\042#if...\042\012",
"\265\275\333ct\261\354t\012",
"\265\375bscrip\202(\242\355\303\255\306\371m\226\223\375bscripts)\347",
"\265\363\201\316\351\375m\235z\210o\012",
"\343\364o\217\206\315e\234\202\242c\344s\235a\202\270\200\213\206\304\361\352(\231\204t\235a\202l\203\200%d\232",
"\217k\221w\336\334\220c\205v\322",
"\303\203\233x ou\202\304bo\217d\207(\327\216\232",
"\303\360\203\233x\235(\327\216\232",
"\312do\310\242\340\376\252\302a\342\202\243u\200(\312%d\232",
"\312typ\200mis\345\275 (\312%d\232",
"e\364t\223\315e\234t\012",
"\265\231r\357(po\253\236\223n\201-\365m\203\224\235\231r\203g\232",
"\271t\241 \275\333c\365\207\331l\203\322",
"\354\202\250 \340\207\221 \335\322",
"dupl\332\224\200\042c\351e\330lab\341 (\243u\200%d\232",
"\265\341lip\222s\316\303\335\200\272\242k\221wn\012",
"\265\343\230\203a\237\304cl\351\207speci\361\210\314",
"\275\333ct\261\354\202\271ce\274\207r\226g\200f\255pack\235\231r\203g\012",
"po\222\214\337p\333me\365\207\324\311c\274\200\212l nam\235p\333me\365\314",
"\306\371m\226\223\273\266t\314",
"\217k\221w\336\303\335\200(\327\216\232",
"\303\335\310d\371\242\345\275\316\255\233\231\203a\237\303\272\306\371sm\212l\012",
"\303\334\234\222\201\207d\371\242\345\275\012",
"\265l\203\200\307t\203ua\214\012",
"\265r\226g\322",
"\265\375bscript\316\251\200\042[ ]\330\353\224\225\207\331\305j\255\334\234\222\201\314",
"m\342\205-\334\234\222\201\337\256y\207\360f\342l\223\203i\205\212iz\274\012",
"\271ce\274\357\305ximum \374\230\261\304\334\234\222\201\314",
"\217\345\275\235c\344s\357b\241c\200(\042}\042\232",
"\231\204\202\304\273bod\223\362\270ou\202\273head\210\012",
"\256ys\316\344c\337\301\310\226\206\273\266t\207c\226\242\313pu\236\332 (\327\216\232",
"\217f\203ish\235\363\331be\370\200\343\364il\261\334\220c\205v\322",
"dupl\332\224\200\266t; sam\200\312\272p\351s\235tw\332\322",
"\273\312\367\242\340\376\252\302a\342\202\243u\200(\327\216\232",
"m\342\205p\352\042#\341se\330\334\220c\205v\310betwe\213 \042#if ... #\213\334f\042\012",
"\042#\341seif\330\334\220c\205\376f\240\344w\207\355\042#\341se\330\334\220c\205v\322",
"\374\230\261\304\353\226d\207do\310\242\361\202\270\200\353\224\225\012",
"\273\220s\342\202\373\304\353\224\225\227 \360\216\012",
"c\226\242\275\226g\200\311\326\235\353\224\225\314",
"\273\312\367\201l\223\340\376\252s\203g\352\373(\312%d\232",
"\273\312\367\242\313\252\220f\210\213c\200\312\255\355\303(\312\216\232",
"\327c\226\242\313bo\270 \252\220f\210\213c\200\226\206\355\303(\327\216\232",
"\265\241\214\337\374\230\261\311ci\222\331\372#p\241g\305\012",
"\241\214\337\374\230\261\370\305\202\212\220ad\223\326\274\012",
"\241\214\337\374\230\261\375pp\225\202wa\207\242\213\254\274\012",
"\251\210-\326\235\353\224\255\360\233cl\204\235be\370\200\251\200(\366\227\232",
"\042\335e\267\330\353\224\255\272\265\331\042\366\330\250\314",
"\273\312\360\355\303(\312\216\232",
"#\326\200p\224\365\336\324\231\204\202\362\270 \355\212p\340be\205c \275\333c\365\012",
"\203pu\202l\203\200\306\371l\201\260(aft\261\375bs\205tu\214s\232",
"\246n\325x \210r\255\372\270\200\363\201\316\255\265\273c\212l\012",
"m\212\370m\235UTF-8 \213\343d\203g\316\255c\225rupt\235\361le: \211\012",
"\273\251\310bo\270 \042\220turn\330\226\206\042\220tur\336<\243ue>\042\012",
"\203\307\222\231\213\202\220tur\336typ\310(\303& n\201-\256y\232",
"\217k\221w\336\250\316\255\242\252\354\202\250 \323",
"c\226\242\325k\200\252\373a\207\252\302a\342\202\243u\200f\255\355\203\233x\235\303p\333met\261\323",
"\251\210-\326\235\353\224\225\207\226\206na\205\376\366\207\367\242\340\376\315e\314",
"\252\273\255\327\367\201l\223b\341\201\260\306 \252s\203g\352au\306\345\331\323",
"\315\200\307fl\332t: \201\200\304\270\200\315\310\272\212\220ad\223a\253gn\235\306 a\221\270\261i\364le\234\325\237\323",
"\221 \315\310\204\200\326\235f\255\277\012",
"\217k\221w\336au\306\345\201\321",
"\217k\221w\336\315\200\216 f\255au\306\345\201\321",
"pu\236\332 \301\310\226\206\344c\337\301\310\367\242\340\376\315\310\323",
"\315\200\301\310\367\242\313\203i\205\212iz\235\323",
"pu\236\332 \366\207\367\242\220tur\336\256y\207\323",
"a\230i\263ou\207\354t; \373ov\210rid\200\272\220qui\220\206\323"
#endif
};
static char *fatalmsg[] = {
#ifdef SCPACK
/*100*/ "cannot read from file: \"%s\"\n",
/*101*/ "cannot write to file: \"%s\"\n",
/*102*/ "table overflow: \"%s\"\n",
/* table can be: loop table
* literal table
* staging buffer
* option table (response file)
* peephole optimizer table
*/
/*103*/ "insufficient memory\n",
/*104*/ "invalid assembler instruction \"%s\"\n",
/*105*/ "numeric overflow, exceeding capacity\n",
/*106*/ "compiled script exceeds the maximum memory size (%ld bytes)\n",
/*107*/ "too many error messages on one line\n",
/*108*/ "codepage mapping file not found\n",
/*109*/ "invalid path: \"%s\"\n",
/*110*/ "assertion failed: %s\n",
/*111*/ "user error: %s\n"
#else
"c\226\242\220a\206from \361le\347",
"c\226\242writ\200\306 \361le\347",
"t\254\200ov\210f\344w\347",
"\203\375ff\332i\213\202mem\225y\012",
"\265\351se\230l\261\203\231ruc\214\321",
"\374m\210\332 ov\210f\344w\316\271ce\274\357capacity\012",
"\343\364il\235scrip\202\271ce\274\207\270\200\305ximum mem\225\223\335\200(%l\206bytes\232",
"\306\371m\226\223\210r\255messag\310\331\201\200l\203\322",
"\343\233pag\200\305pp\357\361\352\242fo\217d\012",
"\265p\224h\347",
"\351s\210\237fail\274: \211\012",
"\251\261\210r\225: \211\012"
#endif
};
static 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",
/*224*/ "indeterminate array size in \"sizeof\" expression (symbol \"%s\")\n",
/*225*/ "unreachable code\n",
/*226*/ "a variable is assigned to itself (symbol \"%s\")\n",
/*227*/ "more initiallers than enum fields\n",
/*228*/ "length of initialler 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*/ "function is deprecated (symbol \"%s\") %s\n",
/*235*/ "public function lacks forward declaration (symbol \"%s\")\n",
/*236*/ "unknown parameter in substitution (incorrect #define pattern)\n",
/*237*/ "user warning: %s\n"
#else
"\277 \272tr\244\224\235\306 %\206\275\333c\365\314",
"\220\326i\237\304\354t/\305cr\371\323",
"\374\230\261\304\266t\207do\310\242\345\275 \326i\214\012",
"\250 \272nev\261\251\274\347",
"\250 \272a\253gn\235\252\243u\200\270a\202\272nev\261\251\274\347",
"\220d\217d\226\202\343\233: \354\202\363\331\272z\210o\012",
"\220d\217d\226\202te\231: \354\202\363\331\272n\201-z\210o\012",
"\217k\221w\336#p\241g\305\012",
"\273\362\270 \373\220s\342\202\251\235be\370\200\326i\214\316\370c\357\220p\204s\322",
"\366\227 sho\342\206\220tur\336\252\243u\322",
"po\253\236\200\251\200\304\250 be\370\200\203i\205\212iza\214\347",
"po\253\236\223\217\203t\213\233\206a\253gn\234t\012",
"po\253\236\223\217\203t\213\233\206bit\362s\200\353a\214\012",
"\373mis\345\275\012",
"po\253\236\223\252\042\346\330\303\312wa\207\203t\213\233d\347",
"\363\331\340\207\221 effect\012",
"ne\231\235\343m\234t\012",
"\344os\200\203d\213\325\214\012",
"\240\206\231y\352pro\306typ\310\251\235\362\270 \350\214\337sem\332\240umn\314",
"\344c\337\327\216 s\340dow\207\252\327a\202\252\311c\274\357lev\341\012",
"\363\331\362\270 \373ov\210rid\200\324appe\204 betwe\213 p\204\213\270ese\314",
"lab\341 nam\200\216 s\340dow\207\373nam\322",
"\374\230\261\304\334git\207\271ce\274\207\241\214\337\374\230\261\311ci\222\201\012",
"\220d\217d\226\202\042\335e\267\042: \312\335\200\272\212way\2071 \323",
"\203\233\365m\203\224\200\303\335\200\372\042\335e\267\330\363\331\323",
"\217\220a\275\254\200\343\233\012",
"\252\327\272a\253gn\235\306 its\341f \323",
"m\225\200\203i\205\212l\210\207\270\355\213um \361\341d\314",
"l\213g\270 \304\203i\205\212l\261\271ce\274\207\335\200\304\270\200\213um \361\341d\012",
"\203\233x \373mis\345\275 \323",
"\221 i\364le\234\325\237f\255\315\200\216 \372\366\227\316\221 f\212l-back\012",
"\315\200specif\332a\237\331\370w\204\206\233cl\333\237\272ig\221\220d\012",
"outpu\202\361\352\272writt\213\316bu\202\362\270 \343\364ac\202\213\343d\357\334s\254\274\012",
"\315\200\327\216 s\340dow\207\252g\344b\337\301\322",
"\273\272\233\311c\224\235\317) \211\012",
"pu\236\332 \273lack\207\370w\204\206\233cl\333\237\323",
"\217k\221w\336p\333met\261\372\375bs\205tu\237(\203c\225\220c\202#\326\200p\224\365n\232",
"\251\261w\204n\203g: \211\012"
#endif
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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
SC_FUNC int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2])
{
unsigned char stack[STACKSIZE];
short c, top = 0;
int 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

View File

@ -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;
}