Skip to content

Commit

Permalink
makeutype.c generates is_Ligature.c based on current Unicode data
Browse files Browse the repository at this point in the history
Added copyright Authors to satisfy Debian Lint copyright issue #2643.
Added several unicode chart lookup functions, native scripting access,
python scripting, test129.pe and test1009.py.
  • Loading branch information
JoesCat committed Sep 13, 2016
1 parent 1ad2081 commit 62578c1
Show file tree
Hide file tree
Showing 15 changed files with 1,251 additions and 127 deletions.
2 changes: 1 addition & 1 deletion AUTHORS
Expand Up @@ -16,7 +16,7 @@ Arthaey Angosii
Alexey Kryukov - nowakowskittfinstr.c
Alexandre Prokoudine
Andreas Larsen
Barry Schwartz
Barry Schwartz <chemoelectric>
Baruch Even - (debian upstream) baruch
Bastien Dejean
Behnam Esfahbod
Expand Down
243 changes: 215 additions & 28 deletions Unicode/is_Ligature.c
@@ -1,33 +1,220 @@
/* This is a generated file. */
/*
Copyright: 2012 Barry Schwartz
Copyright: 2016 Joe Da Silva
License: BSD-3-clause
Contributions:
*/

/* This file was generated using the program 'makeutype' */

#include "utype.h"
#include <stdlib.h>

/*
* Codepoints whose names match the regular expression
*
* LIGATURE|VULGAR FRACTION
*
*/
static unsigned int matching_codepoints[528] =
{
188, 189, 190, 306, 307, 338, 339, 1188, 1189, 1204, 1205, 1236, 1237, 1415, 1520, 1521, 1522, 1558, 1750, 1751, 8528, 8529, 8530, 8531, 8532, 8533, 8534, 8535, 8536, 8537, 8538, 8539, 8540, 8541, 8542, 8585, 43001, 64256, 64257, 64258, 64259, 64260, 64261, 64262, 64275, 64276, 64277, 64278, 64279, 64287, 64335, 64490, 64491, 64492, 64493, 64494, 64495, 64496, 64497, 64498, 64499, 64500, 64501, 64502, 64503, 64504, 64505, 64506, 64507, 64512, 64513, 64514, 64515, 64516, 64517, 64518, 64519, 64520, 64521, 64522, 64523, 64524, 64525, 64526, 64527, 64528, 64529, 64530, 64531, 64532, 64533, 64534, 64535, 64536, 64537, 64538, 64539, 64540, 64541, 64542, 64543, 64544, 64545, 64546, 64547, 64548, 64549, 64550, 64551, 64552, 64553, 64554, 64555, 64556, 64557, 64558, 64559, 64560, 64561, 64562, 64563, 64564, 64565, 64566, 64567, 64568, 64569, 64570, 64571, 64572, 64573, 64574, 64575, 64576, 64577, 64578, 64579, 64580, 64581, 64582, 64583, 64584, 64585, 64586, 64587, 64588, 64589, 64590, 64591, 64592, 64593, 64594, 64595, 64596, 64597, 64598, 64599, 64600, 64601, 64602, 64603, 64604, 64605, 64606, 64607, 64608, 64609, 64610, 64611, 64612, 64613, 64614, 64615, 64616, 64617, 64618, 64619, 64620, 64621, 64622, 64623, 64624, 64625, 64626, 64627, 64628, 64629, 64630, 64631, 64632, 64633, 64634, 64635, 64636, 64637, 64638, 64639, 64640, 64641, 64642, 64643, 64644, 64645, 64646, 64647, 64648, 64649, 64650, 64651, 64652, 64653, 64654, 64655, 64656, 64657, 64658, 64659, 64660, 64661, 64662, 64663, 64664, 64665, 64666, 64667, 64668, 64669, 64670, 64671, 64672, 64673, 64674, 64675, 64676, 64677, 64678, 64679, 64680, 64681, 64682, 64683, 64684, 64685, 64686, 64687, 64688, 64689, 64690, 64691, 64692, 64693, 64694, 64695, 64696, 64697, 64698, 64699, 64700, 64701, 64702, 64703, 64704, 64705, 64706, 64707, 64708, 64709, 64710, 64711, 64712, 64713, 64714, 64715, 64716, 64717, 64718, 64719, 64720, 64721, 64722, 64723, 64724, 64725, 64726, 64727, 64728, 64729, 64730, 64731, 64732, 64733, 64734, 64735, 64736, 64737, 64738, 64739, 64740, 64741, 64742, 64743, 64744, 64745, 64746, 64747, 64748, 64749, 64750, 64751, 64752, 64753, 64754, 64755, 64756, 64757, 64758, 64759, 64760, 64761, 64762, 64763, 64764, 64765, 64766, 64767, 64768, 64769, 64770, 64771, 64772, 64773, 64774, 64775, 64776, 64777, 64778, 64779, 64780, 64781, 64782, 64783, 64784, 64785, 64786, 64787, 64788, 64789, 64790, 64791, 64792, 64793, 64794, 64795, 64796, 64797, 64798, 64799, 64800, 64801, 64802, 64803, 64804, 64805, 64806, 64807, 64808, 64809, 64810, 64811, 64812, 64813, 64814, 64815, 64816, 64817, 64818, 64819, 64820, 64821, 64822, 64823, 64824, 64825, 64826, 64827, 64828, 64829, 64848, 64849, 64850, 64851, 64852, 64853, 64854, 64855, 64856, 64857, 64858, 64859, 64860, 64861, 64862, 64863, 64864, 64865, 64866, 64867, 64868, 64869, 64870, 64871, 64872, 64873, 64874, 64875, 64876, 64877, 64878, 64879, 64880, 64881, 64882, 64883, 64884, 64885, 64886, 64887, 64888, 64889, 64890, 64891, 64892, 64893, 64894, 64895, 64896, 64897, 64898, 64899, 64900, 64901, 64902, 64903, 64904, 64905, 64906, 64907, 64908, 64909, 64910, 64911, 64914, 64915, 64916, 64917, 64918, 64919, 64920, 64921, 64922, 64923, 64924, 64925, 64926, 64927, 64928, 64929, 64930, 64931, 64932, 64933, 64934, 64935, 64936, 64937, 64938, 64939, 64940, 64941, 64942, 64943, 64944, 64945, 64946, 64947, 64948, 64949, 64950, 64951, 64952, 64953, 64954, 64955, 64956, 64957, 64958, 64959, 64960, 64961, 64962, 64963, 64964, 64965, 64966, 64967, 65008, 65009, 65010, 65011, 65012, 65013, 65014, 65015, 65016, 65017, 65018, 65019, 65021, 65056, 65057, 65269, 65270, 65271, 65272, 65273, 65274, 65275, 65276
};

