git: 9front

Download patch

ref: cedc3158a175ff0368f61a8d00178360e18cc597
parent: bf6941859c2762c8d98e24dfe7e3a594358f2ed4
author: ftrvxmtrx <ftrvxmtrx@gmail.com>
date: Fri May 3 22:43:27 EDT 2013

u9fs: make it compile

--- a/sys/src/cmd/unix/u9fs/makefile
+++ b/sys/src/cmd/unix/u9fs/makefile
@@ -42,7 +42,8 @@
 	strecpy.o\
 	tokenize.o\
 	u9fs.o\
-	utfrune.o
+	utflen.o\
+	utfrune.o\
 
 HFILES=\
 	fcall.h\
--- a/sys/src/cmd/unix/u9fs/plan9.h
+++ b/sys/src/cmd/unix/u9fs/plan9.h
@@ -97,7 +97,8 @@
 	UTFmax		= 3,		/* maximum bytes per rune */
 	Runesync	= 0x80,		/* cannot represent part of a UTF sequence (<) */
 	Runeself	= 0x80,		/* rune and UTF sequences are the same (<) */
-	Runeerror	= 0x80		/* decoding error in UTF */
+	Runeerror	= 0x80,		/* decoding error in UTF */
+	Runemax		= 0xFFFF,	/* 16 bit rune */
 };
 
 extern	int	runetochar(char*, Rune*);
--- /dev/null
+++ b/sys/src/cmd/unix/u9fs/utflen.c
@@ -1,0 +1,22 @@
+#include <plan9.h>
+
+int
+utflen(char *s)
+{
+	int c;
+	long n;
+	Rune rune;
+
+	n = 0;
+	for(;;) {
+		c = *(uchar*)s;
+		if(c < Runeself) {
+			if(c == 0)
+				return n;
+			s++;
+		} else
+			s += chartorune(&rune, s);
+		n++;
+	}
+	return 0;
+}
--