Skip to content

Commit 4b29ca7

Browse files
committed
[librptext] html_entities.cpp: Remove get_table() and get_count().
Since parseHtmlEntity() is now in html_entity.cpp, we don't need these functions at all. Move the html_entity_tbl_t definition from .hpp to .cpp. [librpbase] TextOut_text.cpp: Remove `using LibRpText::HtmlEntities::html_entity_tbl_t;`. [win32] RP_ShellPropSheetExt.cpp: Likewise.
1 parent 0cb948b commit 4b29ca7

4 files changed

Lines changed: 16 additions & 63 deletions

File tree

src/librpbase/TextOut_text.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "librptext/utf8_funcs.hpp"
2222
#include "librptexture/img/rp_image.hpp"
2323
using namespace LibRpText;
24-
using LibRpText::HtmlEntities::html_entity_tbl_t;
2524
using LibRpTexture::rp_image;
2625

2726
// C includes (C++ namespace)

src/librptext/html_entities.cpp

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "html_entities.hpp"
1010

1111
// C includes (C++ namespace)
12+
#include <cstddef> // for size_t
1213
#include <cstdlib>
1314
#include <cstring>
1415

@@ -18,14 +19,26 @@ using std::array;
1819

1920
namespace LibRpText { namespace HtmlEntities {
2021

22+
/**
23+
* HTML entity entry, sorted by entity name.
24+
* Can be used with e.g. bsearch() or std::lower_bound().
25+
* References:
26+
* - https://www.w3schools.com/HTML/html_entities.asp
27+
* - https://www.toptal.com/designers/htmlarrows/symbols/
28+
*/
29+
struct html_entity_tbl_t {
30+
char entity[8]; // HTML entity, minus '&' and ';'
31+
char16_t chr; // UTF-16 code point
32+
};
33+
2134
/**
2235
* HTML entities, sorted by entity name.
2336
* Can be used with e.g. bsearch() or std::lower_bound().
2437
* References:
2538
* - https://www.w3schools.com/HTML/html_entities.asp
2639
* - https://www.toptal.com/designers/htmlarrows/symbols/
2740
*/
28-
static const array<html_entity_tbl_t, 76+1> html_entity_tbl = {{
41+
static const array<html_entity_tbl_t, 76> html_entity_tbl = {{
2942
{"Cfr", 0x212D}, //
3043
{"Copf", 0x2102}, //
3144
{"DD", 0x2145}, //
@@ -103,33 +116,8 @@ static const array<html_entity_tbl_t, 76+1> html_entity_tbl = {{
103116
//{"VerticalSeparator", 0x2758}, // ❘ (TODO: Special check for this one?)
104117
{"weierp", 0x2118}, //
105118
{"yen", 0x00A5}, // ¥
106-
107-
// end of table
108-
{"", 0}
109119
}};
110120

111-
/**
112-
* Get the HTML entities table.
113-
* Table is terminated with an empty-string entry.
114-
*
115-
* @return HTML entities table
116-
*/
117-
const html_entity_tbl_t *get_table(void)
118-
{
119-
return html_entity_tbl.data();
120-
}
121-
122-
/**
123-
* Get the number of entries in the HTML entities table.
124-
* NOTE: This does *not* include the empty-string terminator entry.
125-
*
126-
* @return Number of entries in the HTML entities table
127-
*/
128-
size_t get_count(void)
129-
{
130-
return html_entity_tbl.size() - 1;
131-
}
132-
133121
/** Wrapper functions for T_parseHtmlEntity **/
134122

135123
static inline const char *strchr_wrapper(const char *s, int c)
@@ -226,8 +214,8 @@ static char16_t T_parseHtmlEntity(const CharType *&entity)
226214
key.entity[len] = '\0';
227215
key.chr = 0;
228216

229-
void *ptr = bsearch(&key, HtmlEntities::get_table(),
230-
HtmlEntities::get_count(), sizeof(html_entity_tbl_t),
217+
void *ptr = bsearch(&key, html_entity_tbl.data(),
218+
html_entity_tbl.size(), sizeof(html_entity_tbl_t),
231219
[](const void *a, const void *b) -> int
232220
{
233221
const html_entity_tbl_t *const pa = static_cast<const html_entity_tbl_t*>(a);

src/librptext/html_entities.hpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,8 @@
1414
// NOTE: gcc-5 on Ubuntu 16.04 is missing <cuchar>...
1515
#include <uchar.h> // for char16_t
1616

17-
// C includes (C++ namespace)
18-
#include <cstddef> // for size_t
19-
2017
namespace LibRpText { namespace HtmlEntities {
2118

22-
/**
23-
* HTML entity entry, sorted by entity name.
24-
* Can be used with e.g. bsearch() or std::lower_bound().
25-
* References:
26-
* - https://www.w3schools.com/HTML/html_entities.asp
27-
* - https://www.toptal.com/designers/htmlarrows/symbols/
28-
*/
29-
struct html_entity_tbl_t {
30-
char entity[8]; // HTML entity, minus '&' and ';'
31-
char16_t chr; // UTF-16 code point
32-
};
33-
34-
/**
35-
* Get the HTML entities table.
36-
* Table is terminated with an empty-string entry.
37-
*
38-
* @return HTML entities table
39-
*/
40-
RP_LIBROMDATA_PUBLIC
41-
const html_entity_tbl_t *get_table(void);
42-
43-
/**
44-
* Get the number of entries in the HTML entities table.
45-
* NOTE: This does *not* include the empty-string terminator entry.
46-
*
47-
* @return Number of entries in the HTML entities table
48-
*/
49-
RP_LIBROMDATA_PUBLIC
50-
size_t get_count(void);
51-
5219
/**
5320
* Parse an HTML entity.
5421
* @param entity Pointer to HTML tag (will be modified) (MUST be pointing to a NULL-terminated string!)

src/win32/RP_ShellPropSheetExt.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
using namespace LibRpBase;
3232
using namespace LibRpFile;
3333
using namespace LibRpText;
34-
using LibRpText::HtmlEntities::html_entity_tbl_t;
3534
using namespace LibRpTexture;
3635
using namespace LibRomData;
3736

0 commit comments

Comments
 (0)