Last active
May 13, 2018 20:49
-
-
Save wincentbalin/9cd38a993c1a7582b49db3781ba94e80 to your computer and use it in GitHub Desktop.
How to compile gcrtraining tools for win32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install pre-requisites (pango is needed for xheights) | |
sudo apt install build-essential libpango1.0-dev | |
# Clone gcrtraining repository | |
git clone https://ancientgreekocr.org/grctraining.git | |
# Compile LibUTF | |
cd grctraining/tools/libutf | |
make CFLAGS="-ansi -pedantic -O2 -Wall -Wextra" | |
cd .. | |
# Compile tools | |
for f in *.c | |
do | |
gcc -ansi -pedantic -O2 -Wall -Wextra -s -o `basename $f .c` $f -L libutf -lutf $(pkg-config --cflags --libs pangocairo) | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* See LICENSE file for copyright and license details. */ | |
#define usage "utf8only\n\n" \ | |
"Outputs only the lines from stdin which contain exclusively\n" \ | |
"UTF-8 encoded Cuneiform characters (see the ranges[] array\n" \ | |
"for the characters this refers to).\n" | |
#include <stdio.h> | |
#include "libutf/utf.h" | |
#define LENGTH(X) (sizeof X / sizeof X[0]) | |
typedef struct { | |
unsigned int start; | |
unsigned int end; | |
} Range; | |
static const Range ranges[] = { | |
{ 0x12000, 0x123FF }, /* Cuneiform */ | |
{ 0x12400, 0x1247F }, /* Cuneiform Numbers and Punctuation */ | |
{ 0x12480, 0x1254F }, /* Early Dynastic Cuneiform */ | |
}; | |
int main(int argc, char *argv[]) { | |
unsigned int b, i, n; | |
unsigned int inrange, print, runenum; | |
char buf[BUFSIZ]; | |
Rune rune; | |
if(argc != 1) { | |
fputs("usage: " usage, stdout); | |
return 1; | |
} | |
while(fgets(buf, BUFSIZ, stdin)) { | |
runenum = utflen(buf); | |
print = 1; | |
for(i = 0, b = 0; i < runenum; i++) { | |
b += chartorune(&rune, buf + b); | |
if(rune == '\n' || rune == ' ') { | |
break; | |
} | |
inrange = 0; | |
for(n = 0; n < LENGTH(ranges); n++) { | |
if(rune >= ranges[n].start && rune <= ranges[n].end) { | |
inrange = 1; | |
} | |
} | |
if(!inrange) { | |
print = 0; | |
} | |
} | |
if(print) { | |
fputs(buf, stdout); | |
} | |
} | |
return 0; | |
} |
The file utf8cuneiformonly.c
is a quick amendment of utf8greekonly.c
to the Cuneiform Unicode ranges.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you should need the gcrtraining tools under win32, you might compile them using MXE. On condition that MXE is installed in
/opt/mxe
, you will compile libutf first withand then compile all the tools with