shithub: mc

Download patch

ref: 49fcb8a106211d40ee2e94a52a82fbee99cc37e9
parent: 4be1adfd0a6da6bf6d0098238bf9343ca6d38cb3
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Oct 12 15:15:14 EDT 2012

Fix option parsing.

--- a/libstd/option.myr
+++ b/libstd/option.myr
@@ -10,7 +10,7 @@
 
 		/* state */
 		optidx	: size
-		curopts	: byte[:]
+		curopt	: byte[:]
 		args	: byte[:][:]
 	;;
 
@@ -45,7 +45,7 @@
 const nextopt = {ctx
 	var i
 
-	for i = ctx.optidx + 1; i < ctx.optidx.len; i++
+	for i = ctx.optidx + 1; i < ctx.args.len; i++
 		if decode(ctx.args[i]) == '-'
 			goto foundopt
 		else
@@ -53,7 +53,9 @@
 			/* ctx.args = slappend(ctx.args, ctx.args[i]) */
 		;;
 	;;
+	-> false
 :foundopt
 	ctx.optidx = i
-	ctx.curopts = ctx.opts[i]
+	ctx.curopt = ctx.opts[i]
+	-> true
 }
--