2021-08-19 04:57:11 +00:00
|
|
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
|
|
|
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
|
|
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
|
|
|
│ Python 3 │
|
|
|
|
│ https://docs.python.org/3/license.html │
|
|
|
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
2021-09-28 05:58:51 +00:00
|
|
|
#include "third_party/python/Modules/unicodedata.h"
|
2021-08-19 04:57:11 +00:00
|
|
|
/* clang-format off */
|
|
|
|
|
2021-09-28 05:58:51 +00:00
|
|
|
int
|
|
|
|
_PyUnicode_FindNfcIndex(const _PyUnicode_Reindex *nfc, Py_UCS4 code)
|
2021-08-19 04:57:11 +00:00
|
|
|
{
|
2021-09-28 05:58:51 +00:00
|
|
|
unsigned int index;
|
|
|
|
for (index = 0; nfc[index].start; index++) {
|
|
|
|
unsigned int start = nfc[index].start;
|
|
|
|
if (code < start)
|
|
|
|
return -1;
|
|
|
|
if (code <= start + nfc[index].count) {
|
|
|
|
unsigned int delta = code - start;
|
|
|
|
return nfc[index].index + delta;
|
|
|
|
}
|
2021-08-19 04:57:11 +00:00
|
|
|
}
|
2021-09-28 05:58:51 +00:00
|
|
|
return -1;
|
2021-08-19 04:57:11 +00:00
|
|
|
}
|