diff src/luan/modules/mmake.luan @ 1716:b82767112d8e

add String.regex
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 24 Jul 2022 23:43:03 -0600
parents 4d6c1bb8f975
children c637a2a1023d
line wrap: on
line diff
--- a/src/luan/modules/mmake.luan	Sat Jul 23 21:53:04 2022 -0600
+++ b/src/luan/modules/mmake.luan	Sun Jul 24 23:43:03 2022 -0600
@@ -5,7 +5,12 @@
 local print = Io.print
 local output_to = Io.output_to
 local String = require "luan:String.luan"
+local regex = String.regex
+local substring = String.sub
+local ends_with = String.ends_with
 local Time = require "luan:Time.luan"
+local time_now = Time.now
+local time_format = Time.format
 
 
 local compiler = Table.concat( { "javac -g -encoding UTF8", ... }, " " )
@@ -13,7 +18,7 @@
 
 local function header()
 %>
-# Makefile created on <%=Time.format(Time.now())%> by Mmake
+# Makefile created on <%=time_format(time_now())%> by Mmake
 
 .SUFFIXES: .java .class
 
@@ -29,8 +34,8 @@
 	local dirs = {}
 	for _, file in ipairs(dir.children()) do
 		local name = file.name()
-		if String.matches(name,[[\.java$]]) then
-			javas[#javas+1] = String.sub(name,1,-6)
+		if ends_with(name,".java") then
+			javas[#javas+1] = substring(name,1,-6)
 		end
 		if file.is_directory() and mmake(file) then
 			dirs[#dirs+1] = name
@@ -41,8 +46,9 @@
 	end
 	local out = dir.child("Makefile").text_writer()
 	output_to(out,header)
+	local r = regex([[\$]])
 	for _, s in ipairs(javas) do
-		s = String.gsub(s,[[\$]],[[\$\$]])
+		s = r.gsub(s,[[\$\$]])
 		out.write( "\\\n\t\t",  s , ".class" )
 	end
 	for _, s in ipairs(dirs) do