aded buffer_getc, buffer_getn get n bytes less only if EOF and
buffer_get_token for getting n bytes till finding a termination char or EOF/error.
This commit is contained in:
15
buffer/buffer_get_token.c
Normal file
15
buffer/buffer_get_token.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "byte.h"
|
||||
#include "buffer.h"
|
||||
#include "scan.h"
|
||||
|
||||
int buffer_get_token(buffer* b,char* x,unsigned int len,const char* charset,unsigned int setlen) {
|
||||
int blen;
|
||||
|
||||
for (blen=0;blen<len;++blen) {
|
||||
if ((r=buffer_getc(b,*x))<0) return r;
|
||||
if (r==0) return blen;
|
||||
if (byte_chr(charset,clen,*x)<clen) return blen;
|
||||
++x;
|
||||
}
|
||||
return blen;
|
||||
}
|
||||
Reference in New Issue
Block a user