Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libcurses/slave tests/libcurses: improve code loca...



details:   https://anonhg.NetBSD.org/src/rev/e54691140b24
branches:  trunk
changeset: 983917:e54691140b24
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jun 13 19:41:12 2021 +0000

description:
tests/libcurses: improve code locality in linter

No functional change.

diffstat:

 tests/lib/libcurses/slave/lint.lua |  26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)

diffs (51 lines):

diff -r de8d9ce8bcc2 -r e54691140b24 tests/lib/libcurses/slave/lint.lua
--- a/tests/lib/libcurses/slave/lint.lua        Sun Jun 13 19:25:08 2021 +0000
+++ b/tests/lib/libcurses/slave/lint.lua        Sun Jun 13 19:41:12 2021 +0000
@@ -1,5 +1,5 @@
 #! /usr/bin/lua
--- $NetBSD: lint.lua,v 1.4 2021/06/13 19:25:08 rillig Exp $
+-- $NetBSD: lint.lua,v 1.5 2021/06/13 19:41:12 rillig Exp $
 
 --[[
 
@@ -53,29 +53,27 @@
 
   for lineno, line in ipairs(lines) do
 
-    local line_argc = num(line:match("^\tARGC%((%d)"))
-    local line_arg = line:match("^\tARG_[%w_]+%(")
-
+    local line_argc = num(line:match("^\tARGC%((%d+)"))
     if line_argc and line_argc > 0 then
       curr_argc, curr_arg = line_argc, 0
+      goto next
     end
 
-    if line_arg and not curr_arg then
+    local line_arg = line:match("^\tARG_[%w_]+%(")
+    if line_arg and curr_arg then
+      curr_arg = curr_arg + 1
+      if curr_arg == curr_argc then
+        curr_argc, curr_arg = nil, nil
+      end
+    elseif line_arg then
       errors:add("%s:%d: ARG without preceding ARGC", fname, lineno)
-    end
-
-    if not line_arg and curr_arg and not line_argc then
+    elseif curr_arg then
       errors:add("%s:%d: expecting ARG %d, got %s",
         fname, lineno, curr_arg, line)
       curr_argc, curr_arg = nil, nil
     end
 
-    if line_arg and curr_arg then
-      curr_arg = curr_arg + 1
-      if curr_arg == curr_argc then
-        curr_argc, curr_arg = nil, nil
-      end
-    end
+    ::next::
   end
 end
 



Home | Main Index | Thread Index | Old Index