netsurf: branch master updated. release/3.10-93-gbca82df
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/bca82dfe83530c9994259...
...commit http://git.netsurf-browser.org/netsurf.git/commit/bca82dfe83530c999425983...
...tree http://git.netsurf-browser.org/netsurf.git/tree/bca82dfe83530c99942598332...
The branch, master has been updated
via bca82dfe83530c9994259833214f1bc097c5a685 (commit)
from 27b178b04bdd12f02934b9eb0b9a5a00326e4ad1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=bca82dfe83530c99942...
commit bca82dfe83530c9994259833214f1bc097c5a685
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
do not count the null terminator in list counter style length formatting
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
index d2be0f7..af643df 100644
--- a/content/handlers/html/list_counter_style.c
+++ b/content/handlers/html/list_counter_style.c
@@ -523,7 +523,7 @@ list_counter_style_value(char *text,
res = text_len-2;
}
text[res++] = '.';
- text[res++] = 0;
+ text[res] = 0;
return res;
}
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/list_counter_style.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
index d2be0f7..af643df 100644
--- a/content/handlers/html/list_counter_style.c
+++ b/content/handlers/html/list_counter_style.c
@@ -523,7 +523,7 @@ list_counter_style_value(char *text,
res = text_len-2;
}
text[res++] = '.';
- text[res++] = 0;
+ text[res] = 0;
return res;
}
--
NetSurf Browser
2 years, 7 months
netsurf: branch master updated. release/3.10-92-g27b178b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/27b178b04bdd12f02934b...
...commit http://git.netsurf-browser.org/netsurf.git/commit/27b178b04bdd12f02934b9e...
...tree http://git.netsurf-browser.org/netsurf.git/tree/27b178b04bdd12f02934b9eb0...
The branch, master has been updated
via 27b178b04bdd12f02934b9eb0b9a5a00326e4ad1 (commit)
via 83ebc3bb8ee84284e68e2cb87873c1934e1b92b5 (commit)
from 13c1b11317d0153af235f1f2d15798a9cd942358 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=27b178b04bdd12f0293...
commit 27b178b04bdd12f02934b9eb0b9a5a00326e4ad1
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
implement armenian and georgian list counter styles
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
index a5ce3ae..d2be0f7 100644
--- a/content/handlers/html/list_counter_style.c
+++ b/content/handlers/html/list_counter_style.c
@@ -70,6 +70,93 @@ map_aval_to_symbols(char *buf, const size_t buflen,
/**
+ * generate numeric symbol values
+ *
+ * fills array with numeric values that represent the input value
+ *
+ * \param ares Buffer to recive the converted values
+ * \param alen the length of \a ares buffer
+ * \param value The value to convert
+ * \param slen The number of symbols in the alphabet
+ * \return The length a complete conversion which may be larger than \a alen
+ */
+static size_t
+calc_numeric_system(uint8_t *ares,
+ const size_t alen,
+ int value,
+ unsigned char slen)
+{
+ size_t idx = 0;
+ uint8_t *first;
+ uint8_t *last;
+
+ /* generate alphabet values in ascending order */
+ while (value > 0) {
+ if (idx < alen) ares[idx] = value % slen;
+ idx++;
+ value = value / slen;
+ }
+
+ /* put the values in decending order */
+ first = ares;
+ if (idx < alen) {
+ last = first + (idx - 1);
+ } else {
+ last = first + (alen - 1);
+ }
+ while (first < last) {
+ *first ^= *last;
+ *last ^= *first;
+ *first ^= *last;
+ first++;
+ last--;
+ }
+
+ return idx;
+}
+
+
+/**
+ * generate addative symbol values
+ *
+ * fills array with numeric values that represent the input value
+ *
+ * \param ares Buffer to recive the converted values
+ * \param alen the length of \a ares buffer
+ * \param value The value to convert
+ * \param wlen The number of weights
+ * \return The length a complete conversion which may be larger than \a alen
+ */
+static size_t
+calc_additive_system(uint8_t *ares,
+ const size_t alen,
+ int value,
+ const int weights[],
+ unsigned char wlen)
+{
+ size_t widx; /* weight index */
+ size_t aidx = 0;
+ size_t idx;
+ size_t times; /* number of times a weight occours */
+
+ /* iterate over the available weights */
+ for (widx = 0; widx < wlen;widx++) {
+ times = value / weights[widx];
+ if (times > 0) {
+ for (idx=0;idx < times;idx++) {
+ if (aidx < alen) ares[aidx] = widx;
+ aidx++;
+ }
+
+ value -= times * weights[widx];
+ }
+ }
+
+ return aidx;
+}
+
+
+/**
* generate alphabet symbol values for latin and greek labelling
*
* fills array with alphabet values suitable for the input value
@@ -81,10 +168,10 @@ map_aval_to_symbols(char *buf, const size_t buflen,
* \return The length a complete conversion which may be larger than \a alen
*/
static size_t
-calc_alphabet_values(uint8_t *ares,
- const size_t alen,
- int value,
- unsigned char slen)
+calc_alphabet_system(uint8_t *ares,
+ const size_t alen,
+ int value,
+ unsigned char slen)
{
size_t idx = 0;
uint8_t *first;
@@ -120,10 +207,13 @@ calc_alphabet_values(uint8_t *ares,
/**
* Roman numeral conversion
*
- * \return The number of characters that are nesesary for full output
+ * \return The number of numerals that are nesesary for full output
*/
static int
-ntoromannumeral(char *buf, const size_t maxlen, int value, const char *C)
+calc_roman_system(uint8_t *buf,
+ const size_t maxlen,
+ int value,
+ unsigned char slen)
{
const int S[] = { 0, 2, 4, 2, 4, 2, 4 };
const int D[] = { 1000, 500, 100, 50, 10, 5, 1 };
@@ -132,6 +222,8 @@ ntoromannumeral(char *buf, const size_t maxlen, int value, const char *C)
unsigned int i = 0; /* index into maps */
int r, r2;
+ assert(slen == 7);
+
while (value > 0) {
if (D[i] <= value) {
r = value / D[i];
@@ -143,15 +235,15 @@ ntoromannumeral(char *buf, const size_t maxlen, int value, const char *C)
if (i < L && r2 >= S[i+1]) {
/* will violate repeat boundary on next pass */
value = value - (r2 * D[i+1]);
- if (k < maxlen) buf[k++] = C[i+1];
- if (k < maxlen) buf[k++] = C[i-1];
+ if (k < maxlen) buf[k++] = i+1;
+ if (k < maxlen) buf[k++] = i-1;
} else if (S[i] && r >= S[i]) {
/* violated repeat boundary on this pass */
- if (k < maxlen) buf[k++] = C[i];
- if (k < maxlen) buf[k++] = C[i-1];
+ if (k < maxlen) buf[k++] = i;
+ if (k < maxlen) buf[k++] = i-1;
} else {
while (r-- > 0 && k < maxlen) {
- buf[k++] = C[i];
+ buf[k++] = i;
}
}
}
@@ -167,19 +259,43 @@ ntoromannumeral(char *buf, const size_t maxlen, int value, const char *C)
/**
* lower case roman numeral
*/
-static int ntolcromannumeral(char *buf, const size_t maxlen, int value)
+static int ntolcromannumeral(char *buf, const size_t buflen, int value)
{
- const char C[] = { 'm', 'd', 'c', 'l', 'x', 'v', 'i' };
- return ntoromannumeral(buf, maxlen, value, C);
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "m", "d", "c", "l", "x", "v", "i"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_roman_system(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
}
/**
* upper case roman numeral
*/
-static int ntoucromannumeral(char *buf, const size_t maxlen, int value)
+static int ntoucromannumeral(char *buf, const size_t buflen, int value)
{
- const char C[] = { 'M', 'D', 'C', 'L', 'X', 'V', 'I' };
- return ntoromannumeral(buf, maxlen, value, C);
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "M", "D", "C", "L", "X", "V", "I"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_roman_system(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
}
@@ -196,7 +312,7 @@ static int ntolcalpha(char *buf, const size_t buflen, int value)
};
const size_t symtablen = sizeof(symtab) / 4;
- alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
+ alen = calc_alphabet_system(aval, sizeof(aval), value, symtablen);
if (alen >= sizeof(aval)) {
*buf = '?';
return 1;
@@ -216,7 +332,7 @@ static int ntoucalpha(char *buf, const size_t buflen, int value)
};
const size_t symtablen = sizeof(symtab) / 4;
- alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
+ alen = calc_alphabet_system(aval, sizeof(aval), value, symtablen);
if (alen >= sizeof(aval)) {
*buf = '?';
return 1;
@@ -236,7 +352,27 @@ static int ntolcgreek(char *buf, const size_t buflen, int value)
};
const size_t symtablen = sizeof(symtab) / 4;
- alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
+ alen = calc_alphabet_system(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+#if 0
+static int ntolchex(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
+ "a", "b", "c", "d", "e", "f"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_numeric_system(aval, sizeof(aval), value, symtablen);
if (alen >= sizeof(aval)) {
*buf = '?';
return 1;
@@ -244,7 +380,82 @@ static int ntolcgreek(char *buf, const size_t buflen, int value)
return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
}
+#endif
+static int ntodecimal(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_numeric_system(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+static int ntoarmenian(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��"
+ };
+ const int weighttab[] = {
+ 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
+ 900, 800, 700, 600, 500, 400, 300, 200, 100,
+ 90, 80, 70, 60, 50, 40, 30, 20, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_additive_system(aval, sizeof(aval), value, weighttab, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+
+static int ntogeorgian(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ };
+ const int weighttab[] = {
+ 10000,
+ 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
+ 900, 800, 700, 600, 500, 400, 300, 200, 100,
+ 90, 80, 70, 60, 50, 40, 30, 20, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_additive_system(aval, sizeof(aval), value, weighttab, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
/**
* format value into a list marker with a style
@@ -288,10 +499,16 @@ list_counter_style_value(char *text,
break;
case CSS_LIST_STYLE_TYPE_ARMENIAN:
+ res = ntoarmenian(text, text_len, value);
+ break;
+
case CSS_LIST_STYLE_TYPE_GEORGIAN:
+ res = ntogeorgian(text, text_len, value);
+ break;
+
case CSS_LIST_STYLE_TYPE_DECIMAL:
default:
- res = snprintf(text, text_len, "%u", value);
+ res = ntodecimal(text, text_len, value);
break;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=83ebc3bb8ee84284e68...
commit 83ebc3bb8ee84284e68e2cb87873c1934e1b92b5
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
split counter style handling out of the box code
diff --git a/content/handlers/html/Makefile b/content/handlers/html/Makefile
index 8bb329b..968c96f 100644
--- a/content/handlers/html/Makefile
+++ b/content/handlers/html/Makefile
@@ -16,6 +16,7 @@ S_HTML := box_construct.c \
imagemap.c \
interaction.c \
layout.c \
+ list_counter_style.c \
object.c \
redraw.c \
redraw_border.c \
diff --git a/content/handlers/html/box_construct.c b/content/handlers/html/box_construct.c
index cf0d916..9204090 100644
--- a/content/handlers/html/box_construct.c
+++ b/content/handlers/html/box_construct.c
@@ -47,6 +47,7 @@
#include "html/box_special.h"
#include "html/box_normalise.h"
#include "html/form_internal.h"
+#include "html/list_counter_style.h"
/**
* Context for box tree construction
@@ -396,284 +397,13 @@ static unsigned int compute_list_marker_index(struct box *last)
return last->list_marker->rows + 1;
}
-
-/**
- * Roman numeral conversion
- *
- * \return The number of characters that are nesesary for full output
- */
-static int
-ntoromannumeral(char *buf, const size_t maxlen, int value, const char *C)
-{
- const int S[] = { 0, 2, 4, 2, 4, 2, 4 };
- const int D[] = { 1000, 500, 100, 50, 10, 5, 1 };
- const size_t L = sizeof(D) / sizeof(int) - 1;
- size_t k = 0; /* index into output buffer */
- unsigned int i = 0; /* index into maps */
- int r, r2;
-
- while (value > 0) {
- if (D[i] <= value) {
- r = value / D[i];
- value = value - (r * D[i]);
- if (i < L) {
- /* lookahead */
- r2 = value / D[i+1];
- }
- if (i < L && r2 >= S[i+1]) {
- /* will violate repeat boundary on next pass */
- value = value - (r2 * D[i+1]);
- if (k < maxlen) buf[k++] = C[i+1];
- if (k < maxlen) buf[k++] = C[i-1];
- } else if (S[i] && r >= S[i]) {
- /* violated repeat boundary on this pass */
- if (k < maxlen) buf[k++] = C[i];
- if (k < maxlen) buf[k++] = C[i-1];
- } else {
- while (r-- > 0 && k < maxlen) {
- buf[k++] = C[i];
- }
- }
- }
- i++;
- }
- if (k < maxlen) {
- buf[k] = '\0';
- }
- return k;
-}
-
-
-/**
- * lower case roman numeral
- */
-static int ntolcromannumeral(char *buf, const size_t maxlen, int value)
-{
- const char C[] = { 'm', 'd', 'c', 'l', 'x', 'v', 'i' };
- return ntoromannumeral(buf, maxlen, value, C);
-}
-
-/**
- * upper case roman numeral
- */
-static int ntoucromannumeral(char *buf, const size_t maxlen, int value)
-{
- const char C[] = { 'M', 'D', 'C', 'L', 'X', 'V', 'I' };
- return ntoromannumeral(buf, maxlen, value, C);
-}
-
-
-/**
- * generate alphabet symbol values for latin and greek labelling
- *
- * fills array with alphabet values suitable for the input value
- *
- * \param ares Buffer to recive the converted values
- * \param alen the length of \a ares buffer
- * \param value The value to convert
- * \param slen The number of symbols in the alphabet
- * \return The length a complete conversion which may be larger than \a alen
- */
-static size_t
-calc_alphabet_values(uint8_t *ares,
- const size_t alen,
- int value,
- unsigned char slen)
-{
- size_t idx = 0;
- uint8_t *first;
- uint8_t *last;
-
- /* generate alphabet values in ascending order */
- while (value > 0) {
- --value;
- if (idx < alen) ares[idx] = value % slen;
- idx++;
- value = value / slen;
- }
-
- /* put the values in decending order */
- first = ares;
- if (idx < alen) {
- last = first + (idx - 1);
- } else {
- last = first + (alen - 1);
- }
- while (first < last) {
- *first ^= *last;
- *last ^= *first;
- *first ^= *last;
- first++;
- last--;
- }
-
- return idx;
-}
-
-/**
- * maps alphabet values to output values with a symbol table
- *
- * Takes a list of alphabet values and for each one outputs the
- * compete symbol (in utf8) to an output buffer.
- *
- * \param buf The oputput buffer
- * \param buflen the length of \a buf
- * \param aval array of alphabet values
- * \param alen The number of values in \a alen
- * \param symtab The symbol table
- * \param symtablen The number of symbols in \a symtab
- * \return The number of bytes needed in the output buffer whichmay be
- * larger than \a buflen but the buffer will not be overrun
- */
-static int
-map_aval_to_symbols(char *buf, const size_t buflen,
- const uint8_t *aval, const size_t alen,
- const char symtab[][4], const size_t symtablen)
-{
- size_t oidx;
- size_t aidx;
- int sidx;
-
- oidx = 0;
- for (aidx=0; aidx < alen; aidx++) {
- sidx=0;
- while ((sidx < 4) &&
- (symtab[aval[aidx]][sidx] != 0)) {
- if (oidx < buflen) {
- buf[oidx] = symtab[aval[aidx]][sidx];
- }
- oidx++;
- sidx++;
- }
- }
- return oidx;
-}
-
-static int ntolcalpha(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
- "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
- "u", "v", "w", "x", "y", "z"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-static int ntoucalpha(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
- "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
- "U", "V", "W", "X", "Y", "Z"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-static int ntolcgreek(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
/**
- * format value into a list marker with a style
+ * maximum length of a list marker
*
- * The value is a one based index into the list. This means for
- * numeric printing the value must be incremented by one.
+ * enough for 9,999,999,999,999,999,999 in decimal
+ * or six characters for 3byte utf8
*/
-static size_t
-format_list_marker_value(char *text,
- size_t text_len,
- enum css_list_style_type_e list_style_type,
- unsigned int value)
-{
- int res = -1;
-
- switch (list_style_type) {
- case CSS_LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO:
- res = snprintf(text, text_len, "%02u", value);
- break;
-
- case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
- res = ntolcromannumeral(text, text_len, value);
- break;
-
- case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
- res = ntoucromannumeral(text, text_len, value);
- break;
-
- case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
- case CSS_LIST_STYLE_TYPE_LOWER_LATIN:
- res = ntolcalpha(text, text_len, value);
- break;
-
- case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
- case CSS_LIST_STYLE_TYPE_UPPER_LATIN:
- res = ntoucalpha(text, text_len, value);
- break;
-
- case CSS_LIST_STYLE_TYPE_LOWER_GREEK:
- res = ntolcgreek(text, text_len, value);
- break;
-
- case CSS_LIST_STYLE_TYPE_ARMENIAN:
- case CSS_LIST_STYLE_TYPE_GEORGIAN:
- case CSS_LIST_STYLE_TYPE_DECIMAL:
- default:
- res = snprintf(text, text_len, "%u", value);
- break;
- }
-
- /* deal with error */
- if (res < 0) {
- text[0] = 0;
- return 0;
- }
-
- /* deal with overflow */
- if ((size_t)res >= (text_len-2)) {
- res = text_len-2;
- }
- text[res++] = '.';
- text[res++] = 0;
-
- return res;
-}
-
+#define LIST_MARKER_SIZE 20
/**
* Construct a list marker box
@@ -731,12 +461,12 @@ box_construct_marker(struct box *box,
default:
marker->rows = compute_list_marker_index(parent->last);
- marker->text = talloc_array(ctx->bctx, char, 20);
+ marker->text = talloc_array(ctx->bctx, char, LIST_MARKER_SIZE);
if (marker->text == NULL)
return false;
- marker->length = format_list_marker_value(marker->text,
- 20,
+ marker->length = list_counter_style_value(marker->text,
+ LIST_MARKER_SIZE,
list_style_type,
marker->rows);
break;
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
new file mode 100644
index 0000000..a5ce3ae
--- /dev/null
+++ b/content/handlers/html/list_counter_style.c
@@ -0,0 +1,312 @@
+/*
+ * Copyright 2021 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * Implementation of css list counter styling
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+
+#include "css/select.h"
+
+#include "html/list_counter_style.h"
+
+
+/**
+ * maps alphabet values to output values with a symbol table
+ *
+ * Takes a list of alphabet values and for each one outputs the
+ * compete symbol (in utf8) to an output buffer.
+ *
+ * \param buf The oputput buffer
+ * \param buflen the length of \a buf
+ * \param aval array of alphabet values
+ * \param alen The number of values in \a alen
+ * \param symtab The symbol table
+ * \param symtablen The number of symbols in \a symtab
+ * \return The number of bytes needed in the output buffer whichmay be
+ * larger than \a buflen but the buffer will not be overrun
+ */
+static int
+map_aval_to_symbols(char *buf, const size_t buflen,
+ const uint8_t *aval, const size_t alen,
+ const char symtab[][4], const size_t symtablen)
+{
+ size_t oidx;
+ size_t aidx;
+ int sidx;
+
+ oidx = 0;
+ for (aidx=0; aidx < alen; aidx++) {
+ sidx=0;
+ while ((sidx < 4) &&
+ (symtab[aval[aidx]][sidx] != 0)) {
+ if (oidx < buflen) {
+ buf[oidx] = symtab[aval[aidx]][sidx];
+ }
+ oidx++;
+ sidx++;
+ }
+ }
+ return oidx;
+}
+
+
+/**
+ * generate alphabet symbol values for latin and greek labelling
+ *
+ * fills array with alphabet values suitable for the input value
+ *
+ * \param ares Buffer to recive the converted values
+ * \param alen the length of \a ares buffer
+ * \param value The value to convert
+ * \param slen The number of symbols in the alphabet
+ * \return The length a complete conversion which may be larger than \a alen
+ */
+static size_t
+calc_alphabet_values(uint8_t *ares,
+ const size_t alen,
+ int value,
+ unsigned char slen)
+{
+ size_t idx = 0;
+ uint8_t *first;
+ uint8_t *last;
+
+ /* generate alphabet values in ascending order */
+ while (value > 0) {
+ --value;
+ if (idx < alen) ares[idx] = value % slen;
+ idx++;
+ value = value / slen;
+ }
+
+ /* put the values in decending order */
+ first = ares;
+ if (idx < alen) {
+ last = first + (idx - 1);
+ } else {
+ last = first + (alen - 1);
+ }
+ while (first < last) {
+ *first ^= *last;
+ *last ^= *first;
+ *first ^= *last;
+ first++;
+ last--;
+ }
+
+ return idx;
+}
+
+
+/**
+ * Roman numeral conversion
+ *
+ * \return The number of characters that are nesesary for full output
+ */
+static int
+ntoromannumeral(char *buf, const size_t maxlen, int value, const char *C)
+{
+ const int S[] = { 0, 2, 4, 2, 4, 2, 4 };
+ const int D[] = { 1000, 500, 100, 50, 10, 5, 1 };
+ const size_t L = sizeof(D) / sizeof(int) - 1;
+ size_t k = 0; /* index into output buffer */
+ unsigned int i = 0; /* index into maps */
+ int r, r2;
+
+ while (value > 0) {
+ if (D[i] <= value) {
+ r = value / D[i];
+ value = value - (r * D[i]);
+ if (i < L) {
+ /* lookahead */
+ r2 = value / D[i+1];
+ }
+ if (i < L && r2 >= S[i+1]) {
+ /* will violate repeat boundary on next pass */
+ value = value - (r2 * D[i+1]);
+ if (k < maxlen) buf[k++] = C[i+1];
+ if (k < maxlen) buf[k++] = C[i-1];
+ } else if (S[i] && r >= S[i]) {
+ /* violated repeat boundary on this pass */
+ if (k < maxlen) buf[k++] = C[i];
+ if (k < maxlen) buf[k++] = C[i-1];
+ } else {
+ while (r-- > 0 && k < maxlen) {
+ buf[k++] = C[i];
+ }
+ }
+ }
+ i++;
+ }
+ if (k < maxlen) {
+ buf[k] = '\0';
+ }
+ return k;
+}
+
+
+/**
+ * lower case roman numeral
+ */
+static int ntolcromannumeral(char *buf, const size_t maxlen, int value)
+{
+ const char C[] = { 'm', 'd', 'c', 'l', 'x', 'v', 'i' };
+ return ntoromannumeral(buf, maxlen, value, C);
+}
+
+/**
+ * upper case roman numeral
+ */
+static int ntoucromannumeral(char *buf, const size_t maxlen, int value)
+{
+ const char C[] = { 'M', 'D', 'C', 'L', 'X', 'V', 'I' };
+ return ntoromannumeral(buf, maxlen, value, C);
+}
+
+
+
+
+static int ntolcalpha(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
+ "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
+ "u", "v", "w", "x", "y", "z"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+static int ntoucalpha(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
+ "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
+ "U", "V", "W", "X", "Y", "Z"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+static int ntolcgreek(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+
+/**
+ * format value into a list marker with a style
+ *
+ * The value is a one based index into the list. This means for
+ * numeric printing the value must be incremented by one.
+ */
+size_t
+list_counter_style_value(char *text,
+ size_t text_len,
+ enum css_list_style_type_e list_style_type,
+ unsigned int value)
+{
+ int res = -1;
+
+ switch (list_style_type) {
+ case CSS_LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO:
+ res = snprintf(text, text_len, "%02u", value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
+ res = ntolcromannumeral(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
+ res = ntoucromannumeral(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
+ case CSS_LIST_STYLE_TYPE_LOWER_LATIN:
+ res = ntolcalpha(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
+ case CSS_LIST_STYLE_TYPE_UPPER_LATIN:
+ res = ntoucalpha(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_LOWER_GREEK:
+ res = ntolcgreek(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_ARMENIAN:
+ case CSS_LIST_STYLE_TYPE_GEORGIAN:
+ case CSS_LIST_STYLE_TYPE_DECIMAL:
+ default:
+ res = snprintf(text, text_len, "%u", value);
+ break;
+ }
+
+ /* deal with error */
+ if (res < 0) {
+ text[0] = 0;
+ return 0;
+ }
+
+ /* deal with overflow */
+ if ((size_t)res >= (text_len-2)) {
+ res = text_len-2;
+ }
+ text[res++] = '.';
+ text[res++] = 0;
+
+ return res;
+}
diff --git a/content/handlers/html/list_counter_style.h b/content/handlers/html/list_counter_style.h
new file mode 100644
index 0000000..6446b93
--- /dev/null
+++ b/content/handlers/html/list_counter_style.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2021 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * List counter style handling
+ *
+ * These functions provide font related services. They all work on
+ * UTF-8 strings with lengths given.
+ */
+
+#ifndef NETSURF_HTML_LIST_COUNTER_STYLE_H
+#define NETSURF_HTML_LIST_COUNTER_STYLE_H
+
+/**
+ * format value into a list marker with a style
+ *
+ * \param text The buffer to recive the output
+ * \param text_len The length available in \a text
+ * \param list_style_type The css list style type
+ * \param value The value to style
+ * \return The size of data placed in \a text
+ */
+size_t
+list_counter_style_value(char *text,
+ size_t text_len,
+ enum css_list_style_type_e list_style_type,
+ unsigned int value);
+
+#endif
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/Makefile | 1 +
content/handlers/html/box_construct.c | 286 +----------
content/handlers/html/list_counter_style.c | 529 ++++++++++++++++++++
.../handlers/html/{font.h => list_counter_style.h} | 28 +-
4 files changed, 553 insertions(+), 291 deletions(-)
create mode 100644 content/handlers/html/list_counter_style.c
copy content/handlers/html/{font.h => list_counter_style.h} (57%)
diff --git a/content/handlers/html/Makefile b/content/handlers/html/Makefile
index 8bb329b..968c96f 100644
--- a/content/handlers/html/Makefile
+++ b/content/handlers/html/Makefile
@@ -16,6 +16,7 @@ S_HTML := box_construct.c \
imagemap.c \
interaction.c \
layout.c \
+ list_counter_style.c \
object.c \
redraw.c \
redraw_border.c \
diff --git a/content/handlers/html/box_construct.c b/content/handlers/html/box_construct.c
index cf0d916..9204090 100644
--- a/content/handlers/html/box_construct.c
+++ b/content/handlers/html/box_construct.c
@@ -47,6 +47,7 @@
#include "html/box_special.h"
#include "html/box_normalise.h"
#include "html/form_internal.h"
+#include "html/list_counter_style.h"
/**
* Context for box tree construction
@@ -396,284 +397,13 @@ static unsigned int compute_list_marker_index(struct box *last)
return last->list_marker->rows + 1;
}
-
-/**
- * Roman numeral conversion
- *
- * \return The number of characters that are nesesary for full output
- */
-static int
-ntoromannumeral(char *buf, const size_t maxlen, int value, const char *C)
-{
- const int S[] = { 0, 2, 4, 2, 4, 2, 4 };
- const int D[] = { 1000, 500, 100, 50, 10, 5, 1 };
- const size_t L = sizeof(D) / sizeof(int) - 1;
- size_t k = 0; /* index into output buffer */
- unsigned int i = 0; /* index into maps */
- int r, r2;
-
- while (value > 0) {
- if (D[i] <= value) {
- r = value / D[i];
- value = value - (r * D[i]);
- if (i < L) {
- /* lookahead */
- r2 = value / D[i+1];
- }
- if (i < L && r2 >= S[i+1]) {
- /* will violate repeat boundary on next pass */
- value = value - (r2 * D[i+1]);
- if (k < maxlen) buf[k++] = C[i+1];
- if (k < maxlen) buf[k++] = C[i-1];
- } else if (S[i] && r >= S[i]) {
- /* violated repeat boundary on this pass */
- if (k < maxlen) buf[k++] = C[i];
- if (k < maxlen) buf[k++] = C[i-1];
- } else {
- while (r-- > 0 && k < maxlen) {
- buf[k++] = C[i];
- }
- }
- }
- i++;
- }
- if (k < maxlen) {
- buf[k] = '\0';
- }
- return k;
-}
-
-
-/**
- * lower case roman numeral
- */
-static int ntolcromannumeral(char *buf, const size_t maxlen, int value)
-{
- const char C[] = { 'm', 'd', 'c', 'l', 'x', 'v', 'i' };
- return ntoromannumeral(buf, maxlen, value, C);
-}
-
-/**
- * upper case roman numeral
- */
-static int ntoucromannumeral(char *buf, const size_t maxlen, int value)
-{
- const char C[] = { 'M', 'D', 'C', 'L', 'X', 'V', 'I' };
- return ntoromannumeral(buf, maxlen, value, C);
-}
-
-
-/**
- * generate alphabet symbol values for latin and greek labelling
- *
- * fills array with alphabet values suitable for the input value
- *
- * \param ares Buffer to recive the converted values
- * \param alen the length of \a ares buffer
- * \param value The value to convert
- * \param slen The number of symbols in the alphabet
- * \return The length a complete conversion which may be larger than \a alen
- */
-static size_t
-calc_alphabet_values(uint8_t *ares,
- const size_t alen,
- int value,
- unsigned char slen)
-{
- size_t idx = 0;
- uint8_t *first;
- uint8_t *last;
-
- /* generate alphabet values in ascending order */
- while (value > 0) {
- --value;
- if (idx < alen) ares[idx] = value % slen;
- idx++;
- value = value / slen;
- }
-
- /* put the values in decending order */
- first = ares;
- if (idx < alen) {
- last = first + (idx - 1);
- } else {
- last = first + (alen - 1);
- }
- while (first < last) {
- *first ^= *last;
- *last ^= *first;
- *first ^= *last;
- first++;
- last--;
- }
-
- return idx;
-}
-
-/**
- * maps alphabet values to output values with a symbol table
- *
- * Takes a list of alphabet values and for each one outputs the
- * compete symbol (in utf8) to an output buffer.
- *
- * \param buf The oputput buffer
- * \param buflen the length of \a buf
- * \param aval array of alphabet values
- * \param alen The number of values in \a alen
- * \param symtab The symbol table
- * \param symtablen The number of symbols in \a symtab
- * \return The number of bytes needed in the output buffer whichmay be
- * larger than \a buflen but the buffer will not be overrun
- */
-static int
-map_aval_to_symbols(char *buf, const size_t buflen,
- const uint8_t *aval, const size_t alen,
- const char symtab[][4], const size_t symtablen)
-{
- size_t oidx;
- size_t aidx;
- int sidx;
-
- oidx = 0;
- for (aidx=0; aidx < alen; aidx++) {
- sidx=0;
- while ((sidx < 4) &&
- (symtab[aval[aidx]][sidx] != 0)) {
- if (oidx < buflen) {
- buf[oidx] = symtab[aval[aidx]][sidx];
- }
- oidx++;
- sidx++;
- }
- }
- return oidx;
-}
-
-static int ntolcalpha(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
- "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
- "u", "v", "w", "x", "y", "z"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-static int ntoucalpha(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
- "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
- "U", "V", "W", "X", "Y", "Z"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-static int ntolcgreek(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
/**
- * format value into a list marker with a style
+ * maximum length of a list marker
*
- * The value is a one based index into the list. This means for
- * numeric printing the value must be incremented by one.
+ * enough for 9,999,999,999,999,999,999 in decimal
+ * or six characters for 3byte utf8
*/
-static size_t
-format_list_marker_value(char *text,
- size_t text_len,
- enum css_list_style_type_e list_style_type,
- unsigned int value)
-{
- int res = -1;
-
- switch (list_style_type) {
- case CSS_LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO:
- res = snprintf(text, text_len, "%02u", value);
- break;
-
- case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
- res = ntolcromannumeral(text, text_len, value);
- break;
-
- case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
- res = ntoucromannumeral(text, text_len, value);
- break;
-
- case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
- case CSS_LIST_STYLE_TYPE_LOWER_LATIN:
- res = ntolcalpha(text, text_len, value);
- break;
-
- case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
- case CSS_LIST_STYLE_TYPE_UPPER_LATIN:
- res = ntoucalpha(text, text_len, value);
- break;
-
- case CSS_LIST_STYLE_TYPE_LOWER_GREEK:
- res = ntolcgreek(text, text_len, value);
- break;
-
- case CSS_LIST_STYLE_TYPE_ARMENIAN:
- case CSS_LIST_STYLE_TYPE_GEORGIAN:
- case CSS_LIST_STYLE_TYPE_DECIMAL:
- default:
- res = snprintf(text, text_len, "%u", value);
- break;
- }
-
- /* deal with error */
- if (res < 0) {
- text[0] = 0;
- return 0;
- }
-
- /* deal with overflow */
- if ((size_t)res >= (text_len-2)) {
- res = text_len-2;
- }
- text[res++] = '.';
- text[res++] = 0;
-
- return res;
-}
-
+#define LIST_MARKER_SIZE 20
/**
* Construct a list marker box
@@ -731,12 +461,12 @@ box_construct_marker(struct box *box,
default:
marker->rows = compute_list_marker_index(parent->last);
- marker->text = talloc_array(ctx->bctx, char, 20);
+ marker->text = talloc_array(ctx->bctx, char, LIST_MARKER_SIZE);
if (marker->text == NULL)
return false;
- marker->length = format_list_marker_value(marker->text,
- 20,
+ marker->length = list_counter_style_value(marker->text,
+ LIST_MARKER_SIZE,
list_style_type,
marker->rows);
break;
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
new file mode 100644
index 0000000..d2be0f7
--- /dev/null
+++ b/content/handlers/html/list_counter_style.c
@@ -0,0 +1,529 @@
+/*
+ * Copyright 2021 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * Implementation of css list counter styling
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+
+#include "css/select.h"
+
+#include "html/list_counter_style.h"
+
+
+/**
+ * maps alphabet values to output values with a symbol table
+ *
+ * Takes a list of alphabet values and for each one outputs the
+ * compete symbol (in utf8) to an output buffer.
+ *
+ * \param buf The oputput buffer
+ * \param buflen the length of \a buf
+ * \param aval array of alphabet values
+ * \param alen The number of values in \a alen
+ * \param symtab The symbol table
+ * \param symtablen The number of symbols in \a symtab
+ * \return The number of bytes needed in the output buffer whichmay be
+ * larger than \a buflen but the buffer will not be overrun
+ */
+static int
+map_aval_to_symbols(char *buf, const size_t buflen,
+ const uint8_t *aval, const size_t alen,
+ const char symtab[][4], const size_t symtablen)
+{
+ size_t oidx;
+ size_t aidx;
+ int sidx;
+
+ oidx = 0;
+ for (aidx=0; aidx < alen; aidx++) {
+ sidx=0;
+ while ((sidx < 4) &&
+ (symtab[aval[aidx]][sidx] != 0)) {
+ if (oidx < buflen) {
+ buf[oidx] = symtab[aval[aidx]][sidx];
+ }
+ oidx++;
+ sidx++;
+ }
+ }
+ return oidx;
+}
+
+
+/**
+ * generate numeric symbol values
+ *
+ * fills array with numeric values that represent the input value
+ *
+ * \param ares Buffer to recive the converted values
+ * \param alen the length of \a ares buffer
+ * \param value The value to convert
+ * \param slen The number of symbols in the alphabet
+ * \return The length a complete conversion which may be larger than \a alen
+ */
+static size_t
+calc_numeric_system(uint8_t *ares,
+ const size_t alen,
+ int value,
+ unsigned char slen)
+{
+ size_t idx = 0;
+ uint8_t *first;
+ uint8_t *last;
+
+ /* generate alphabet values in ascending order */
+ while (value > 0) {
+ if (idx < alen) ares[idx] = value % slen;
+ idx++;
+ value = value / slen;
+ }
+
+ /* put the values in decending order */
+ first = ares;
+ if (idx < alen) {
+ last = first + (idx - 1);
+ } else {
+ last = first + (alen - 1);
+ }
+ while (first < last) {
+ *first ^= *last;
+ *last ^= *first;
+ *first ^= *last;
+ first++;
+ last--;
+ }
+
+ return idx;
+}
+
+
+/**
+ * generate addative symbol values
+ *
+ * fills array with numeric values that represent the input value
+ *
+ * \param ares Buffer to recive the converted values
+ * \param alen the length of \a ares buffer
+ * \param value The value to convert
+ * \param wlen The number of weights
+ * \return The length a complete conversion which may be larger than \a alen
+ */
+static size_t
+calc_additive_system(uint8_t *ares,
+ const size_t alen,
+ int value,
+ const int weights[],
+ unsigned char wlen)
+{
+ size_t widx; /* weight index */
+ size_t aidx = 0;
+ size_t idx;
+ size_t times; /* number of times a weight occours */
+
+ /* iterate over the available weights */
+ for (widx = 0; widx < wlen;widx++) {
+ times = value / weights[widx];
+ if (times > 0) {
+ for (idx=0;idx < times;idx++) {
+ if (aidx < alen) ares[aidx] = widx;
+ aidx++;
+ }
+
+ value -= times * weights[widx];
+ }
+ }
+
+ return aidx;
+}
+
+
+/**
+ * generate alphabet symbol values for latin and greek labelling
+ *
+ * fills array with alphabet values suitable for the input value
+ *
+ * \param ares Buffer to recive the converted values
+ * \param alen the length of \a ares buffer
+ * \param value The value to convert
+ * \param slen The number of symbols in the alphabet
+ * \return The length a complete conversion which may be larger than \a alen
+ */
+static size_t
+calc_alphabet_system(uint8_t *ares,
+ const size_t alen,
+ int value,
+ unsigned char slen)
+{
+ size_t idx = 0;
+ uint8_t *first;
+ uint8_t *last;
+
+ /* generate alphabet values in ascending order */
+ while (value > 0) {
+ --value;
+ if (idx < alen) ares[idx] = value % slen;
+ idx++;
+ value = value / slen;
+ }
+
+ /* put the values in decending order */
+ first = ares;
+ if (idx < alen) {
+ last = first + (idx - 1);
+ } else {
+ last = first + (alen - 1);
+ }
+ while (first < last) {
+ *first ^= *last;
+ *last ^= *first;
+ *first ^= *last;
+ first++;
+ last--;
+ }
+
+ return idx;
+}
+
+
+/**
+ * Roman numeral conversion
+ *
+ * \return The number of numerals that are nesesary for full output
+ */
+static int
+calc_roman_system(uint8_t *buf,
+ const size_t maxlen,
+ int value,
+ unsigned char slen)
+{
+ const int S[] = { 0, 2, 4, 2, 4, 2, 4 };
+ const int D[] = { 1000, 500, 100, 50, 10, 5, 1 };
+ const size_t L = sizeof(D) / sizeof(int) - 1;
+ size_t k = 0; /* index into output buffer */
+ unsigned int i = 0; /* index into maps */
+ int r, r2;
+
+ assert(slen == 7);
+
+ while (value > 0) {
+ if (D[i] <= value) {
+ r = value / D[i];
+ value = value - (r * D[i]);
+ if (i < L) {
+ /* lookahead */
+ r2 = value / D[i+1];
+ }
+ if (i < L && r2 >= S[i+1]) {
+ /* will violate repeat boundary on next pass */
+ value = value - (r2 * D[i+1]);
+ if (k < maxlen) buf[k++] = i+1;
+ if (k < maxlen) buf[k++] = i-1;
+ } else if (S[i] && r >= S[i]) {
+ /* violated repeat boundary on this pass */
+ if (k < maxlen) buf[k++] = i;
+ if (k < maxlen) buf[k++] = i-1;
+ } else {
+ while (r-- > 0 && k < maxlen) {
+ buf[k++] = i;
+ }
+ }
+ }
+ i++;
+ }
+ if (k < maxlen) {
+ buf[k] = '\0';
+ }
+ return k;
+}
+
+
+/**
+ * lower case roman numeral
+ */
+static int ntolcromannumeral(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "m", "d", "c", "l", "x", "v", "i"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_roman_system(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+/**
+ * upper case roman numeral
+ */
+static int ntoucromannumeral(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "M", "D", "C", "L", "X", "V", "I"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_roman_system(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+
+
+
+static int ntolcalpha(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
+ "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
+ "u", "v", "w", "x", "y", "z"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_alphabet_system(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+static int ntoucalpha(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
+ "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
+ "U", "V", "W", "X", "Y", "Z"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_alphabet_system(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+static int ntolcgreek(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_alphabet_system(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+#if 0
+static int ntolchex(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
+ "a", "b", "c", "d", "e", "f"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_numeric_system(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+#endif
+
+static int ntodecimal(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_numeric_system(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+static int ntoarmenian(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��"
+ };
+ const int weighttab[] = {
+ 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
+ 900, 800, 700, 600, 500, 400, 300, 200, 100,
+ 90, 80, 70, 60, 50, 40, 30, 20, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_additive_system(aval, sizeof(aval), value, weighttab, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+
+static int ntogeorgian(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ };
+ const int weighttab[] = {
+ 10000,
+ 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
+ 900, 800, 700, 600, 500, 400, 300, 200, 100,
+ 90, 80, 70, 60, 50, 40, 30, 20, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_additive_system(aval, sizeof(aval), value, weighttab, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+/**
+ * format value into a list marker with a style
+ *
+ * The value is a one based index into the list. This means for
+ * numeric printing the value must be incremented by one.
+ */
+size_t
+list_counter_style_value(char *text,
+ size_t text_len,
+ enum css_list_style_type_e list_style_type,
+ unsigned int value)
+{
+ int res = -1;
+
+ switch (list_style_type) {
+ case CSS_LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO:
+ res = snprintf(text, text_len, "%02u", value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
+ res = ntolcromannumeral(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
+ res = ntoucromannumeral(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
+ case CSS_LIST_STYLE_TYPE_LOWER_LATIN:
+ res = ntolcalpha(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
+ case CSS_LIST_STYLE_TYPE_UPPER_LATIN:
+ res = ntoucalpha(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_LOWER_GREEK:
+ res = ntolcgreek(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_ARMENIAN:
+ res = ntoarmenian(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_GEORGIAN:
+ res = ntogeorgian(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_DECIMAL:
+ default:
+ res = ntodecimal(text, text_len, value);
+ break;
+ }
+
+ /* deal with error */
+ if (res < 0) {
+ text[0] = 0;
+ return 0;
+ }
+
+ /* deal with overflow */
+ if ((size_t)res >= (text_len-2)) {
+ res = text_len-2;
+ }
+ text[res++] = '.';
+ text[res++] = 0;
+
+ return res;
+}
diff --git a/content/handlers/html/font.h b/content/handlers/html/list_counter_style.h
similarity index 57%
copy from content/handlers/html/font.h
copy to content/handlers/html/list_counter_style.h
index 5f69ee7..6446b93 100644
--- a/content/handlers/html/font.h
+++ b/content/handlers/html/list_counter_style.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Vincent Sanders <vince(a)netsurf-browser.org>
+ * Copyright 2021 Vincent Sanders <vince(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -18,26 +18,28 @@
/**
* \file
- * Internal font handling interfaces.
+ * List counter style handling
*
* These functions provide font related services. They all work on
* UTF-8 strings with lengths given.
*/
-#ifndef NETSURF_HTML_FONT_H
-#define NETSURF_HTML_FONT_H
-
-struct plot_font_style;
+#ifndef NETSURF_HTML_LIST_COUNTER_STYLE_H
+#define NETSURF_HTML_LIST_COUNTER_STYLE_H
/**
- * Populate a font style using data from a computed CSS style
+ * format value into a list marker with a style
*
- * \param len_ctx Length conversion context
- * \param css Computed style to consider
- * \param fstyle Font style to populate
+ * \param text The buffer to recive the output
+ * \param text_len The length available in \a text
+ * \param list_style_type The css list style type
+ * \param value The value to style
+ * \return The size of data placed in \a text
*/
-void font_plot_style_from_css(const nscss_len_ctx *len_ctx,
- const css_computed_style *css,
- struct plot_font_style *fstyle);
+size_t
+list_counter_style_value(char *text,
+ size_t text_len,
+ enum css_list_style_type_e list_style_type,
+ unsigned int value);
#endif
--
NetSurf Browser
2 years, 7 months
netsurf-test: branch master updated. affedad2a5fe033099e9cf76b9a2188a1e9c9225
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf-test.git/shortlog/affedad2a5fe0330...
...commit http://git.netsurf-browser.org/netsurf-test.git/commit/affedad2a5fe033099...
...tree http://git.netsurf-browser.org/netsurf-test.git/tree/affedad2a5fe033099e9...
The branch, master has been updated
via affedad2a5fe033099e9cf76b9a2188a1e9c9225 (commit)
from 7b2cf96741b2ae2f9426f26ee9d05ed60da57911 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf-test.git/commit/?id=affedad2a5fe03...
commit affedad2a5fe033099e9cf76b9a2188a1e9c9225
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix integer cast in ordered list cgi
diff --git a/cgi-bin/ordered-list.cgi b/cgi-bin/ordered-list.cgi
index 2096d0e..6548699 100755
--- a/cgi-bin/ordered-list.cgi
+++ b/cgi-bin/ordered-list.cgi
@@ -30,7 +30,7 @@ def main():
liststyle = params['liststyle'].value
if 'listcount' in params and re.match('^[0-9]+$', params['listcount'].value):
- listcount = num(params['listcount'].value)
+ listcount = int(params['listcount'].value)
if listcount > 10000:
listcount = 10000
-----------------------------------------------------------------------
Summary of changes:
cgi-bin/ordered-list.cgi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cgi-bin/ordered-list.cgi b/cgi-bin/ordered-list.cgi
index 2096d0e..6548699 100755
--- a/cgi-bin/ordered-list.cgi
+++ b/cgi-bin/ordered-list.cgi
@@ -30,7 +30,7 @@ def main():
liststyle = params['liststyle'].value
if 'listcount' in params and re.match('^[0-9]+$', params['listcount'].value):
- listcount = num(params['listcount'].value)
+ listcount = int(params['listcount'].value)
if listcount > 10000:
listcount = 10000
--
NetSurf test cases
2 years, 7 months
netsurf-test: branch master updated. 7b2cf96741b2ae2f9426f26ee9d05ed60da57911
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf-test.git/shortlog/7b2cf96741b2ae2f...
...commit http://git.netsurf-browser.org/netsurf-test.git/commit/7b2cf96741b2ae2f94...
...tree http://git.netsurf-browser.org/netsurf-test.git/tree/7b2cf96741b2ae2f9426...
The branch, master has been updated
via 7b2cf96741b2ae2f9426f26ee9d05ed60da57911 (commit)
from 0db0abac48773ee2fb250aad99e6a215e05c3bd7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf-test.git/commit/?id=7b2cf96741b2ae...
commit 7b2cf96741b2ae2f9426f26ee9d05ed60da57911
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add ordered list generator cgi
diff --git a/cgi-bin/ordered-list.cgi b/cgi-bin/ordered-list.cgi
new file mode 100755
index 0000000..2096d0e
--- /dev/null
+++ b/cgi-bin/ordered-list.cgi
@@ -0,0 +1,59 @@
+#!/usr/bin/python3
+
+'''
+NetSurf test ordered list generator
+
+The liststyle form parameter may be given to select different list style types.
+'''
+
+import os
+import re
+import cgi
+import cgitb
+
+cgitb.enable()
+
+def main():
+ '''
+ The test plan generator
+ '''
+ docroot = os.environ["DOCUMENT_ROOT"]
+
+ testroot = os.path.join(docroot, "monkey-test")
+
+ params = cgi.FieldStorage()
+
+ liststyle = 'decimal'
+ listcount = 1000
+
+ if 'liststyle' in params and re.match('^[A-Za-z0-9-]+$', params['liststyle'].value):
+ liststyle = params['liststyle'].value
+
+ if 'listcount' in params and re.match('^[0-9]+$', params['listcount'].value):
+ listcount = num(params['listcount'].value)
+
+ if listcount > 10000:
+ listcount = 10000
+
+ print('Content-Type: text/html')
+ print('')
+
+ print('<!DOCTYPE html>')
+ print('<html>')
+ print('<head>')
+ print('<style>')
+ print('ol.a {list-style-type:',liststyle,';}')
+ print('</style>')
+ print('</head>')
+ print('<body>')
+ print('<h1>ordered list marker test with',liststyle,'style</h1>')
+ print('<ol class="a">')
+ for num in range(1, listcount):
+ print('<li>',num,'</li>', sep="")
+
+ print('</ol>')
+ print('</body>')
+ print('</html>')
+
+if __name__ == "__main__":
+ main()
-----------------------------------------------------------------------
Summary of changes:
cgi-bin/ordered-list.cgi | 59 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100755 cgi-bin/ordered-list.cgi
diff --git a/cgi-bin/ordered-list.cgi b/cgi-bin/ordered-list.cgi
new file mode 100755
index 0000000..2096d0e
--- /dev/null
+++ b/cgi-bin/ordered-list.cgi
@@ -0,0 +1,59 @@
+#!/usr/bin/python3
+
+'''
+NetSurf test ordered list generator
+
+The liststyle form parameter may be given to select different list style types.
+'''
+
+import os
+import re
+import cgi
+import cgitb
+
+cgitb.enable()
+
+def main():
+ '''
+ The test plan generator
+ '''
+ docroot = os.environ["DOCUMENT_ROOT"]
+
+ testroot = os.path.join(docroot, "monkey-test")
+
+ params = cgi.FieldStorage()
+
+ liststyle = 'decimal'
+ listcount = 1000
+
+ if 'liststyle' in params and re.match('^[A-Za-z0-9-]+$', params['liststyle'].value):
+ liststyle = params['liststyle'].value
+
+ if 'listcount' in params and re.match('^[0-9]+$', params['listcount'].value):
+ listcount = num(params['listcount'].value)
+
+ if listcount > 10000:
+ listcount = 10000
+
+ print('Content-Type: text/html')
+ print('')
+
+ print('<!DOCTYPE html>')
+ print('<html>')
+ print('<head>')
+ print('<style>')
+ print('ol.a {list-style-type:',liststyle,';}')
+ print('</style>')
+ print('</head>')
+ print('<body>')
+ print('<h1>ordered list marker test with',liststyle,'style</h1>')
+ print('<ol class="a">')
+ for num in range(1, listcount):
+ print('<li>',num,'</li>', sep="")
+
+ print('</ol>')
+ print('</body>')
+ print('</html>')
+
+if __name__ == "__main__":
+ main()
--
NetSurf test cases
2 years, 7 months
netsurf: branch master updated. release/3.10-90-g13c1b11
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/13c1b11317d0153af235f...
...commit http://git.netsurf-browser.org/netsurf.git/commit/13c1b11317d0153af235f1f...
...tree http://git.netsurf-browser.org/netsurf.git/tree/13c1b11317d0153af235f1f2d...
The branch, master has been updated
via 13c1b11317d0153af235f1f2d15798a9cd942358 (commit)
from 4455f1b712add554a1d61b33c25292f3c2acfa8e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=13c1b11317d0153af23...
commit 13c1b11317d0153af235f1f2d15798a9cd942358
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
css: hints: Add support for OL type attribute.
diff --git a/content/handlers/css/hints.c b/content/handlers/css/hints.c
index 9748030..defeae1 100644
--- a/content/handlers/css/hints.c
+++ b/content/handlers/css/hints.c
@@ -1579,6 +1579,50 @@ static void css_hint_white_space_nowrap(
}
}
+static void css_hint_list(
+ nscss_select_ctx *ctx,
+ dom_node *node)
+{
+ struct css_hint *hint = &(hint_ctx.hints[hint_ctx.len]);
+ dom_exception err;
+ dom_string *attr;
+
+ err = dom_element_get_attribute(node, corestring_dom_type, &attr);
+ if (err == DOM_NO_ERR && attr != NULL) {
+ const char *attr_str = dom_string_data(attr);
+ size_t attr_len = dom_string_byte_length(attr);
+ enum css_list_style_type_e type = CSS_LIST_STYLE_TYPE_INHERIT;
+
+ if (attr_len == 1) {
+ switch (attr_str[0]) {
+ case 'a':
+ type = CSS_LIST_STYLE_TYPE_LOWER_ALPHA;
+ break;
+ case 'A':
+ type = CSS_LIST_STYLE_TYPE_UPPER_ALPHA;
+ break;
+ case 'i':
+ type = CSS_LIST_STYLE_TYPE_LOWER_ROMAN;
+ break;
+ case 'I':
+ type = CSS_LIST_STYLE_TYPE_UPPER_ROMAN;
+ break;
+ case '1':
+ type = CSS_LIST_STYLE_TYPE_DECIMAL;
+ break;
+ }
+ }
+
+ if (type != CSS_LIST_STYLE_TYPE_INHERIT) {
+ hint->prop = CSS_PROP_LIST_STYLE_TYPE;
+ hint->status = type;
+ css_hint_advance(&hint);
+ }
+
+ dom_string_unref(attr);
+ }
+}
+
/* Exported function, documeted in css/hints.h */
css_error node_presentational_hint(void *pw, void *node,
@@ -1671,6 +1715,9 @@ css_error node_presentational_hint(void *pw, void *node,
case DOM_HTML_ELEMENT_TYPE_CANVAS:
css_hint_height_width_canvas(pw, node);
break;
+ case DOM_HTML_ELEMENT_TYPE_OL:
+ css_hint_list(pw, node);
+ break;
default:
break;
}
-----------------------------------------------------------------------
Summary of changes:
content/handlers/css/hints.c | 47 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/content/handlers/css/hints.c b/content/handlers/css/hints.c
index 9748030..defeae1 100644
--- a/content/handlers/css/hints.c
+++ b/content/handlers/css/hints.c
@@ -1579,6 +1579,50 @@ static void css_hint_white_space_nowrap(
}
}
+static void css_hint_list(
+ nscss_select_ctx *ctx,
+ dom_node *node)
+{
+ struct css_hint *hint = &(hint_ctx.hints[hint_ctx.len]);
+ dom_exception err;
+ dom_string *attr;
+
+ err = dom_element_get_attribute(node, corestring_dom_type, &attr);
+ if (err == DOM_NO_ERR && attr != NULL) {
+ const char *attr_str = dom_string_data(attr);
+ size_t attr_len = dom_string_byte_length(attr);
+ enum css_list_style_type_e type = CSS_LIST_STYLE_TYPE_INHERIT;
+
+ if (attr_len == 1) {
+ switch (attr_str[0]) {
+ case 'a':
+ type = CSS_LIST_STYLE_TYPE_LOWER_ALPHA;
+ break;
+ case 'A':
+ type = CSS_LIST_STYLE_TYPE_UPPER_ALPHA;
+ break;
+ case 'i':
+ type = CSS_LIST_STYLE_TYPE_LOWER_ROMAN;
+ break;
+ case 'I':
+ type = CSS_LIST_STYLE_TYPE_UPPER_ROMAN;
+ break;
+ case '1':
+ type = CSS_LIST_STYLE_TYPE_DECIMAL;
+ break;
+ }
+ }
+
+ if (type != CSS_LIST_STYLE_TYPE_INHERIT) {
+ hint->prop = CSS_PROP_LIST_STYLE_TYPE;
+ hint->status = type;
+ css_hint_advance(&hint);
+ }
+
+ dom_string_unref(attr);
+ }
+}
+
/* Exported function, documeted in css/hints.h */
css_error node_presentational_hint(void *pw, void *node,
@@ -1671,6 +1715,9 @@ css_error node_presentational_hint(void *pw, void *node,
case DOM_HTML_ELEMENT_TYPE_CANVAS:
css_hint_height_width_canvas(pw, node);
break;
+ case DOM_HTML_ELEMENT_TYPE_OL:
+ css_hint_list(pw, node);
+ break;
default:
break;
}
--
NetSurf Browser
2 years, 7 months
netsurf: branch master updated. release/3.10-89-g4455f1b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/4455f1b712add554a1d61...
...commit http://git.netsurf-browser.org/netsurf.git/commit/4455f1b712add554a1d61b3...
...tree http://git.netsurf-browser.org/netsurf.git/tree/4455f1b712add554a1d61b33c...
The branch, master has been updated
via 4455f1b712add554a1d61b33c25292f3c2acfa8e (commit)
from da2aa05b730560024760a25dabc2078f578efd10 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=4455f1b712add554a1d...
commit 4455f1b712add554a1d61b33c25292f3c2acfa8e
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
implement list marker counting for roman, latin and greek
diff --git a/content/handlers/html/box_construct.c b/content/handlers/html/box_construct.c
index e2eaf8c..cf0d916 100644
--- a/content/handlers/html/box_construct.c
+++ b/content/handlers/html/box_construct.c
@@ -350,6 +350,332 @@ box_construct_generate(dom_node *n,
/**
+ * compute the index for a list marker
+ *
+ * calculates a one based index of a list item
+ */
+static unsigned int compute_list_marker_index(struct box *last)
+{
+ /* Drill down into last child of parent
+ * to find the list marker (if any)
+ *
+ * Floated list boxes end up as:
+ *
+ * parent
+ * BOX_INLINE_CONTAINER
+ * BOX_FLOAT_{LEFT,RIGHT}
+ * BOX_BLOCK <-- list box
+ * ...
+ */
+ while ((last != NULL) && (last->list_marker == NULL)) {
+ struct box *last_inner = last;
+
+ while (last_inner != NULL) {
+ if (last_inner->list_marker != NULL) {
+ break;
+ }
+ if (last_inner->type == BOX_INLINE_CONTAINER ||
+ last_inner->type == BOX_FLOAT_LEFT ||
+ last_inner->type == BOX_FLOAT_RIGHT) {
+ last_inner = last_inner->last;
+ } else {
+ last_inner = NULL;
+ }
+ }
+ if (last_inner != NULL) {
+ last = last_inner;
+ } else {
+ last = last->prev;
+ }
+ }
+
+ if ((last == NULL) || (last->list_marker == NULL)) {
+ return 1;
+ }
+
+ return last->list_marker->rows + 1;
+}
+
+
+/**
+ * Roman numeral conversion
+ *
+ * \return The number of characters that are nesesary for full output
+ */
+static int
+ntoromannumeral(char *buf, const size_t maxlen, int value, const char *C)
+{
+ const int S[] = { 0, 2, 4, 2, 4, 2, 4 };
+ const int D[] = { 1000, 500, 100, 50, 10, 5, 1 };
+ const size_t L = sizeof(D) / sizeof(int) - 1;
+ size_t k = 0; /* index into output buffer */
+ unsigned int i = 0; /* index into maps */
+ int r, r2;
+
+ while (value > 0) {
+ if (D[i] <= value) {
+ r = value / D[i];
+ value = value - (r * D[i]);
+ if (i < L) {
+ /* lookahead */
+ r2 = value / D[i+1];
+ }
+ if (i < L && r2 >= S[i+1]) {
+ /* will violate repeat boundary on next pass */
+ value = value - (r2 * D[i+1]);
+ if (k < maxlen) buf[k++] = C[i+1];
+ if (k < maxlen) buf[k++] = C[i-1];
+ } else if (S[i] && r >= S[i]) {
+ /* violated repeat boundary on this pass */
+ if (k < maxlen) buf[k++] = C[i];
+ if (k < maxlen) buf[k++] = C[i-1];
+ } else {
+ while (r-- > 0 && k < maxlen) {
+ buf[k++] = C[i];
+ }
+ }
+ }
+ i++;
+ }
+ if (k < maxlen) {
+ buf[k] = '\0';
+ }
+ return k;
+}
+
+
+/**
+ * lower case roman numeral
+ */
+static int ntolcromannumeral(char *buf, const size_t maxlen, int value)
+{
+ const char C[] = { 'm', 'd', 'c', 'l', 'x', 'v', 'i' };
+ return ntoromannumeral(buf, maxlen, value, C);
+}
+
+/**
+ * upper case roman numeral
+ */
+static int ntoucromannumeral(char *buf, const size_t maxlen, int value)
+{
+ const char C[] = { 'M', 'D', 'C', 'L', 'X', 'V', 'I' };
+ return ntoromannumeral(buf, maxlen, value, C);
+}
+
+
+/**
+ * generate alphabet symbol values for latin and greek labelling
+ *
+ * fills array with alphabet values suitable for the input value
+ *
+ * \param ares Buffer to recive the converted values
+ * \param alen the length of \a ares buffer
+ * \param value The value to convert
+ * \param slen The number of symbols in the alphabet
+ * \return The length a complete conversion which may be larger than \a alen
+ */
+static size_t
+calc_alphabet_values(uint8_t *ares,
+ const size_t alen,
+ int value,
+ unsigned char slen)
+{
+ size_t idx = 0;
+ uint8_t *first;
+ uint8_t *last;
+
+ /* generate alphabet values in ascending order */
+ while (value > 0) {
+ --value;
+ if (idx < alen) ares[idx] = value % slen;
+ idx++;
+ value = value / slen;
+ }
+
+ /* put the values in decending order */
+ first = ares;
+ if (idx < alen) {
+ last = first + (idx - 1);
+ } else {
+ last = first + (alen - 1);
+ }
+ while (first < last) {
+ *first ^= *last;
+ *last ^= *first;
+ *first ^= *last;
+ first++;
+ last--;
+ }
+
+ return idx;
+}
+
+/**
+ * maps alphabet values to output values with a symbol table
+ *
+ * Takes a list of alphabet values and for each one outputs the
+ * compete symbol (in utf8) to an output buffer.
+ *
+ * \param buf The oputput buffer
+ * \param buflen the length of \a buf
+ * \param aval array of alphabet values
+ * \param alen The number of values in \a alen
+ * \param symtab The symbol table
+ * \param symtablen The number of symbols in \a symtab
+ * \return The number of bytes needed in the output buffer whichmay be
+ * larger than \a buflen but the buffer will not be overrun
+ */
+static int
+map_aval_to_symbols(char *buf, const size_t buflen,
+ const uint8_t *aval, const size_t alen,
+ const char symtab[][4], const size_t symtablen)
+{
+ size_t oidx;
+ size_t aidx;
+ int sidx;
+
+ oidx = 0;
+ for (aidx=0; aidx < alen; aidx++) {
+ sidx=0;
+ while ((sidx < 4) &&
+ (symtab[aval[aidx]][sidx] != 0)) {
+ if (oidx < buflen) {
+ buf[oidx] = symtab[aval[aidx]][sidx];
+ }
+ oidx++;
+ sidx++;
+ }
+ }
+ return oidx;
+}
+
+static int ntolcalpha(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
+ "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
+ "u", "v", "w", "x", "y", "z"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+static int ntoucalpha(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
+ "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
+ "U", "V", "W", "X", "Y", "Z"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+static int ntolcgreek(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+/**
+ * format value into a list marker with a style
+ *
+ * The value is a one based index into the list. This means for
+ * numeric printing the value must be incremented by one.
+ */
+static size_t
+format_list_marker_value(char *text,
+ size_t text_len,
+ enum css_list_style_type_e list_style_type,
+ unsigned int value)
+{
+ int res = -1;
+
+ switch (list_style_type) {
+ case CSS_LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO:
+ res = snprintf(text, text_len, "%02u", value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
+ res = ntolcromannumeral(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
+ res = ntoucromannumeral(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
+ case CSS_LIST_STYLE_TYPE_LOWER_LATIN:
+ res = ntolcalpha(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
+ case CSS_LIST_STYLE_TYPE_UPPER_LATIN:
+ res = ntoucalpha(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_LOWER_GREEK:
+ res = ntolcgreek(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_ARMENIAN:
+ case CSS_LIST_STYLE_TYPE_GEORGIAN:
+ case CSS_LIST_STYLE_TYPE_DECIMAL:
+ default:
+ res = snprintf(text, text_len, "%u", value);
+ break;
+ }
+
+ /* deal with error */
+ if (res < 0) {
+ text[0] = 0;
+ return 0;
+ }
+
+ /* deal with overflow */
+ if ((size_t)res >= (text_len-2)) {
+ res = text_len-2;
+ }
+ text[res++] = '.';
+ text[res++] = 0;
+
+ return res;
+}
+
+
+/**
* Construct a list marker box
*
* \param box Box to attach marker to
@@ -366,6 +692,7 @@ box_construct_marker(struct box *box,
{
lwc_string *image_uri;
struct box *marker;
+ enum css_list_style_type_e list_style_type;
marker = box_create(NULL, box->style, false, NULL, NULL, title,
NULL, ctx->bctx);
@@ -374,83 +701,46 @@ box_construct_marker(struct box *box,
marker->type = BOX_BLOCK;
+ list_style_type = css_computed_list_style_type(box->style);
+
/** \todo marker content (list-style-type) */
- switch (css_computed_list_style_type(box->style)) {
+ switch (list_style_type) {
case CSS_LIST_STYLE_TYPE_DISC:
/* 2022 BULLET */
marker->text = (char *) "\342\200\242";
marker->length = 3;
break;
+
case CSS_LIST_STYLE_TYPE_CIRCLE:
/* 25CB WHITE CIRCLE */
marker->text = (char *) "\342\227\213";
marker->length = 3;
break;
+
case CSS_LIST_STYLE_TYPE_SQUARE:
/* 25AA BLACK SMALL SQUARE */
marker->text = (char *) "\342\226\252";
marker->length = 3;
break;
- case CSS_LIST_STYLE_TYPE_DECIMAL:
- case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
- case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
- case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
- case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
- default:
- if (parent->last) {
- struct box *last = parent->last;
-
- /* Drill down into last child of parent
- * to find the list marker (if any)
- *
- * Floated list boxes end up as:
- *
- * parent
- * BOX_INLINE_CONTAINER
- * BOX_FLOAT_{LEFT,RIGHT}
- * BOX_BLOCK <-- list box
- * ...
- */
- while (last != NULL && last->list_marker == NULL) {
- struct box *last_inner = last;
-
- while (last_inner != NULL) {
- if (last_inner->list_marker != NULL)
- break;
- if (last_inner->type ==
- BOX_INLINE_CONTAINER ||
- last_inner->type ==
- BOX_FLOAT_LEFT ||
- last_inner->type ==
- BOX_FLOAT_RIGHT) {
- last_inner = last_inner->last;
- } else {
- last_inner = NULL;
- }
- }
- if (last_inner != NULL) {
- last = last_inner;
- } else {
- last = last->prev;
- }
- }
- if (last && last->list_marker) {
- marker->rows = last->list_marker->rows + 1;
- }
- }
+ case CSS_LIST_STYLE_TYPE_NONE:
+ marker->text = 0;
+ marker->length = 0;
+ break;
+
+ default:
+ marker->rows = compute_list_marker_index(parent->last);
marker->text = talloc_array(ctx->bctx, char, 20);
if (marker->text == NULL)
return false;
- snprintf(marker->text, 20, "%u.", marker->rows);
- marker->length = strlen(marker->text);
- break;
- case CSS_LIST_STYLE_TYPE_NONE:
- marker->text = 0;
- marker->length = 0;
+ marker->length = format_list_marker_value(marker->text,
+ 20,
+ list_style_type,
+ marker->rows);
break;
+
}
if (css_computed_list_style_image(box->style, &image_uri) == CSS_LIST_STYLE_IMAGE_URI &&
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/box_construct.c | 398 ++++++++++++++++++++++++++++-----
1 file changed, 344 insertions(+), 54 deletions(-)
diff --git a/content/handlers/html/box_construct.c b/content/handlers/html/box_construct.c
index e2eaf8c..cf0d916 100644
--- a/content/handlers/html/box_construct.c
+++ b/content/handlers/html/box_construct.c
@@ -350,6 +350,332 @@ box_construct_generate(dom_node *n,
/**
+ * compute the index for a list marker
+ *
+ * calculates a one based index of a list item
+ */
+static unsigned int compute_list_marker_index(struct box *last)
+{
+ /* Drill down into last child of parent
+ * to find the list marker (if any)
+ *
+ * Floated list boxes end up as:
+ *
+ * parent
+ * BOX_INLINE_CONTAINER
+ * BOX_FLOAT_{LEFT,RIGHT}
+ * BOX_BLOCK <-- list box
+ * ...
+ */
+ while ((last != NULL) && (last->list_marker == NULL)) {
+ struct box *last_inner = last;
+
+ while (last_inner != NULL) {
+ if (last_inner->list_marker != NULL) {
+ break;
+ }
+ if (last_inner->type == BOX_INLINE_CONTAINER ||
+ last_inner->type == BOX_FLOAT_LEFT ||
+ last_inner->type == BOX_FLOAT_RIGHT) {
+ last_inner = last_inner->last;
+ } else {
+ last_inner = NULL;
+ }
+ }
+ if (last_inner != NULL) {
+ last = last_inner;
+ } else {
+ last = last->prev;
+ }
+ }
+
+ if ((last == NULL) || (last->list_marker == NULL)) {
+ return 1;
+ }
+
+ return last->list_marker->rows + 1;
+}
+
+
+/**
+ * Roman numeral conversion
+ *
+ * \return The number of characters that are nesesary for full output
+ */
+static int
+ntoromannumeral(char *buf, const size_t maxlen, int value, const char *C)
+{
+ const int S[] = { 0, 2, 4, 2, 4, 2, 4 };
+ const int D[] = { 1000, 500, 100, 50, 10, 5, 1 };
+ const size_t L = sizeof(D) / sizeof(int) - 1;
+ size_t k = 0; /* index into output buffer */
+ unsigned int i = 0; /* index into maps */
+ int r, r2;
+
+ while (value > 0) {
+ if (D[i] <= value) {
+ r = value / D[i];
+ value = value - (r * D[i]);
+ if (i < L) {
+ /* lookahead */
+ r2 = value / D[i+1];
+ }
+ if (i < L && r2 >= S[i+1]) {
+ /* will violate repeat boundary on next pass */
+ value = value - (r2 * D[i+1]);
+ if (k < maxlen) buf[k++] = C[i+1];
+ if (k < maxlen) buf[k++] = C[i-1];
+ } else if (S[i] && r >= S[i]) {
+ /* violated repeat boundary on this pass */
+ if (k < maxlen) buf[k++] = C[i];
+ if (k < maxlen) buf[k++] = C[i-1];
+ } else {
+ while (r-- > 0 && k < maxlen) {
+ buf[k++] = C[i];
+ }
+ }
+ }
+ i++;
+ }
+ if (k < maxlen) {
+ buf[k] = '\0';
+ }
+ return k;
+}
+
+
+/**
+ * lower case roman numeral
+ */
+static int ntolcromannumeral(char *buf, const size_t maxlen, int value)
+{
+ const char C[] = { 'm', 'd', 'c', 'l', 'x', 'v', 'i' };
+ return ntoromannumeral(buf, maxlen, value, C);
+}
+
+/**
+ * upper case roman numeral
+ */
+static int ntoucromannumeral(char *buf, const size_t maxlen, int value)
+{
+ const char C[] = { 'M', 'D', 'C', 'L', 'X', 'V', 'I' };
+ return ntoromannumeral(buf, maxlen, value, C);
+}
+
+
+/**
+ * generate alphabet symbol values for latin and greek labelling
+ *
+ * fills array with alphabet values suitable for the input value
+ *
+ * \param ares Buffer to recive the converted values
+ * \param alen the length of \a ares buffer
+ * \param value The value to convert
+ * \param slen The number of symbols in the alphabet
+ * \return The length a complete conversion which may be larger than \a alen
+ */
+static size_t
+calc_alphabet_values(uint8_t *ares,
+ const size_t alen,
+ int value,
+ unsigned char slen)
+{
+ size_t idx = 0;
+ uint8_t *first;
+ uint8_t *last;
+
+ /* generate alphabet values in ascending order */
+ while (value > 0) {
+ --value;
+ if (idx < alen) ares[idx] = value % slen;
+ idx++;
+ value = value / slen;
+ }
+
+ /* put the values in decending order */
+ first = ares;
+ if (idx < alen) {
+ last = first + (idx - 1);
+ } else {
+ last = first + (alen - 1);
+ }
+ while (first < last) {
+ *first ^= *last;
+ *last ^= *first;
+ *first ^= *last;
+ first++;
+ last--;
+ }
+
+ return idx;
+}
+
+/**
+ * maps alphabet values to output values with a symbol table
+ *
+ * Takes a list of alphabet values and for each one outputs the
+ * compete symbol (in utf8) to an output buffer.
+ *
+ * \param buf The oputput buffer
+ * \param buflen the length of \a buf
+ * \param aval array of alphabet values
+ * \param alen The number of values in \a alen
+ * \param symtab The symbol table
+ * \param symtablen The number of symbols in \a symtab
+ * \return The number of bytes needed in the output buffer whichmay be
+ * larger than \a buflen but the buffer will not be overrun
+ */
+static int
+map_aval_to_symbols(char *buf, const size_t buflen,
+ const uint8_t *aval, const size_t alen,
+ const char symtab[][4], const size_t symtablen)
+{
+ size_t oidx;
+ size_t aidx;
+ int sidx;
+
+ oidx = 0;
+ for (aidx=0; aidx < alen; aidx++) {
+ sidx=0;
+ while ((sidx < 4) &&
+ (symtab[aval[aidx]][sidx] != 0)) {
+ if (oidx < buflen) {
+ buf[oidx] = symtab[aval[aidx]][sidx];
+ }
+ oidx++;
+ sidx++;
+ }
+ }
+ return oidx;
+}
+
+static int ntolcalpha(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
+ "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
+ "u", "v", "w", "x", "y", "z"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+static int ntoucalpha(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
+ "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
+ "U", "V", "W", "X", "Y", "Z"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+static int ntolcgreek(char *buf, const size_t buflen, int value)
+{
+ size_t alen;
+ uint8_t aval[20];
+ const char symtab[][4] = {
+ "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��"
+ };
+ const size_t symtablen = sizeof(symtab) / 4;
+
+ alen = calc_alphabet_values(aval, sizeof(aval), value, symtablen);
+ if (alen >= sizeof(aval)) {
+ *buf = '?';
+ return 1;
+ }
+
+ return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
+}
+
+/**
+ * format value into a list marker with a style
+ *
+ * The value is a one based index into the list. This means for
+ * numeric printing the value must be incremented by one.
+ */
+static size_t
+format_list_marker_value(char *text,
+ size_t text_len,
+ enum css_list_style_type_e list_style_type,
+ unsigned int value)
+{
+ int res = -1;
+
+ switch (list_style_type) {
+ case CSS_LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO:
+ res = snprintf(text, text_len, "%02u", value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
+ res = ntolcromannumeral(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
+ res = ntoucromannumeral(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
+ case CSS_LIST_STYLE_TYPE_LOWER_LATIN:
+ res = ntolcalpha(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
+ case CSS_LIST_STYLE_TYPE_UPPER_LATIN:
+ res = ntoucalpha(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_LOWER_GREEK:
+ res = ntolcgreek(text, text_len, value);
+ break;
+
+ case CSS_LIST_STYLE_TYPE_ARMENIAN:
+ case CSS_LIST_STYLE_TYPE_GEORGIAN:
+ case CSS_LIST_STYLE_TYPE_DECIMAL:
+ default:
+ res = snprintf(text, text_len, "%u", value);
+ break;
+ }
+
+ /* deal with error */
+ if (res < 0) {
+ text[0] = 0;
+ return 0;
+ }
+
+ /* deal with overflow */
+ if ((size_t)res >= (text_len-2)) {
+ res = text_len-2;
+ }
+ text[res++] = '.';
+ text[res++] = 0;
+
+ return res;
+}
+
+
+/**
* Construct a list marker box
*
* \param box Box to attach marker to
@@ -366,6 +692,7 @@ box_construct_marker(struct box *box,
{
lwc_string *image_uri;
struct box *marker;
+ enum css_list_style_type_e list_style_type;
marker = box_create(NULL, box->style, false, NULL, NULL, title,
NULL, ctx->bctx);
@@ -374,83 +701,46 @@ box_construct_marker(struct box *box,
marker->type = BOX_BLOCK;
+ list_style_type = css_computed_list_style_type(box->style);
+
/** \todo marker content (list-style-type) */
- switch (css_computed_list_style_type(box->style)) {
+ switch (list_style_type) {
case CSS_LIST_STYLE_TYPE_DISC:
/* 2022 BULLET */
marker->text = (char *) "\342\200\242";
marker->length = 3;
break;
+
case CSS_LIST_STYLE_TYPE_CIRCLE:
/* 25CB WHITE CIRCLE */
marker->text = (char *) "\342\227\213";
marker->length = 3;
break;
+
case CSS_LIST_STYLE_TYPE_SQUARE:
/* 25AA BLACK SMALL SQUARE */
marker->text = (char *) "\342\226\252";
marker->length = 3;
break;
- case CSS_LIST_STYLE_TYPE_DECIMAL:
- case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
- case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
- case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
- case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
- default:
- if (parent->last) {
- struct box *last = parent->last;
-
- /* Drill down into last child of parent
- * to find the list marker (if any)
- *
- * Floated list boxes end up as:
- *
- * parent
- * BOX_INLINE_CONTAINER
- * BOX_FLOAT_{LEFT,RIGHT}
- * BOX_BLOCK <-- list box
- * ...
- */
- while (last != NULL && last->list_marker == NULL) {
- struct box *last_inner = last;
-
- while (last_inner != NULL) {
- if (last_inner->list_marker != NULL)
- break;
- if (last_inner->type ==
- BOX_INLINE_CONTAINER ||
- last_inner->type ==
- BOX_FLOAT_LEFT ||
- last_inner->type ==
- BOX_FLOAT_RIGHT) {
- last_inner = last_inner->last;
- } else {
- last_inner = NULL;
- }
- }
- if (last_inner != NULL) {
- last = last_inner;
- } else {
- last = last->prev;
- }
- }
- if (last && last->list_marker) {
- marker->rows = last->list_marker->rows + 1;
- }
- }
+ case CSS_LIST_STYLE_TYPE_NONE:
+ marker->text = 0;
+ marker->length = 0;
+ break;
+
+ default:
+ marker->rows = compute_list_marker_index(parent->last);
marker->text = talloc_array(ctx->bctx, char, 20);
if (marker->text == NULL)
return false;
- snprintf(marker->text, 20, "%u.", marker->rows);
- marker->length = strlen(marker->text);
- break;
- case CSS_LIST_STYLE_TYPE_NONE:
- marker->text = 0;
- marker->length = 0;
+ marker->length = format_list_marker_value(marker->text,
+ 20,
+ list_style_type,
+ marker->rows);
break;
+
}
if (css_computed_list_style_image(box->style, &image_uri) == CSS_LIST_STYLE_IMAGE_URI &&
--
NetSurf Browser
2 years, 7 months
libdom: branch master updated. release/0.4.1-5-gc90f98b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/c90f98b7d5bdaecb1c497b...
...commit http://git.netsurf-browser.org/libdom.git/commit/c90f98b7d5bdaecb1c497b15...
...tree http://git.netsurf-browser.org/libdom.git/tree/c90f98b7d5bdaecb1c497b155a...
The branch, master has been updated
via c90f98b7d5bdaecb1c497b155af5347aedb1d617 (commit)
from abfd646c26f2e00484266507523c420bcb9ea7b8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libdom.git/commit/?id=c90f98b7d5bdaecb1c49...
commit c90f98b7d5bdaecb1c497b155af5347aedb1d617
Author: John-Mark Bell <jmb(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Fix pkg-config file expat library linkage
diff --git a/Makefile b/Makefile
index 1c6d9ff..5690403 100644
--- a/Makefile
+++ b/Makefile
@@ -157,3 +157,6 @@ ifeq ($(WITH_HUBBUB_BINDING),yes)
REQUIRED_PKGS := $(REQUIRED_PKGS) libhubbub
endif
+ifeq ($(WITH_EXPAT_BINDING),yes)
+ REQUIRED_LIBS := $(REQUIRED_LIBS) expat
+endif
diff --git a/Makefile.config b/Makefile.config
index 04971d5..0aba3ff 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -3,6 +3,9 @@
# Build the libxml2 binding?
# yes | no
WITH_LIBXML_BINDING := no
+
+# Build the expat binding?
+# yes | no
WITH_EXPAT_BINDING := yes
# Build the hubbub binding?
diff --git a/libdom.pc.in b/libdom.pc.in
index 406ed9e..86a97bb 100644
--- a/libdom.pc.in
+++ b/libdom.pc.in
@@ -7,5 +7,5 @@ Name: libdom
Description: W3C DOM implementation
Version: VERSION
REQUIRED
-Libs: -L${libdir} -ldom -lexpat
+Libs: -L${libdir} -ldom LIBRARIES
Cflags: -I${includedir}
-----------------------------------------------------------------------
Summary of changes:
Makefile | 3 +++
Makefile.config | 3 +++
libdom.pc.in | 2 +-
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 1c6d9ff..5690403 100644
--- a/Makefile
+++ b/Makefile
@@ -157,3 +157,6 @@ ifeq ($(WITH_HUBBUB_BINDING),yes)
REQUIRED_PKGS := $(REQUIRED_PKGS) libhubbub
endif
+ifeq ($(WITH_EXPAT_BINDING),yes)
+ REQUIRED_LIBS := $(REQUIRED_LIBS) expat
+endif
diff --git a/Makefile.config b/Makefile.config
index 04971d5..0aba3ff 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -3,6 +3,9 @@
# Build the libxml2 binding?
# yes | no
WITH_LIBXML_BINDING := no
+
+# Build the expat binding?
+# yes | no
WITH_EXPAT_BINDING := yes
# Build the hubbub binding?
diff --git a/libdom.pc.in b/libdom.pc.in
index 406ed9e..86a97bb 100644
--- a/libdom.pc.in
+++ b/libdom.pc.in
@@ -7,5 +7,5 @@ Name: libdom
Description: W3C DOM implementation
Version: VERSION
REQUIRED
-Libs: -L${libdir} -ldom -lexpat
+Libs: -L${libdir} -ldom LIBRARIES
Cflags: -I${includedir}
--
Document Object Model library
2 years, 7 months
netsurf: branch master updated. release/3.10-88-gda2aa05
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/da2aa05b730560024760a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/da2aa05b730560024760a25...
...tree http://git.netsurf-browser.org/netsurf.git/tree/da2aa05b730560024760a25da...
The branch, master has been updated
via da2aa05b730560024760a25dabc2078f578efd10 (commit)
from 98496cdae16a9196bff930fff52e198a9856e2cb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=da2aa05b73056002476...
commit da2aa05b730560024760a25dabc2078f578efd10
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Prevent overflow of disc cache hysteresis.
The default disc cache size is 1GB (1024 * 1024 * 1024).
On systems with 32bit size_t, the hysteresis calculation,
which multiplied 1GB by 20 would overflow, causing a zero
hysteresis.
(1024 * 1024 * 1024) * 20 % (2^32)
= 0
Thanks to Jonas Amoson for reporting.
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 6cc3a11..fd838b8 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -155,10 +155,10 @@ nserror netsurf_init(const char *store_path)
hlcache_parameters.llcache.fetch_attempts = nsoption_uint(max_retried_fetches);
/* image cache is 25% of total memory cache size */
- image_cache_parameters.limit = (hlcache_parameters.llcache.limit * 25) / 100;
+ image_cache_parameters.limit = hlcache_parameters.llcache.limit / 4;
/* image cache hysteresis is 20% of the image cache size */
- image_cache_parameters.hysteresis = (image_cache_parameters.limit * 20) / 100;
+ image_cache_parameters.hysteresis = image_cache_parameters.limit / 5;
/* account for image cache use from total */
hlcache_parameters.llcache.limit -= image_cache_parameters.limit;
@@ -167,7 +167,7 @@ nserror netsurf_init(const char *store_path)
hlcache_parameters.llcache.store.limit = nsoption_uint(disc_cache_size);
/* set backing store hysterissi to 20% */
- hlcache_parameters.llcache.store.hysteresis = (hlcache_parameters.llcache.store.limit * 20) / 100;;
+ hlcache_parameters.llcache.store.hysteresis = hlcache_parameters.llcache.store.limit / 5;
/* set the path to the backing store */
hlcache_parameters.llcache.store.path =
-----------------------------------------------------------------------
Summary of changes:
desktop/netsurf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 6cc3a11..fd838b8 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -155,10 +155,10 @@ nserror netsurf_init(const char *store_path)
hlcache_parameters.llcache.fetch_attempts = nsoption_uint(max_retried_fetches);
/* image cache is 25% of total memory cache size */
- image_cache_parameters.limit = (hlcache_parameters.llcache.limit * 25) / 100;
+ image_cache_parameters.limit = hlcache_parameters.llcache.limit / 4;
/* image cache hysteresis is 20% of the image cache size */
- image_cache_parameters.hysteresis = (image_cache_parameters.limit * 20) / 100;
+ image_cache_parameters.hysteresis = image_cache_parameters.limit / 5;
/* account for image cache use from total */
hlcache_parameters.llcache.limit -= image_cache_parameters.limit;
@@ -167,7 +167,7 @@ nserror netsurf_init(const char *store_path)
hlcache_parameters.llcache.store.limit = nsoption_uint(disc_cache_size);
/* set backing store hysterissi to 20% */
- hlcache_parameters.llcache.store.hysteresis = (hlcache_parameters.llcache.store.limit * 20) / 100;;
+ hlcache_parameters.llcache.store.hysteresis = hlcache_parameters.llcache.store.limit / 5;
/* set the path to the backing store */
hlcache_parameters.llcache.store.path =
--
NetSurf Browser
2 years, 8 months
netsurf: branch master updated. release/3.10-87-g98496cd
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/98496cdae16a9196bff93...
...commit http://git.netsurf-browser.org/netsurf.git/commit/98496cdae16a9196bff930f...
...tree http://git.netsurf-browser.org/netsurf.git/tree/98496cdae16a9196bff930fff...
The branch, master has been updated
via 98496cdae16a9196bff930fff52e198a9856e2cb (commit)
from ed5076421f3c9e93f000ae7d963f8b623b8c22db (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=98496cdae16a9196bff...
commit 98496cdae16a9196bff930fff52e198a9856e2cb
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
move remaining macros into separate macro makefile
diff --git a/Makefile b/Makefile
index 80330b5..ac38b50 100644
--- a/Makefile
+++ b/Makefile
@@ -300,20 +300,6 @@ S_COMMON := \
# Message targets
# ----------------------------------------------------------------------------
-# Message splitting rule generation macro
-# 1 = Language
-define split_messages
-
-$$(MESSAGES_TARGET)/$(1)/Messages: resources/FatMessages $$(TOOLROOT)/split-messages
- $$(VQ)echo "MSGSPLIT: Language: $(1) Filter: $$(MESSAGES_FILTER)"
- $$(Q)$$(MKDIR) -p $$(MESSAGES_TARGET)/$(1)
- $$(Q)$$(RM) $$@
- $$(Q)$$(TOOLROOT)/split-messages -l $(1) -p $$(MESSAGES_FILTER) -f messages -o $$@ -z $$<
-
-CLEAN_MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
-MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
-
-endef
# generate the message file rules
$(eval $(foreach LANG,$(MESSAGES_LANGUAGES), \
@@ -364,7 +350,7 @@ ifeq ($(TARGET),beos)
$(Q)$(BEOS_SETVER) $(EXETARGET) \
-app $(VERSION_MAJ) $(VERSION_MIN) 0 d 0 \
-short "NetSurf $(VERSION_FULL)" \
- -long "NetSurf $(VERSION_FULL) �� 2003 - 2016 The NetSurf Developers"
+ -long "NetSurf $(VERSION_FULL) �� 2003 - 2021 The NetSurf Developers"
$(VQ)echo " MIMESET: $(EXETARGET)"
$(Q)$(BEOS_MIMESET) $(EXETARGET)
endif
@@ -388,79 +374,6 @@ all-program: $(EXETARGET) $(POSTEXES)
.SUFFIXES:
DEPFILES :=
-# Now some macros which build the make system
-
-# 1 = Source file
-# 2 = dep filename, no prefix
-# 3 = obj filename, no prefix
-define dependency_generate_c
-DEPFILES += $(2)
-
-endef
-
-# 1 = Source file
-# 2 = dep filename, no prefix
-# 3 = obj filename, no prefix
-define dependency_generate_s
-DEPFILES += $(2)
-
-endef
-
-# 1 = Source file
-# 2 = obj filename, no prefix
-# 3 = dep filename, no prefix
-ifeq ($(CC_MAJOR),2)
-# simpler deps tracking for gcc2...
-define compile_target_c
-$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
- $$(VQ)echo " DEP: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(CC) $$(IFLAGS) $$(CFLAGS) -MM \
- $(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
- > $$(DEPROOT)/$(3)
- $$(VQ)echo " COMPILE: $(1)"
- $$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
-
-endef
-else
-define compile_target_c
-$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
- $$(VQ)echo " COMPILE: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) \
- -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
- -MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
-
-endef
-endif
-
-define compile_target_cpp
-$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
- $$(VQ)echo " DEP: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(CC) $$(IFLAGS) $$(CXXFLAGS) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) -MM \
- $(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
- > $$(DEPROOT)/$(3)
- $$(VQ)echo " COMPILE: $(1)"
- $$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CXX) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) $$(IFLAGS) $$(CXXFLAGS) $(CXXFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
-
-endef
-
-# 1 = Source file
-# 2 = obj filename, no prefix
-# 3 = dep filename, no prefix
-define compile_target_s
-$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
- $$(VQ)echo "ASSEMBLE: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CC) $$(ASFLAGS) -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
- -MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
-
-endef
# Rules to construct dep lines for each object...
$(eval $(foreach SOURCE,$(filter %.c,$(SOURCES)), \
diff --git a/Makefile.macros b/Makefile.macros
index 37a9954..d8468b4 100644
--- a/Makefile.macros
+++ b/Makefile.macros
@@ -27,6 +27,7 @@ define feature_enabled
endif
endef
+
# A macro that conditionaly adds flags to the build with a uniform display.
#
# 1: Feature name (ie, NETSURF_USE_BMP -> BMP)
@@ -56,6 +57,7 @@ define feature_switch
endif
endef
+
# Extend flags with appropriate values from pkg-config for enabled features
#
# 1: pkg-config required modules for feature
@@ -82,6 +84,7 @@ define pkg_config_find_and_add
endif
endef
+
# Extend flags with appropriate values from pkg-config for enabled features
#
# 1: Feature name (ie, NETSURF_USE_RSVG -> RSVG)
@@ -135,3 +138,112 @@ define pkg_config_find_and_add_enabled
endif
endif
endef
+
+
+# Message splitting rule generation macro
+#
+# 1 = Language
+define split_messages
+
+$$(MESSAGES_TARGET)/$(1)/Messages: resources/FatMessages $$(TOOLROOT)/split-messages
+ $$(VQ)echo "MSGSPLIT: Language: $(1) Filter: $$(MESSAGES_FILTER)"
+ $$(Q)$$(MKDIR) -p $$(MESSAGES_TARGET)/$(1)
+ $$(Q)$$(RM) $$@
+ $$(Q)$$(TOOLROOT)/split-messages -l $(1) -p $$(MESSAGES_FILTER) -f messages -o $$@ -z $$<
+
+CLEAN_MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
+MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
+
+endef
+
+
+# Now some macros which build the make system
+
+# Extend dependancy files for c source files
+#
+# 1 = Source file
+# 2 = dep filename, no prefix
+# 3 = obj filename, no prefix
+define dependency_generate_c
+DEPFILES += $(2)
+
+endef
+
+
+# Extend dependancy files for s source files
+#
+# 1 = Source file
+# 2 = dep filename, no prefix
+# 3 = obj filename, no prefix
+define dependency_generate_s
+DEPFILES += $(2)
+
+endef
+
+
+# Rule generator to compile c files
+#
+# 1 = Source file
+# 2 = obj filename, no prefix
+# 3 = dep filename, no prefix
+ifeq ($(CC_MAJOR),2)
+# simpler deps tracking for gcc2...
+define compile_target_c
+$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
+ $$(VQ)echo " DEP: $(1)"
+ $$(Q)$$(RM) $$(DEPROOT)/$(3)
+ $$(Q)$$(CC) $$(IFLAGS) $$(CFLAGS) -MM \
+ $(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
+ > $$(DEPROOT)/$(3)
+ $$(VQ)echo " COMPILE: $(1)"
+ $$(Q)$$(RM) $$(OBJROOT)/$(2)
+ $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
+
+endef
+else
+define compile_target_c
+$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
+ $$(VQ)echo " COMPILE: $(1)"
+ $$(Q)$$(RM) $$(DEPROOT)/$(3)
+ $$(Q)$$(RM) $$(OBJROOT)/$(2)
+ $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) \
+ -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
+ -MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
+
+endef
+endif
+
+
+# Rule generator to compile cpp files
+#
+# 1 = Source file
+# 2 = obj filename, no prefix
+# 3 = dep filename, no prefix
+define compile_target_cpp
+$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
+ $$(VQ)echo " DEP: $(1)"
+ $$(Q)$$(RM) $$(DEPROOT)/$(3)
+ $$(Q)$$(CC) $$(IFLAGS) $$(CXXFLAGS) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) -MM \
+ $(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
+ > $$(DEPROOT)/$(3)
+ $$(VQ)echo " COMPILE: $(1)"
+ $$(Q)$$(RM) $$(OBJROOT)/$(2)
+ $$(Q)$$(CXX) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) $$(IFLAGS) $$(CXXFLAGS) $(CXXFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
+
+endef
+
+
+# Rule generator to compile s files
+#
+# 1 = Source file
+# 2 = obj filename, no prefix
+# 3 = dep filename, no prefix
+define compile_target_s
+$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
+ $$(VQ)echo "ASSEMBLE: $(1)"
+ $$(Q)$$(RM) $$(DEPROOT)/$(3)
+ $$(Q)$$(RM) $$(OBJROOT)/$(2)
+ $$(Q)$$(CC) $$(ASFLAGS) -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
+ -MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
+
+endef
-----------------------------------------------------------------------
Summary of changes:
Makefile | 89 +------------------------------------------
Makefile.macros | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 113 insertions(+), 88 deletions(-)
diff --git a/Makefile b/Makefile
index 80330b5..ac38b50 100644
--- a/Makefile
+++ b/Makefile
@@ -300,20 +300,6 @@ S_COMMON := \
# Message targets
# ----------------------------------------------------------------------------
-# Message splitting rule generation macro
-# 1 = Language
-define split_messages
-
-$$(MESSAGES_TARGET)/$(1)/Messages: resources/FatMessages $$(TOOLROOT)/split-messages
- $$(VQ)echo "MSGSPLIT: Language: $(1) Filter: $$(MESSAGES_FILTER)"
- $$(Q)$$(MKDIR) -p $$(MESSAGES_TARGET)/$(1)
- $$(Q)$$(RM) $$@
- $$(Q)$$(TOOLROOT)/split-messages -l $(1) -p $$(MESSAGES_FILTER) -f messages -o $$@ -z $$<
-
-CLEAN_MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
-MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
-
-endef
# generate the message file rules
$(eval $(foreach LANG,$(MESSAGES_LANGUAGES), \
@@ -364,7 +350,7 @@ ifeq ($(TARGET),beos)
$(Q)$(BEOS_SETVER) $(EXETARGET) \
-app $(VERSION_MAJ) $(VERSION_MIN) 0 d 0 \
-short "NetSurf $(VERSION_FULL)" \
- -long "NetSurf $(VERSION_FULL) �� 2003 - 2016 The NetSurf Developers"
+ -long "NetSurf $(VERSION_FULL) �� 2003 - 2021 The NetSurf Developers"
$(VQ)echo " MIMESET: $(EXETARGET)"
$(Q)$(BEOS_MIMESET) $(EXETARGET)
endif
@@ -388,79 +374,6 @@ all-program: $(EXETARGET) $(POSTEXES)
.SUFFIXES:
DEPFILES :=
-# Now some macros which build the make system
-
-# 1 = Source file
-# 2 = dep filename, no prefix
-# 3 = obj filename, no prefix
-define dependency_generate_c
-DEPFILES += $(2)
-
-endef
-
-# 1 = Source file
-# 2 = dep filename, no prefix
-# 3 = obj filename, no prefix
-define dependency_generate_s
-DEPFILES += $(2)
-
-endef
-
-# 1 = Source file
-# 2 = obj filename, no prefix
-# 3 = dep filename, no prefix
-ifeq ($(CC_MAJOR),2)
-# simpler deps tracking for gcc2...
-define compile_target_c
-$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
- $$(VQ)echo " DEP: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(CC) $$(IFLAGS) $$(CFLAGS) -MM \
- $(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
- > $$(DEPROOT)/$(3)
- $$(VQ)echo " COMPILE: $(1)"
- $$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
-
-endef
-else
-define compile_target_c
-$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
- $$(VQ)echo " COMPILE: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) \
- -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
- -MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
-
-endef
-endif
-
-define compile_target_cpp
-$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
- $$(VQ)echo " DEP: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(CC) $$(IFLAGS) $$(CXXFLAGS) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) -MM \
- $(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
- > $$(DEPROOT)/$(3)
- $$(VQ)echo " COMPILE: $(1)"
- $$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CXX) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) $$(IFLAGS) $$(CXXFLAGS) $(CXXFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
-
-endef
-
-# 1 = Source file
-# 2 = obj filename, no prefix
-# 3 = dep filename, no prefix
-define compile_target_s
-$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
- $$(VQ)echo "ASSEMBLE: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CC) $$(ASFLAGS) -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
- -MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
-
-endef
# Rules to construct dep lines for each object...
$(eval $(foreach SOURCE,$(filter %.c,$(SOURCES)), \
diff --git a/Makefile.macros b/Makefile.macros
index 37a9954..d8468b4 100644
--- a/Makefile.macros
+++ b/Makefile.macros
@@ -27,6 +27,7 @@ define feature_enabled
endif
endef
+
# A macro that conditionaly adds flags to the build with a uniform display.
#
# 1: Feature name (ie, NETSURF_USE_BMP -> BMP)
@@ -56,6 +57,7 @@ define feature_switch
endif
endef
+
# Extend flags with appropriate values from pkg-config for enabled features
#
# 1: pkg-config required modules for feature
@@ -82,6 +84,7 @@ define pkg_config_find_and_add
endif
endef
+
# Extend flags with appropriate values from pkg-config for enabled features
#
# 1: Feature name (ie, NETSURF_USE_RSVG -> RSVG)
@@ -135,3 +138,112 @@ define pkg_config_find_and_add_enabled
endif
endif
endef
+
+
+# Message splitting rule generation macro
+#
+# 1 = Language
+define split_messages
+
+$$(MESSAGES_TARGET)/$(1)/Messages: resources/FatMessages $$(TOOLROOT)/split-messages
+ $$(VQ)echo "MSGSPLIT: Language: $(1) Filter: $$(MESSAGES_FILTER)"
+ $$(Q)$$(MKDIR) -p $$(MESSAGES_TARGET)/$(1)
+ $$(Q)$$(RM) $$@
+ $$(Q)$$(TOOLROOT)/split-messages -l $(1) -p $$(MESSAGES_FILTER) -f messages -o $$@ -z $$<
+
+CLEAN_MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
+MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
+
+endef
+
+
+# Now some macros which build the make system
+
+# Extend dependancy files for c source files
+#
+# 1 = Source file
+# 2 = dep filename, no prefix
+# 3 = obj filename, no prefix
+define dependency_generate_c
+DEPFILES += $(2)
+
+endef
+
+
+# Extend dependancy files for s source files
+#
+# 1 = Source file
+# 2 = dep filename, no prefix
+# 3 = obj filename, no prefix
+define dependency_generate_s
+DEPFILES += $(2)
+
+endef
+
+
+# Rule generator to compile c files
+#
+# 1 = Source file
+# 2 = obj filename, no prefix
+# 3 = dep filename, no prefix
+ifeq ($(CC_MAJOR),2)
+# simpler deps tracking for gcc2...
+define compile_target_c
+$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
+ $$(VQ)echo " DEP: $(1)"
+ $$(Q)$$(RM) $$(DEPROOT)/$(3)
+ $$(Q)$$(CC) $$(IFLAGS) $$(CFLAGS) -MM \
+ $(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
+ > $$(DEPROOT)/$(3)
+ $$(VQ)echo " COMPILE: $(1)"
+ $$(Q)$$(RM) $$(OBJROOT)/$(2)
+ $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
+
+endef
+else
+define compile_target_c
+$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
+ $$(VQ)echo " COMPILE: $(1)"
+ $$(Q)$$(RM) $$(DEPROOT)/$(3)
+ $$(Q)$$(RM) $$(OBJROOT)/$(2)
+ $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) \
+ -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
+ -MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
+
+endef
+endif
+
+
+# Rule generator to compile cpp files
+#
+# 1 = Source file
+# 2 = obj filename, no prefix
+# 3 = dep filename, no prefix
+define compile_target_cpp
+$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
+ $$(VQ)echo " DEP: $(1)"
+ $$(Q)$$(RM) $$(DEPROOT)/$(3)
+ $$(Q)$$(CC) $$(IFLAGS) $$(CXXFLAGS) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) -MM \
+ $(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
+ > $$(DEPROOT)/$(3)
+ $$(VQ)echo " COMPILE: $(1)"
+ $$(Q)$$(RM) $$(OBJROOT)/$(2)
+ $$(Q)$$(CXX) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) $$(IFLAGS) $$(CXXFLAGS) $(CXXFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
+
+endef
+
+
+# Rule generator to compile s files
+#
+# 1 = Source file
+# 2 = obj filename, no prefix
+# 3 = dep filename, no prefix
+define compile_target_s
+$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
+ $$(VQ)echo "ASSEMBLE: $(1)"
+ $$(Q)$$(RM) $$(DEPROOT)/$(3)
+ $$(Q)$$(RM) $$(OBJROOT)/$(2)
+ $$(Q)$$(CC) $$(ASFLAGS) -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
+ -MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
+
+endef
--
NetSurf Browser
2 years, 8 months
netsurf: branch master updated. release/3.10-86-ged50764
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/ed5076421f3c9e93f000a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/ed5076421f3c9e93f000ae7...
...tree http://git.netsurf-browser.org/netsurf.git/tree/ed5076421f3c9e93f000ae7d9...
The branch, master has been updated
via ed5076421f3c9e93f000ae7d963f8b623b8c22db (commit)
from 8a2c5bd3ed3be593c94aa838feea70665cf75b9f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ed5076421f3c9e93f00...
commit ed5076421f3c9e93f000ae7d963f8b623b8c22db
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
remove stray tab in hts makefile to fix amigaos3 build
diff --git a/frontends/Makefile.hts b/frontends/Makefile.hts
index 1915b35..b5af240 100644
--- a/frontends/Makefile.hts
+++ b/frontends/Makefile.hts
@@ -106,7 +106,7 @@ else
else
ifeq ($(TARGET),amigaos3)
override TARGET := amiga
- SUBTARGET = os3
+ SUBTARGET = os3
endif
endif
endif
-----------------------------------------------------------------------
Summary of changes:
frontends/Makefile.hts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontends/Makefile.hts b/frontends/Makefile.hts
index 1915b35..b5af240 100644
--- a/frontends/Makefile.hts
+++ b/frontends/Makefile.hts
@@ -106,7 +106,7 @@ else
else
ifeq ($(TARGET),amigaos3)
override TARGET := amiga
- SUBTARGET = os3
+ SUBTARGET = os3
endif
endif
endif
--
NetSurf Browser
2 years, 8 months