mirror of
https://github.com/nmap/nmap.git
synced 2026-01-02 04:49:02 +00:00
Merge branch 'nse-lua53'
Lua 5.3 adds several awesome features of particular interest to nmap including bitwise operators and integers, a utf8 library, and standard binary pack/unpack functions. In addition to adding Lua 5.3, this branch changes: o Complete removal of the NSE bit library (in C), It has been replaced with a new Lua library wrapping Lua 5.3's bit-wise operators. o Complete removal of the NSE bin library (in C). It has been replaced with a new Lua library wrapping Lua 5.3's string.pack|unpack functions. o The bin.pack "B" format specifier (which has never worked correctly) is unimplemented. All scripts/libraries which use it have been updated. Most usage of this option was to allow string based bit-wise operations which are no longer necessary now that Lua 5.3 provides integers and bit-wise operators. o The base32/base64 libraries have been reimplemented using Lua 5.3's new bitwise operators. (This library was the main user of the bin.pack "B" format specifier.) o A new "bits" library has been added for common bit hacks. Currently only has a reverse function. Thanks to David Fifield, Daniel Miller, Jacek Wielemborek, and Paulino Calderon for testing this branch.
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
/*
|
||||
** $Id: luac.c,v 1.69 2011/11/29 17:46:33 lhf Exp $
|
||||
** Lua compiler (saves bytecodes to files; also list bytecodes)
|
||||
** $Id: luac.c,v 1.75 2015/03/12 01:58:27 lhf Exp $
|
||||
** Lua compiler (saves bytecodes to files; also lists bytecodes)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#define luac_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "lprefix.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define luac_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
@@ -47,14 +50,14 @@ static void cannot(const char* what)
|
||||
static void usage(const char* message)
|
||||
{
|
||||
if (*message=='-')
|
||||
fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message);
|
||||
fprintf(stderr,"%s: unrecognized option '%s'\n",progname,message);
|
||||
else
|
||||
fprintf(stderr,"%s: %s\n",progname,message);
|
||||
fprintf(stderr,
|
||||
"usage: %s [options] [filenames]\n"
|
||||
"Available options are:\n"
|
||||
" -l list (use -l -l for full listing)\n"
|
||||
" -o name output to file " LUA_QL("name") " (default is \"%s\")\n"
|
||||
" -o name output to file 'name' (default is \"%s\")\n"
|
||||
" -p parse only\n"
|
||||
" -s strip debug information\n"
|
||||
" -v show version information\n"
|
||||
@@ -89,7 +92,7 @@ static int doargs(int argc, char* argv[])
|
||||
{
|
||||
output=argv[++i];
|
||||
if (output==NULL || *output==0 || (*output=='-' && output[1]!=0))
|
||||
usage(LUA_QL("-o") " needs argument");
|
||||
usage("'-o' needs argument");
|
||||
if (IS("-")) output=NULL;
|
||||
}
|
||||
else if (IS("-p")) /* parse only */
|
||||
@@ -203,7 +206,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
/*
|
||||
** $Id: print.c,v 1.69 2013/07/04 01:03:46 lhf Exp $
|
||||
** $Id: luac.c,v 1.75 2015/03/12 01:58:27 lhf Exp $
|
||||
** print bytecodes
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -223,7 +226,7 @@ int main(int argc, char* argv[])
|
||||
static void PrintString(const TString* ts)
|
||||
{
|
||||
const char* s=getstr(ts);
|
||||
size_t i,n=ts->tsv.len;
|
||||
size_t i,n=tsslen(ts);
|
||||
printf("%c",'"');
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
@@ -251,7 +254,7 @@ static void PrintString(const TString* ts)
|
||||
static void PrintConstant(const Proto* f, int i)
|
||||
{
|
||||
const TValue* o=&f->k[i];
|
||||
switch (ttypenv(o))
|
||||
switch (ttype(o))
|
||||
{
|
||||
case LUA_TNIL:
|
||||
printf("nil");
|
||||
@@ -259,11 +262,19 @@ static void PrintConstant(const Proto* f, int i)
|
||||
case LUA_TBOOLEAN:
|
||||
printf(bvalue(o) ? "true" : "false");
|
||||
break;
|
||||
case LUA_TNUMBER:
|
||||
printf(LUA_NUMBER_FMT,nvalue(o));
|
||||
case LUA_TNUMFLT:
|
||||
{
|
||||
char buff[100];
|
||||
sprintf(buff,LUA_NUMBER_FMT,fltvalue(o));
|
||||
printf("%s",buff);
|
||||
if (buff[strspn(buff,"-0123456789")]=='\0') printf(".0");
|
||||
break;
|
||||
case LUA_TSTRING:
|
||||
PrintString(rawtsvalue(o));
|
||||
}
|
||||
case LUA_TNUMINT:
|
||||
printf(LUA_INTEGER_FMT,ivalue(o));
|
||||
break;
|
||||
case LUA_TSHRSTR: case LUA_TLNGSTR:
|
||||
PrintString(tsvalue(o));
|
||||
break;
|
||||
default: /* cannot happen */
|
||||
printf("? type=%d",ttype(o));
|
||||
@@ -337,8 +348,14 @@ static void PrintCode(const Proto* f)
|
||||
case OP_ADD:
|
||||
case OP_SUB:
|
||||
case OP_MUL:
|
||||
case OP_DIV:
|
||||
case OP_POW:
|
||||
case OP_DIV:
|
||||
case OP_IDIV:
|
||||
case OP_BAND:
|
||||
case OP_BOR:
|
||||
case OP_BXOR:
|
||||
case OP_SHL:
|
||||
case OP_SHR:
|
||||
case OP_EQ:
|
||||
case OP_LT:
|
||||
case OP_LE:
|
||||
|
||||
Reference in New Issue
Block a user