Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 tests/lint: shorten code for checking re...



details:   https://anonhg.NetBSD.org/src/rev/4f6d761070e7
branches:  trunk
changeset: 953185:4f6d761070e7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 28 12:45:47 2021 +0000

description:
tests/lint: shorten code for checking redundancy in files

No functional change.

diffstat:

 usr.bin/xlint/lint1/check-msgs.lua |  11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diffs (27 lines):

diff -r 7b6257e9698a -r 4f6d761070e7 usr.bin/xlint/lint1/check-msgs.lua
--- a/usr.bin/xlint/lint1/check-msgs.lua        Sun Feb 28 12:40:00 2021 +0000
+++ b/usr.bin/xlint/lint1/check-msgs.lua        Sun Feb 28 12:45:47 2021 +0000
@@ -1,5 +1,5 @@
 #! /usr/bin/lua
--- $NetBSD: check-msgs.lua,v 1.8 2021/02/28 12:40:00 rillig Exp $
+-- $NetBSD: check-msgs.lua,v 1.9 2021/02/28 12:45:47 rillig Exp $
 
 --[[
 
@@ -113,14 +113,9 @@
 
 local function file_contains(filename, text)
   local f = assert(io.open(filename, "r"))
-  for line in f:lines() do
-    if line:find(text, 1, true) then
-      f:close()
-      return true
-    end
-  end
+  local found = f:read("a"):find(text, 1, true)
   f:close()
-  return false
+  return found
 end
 
 local function check_test_files(msgs)



Home | Main Index | Thread Index | Old Index