This repository was archived by the owner on Jan 21, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515// Author: jdtang@google.com (Jonathan Tang)
1616
1717#include "gumbo.h"
18+ #include "util.h"
1819
1920#include <assert.h>
2021#include <ctype.h>
@@ -60,14 +61,21 @@ void gumbo_tag_from_original_text(GumboStringPiece* text) {
6061 }
6162}
6263
64+ /*
65+ * Override the `tolower` implementation in the perfect hash
66+ * to use ours. We need a custom `tolower` that only does ASCII
67+ * characters and is locale-independent to remain truthy to the
68+ * standard
69+ */
70+ #define tolower (c ) gumbo_tolower(c)
6371#include "tag_perf.h"
6472
6573static int
6674case_memcmp (const char * s1 , const char * s2 , int n )
6775{
6876 while (n -- ) {
69- unsigned char c1 = tolower (* s1 ++ );
70- unsigned char c2 = tolower (* s2 ++ );
77+ unsigned char c1 = gumbo_tolower (* s1 ++ );
78+ unsigned char c2 = gumbo_tolower (* s2 ++ );
7179 if (c1 != c2 )
7280 return (int )c1 - (int )c2 ;
7381 }
Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ static inline void gumbo_free(void *ptr)
5757 gumbo_user_free (ptr );
5858}
5959
60+ static inline int gumbo_tolower (int c )
61+ {
62+ return c | ((c >= 'A' && c <= 'Z' ) << 5 );
63+ }
64+
6065// Debug wrapper for printf, to make it easier to turn off debugging info when
6166// required.
6267void gumbo_debug (const char * format , ...);
You can’t perform that action at this time.
0 commit comments