From 9e9c8f167b068fe506e633c71f2395f59bd8ce0b Mon Sep 17 00:00:00 2001 From: Mike Mason Date: Tue, 4 Dec 2007 21:55:36 +0000 Subject: Added timezone information to date.lua. Added fs.file_write to be able to add newlines at the end of the file(most strings don't have them) and also added a function to format.lua git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@408 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lib/format.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/format.lua') diff --git a/lib/format.lua b/lib/format.lua index 903a593..dff5019 100644 --- a/lib/format.lua +++ b/lib/format.lua @@ -39,6 +39,15 @@ function cap_begin_word ( a ) return data end +function search_replace (path , find, replace) + local f = fs.read_file_as_array(path) + local lines = {} + for a,b in ipairs(f) do + local c = string.gsub(b, find, replace) + lines[#lines + 1] = c end + return lines +end + -- This code comes from http://lua-users.org/wiki/SplitJoin -- -- example: format.table_to_string(", ", {"Anna", "Bob", "Charlie", "Dolores"}) -- cgit v1.2.3