diff options
author | ftrvxmtrx <ftrvxmtrx@gmail.com> | 2013-05-04 02:43:27 +0200 |
---|---|---|
committer | ftrvxmtrx <ftrvxmtrx@gmail.com> | 2013-05-04 02:43:27 +0200 |
commit | f33e22c444fd76db0c6959ee2f148852dde40c3d (patch) | |
tree | 4792a016712df04c574b6d73c236da48fe15c5a5 /sys | |
parent | 9de8d61fe6a08ec9bb021bf13fcd6536b797d1ea (diff) |
u9fs: make it compile
Diffstat (limited to 'sys')
-rw-r--r-- | sys/src/cmd/unix/u9fs/makefile | 3 | ||||
-rw-r--r-- | sys/src/cmd/unix/u9fs/plan9.h | 3 | ||||
-rw-r--r-- | sys/src/cmd/unix/u9fs/utflen.c | 22 |
3 files changed, 26 insertions, 2 deletions
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 <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; +} |