make buffer_get_token write \0 to buffer on end of file so it can be
distinguished from a length 0 token.
This commit is contained in:
parent
a11c1f8ec0
commit
12fbaf7c9c
1
CHANGES
1
CHANGES
@ -1,4 +1,5 @@
|
|||||||
0.13:
|
0.13:
|
||||||
|
fixed several bugs in test/uudecode.c
|
||||||
|
|
||||||
0.12:
|
0.12:
|
||||||
add textcode api for uuencode/uudecode, base64, quoted printable,
|
add textcode api for uuencode/uudecode, base64, quoted printable,
|
||||||
|
5
buffer.h
5
buffer.h
@ -38,6 +38,11 @@ extern int buffer_bget(buffer* b,char* x,unsigned int len);
|
|||||||
extern int buffer_feed(buffer* b);
|
extern int buffer_feed(buffer* b);
|
||||||
extern int buffer_getc(buffer* b,char* x);
|
extern int buffer_getc(buffer* b,char* x);
|
||||||
extern int buffer_getn(buffer* b,char* x,unsigned int len);
|
extern int buffer_getn(buffer* b,char* x,unsigned int len);
|
||||||
|
|
||||||
|
/* read bytes until the destination buffer is full (len bytes), end of
|
||||||
|
* file is reached or the read char is in charset (setlen bytes). An
|
||||||
|
* empty line when looking for \n will write '\n' to x and return 0. If
|
||||||
|
* EOF is reached, \0 is written to the buffer */
|
||||||
extern int buffer_get_token(buffer* b,char* x,unsigned int len,const char* charset,unsigned int setlen);
|
extern int buffer_get_token(buffer* b,char* x,unsigned int len,const char* charset,unsigned int setlen);
|
||||||
#define buffer_getline(b,x,len) buffer_get_token((b),(x),(len),"\n",1)
|
#define buffer_getline(b,x,len) buffer_get_token((b),(x),(len),"\n",1)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ int buffer_get_token(buffer* b,char* x,unsigned int len,const char* charset,unsi
|
|||||||
for (blen=0;blen<len;++blen) {
|
for (blen=0;blen<len;++blen) {
|
||||||
register int r;
|
register int r;
|
||||||
if ((r=buffer_getc(b,x))<0) return r;
|
if ((r=buffer_getc(b,x))<0) return r;
|
||||||
if (r==0) break;
|
if (r==0) { *x=0; break; }
|
||||||
if (byte_chr(charset,setlen,*x)<setlen) break;
|
if (byte_chr(charset,setlen,*x)<setlen) break;
|
||||||
++x;
|
++x;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user