gluon/patches/packages/luci/0001-libs-web-rename-template_parser-field-mmap-to-the-more-generic-data.patch
2014-05-16 13:01:06 +02:00

107 lines
3.3 KiB
Diff

From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Fri, 16 May 2014 10:57:26 +0200
Subject: libs/web: rename template_parser field "mmap" to the more generic "data"
diff --git a/libs/web/src/template_parser.c b/libs/web/src/template_parser.c
index 6054451..fc8607b 100644
--- a/libs/web/src/template_parser.c
+++ b/libs/web/src/template_parser.c
@@ -82,15 +82,15 @@ struct template_parser * template_open(const char *file)
goto err;
parser->size = s.st_size;
- parser->mmap = mmap(NULL, parser->size, PROT_READ, MAP_PRIVATE,
+ parser->data = mmap(NULL, parser->size, PROT_READ, MAP_PRIVATE,
parser->fd, 0);
- if (parser->mmap != MAP_FAILED)
+ if (parser->data != MAP_FAILED)
{
- parser->off = parser->mmap;
+ parser->off = parser->data;
parser->cur_chunk.type = T_TYPE_INIT;
- parser->cur_chunk.s = parser->mmap;
- parser->cur_chunk.e = parser->mmap;
+ parser->cur_chunk.s = parser->data;
+ parser->cur_chunk.e = parser->data;
return parser;
}
@@ -108,8 +108,8 @@ void template_close(struct template_parser *parser)
if (parser->gc != NULL)
free(parser->gc);
- if ((parser->mmap != NULL) && (parser->mmap != MAP_FAILED))
- munmap(parser->mmap, parser->size);
+ if ((parser->data != NULL) && (parser->data != MAP_FAILED))
+ munmap(parser->data, parser->size);
if (parser->fd >= 0)
close(parser->fd);
@@ -121,7 +121,7 @@ void template_text(struct template_parser *parser, const char *e)
{
const char *s = parser->off;
- if (s < (parser->mmap + parser->size))
+ if (s < (parser->data + parser->size))
{
if (parser->strip_after)
{
@@ -291,7 +291,7 @@ template_format_chunk(struct template_parser *parser, size_t *sz)
const char *template_reader(lua_State *L, void *ud, size_t *sz)
{
struct template_parser *parser = ud;
- int rem = parser->size - (parser->off - parser->mmap);
+ int rem = parser->size - (parser->off - parser->data);
char *tag;
parser->prv_chunk = parser->cur_chunk;
@@ -314,8 +314,8 @@ const char *template_reader(lua_State *L, void *ud, size_t *sz)
}
else
{
- template_text(parser, parser->mmap + parser->size);
- parser->off = parser->mmap + parser->size;
+ template_text(parser, parser->data + parser->size);
+ parser->off = parser->data + parser->size;
}
}
@@ -331,7 +331,7 @@ const char *template_reader(lua_State *L, void *ud, size_t *sz)
else
{
/* unexpected EOF */
- template_code(parser, parser->mmap + parser->size);
+ template_code(parser, parser->data + parser->size);
*sz = 1;
return "\033";
@@ -366,12 +366,12 @@ int template_error(lua_State *L, struct template_parser *parser)
if (strfind((char *)err, strlen(err), "'char(27)'", 10) != NULL)
{
- off = parser->mmap + parser->size;
+ off = parser->data + parser->size;
err = "'%>' expected before end of file";
chunkline = 0;
}
- for (ptr = parser->mmap; ptr < off; ptr++)
+ for (ptr = parser->data; ptr < off; ptr++)
if (*ptr == '\n')
line++;
diff --git a/libs/web/src/template_parser.h b/libs/web/src/template_parser.h
index d1c6062..ad03cbc 100644
--- a/libs/web/src/template_parser.h
+++ b/libs/web/src/template_parser.h
@@ -58,7 +58,7 @@ struct template_chunk {
struct template_parser {
int fd;
uint32_t size;
- char *mmap;
+ char *data;
char *off;
char *gc;
int line;