u9fs: make it compile

This commit is contained in:
ftrvxmtrx 2013-05-04 02:43:27 +02:00
parent 9de8d61fe6
commit f33e22c444
3 changed files with 26 additions and 2 deletions

View file

@ -42,7 +42,8 @@ OFILES=\
strecpy.o\
tokenize.o\
u9fs.o\
utfrune.o
utflen.o\
utfrune.o\
HFILES=\
fcall.h\

View file

@ -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*);

View file

@ -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;
}