shithub: pico

Download patch

ref: 6160f68952923abe4a620d7fc1e5d2d9e6107448
parent: cfbf70e39b53d3b7578c7e17b8b89b7fd24aa3f5
author: qwx <qwx@sciops.net>
date: Mon Mar 2 19:30:05 EST 2020

image name bug fixes

- fix name regex to allow '$' in names
- check for and allow reusing known images
- fix name reference counting

--- a/pico
+++ b/pico
@@ -17,10 +17,8 @@
 function newname(file, name){
 	if(name == "")
 		name = "$" length(ref)+1
-	if(!(name in ref)){
-		ref[name] = ""
-		idx[name] = length(ref)
-	}
+	ref[name in ref ? name ",$" idx[name] : name] = ""
+	idx[name] = length(ref)
 	path[name] = file
 	new = name
 }
@@ -65,7 +63,7 @@
 BEGIN{
 	X = 0
 	Y = 0
-	opx = "!-\\/:-@\\[-\\^`\\{-~"
+	opx = "!-#%-\\/:-@\\[-\\^`\\{-~"
 	namex = "[^0-9" opx "][^" opx "]*"
 	pref="/tmp/pico.'^$pid^'"
 	mkfile = pref ".mk"
@@ -185,6 +183,8 @@
 				next
 			}else if(i < ntok && tok[i+1] == "(")
 				expr = expr " " tok[i]
+			else if(i == 1 && ntok >= 3 && tok[2] == "=")
+				new = tok[i]
 			else if(tok[i] in ref){
 				ref[tok[i]] = 1
 				expr = expr " *﹩byte(﹩im[" idx[tok[i]] "], "
@@ -193,12 +193,8 @@
 					gotsym = 1
 				}else
 					expr = expr "x,y,z)"
-			}else{
-				if(i == 1 && ntok >= 3 && tok[2] == "=")
-					new = tok[i]
-				else
-					expr = expr " " tok[i]
-			}
+			}else
+				expr = expr " " tok[i]
 		}else if(tok[i] == "="){
 			if(i != 2){
 				print "invalid assignment"