liblua: fix mix of spaces & tabs

This commit is contained in:
Philippe Teuwen 2019-03-09 18:16:50 +01:00
commit 2b1b76c2a9
53 changed files with 1030 additions and 1029 deletions

View file

@ -20,17 +20,17 @@
#include "lundump.h"
static void PrintFunction(const Proto* f, int full);
#define luaU_print PrintFunction
#define luaU_print PrintFunction
#define PROGNAME "luac" /* default program name */
#define OUTPUT PROGNAME ".out" /* default output file */
#define PROGNAME "luac" /* default program name */
#define OUTPUT PROGNAME ".out" /* default output file */
static int listing=0; /* list bytecodes? */
static int dumping=1; /* dump bytecodes? */
static int stripping=0; /* strip debug information? */
static char Output[]={ OUTPUT }; /* default output file name */
static const char* output=Output; /* actual output file name */
static const char* progname=PROGNAME; /* actual program name */
static int listing=0; /* list bytecodes? */
static int dumping=1; /* dump bytecodes? */
static int stripping=0; /* strip debug information? */
static char Output[]={ OUTPUT }; /* default output file name */
static const char* output=Output; /* actual output file name */
static const char* progname=PROGNAME; /* actual program name */
static void fatal(const char* message)
{
@ -64,7 +64,7 @@ static void usage(const char* message)
exit(EXIT_FAILURE);
}
#define IS(s) (strcmp(argv[i],s)==0)
#define IS(s) (strcmp(argv[i],s)==0)
static int doargs(int argc, char* argv[])
{
@ -73,32 +73,32 @@ static int doargs(int argc, char* argv[])
if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0];
for (i=1; i<argc; i++)
{
if (*argv[i]!='-') /* end of options; keep it */
if (*argv[i]!='-') /* end of options; keep it */
break;
else if (IS("--")) /* end of options; skip it */
else if (IS("--")) /* end of options; skip it */
{
++i;
if (version) ++version;
break;
}
else if (IS("-")) /* end of options; use stdin */
else if (IS("-")) /* end of options; use stdin */
break;
else if (IS("-l")) /* list */
else if (IS("-l")) /* list */
++listing;
else if (IS("-o")) /* output file */
else if (IS("-o")) /* output file */
{
output=argv[++i];
if (output==NULL || *output==0 || (*output=='-' && output[1]!=0))
usage(LUA_QL("-o") " needs argument");
if (IS("-")) output=NULL;
}
else if (IS("-p")) /* parse only */
else if (IS("-p")) /* parse only */
dumping=0;
else if (IS("-s")) /* strip debug information */
else if (IS("-s")) /* strip debug information */
stripping=1;
else if (IS("-v")) /* show version */
else if (IS("-v")) /* show version */
++version;
else /* unknown option */
else /* unknown option */
usage(argv[i]);
}
if (i==argc && (listing || !dumping))
@ -218,7 +218,7 @@ int main(int argc, char* argv[])
#include "lobject.h"
#include "lopcodes.h"
#define VOID(p) ((const void*)(p))
#define VOID(p) ((const void*)(p))
static void PrintString(const TString* ts)
{
@ -239,10 +239,10 @@ static void PrintString(const TString* ts)
case '\r': printf("\\r"); break;
case '\t': printf("\\t"); break;
case '\v': printf("\\v"); break;
default: if (isprint(c))
printf("%c",c);
else
printf("\\%03d",c);
default: if (isprint(c))
printf("%c",c);
else
printf("\\%03d",c);
}
}
printf("%c",'"');
@ -254,25 +254,25 @@ static void PrintConstant(const Proto* f, int i)
switch (ttype(o))
{
case LUA_TNIL:
printf("nil");
break;
printf("nil");
break;
case LUA_TBOOLEAN:
printf(bvalue(o) ? "true" : "false");
break;
printf(bvalue(o) ? "true" : "false");
break;
case LUA_TNUMBER:
printf(LUA_NUMBER_FMT,nvalue(o));
break;
printf(LUA_NUMBER_FMT,nvalue(o));
break;
case LUA_TSTRING:
PrintString(rawtsvalue(o));
break;
default: /* cannot happen */
printf("? type=%d",ttype(o));
break;
PrintString(rawtsvalue(o));
break;
default: /* cannot happen */
printf("? type=%d",ttype(o));
break;
}
}
#define UPVALNAME(x) ((f->upvalues[x].name) ? getstr(f->upvalues[x].name) : "-")
#define MYK(x) (-1-(x))
#define MYK(x) (-1-(x))
static void PrintCode(const Proto* f)
{
@ -372,8 +372,8 @@ static void PrintCode(const Proto* f)
}
}
#define SS(x) ((x==1)?"":"s")
#define S(x) (int)(x),SS(x)
#define SS(x) ((x==1)?"":"s")
#define S(x) (int)(x),SS(x)
static void PrintHeader(const Proto* f)
{
@ -385,14 +385,14 @@ static void PrintHeader(const Proto* f)
else
s="(string)";
printf("\n%s <%s:%d,%d> (%d instruction%s at %p)\n",
(f->linedefined==0)?"main":"function",s,
f->linedefined,f->lastlinedefined,
S(f->sizecode),VOID(f));
(f->linedefined==0)?"main":"function",s,
f->linedefined,f->lastlinedefined,
S(f->sizecode),VOID(f));
printf("%d%s param%s, %d slot%s, %d upvalue%s, ",
(int)(f->numparams),f->is_vararg?"+":"",SS(f->numparams),
S(f->maxstacksize),S(f->sizeupvalues));
(int)(f->numparams),f->is_vararg?"+":"",SS(f->numparams),
S(f->maxstacksize),S(f->sizeupvalues));
printf("%d local%s, %d constant%s, %d function%s\n",
S(f->sizelocvars),S(f->sizek),S(f->sizep));
S(f->sizelocvars),S(f->sizek),S(f->sizep));
}
static void PrintDebug(const Proto* f)