MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / ucomp

Function ucomp

internal/cbm/doc_pdf.c:137–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137static bool ucomp(uint32_t a, uint32_t b, uint32_t *out) {
138 /* Hangul, algorithmically */
139 enum {
140 SBASE = 0xAC00,
141 LBASE = 0x1100,
142 VBASE = 0x1161,
143 TBASE = 0x11A7,
144 LCOUNT = 19,
145 VCOUNT = 21,
146 TCOUNT = 28,
147 NCOUNT = VCOUNT * TCOUNT,
148 SCOUNT = LCOUNT * NCOUNT
149 };
150 if (a >= LBASE && a < LBASE + LCOUNT && b >= VBASE && b < VBASE + VCOUNT) {
151 *out = SBASE + ((a - LBASE) * VCOUNT + (b - VBASE)) * TCOUNT;
152 return true;
153 }
154 if (a >= SBASE && a < SBASE + SCOUNT && (a - SBASE) % TCOUNT == 0 && b > TBASE &&
155 b < TBASE + TCOUNT) {
156 *out = a + (b - TBASE);
157 return true;
158 }
159 int lo = 0;
160 int hi = PDF_UCOMP_COUNT - 1;
161 while (lo <= hi) {
162 int mid = lo + (hi - lo) / 2;
163 const pdf_ucomp_t *e = &PDF_UCOMP[mid];
164 if (e->first < a || (e->first == a && e->second < b)) {
165 lo = mid + 1;
166 } else if (e->first > a || e->second > b) {
167 hi = mid - 1;
168 } else {
169 *out = e->composite;
170 return true;
171 }
172 }
173 return false;
174}
175
176static bool normalise(const char *s, size_t n, u32v_t *out) {
177 size_t i = 0;

Callers 1

normaliseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected