u9fs: make it compile
This commit is contained in:
parent
9de8d61fe6
commit
f33e22c444
3 changed files with 26 additions and 2 deletions
|
@ -42,7 +42,8 @@ OFILES=\
|
|||
strecpy.o\
|
||||
tokenize.o\
|
||||
u9fs.o\
|
||||
utfrune.o
|
||||
utflen.o\
|
||||
utfrune.o\
|
||||
|
||||
HFILES=\
|
||||
fcall.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*);
|
||||
|
|
22
sys/src/cmd/unix/u9fs/utflen.c
Normal file
22
sys/src/cmd/unix/u9fs/utflen.c
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue