aboutsummaryrefslogtreecommitdiff
path: root/lzio.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-10-08 15:46:08 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-10-08 15:46:08 -0300
commitb3d0682fb94f56a438dbb4fdb2b3440ccc10cfb4 (patch)
tree746fc9900768dfaf1ddffca35cb4f6fd55903bbf /lzio.h
parent02afc892d5ce5d85e88faac443d7294589ee697a (diff)
downloadlua-b3d0682fb94f56a438dbb4fdb2b3440ccc10cfb4.tar.gz
lua-b3d0682fb94f56a438dbb4fdb2b3440ccc10cfb4.tar.bz2
lua-b3d0682fb94f56a438dbb4fdb2b3440ccc10cfb4.zip
use of different buffers for scanner and concatenation
Diffstat (limited to 'lzio.h')
-rw-r--r--lzio.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/lzio.h b/lzio.h
index e7807ec3..f2fbad90 100644
--- a/lzio.h
+++ b/lzio.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lzio.h,v 1.12 2002/06/06 12:40:22 roberto Exp roberto $ 2** $Id: lzio.h,v 1.13 2002/08/05 18:45:02 roberto Exp roberto $
3** Buffered streams 3** Buffered streams
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -13,7 +13,7 @@
13 13
14#define EOZ (-1) /* end of stream */ 14#define EOZ (-1) /* end of stream */
15 15
16typedef struct zio ZIO; 16typedef struct Zio ZIO;
17 17
18#define zgetc(z) (((z)->n--)>0 ? \ 18#define zgetc(z) (((z)->n--)>0 ? \
19 cast(int, cast(unsigned char, *(z)->p++)) : \ 19 cast(int, cast(unsigned char, *(z)->p++)) : \
@@ -26,9 +26,30 @@ size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
26int luaZ_lookahead (ZIO *z); 26int luaZ_lookahead (ZIO *z);
27 27
28 28
29
30typedef struct Mbuffer {
31 char *buffer;
32 size_t buffsize;
33} Mbuffer;
34
35
36char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
37
38#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
39
40#define luaZ_sizebuffer(buff) ((buff)->buffsize)
41#define luaZ_buffer(buff) ((buff)->buffer)
42
43#define luaZ_resizebuffer(L, buff, size) \
44 (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
45 (buff)->buffsize = size)
46
47#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
48
49
29/* --------- Private Part ------------------ */ 50/* --------- Private Part ------------------ */
30 51
31struct zio { 52struct Zio {
32 size_t n; /* bytes still unread */ 53 size_t n; /* bytes still unread */
33 const char *p; /* current position in buffer */ 54 const char *p; /* current position in buffer */
34 lua_Chunkreader reader; 55 lua_Chunkreader reader;