mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
Refactoring: use struct string instead of unsigned char.
It probably doesn't make sense, but there is one warning less on OpenBSD.
This commit is contained in:
parent
ac275ee172
commit
cbf70d5304
@ -823,23 +823,22 @@ static struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
roman(unsigned char *p, unsigned n)
|
roman(struct string *p, unsigned n)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (n >= 4000) {
|
if (n >= 4000) {
|
||||||
strcpy(p, "---");
|
add_to_string(p, "---");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!n) {
|
if (!n) {
|
||||||
strcpy(p, "o");
|
add_to_string(p, "o");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p[0] = 0;
|
|
||||||
while (n) {
|
while (n) {
|
||||||
while (roman_tbl[i].n <= n) {
|
while (roman_tbl[i].n <= n) {
|
||||||
n -= roman_tbl[i].n;
|
n -= roman_tbl[i].n;
|
||||||
strcat(p, roman_tbl[i].s);
|
add_to_string(p, roman_tbl[i].s);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
assertm(!(n && !roman_tbl[i].n),
|
assertm(!(n && !roman_tbl[i].n),
|
||||||
@ -874,44 +873,51 @@ html_li(struct html_context *html_context, unsigned char *a,
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
unsigned char c = 0;
|
unsigned char c = 0;
|
||||||
unsigned char n[32];
|
|
||||||
int nlen;
|
int nlen;
|
||||||
int t = par_format.flags & P_LISTMASK;
|
int t = par_format.flags & P_LISTMASK;
|
||||||
int s = get_num(a, "value", html_context->doc_cp);
|
int s = get_num(a, "value", html_context->doc_cp);
|
||||||
|
struct string n;
|
||||||
|
|
||||||
|
if (!init_string(&n)) return;
|
||||||
|
|
||||||
if (s != -1) par_format.list_number = s;
|
if (s != -1) par_format.list_number = s;
|
||||||
|
|
||||||
if (t == P_ALPHA || t == P_alpha) {
|
if (t == P_ALPHA || t == P_alpha) {
|
||||||
|
unsigned char n0;
|
||||||
|
|
||||||
put_chrs(html_context, " ", 6);
|
put_chrs(html_context, " ", 6);
|
||||||
c = 1;
|
c = 1;
|
||||||
n[0] = par_format.list_number
|
n0 = par_format.list_number
|
||||||
? (par_format.list_number - 1) % 26
|
? (par_format.list_number - 1) % 26
|
||||||
+ (t == P_ALPHA ? 'A' : 'a')
|
+ (t == P_ALPHA ? 'A' : 'a')
|
||||||
: 0;
|
: 0;
|
||||||
n[1] = 0;
|
if (n0) add_char_to_string(&n, n0);
|
||||||
|
|
||||||
} else if (t == P_ROMAN || t == P_roman) {
|
} else if (t == P_ROMAN || t == P_roman) {
|
||||||
roman(n, par_format.list_number);
|
roman(&n, par_format.list_number);
|
||||||
if (t == P_ROMAN) {
|
if (t == P_ROMAN) {
|
||||||
unsigned char *x;
|
unsigned char *x;
|
||||||
|
|
||||||
for (x = n; *x; x++) *x = c_toupper(*x);
|
for (x = n.source; *x; x++) *x = c_toupper(*x);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
unsigned char n0[64];
|
||||||
if (par_format.list_number < 10) {
|
if (par_format.list_number < 10) {
|
||||||
put_chrs(html_context, " ", 6);
|
put_chrs(html_context, " ", 6);
|
||||||
c = 1;
|
c = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ulongcat(n, NULL, par_format.list_number, (sizeof(n) - 1), 0);
|
ulongcat(n0, NULL, par_format.list_number, (sizeof(n) - 1), 0);
|
||||||
|
add_to_string(&n, n0);
|
||||||
}
|
}
|
||||||
|
|
||||||
nlen = strlen(n);
|
nlen = n.length;
|
||||||
put_chrs(html_context, n, nlen);
|
put_chrs(html_context, n.source, nlen);
|
||||||
put_chrs(html_context, ". ", 7);
|
put_chrs(html_context, ". ", 7);
|
||||||
par_format.leftmargin += nlen + c + 2;
|
par_format.leftmargin += nlen + c + 2;
|
||||||
par_format.align = ALIGN_LEFT;
|
par_format.align = ALIGN_LEFT;
|
||||||
|
done_string(&n);
|
||||||
|
|
||||||
{
|
{
|
||||||
struct html_element *element;
|
struct html_element *element;
|
||||||
|
32
test/ol.html
Normal file
32
test/ol.html
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<p>roman
|
||||||
|
<ol type="r">
|
||||||
|
<li>roman 1</li>
|
||||||
|
<li>roman 2</li>
|
||||||
|
<li>roman 3</li>
|
||||||
|
</ol>
|
||||||
|
</p>
|
||||||
|
<p>Roman
|
||||||
|
<ol type="R">
|
||||||
|
<li>Roman 1</li>
|
||||||
|
<li>Roman 2</li>
|
||||||
|
<li>Roman 3</li>
|
||||||
|
</ol>
|
||||||
|
</p>
|
||||||
|
<p>alpha
|
||||||
|
<ol type="a">
|
||||||
|
<li>alpha 1</li>
|
||||||
|
<li>alpha 2</li>
|
||||||
|
<li>alpha 3</li>
|
||||||
|
</ol>
|
||||||
|
</p>
|
||||||
|
<p>Alpha
|
||||||
|
<ol type="A">
|
||||||
|
<li>alpha 1</li>
|
||||||
|
<li>alpha 2</li>
|
||||||
|
<li>alpha 3</li>
|
||||||
|
</ol>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user