aboutsummaryrefslogtreecommitdiff
path: root/modules/gcide/tests/greek.c
blob: e7060bd854d2f965132a3417be6020db98d6a615 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* This file is part of GNU Dico.
   Copyright (C) 2012-2018 Sergey Poznyakoff

   GNU Dico is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   GNU Dico is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GNU Dico.  If not, see <http://www.gnu.org/licenses/>. */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "gcide.h"

static void
print_greek(const char *arg)
{
    while (*arg) {
	size_t rd;
	const char *greek = gcide_grk_to_utf8(arg, &rd);
	
	if (greek) {
	    printf("%s", greek);
	    arg += rd;
	} else {
	    if (!(*arg == '-' || isspace(*arg)))
		printf("<!>");
	    putchar(*arg);
	    arg++;
	}
    }
    putchar('\n');
}    

int
main(int argc, char **argv)
{
    if (argc > 1) {
	while (--argc)
	    print_greek(*++argv);
    } else {
	char buf[80];

	while (fgets(buf, sizeof(buf), stdin)) {
	    buf[strlen(buf)-1] = 0;
	    print_greek(buf);
	}
    }
    return 0;
}
	
	

Return to:

Send suggestions and report system problems to the System administrator.