Skip to content

Commit

Permalink
auto-format using the latest intellij-awk : adjust minify.awk
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Dec 20, 2023
1 parent e29a77e commit 5c879a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
26 changes: 13 additions & 13 deletions makesure_candidate
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function prepareArgs(i,arg){
}else
arrPush(ArgGoals,arg)
delete ARGV[i]}
if("-h" in Args||"--help" in Args){
if("-h"in Args||"--help"in Args){
print"makesure ver. " Version
print"Usage: makesure [options...] [-f buildfile] [goals...]"
print" -f,--file buildfile"
Expand All @@ -65,22 +65,22 @@ function prepareArgs(i,arg){
print" -h,--help print help and exit"
print" -U,--selfupdate update makesure to latest version"
realExit(0)
}else if("-v" in Args||"--version" in Args){
}else if("-v"in Args||"--version"in Args){
print Version
realExit(0)
}else if("-U" in Args||"--selfupdate" in Args){
}else if("-U"in Args||"--selfupdate"in Args){
selfUpdate()
realExit(0)}
if(!isFile(ARGV[1])){
if(isFile(ARGV[1]"/Makesurefile"))
ARGV[1]=ARGV[1]"/Makesurefile"
else
die("makesure file not found: " ARGV[1])}
if("-s" in Args||"--silent" in Args)
if("-s"in Args||"--silent"in Args)
Options["silent"]
if("-x" in Args||"--tracing" in Args)
if("-x"in Args||"--tracing"in Args)
Options["tracing"]
if("-t" in Args||"--timing" in Args)
if("-t"in Args||"--timing"in Args)
Options["timing"]}
function splitKV(arg,kv,n){
n=index(arg,"=")
Expand Down Expand Up @@ -113,7 +113,7 @@ function handleShell(){
if(!((Shell=$2)in SupportedShells))
addError("Shell '\''" Shell "'\'' is not supported")}
function timingOn(){
return "timing" in Options&&!("silent" in Options)}
return "timing"in Options&&!("silent"in Options)}
function started(mode){
Mode=mode}
function handleLib(libName){
Expand Down Expand Up @@ -271,8 +271,8 @@ body,goalBody,goalBodies,resolvedGoals,exitCode,t0,t1,t2,goalTimed,list){
instantiateGoals()
if(Error)
die(Error)
list="-l" in Args||"--list" in Args
if(list||"-la" in Args||"--list-all" in Args){
list="-l"in Args||"--list"in Args
if(list||"-la"in Args||"--list-all"in Args){
print"Available goals:"
for(i=0;i in GoalNames;i++){
goalName=GoalNames[i]
Expand Down Expand Up @@ -304,7 +304,7 @@ body,goalBody,goalBodies,resolvedGoals,exitCode,t0,t1,t2,goalTimed,list){
addLine(goalBody,Lib[GoalToLib[goalName]])
addLine(goalBody,body)
goalBodies[goalName]=goalBody[0]}
if("-d" in Args||"--resolved" in Args){
if("-d"in Args||"--resolved"in Args){
printf"Resolved goals to reach for"
for(i=0;i in ArgGoals;i++)
printf" %s",quote2(ArgGoals[i],1)
Expand All @@ -318,7 +318,7 @@ body,goalBody,goalBodies,resolvedGoals,exitCode,t0,t1,t2,goalTimed,list){
goalTimed=timingOn()&&!reachedGoals[goalName]&&!emptyGoals[goalName]
if(goalTimed)
t1=t2?t2:currentTimeMillis()
if(!("silent" in Options))
if(!("silent"in Options))
print" goal " quote2(goalName,1)" " (reachedGoals[goalName]?"[already satisfied].":emptyGoals[goalName]?"[empty].":"...")
exitCode=(reachedGoals[goalName]||emptyGoals[goalName])?0:shellExec(goalBodies[goalName],goalName)
if(exitCode!=0)
Expand Down Expand Up @@ -368,7 +368,7 @@ function checkConditionReached(goalName,conditionStr,script){
script=script "\n" conditionStr
return shellExec(script,goalName "@reached_if")==0}
function shellExec(script,comment,res){
if("tracing" in Options){
if("tracing"in Options){
script=": " quoteArg(comment)"\n" script
script=Shell " -x -e -c " quoteArg(script)
}else
Expand Down Expand Up @@ -528,7 +528,7 @@ function executeGetLine(script,res){
return res}
function closeErr(script){if(close(script)!=0)die("Error executing: " script)}
function dl(url,dest,verbose){
verbose="VERBOSE" in ENVIRON
verbose="VERBOSE"in ENVIRON
if(commandExists("wget")){
if(!ok("wget " (verbose?"":"-q")" " quoteArg(url)" -O" quoteArg(dest)))
return "error with wget"
Expand Down
5 changes: 3 additions & 2 deletions minify.awk
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ in_begin && $1 ~ /^delete/{ next }
gsub(/print +"/, "print\"")
gsub(/printf +"/, "printf\"")
if (!/^ +}/) gsub(/ +}/, "}")
##gsub(/" in/, "\"in")
gsubKeepStrings("^ +in ", "in ")
gsub(Q, Q "\\" Q Q)
if (l = trim($0)) { decreaseIndent(); printf "%s", (l == "}" ? l : (NR == 1 ? "" : "\n") $0) }
}
Expand Down Expand Up @@ -68,4 +68,5 @@ function gsubKeepStrings(regex, replacement, nonString,s,isString,i,c) {
s = s nonString
$0 = s
}
#BEGIN { $0 = "aaa\"aaa\"bbbaaa"; gsubKeepStrings("aaa","AAA"); print }
#BEGIN { $0 = "aaa\"aaa\"bbbaaa"; gsubKeepStrings("aaa","AAA"); print }
#BEGIN { $0 = "if (\"-h\" in Args || \"--help\" in Args) {"; gsubKeepStrings("^ +in", "in"); print }

0 comments on commit 5c879a3

Please sign in to comment.