shithub: mc

Download patch

ref: bb49dad224c9d89f9945362c79920d56bb2b578e
parent: b635e2c01451f39c4468f2b6a43e57902dee99f1
author: Ori Bernstein <[email protected]>
date: Wed Oct 24 10:52:35 EDT 2012

Allow option parsing to actually find options.

--- a/libstd/fmt.myr
+++ b/libstd/fmt.myr
@@ -67,7 +67,7 @@
 				n += intfmt(buf[n:], p_val castto(int64), 16)
 				;;
                         'c':    (c_val, ap) = vanext(ap)
-                                n += encode(buf[n:], c)
+                                n += encode(buf[n:], c_val)
                                 ;;
                         _:
                                 die("Unknown format specifier")
--- a/libstd/option.myr
+++ b/libstd/option.myr
@@ -1,6 +1,7 @@
 use "types.use"
 use "alloc.use"
 use "utf.use"
+use "fmt.use"
 
 pkg std =
 	type optctx = struct
@@ -11,7 +12,7 @@
 		/* state */
 		optidx	: size
 		curarg	: byte[:]
-		args	: byte[:][:]
+		arglist	: byte[:][:]
 	;;
 
 	const optinit	: (opts	: byte[:], opts : byte[:][:] -> optctx*)
@@ -25,7 +26,7 @@
 	ctx.opts = opts
 	ctx.args = args
 	ctx.optidx = 0
-	ctx.args = [][:]
+	ctx.arglist = [][:]
 	nextopt(ctx)
 	-> ctx
 }
@@ -56,6 +57,6 @@
 	-> false
 :foundopt
 	ctx.optidx = i
-	ctx.curarg = ctx.args[i]
+	ctx.curarg = ctx.args[i][1:]
 	-> true
 }