0001-libs-web-rename-template_parser-field-mmap-to-the-more-generic-data.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Fri, 16 May 2014 10:57:26 +0200
  3. Subject: libs/web: rename template_parser field "mmap" to the more generic "data"
  4. diff --git a/modules/base/src/template_parser.c b/modules/base/src/template_parser.c
  5. index 6054451..fc8607b 100644
  6. --- a/modules/base/src/template_parser.c
  7. +++ b/modules/base/src/template_parser.c
  8. @@ -82,15 +82,15 @@ struct template_parser * template_open(const char *file)
  9. goto err;
  10. parser->size = s.st_size;
  11. - parser->mmap = mmap(NULL, parser->size, PROT_READ, MAP_PRIVATE,
  12. + parser->data = mmap(NULL, parser->size, PROT_READ, MAP_PRIVATE,
  13. parser->fd, 0);
  14. - if (parser->mmap != MAP_FAILED)
  15. + if (parser->data != MAP_FAILED)
  16. {
  17. - parser->off = parser->mmap;
  18. + parser->off = parser->data;
  19. parser->cur_chunk.type = T_TYPE_INIT;
  20. - parser->cur_chunk.s = parser->mmap;
  21. - parser->cur_chunk.e = parser->mmap;
  22. + parser->cur_chunk.s = parser->data;
  23. + parser->cur_chunk.e = parser->data;
  24. return parser;
  25. }
  26. @@ -108,8 +108,8 @@ void template_close(struct template_parser *parser)
  27. if (parser->gc != NULL)
  28. free(parser->gc);
  29. - if ((parser->mmap != NULL) && (parser->mmap != MAP_FAILED))
  30. - munmap(parser->mmap, parser->size);
  31. + if ((parser->data != NULL) && (parser->data != MAP_FAILED))
  32. + munmap(parser->data, parser->size);
  33. if (parser->fd >= 0)
  34. close(parser->fd);
  35. @@ -121,7 +121,7 @@ void template_text(struct template_parser *parser, const char *e)
  36. {
  37. const char *s = parser->off;
  38. - if (s < (parser->mmap + parser->size))
  39. + if (s < (parser->data + parser->size))
  40. {
  41. if (parser->strip_after)
  42. {
  43. @@ -291,7 +291,7 @@ template_format_chunk(struct template_parser *parser, size_t *sz)
  44. const char *template_reader(lua_State *L, void *ud, size_t *sz)
  45. {
  46. struct template_parser *parser = ud;
  47. - int rem = parser->size - (parser->off - parser->mmap);
  48. + int rem = parser->size - (parser->off - parser->data);
  49. char *tag;
  50. parser->prv_chunk = parser->cur_chunk;
  51. @@ -314,8 +314,8 @@ const char *template_reader(lua_State *L, void *ud, size_t *sz)
  52. }
  53. else
  54. {
  55. - template_text(parser, parser->mmap + parser->size);
  56. - parser->off = parser->mmap + parser->size;
  57. + template_text(parser, parser->data + parser->size);
  58. + parser->off = parser->data + parser->size;
  59. }
  60. }
  61. @@ -331,7 +331,7 @@ const char *template_reader(lua_State *L, void *ud, size_t *sz)
  62. else
  63. {
  64. /* unexpected EOF */
  65. - template_code(parser, parser->mmap + parser->size);
  66. + template_code(parser, parser->data + parser->size);
  67. *sz = 1;
  68. return "\033";
  69. @@ -366,12 +366,12 @@ int template_error(lua_State *L, struct template_parser *parser)
  70. if (strfind((char *)err, strlen(err), "'char(27)'", 10) != NULL)
  71. {
  72. - off = parser->mmap + parser->size;
  73. + off = parser->data + parser->size;
  74. err = "'%>' expected before end of file";
  75. chunkline = 0;
  76. }
  77. - for (ptr = parser->mmap; ptr < off; ptr++)
  78. + for (ptr = parser->data; ptr < off; ptr++)
  79. if (*ptr == '\n')
  80. line++;
  81. diff --git a/modules/base/src/template_parser.h b/modules/base/src/template_parser.h
  82. index d1c6062..ad03cbc 100644
  83. --- a/modules/base/src/template_parser.h
  84. +++ b/modules/base/src/template_parser.h
  85. @@ -58,7 +58,7 @@ struct template_chunk {
  86. struct template_parser {
  87. int fd;
  88. uint32_t size;
  89. - char *mmap;
  90. + char *data;
  91. char *off;
  92. char *gc;
  93. int line;