diff --git a/src/calibre/ebooks/html_entities.c b/src/calibre/ebooks/html_entities.c
index 30f2fc8f57..ae11ae8ec6 100644
--- a/src/calibre/ebooks/html_entities.c
+++ b/src/calibre/ebooks/html_entities.c
@@ -102,7 +102,7 @@ bad_entity:
if (!num) goto bad_entity;
return num;
} else {
- struct html_entity *s = in_word_set(entity, elen);
+ const struct html_entity *s = in_word_set(entity, elen);
if (!s) goto bad_entity;
ans = strlen(s->val);
memcpy(output, s->val, ans);
diff --git a/src/calibre/ebooks/html_entities.h b/src/calibre/ebooks/html_entities.h
index 3a002e3623..03f6d17520 100644
--- a/src/calibre/ebooks/html_entities.h
+++ b/src/calibre/ebooks/html_entities.h
@@ -1,5 +1,5 @@
/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -t */
+/* Command-line: gperf -t --readonly --includes */
/* Computed positions: -k'1-7,10,12,$' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -30,6 +30,7 @@
#endif
struct html_entity { const char *name, *val; };
+#include
#define TOTAL_KEYWORDS 2127
#define MIN_WORD_LENGTH 2
@@ -48,7 +49,7 @@ inline
static unsigned int
hash (register const char *str, register size_t len)
{
- static unsigned short asso_values[] =
+ static const unsigned short asso_values[] =
{
20839, 20839, 20839, 20839, 20839, 20839, 20839, 20839, 20839, 20839,
20839, 20839, 20839, 20839, 20839, 20839, 20839, 20839, 20839, 20839,
@@ -115,10 +116,10 @@ hash (register const char *str, register size_t len)
return hval + asso_values[(unsigned char)str[len - 1]];
}
-struct html_entity *
+const struct html_entity *
in_word_set (register const char *str, register size_t len)
{
- static struct html_entity wordlist[] =
+ static const struct html_entity wordlist[] =
{
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
diff --git a/src/calibre/ebooks/html_entities.py b/src/calibre/ebooks/html_entities.py
index f181709fcb..0456d9ceaa 100644
--- a/src/calibre/ebooks/html_entities.py
+++ b/src/calibre/ebooks/html_entities.py
@@ -2170,6 +2170,6 @@ struct html_entity { const char *name, *val; }
import subprocess
with open(__file__.replace('.py', '.h'), 'wb') as f:
- cp = subprocess.run(['gperf', '-t'], input='\n'.join(native_lines).encode(), stdout=f)
+ cp = subprocess.run(['gperf', '--struct-type', '--readonly', '--includes'], input='\n'.join(native_lines).encode(), stdout=f)
if cp.returncode != 0:
raise SystemExit(cp.returncode)