From f33e22c444fd76db0c6959ee2f148852dde40c3d Mon Sep 17 00:00:00 2001 From: ftrvxmtrx Date: Sat, 4 May 2013 02:43:27 +0200 Subject: [PATCH] u9fs: make it compile --- sys/src/cmd/unix/u9fs/makefile | 3 ++- sys/src/cmd/unix/u9fs/plan9.h | 3 ++- sys/src/cmd/unix/u9fs/utflen.c | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 sys/src/cmd/unix/u9fs/utflen.c diff --git a/sys/src/cmd/unix/u9fs/makefile b/sys/src/cmd/unix/u9fs/makefile index b834bcaba..9bfef0ba8 100644 --- a/sys/src/cmd/unix/u9fs/makefile +++ b/sys/src/cmd/unix/u9fs/makefile @@ -42,7 +42,8 @@ OFILES=\ strecpy.o\ tokenize.o\ u9fs.o\ - utfrune.o + utflen.o\ + utfrune.o\ HFILES=\ fcall.h\ diff --git a/sys/src/cmd/unix/u9fs/plan9.h b/sys/src/cmd/unix/u9fs/plan9.h index caecb8ed7..942afdc41 100644 --- a/sys/src/cmd/unix/u9fs/plan9.h +++ b/sys/src/cmd/unix/u9fs/plan9.h @@ -97,7 +97,8 @@ enum 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*); diff --git a/sys/src/cmd/unix/u9fs/utflen.c b/sys/src/cmd/unix/u9fs/utflen.c new file mode 100644 index 000000000..7eb5ff507 --- /dev/null +++ b/sys/src/cmd/unix/u9fs/utflen.c @@ -0,0 +1,22 @@ +#include + +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; +}