summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2021-02-02 16:39:41 +0000
committerMichael Drake <michael.drake@codethink.co.uk>2021-02-02 16:39:41 +0000
commit55fadc802ac80286e4f7266866ad789c78f57483 (patch)
treedbeba9044471dfb6f3b64884fbd0817c47b67833
parent3b57deb046a35a8e88fb0db672adf9aac6899aea (diff)
downloadnetsurf-55fadc802ac80286e4f7266866ad789c78f57483.tar.gz
netsurf-55fadc802ac80286e4f7266866ad789c78f57483.tar.bz2
html: list counter style: Revert to string for {pre|post}fix.
-rw-r--r--content/handlers/html/list_counter_style.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
index e864c9b52..81d9aa3d3 100644
--- a/content/handlers/html/list_counter_style.c
+++ b/content/handlers/html/list_counter_style.c
@@ -41,8 +41,8 @@ struct list_counter_style {
const unsigned int length;
const symbol_t value;
} pad;
- const symbol_t prefix;
- const symbol_t postfix;
+ const char *prefix;
+ const char *postfix;
const symbol_t *symbols; /**< array of symbols which represent this style */
const int *weights; /**< symbol weights for additive schemes */
const size_t items; /**< items in symbol and weight table */
@@ -50,6 +50,32 @@ struct list_counter_style {
};
/**
+ * Copy a null-terminated UTF-8 string to buffer at offset, if there is space
+ *
+ * \param[in] buf The output buffer
+ * \param[in] buflen The length of \a buf
+ * \param[in] pos Current position in \a buf
+ * \param[in] str The string to copy into \a buf
+ * \return The number of bytes needed in the output buffer which may be
+ * larger than \a buflen but the buffer will not be overrun
+ */
+static inline size_t
+copy_string(char *buf, const size_t buflen, size_t pos, const char *str)
+{
+ size_t sidx = 0; /* current string index */
+
+ while (str[sidx] != '\0') {
+ if (pos < buflen) {
+ buf[pos] = str[sidx];
+ }
+ pos++;
+ sidx++;
+ }
+
+ return sidx;
+}
+
+/**
* Copy a UTF-8 symbol to buffer at offset, if there is space
*
* \param[in] buf The output buffer
@@ -115,8 +141,8 @@ map_aval_to_symbols(char *buf, const size_t buflen,
}
/* postfix */
- oidx += copy_symbol(buf, buflen, oidx,
- (cstyle->postfix[0] != '\0') ?
+ oidx += copy_string(buf, buflen, oidx,
+ (cstyle->postfix != NULL) ?
cstyle->postfix : postfix);
return oidx;