Home page logo
/

nmap-dev logo Nmap Development mailing list archives

Re: [nmap-svn] r28977 - nmap-exp/aca/nmap/scripts
From: Aleksandar Nikolic <nikolic.alek () gmail com>
Date: Mon, 18 Jun 2012 18:18:10 +0200

OK, I've done a rollback to the previous version , without lua-format.

On Mon, Jun 18, 2012 at 6:12 PM, Patrick Donnelly <batrick () batbytes com> wrote:
On Mon, Jun 18, 2012 at 10:29 AM, Henri Doreau <henri.doreau () gmail com> wrote:
Hi,

just saw this commit:
2012/6/18  <commit-mailer () insecure org>:
Author: aca
Date: Mon Jun 18 07:14:58 2012
New Revision: 28977

Log:
Applied lua-format

Modified:
  nmap-exp/aca/nmap/scripts/pcanywhere-brute.nse
[...]

I might have missed something and I apologize if this has already been
discussed, but what's the reason for adding those ';'? Seems to me
that so far the "rule" for NSE was to not use semicolons to end
statements. Does it change anything internally? Or is it related to
recent/upcoming changes?

For the sake of consistency I'd rather recommend to select one style
(w/ or w/o semicolons) and stick to it.

The reason for using semicolons is to handle a corner case in the Lua
syntax where it is necessary:

f()
("foo"):lower()

can be parsed as either

f()("foo"):lower();

or as

f();
("foo"):lower();

You get this error from Lua:

$ lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
do
f = a
("foo"):lower()
stdin:3: ambiguous syntax (function call x new statement) near '('

Although, after just testing this, apparently in Lua 5.2.0, this
syntax error is gone. Instead, Lua just does the first case:

do
a = string.upper
("foo"):gsub(".", "%1%1")
print(a)
end
FFOOOO

Reformatted to help visualize what's done:

do
a = string.upper("foo"):gsub(".", "%1%1");
print(a);
end
FFOOOO


Now, normally you just won't see this construction at all. The person
writing the code will insert a semicolon to force the statement
termination (or, in Lua 5.2, be caught with their pants down at
run-time).

Anyway, I'm undecided if the semicolons will stay. This is one of the
reasons I haven't reformatted all the code yet. If I do take out
semicolons, then I will have to account for the above case as removing
a semicolon would functionally change the code.

--
- Patrick Donnelly
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]