static int compare_codepoints (const void *codepoint1, const void *codepoint2)
{
const unsigned int *cp1 = (const unsigned int *) codepoint1;
const unsigned int *cp2 = (const unsigned int *) codepoint2;
return ((*cp1 < *cp2) ? -1 : ((*cp1 == *cp2) ? 0 : 1));
}

int is_LIGATURE_or_VULGAR_FRACTION(unsigned int codepoint);

int is_LIGATURE_or_VULGAR_FRACTION(unsigned int codepoint)
{
unsigned int *p =
(unsigned int *) bsearch (&codepoint, matching_codepoints,
528, sizeof (unsigned int),
compare_codepoints);
return (p != (unsigned int *) 0);
/* unicode.org codepoints for ligatures, vulgar fractions, other fractions */

const uint16 ____ligature16[] = {
0x0132, 0x0133, 0x0152, 0x0153, 0x04a4, 0x04a5, 0x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0xfd85, 0xfd86, 0xfd87,
0xfd88, 0xfd89, 0xfd8a, 0xfd8b, 0xfd8c, 0xfd8d, 0xfd8e, 0xfd8f,
0xfd92, 0xfd93, 0xfd94, 0xfd95, 0xfd96, 0xfd97, 0xfd98, 0xfd99,
0xfd9a, 0xfd9b, 0xfd9c, 0xfd9d, 0xfd9e, 0xfd9f, 0xfda0, 0xfda1,
0xfda2, 0xfda3, 0xfda4, 0xfda5, 0xfda6, 0xfda7, 0xfda8, 0xfda9,
0xfdaa, 0xfdab, 0xfdac, 0xfdad, 0xfdae, 0xfdaf, 0xfdb0, 0xfdb1,
0xfdb2, 0xfdb3, 0xfdb4, 0xfdb5, 0xfdb6, 0xfdb7, 0xfdb8, 0xfdb9,
0xfdba, 0xfdbb, 0xfdbc, 0xfdbd, 0xfdbe, 0xfdbf, 0xfdc0, 0xfdc1,
0xfdc2, 0xfdc3, 0xfdc4, 0xfdc5, 0xfdc6, 0xfdc7, 0xfdf0, 0xfdf1,
0xfdf2, 0xfdf3, 0xfdf4, 0xfdf5, 0xfdf6, 0xfdf7, 0xfdf8, 0xfdf9,
0xfdfa, 0xfdfb, 0xfdfd, 0xfe20, 0xfe21, 0xfef5, 0xfef6, 0xfef7,
0xfef8, 0xfef9, 0xfefa, 0xfefb, 0xfefc};

const uint16 ____vulgfrac16[] = {
0x00bc, 0x00bd, 0x00be, 0x2150, 0x2151, 0x2152, 0x2153, 0x2154,
0x2155, 0x2156, 0x2157, 0x2158, 0x2159, 0x215a, 0x215b, 0x215c,
0x215d, 0x215e, 0x2189};

const uint16 ____fraction16[] = {
0x0b72, 0x0b73, 0x0b74, 0x0b75, 0x0b76, 0x0b77, 0x0c78, 0x0c79,
0x0c7a, 0x0c7b, 0x0c7c, 0x0c7d, 0x0c7e, 0x0d73, 0x0d74, 0x0d75,
0x2044, 0x215f, 0x2cfd, 0xa830, 0xa831, 0xa832, 0xa833, 0xa834,
0xa835};

const uint32 ____fraction32[] = {
0x00010e7b, 0x00010e7c, 0x00010e7d, 0x00010e7e};

static int compare_codepoints16(const void *uCode1, const void *uCode2) {
const uint16 *cp1 = (const uint16 *)(uCode1);
const uint16 *cp2 = (const uint16 *)(uCode2);
return( (*cp1 < *cp2) ? -1 : ((*cp1 == *cp2) ? 0 : 1) );
}

static int compare_codepoints32(const void *uCode1, const void *uCode2) {
const uint32 *cp1 = (const uint32 *)(uCode1);
const uint32 *cp2 = (const uint32 *)(uCode2);
return( (*cp1 < *cp2) ? -1 : ((*cp1 == *cp2) ? 0 : 1) );
}

int LigatureCount(void) {
return( 509 );
}

int VulgarFractionCount(void) {
return( 19 );
}

int OtherFractionCount(void) {
return( 29 );
}

int FractionCount(void) {
return( 48 );
}

int32 Ligature_get_U(int n) {
if ( n<0 || n>=509 )
return( -1 );
return( (int32)(____ligature16[n]) );
}

int32 VulgFrac_get_U(int n) {
if ( n<0 || n>=19 )
return( -1 );
return( (int32)(____vulgfrac16[n]) );
}

int32 Fraction_get_U(int n) {
if ( n<0 || n>=29 )
return( -1 );
if ( n<25 )
return( (int32)(____fraction16[n]) );
else
return( (int32)(____fraction32[n-25]) );
}

int Ligature_find_N(uint32 uCode) {
uint16 uCode16, *p16;
int n=-1;

if ( uCode<0x132 || uCode>0xfefc || isligorfrac(uCode)==0 )
return( -1 );
uCode16 = uCode;
p16 = (uint16 *)(bsearch(&uCode16, ____ligature16, 509, \
sizeof(uint16), compare_codepoints16));
if ( p16 ) n = p16 - ____ligature16;
return( n );
}

int VulgFrac_find_N(uint32 uCode) {
uint16 uCode16, *p16;
int n=-1;

if ( uCode<0xbc || uCode>0x2189 || isligorfrac(uCode)==0 )
return( -1 );
uCode16 = uCode;
p16 = (uint16 *)(bsearch(&uCode16, ____vulgfrac16, 19, \
sizeof(uint16), compare_codepoints16));
if ( p16 ) n = p16 - ____vulgfrac16;
return( n );
}

int Fraction_find_N(uint32 uCode) {
uint16 uCode16, *p16;
uint32 *p32;
int n=-1;

if ( uCode<0xb72 || uCode>0x10e7e || (uCode<65536 && isligorfrac(uCode)==0) )
return( -1 );
if ( uCode<25 ) {
uCode16 = uCode;
p16 = (uint16 *)(bsearch(&uCode16, ____fraction16, 25, \
sizeof(uint16), compare_codepoints16));
if ( p16 ) n = p16 - ____fraction16;
} else {
p32 = (uint32 *)(bsearch(&uCode, ____fraction32, 4, \
sizeof(uint32), compare_codepoints32));
if ( p32 ) n = p32 - ____fraction32 + 25;
}
return( n );
}

/* Boolean-style tests (found==0) to see if your codepoint value is listed */
/* unicode.org codepoints for ligatures, vulgar fractions, other fractions */

int is_LIGATURE(uint32 codepoint) {
return( Ligature_find_N(codepoint)<0 );
}

int is_VULGAR_FRACTION(uint32 codepoint) {
return( VulgFrac_find_N(codepoint)<0 );
}

int is_OTHER_FRACTION(uint32 codepoint) {
return( Fraction_find_N(codepoint)<0 );
}

int is_FRACTION(uint32 codepoint) {
return( VulgFrac_find_N(codepoint)<0 && Fraction_find_N(codepoint)<0 );
}

int is_LIGATURE_or_VULGAR_FRACTION(uint32 codepoint) {
return( Ligature_find_N(codepoint)<0 && VulgFrac_find_N(codepoint)<0 );
}

int is_LIGATURE_or_OTHER_FRACTION(uint32 codepoint) {
return( Ligature_find_N(codepoint)<0 && Fraction_find_N(codepoint)<0 );
}

int is_LIGATURE_or_FRACTION(uint32 codepoint) {
return( Ligature_find_N(codepoint)<0 && VulgFrac_find_N(codepoint)<0 && Fraction_find_N(codepoint)<0 );
}

0 comments on commit 62578c1

Please sign in to comment.