suggested by gort.andres000@gmail.com. Á != á, so make sure to do a case-sensitive test. it's hard to resist the urge to do some reformatting of libhtml. ;-). Reference: /n/atom/patch/applied2013/htmlentcase Date: Thu Aug 1 00:32:28 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/libhtml/impl.h Thu Aug 1 00:30:48 2013 +++ /sys/src/libhtml/impl.h Thu Aug 1 00:30:49 2013 @@ -34,6 +34,7 @@ extern int _Strlen(Rune* s); extern Rune* _Strnclass(Rune* s, Rune* cl, int n); extern int _Strncmpci(Rune* s1, int n1, Rune* s2); +extern int _Strncmp(Rune* s1, int n1, Rune* s2); extern Rune* _Strndup(Rune* s, int n); extern Rune* _Strnrclass(Rune* s, Rune* cl, int n); extern Rune* _Strrclass(Rune* s, Rune* cl); @@ -54,7 +55,8 @@ int val; }; -extern int _lookup(StringInt* t, int n, Rune* key, int keylen, int* pans); +extern int _lookupop(StringInt* t, int n, Rune* key, int keylen, int (*)(Rune*, int, Rune*), int* pans); +extern int _lookup(StringInt* t, int n, Rune* key, int keylen, int* pans); extern StringInt* _makestrinttab(Rune** a, int n); extern Rune* _revlookup(StringInt* t, int n, int val); --- /sys/src/libhtml/lex.c Thu Aug 1 00:30:50 2013 +++ /sys/src/libhtml/lex.c Thu Aug 1 00:30:52 2013 @@ -1267,7 +1267,7 @@ } } if(c >= 256 || c != '=' && !(isalpha(c) || isdigit(c))) - fnd = _lookup(chartab, NCHARTAB, buf, k, &ans); + fnd = _lookupop(chartab, NCHARTAB, buf, k, _Strncmp, &ans); } if(!fnd) { backup(ts, savei); --- /sys/src/libhtml/strinttab.c Thu Aug 1 00:30:53 2013 +++ /sys/src/libhtml/strinttab.c Thu Aug 1 00:30:53 2013 @@ -9,7 +9,7 @@ // Array t must be sorted in increasing lexicographic order of key. // If found, return corresponding val in *pans. int -_lookup(StringInt* t, int n, Rune* key, int keylen, int* pans) +_lookupop(StringInt* t, int n, Rune* key, int keylen, int (*cmp)(Rune*, int, Rune*), int* pans) { int min; int max; @@ -20,7 +20,7 @@ max = n - 1; while(min <= max) { try = (min + max)/2; - cmpresult = _Strncmpci(key, keylen, t[try].key); + cmpresult = cmp(key, keylen, t[try].key); if(cmpresult > 0) min = try + 1; else if(cmpresult < 0) @@ -31,6 +31,12 @@ } } return 0; +} + +int +_lookup(StringInt* t, int n, Rune* key, int keylen, int* pans) +{ + return _lookupop(t, n, key, keylen, _Strncmpci, pans); } // Return first key in t[0:n] that corresponds to val, --- /sys/src/libhtml/utils.c Thu Aug 1 00:30:54 2013 +++ /sys/src/libhtml/utils.c Thu Aug 1 00:30:55 2013 @@ -324,6 +324,27 @@ } } +int +_Strncmp(Rune *s1, int n1, Rune *s2) +{ + Rune c1, c2; + + for(;;) { + if(n1-- == 0) { + if(*s2 == 0) + return 0; + return -1; + } + c1 = *s1++; + c2 = *s2++; + if(c1 != c2) { + if(c1 > c2) + return 1; + return -1; + } + } +} + // emalloc and copy Rune* _Strdup(Rune* s)