links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 214582c321c1bb18e9dee925f271c09c82cdcd77
Parent: 118098f2f41c89fe40fcac123581b7b18e69ccd5
Author: opask
Date:   Wed, 13 Mar 2019 08:08:04 -0600

Revert "charsets.c: remove xxstrcmp()"
This is needed until the rest of charsets.c is rewritten.

This reverts commit f1a6025a0f12383fb550de8245f00a3bf5fd7138.

Diffstat:
Mcharsets.c | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/charsets.c b/charsets.c @@ -233,6 +233,20 @@ struct conv_table *get_translation_table(const int from, const int to) return get_translation_table_to_utf_8(from); } +static inline int xxstrcmp(unsigned char *s1, unsigned char *s2, int l2) +{ + while (l2) { + if (*s1 > *s2) + return 1; + if (!*s1 || *s1 < *s2) + return -1; + s1++; + s2++; + l2--; + } + return !!*s1; +} + int get_entity_number(unsigned char *st, int l) { int n = 0; @@ -283,7 +297,7 @@ unsigned char *get_entity_string(unsigned char *st, int l, int encoding) while (s <= e) { int c; int m = (s + e) / 2; - c = strncmp(entities[m].s, (char *)st, l); + c = xxstrcmp(cast_uchar entities[m].s, st, l); if (!c) { n = entities[m].c; goto f;