diff options
Diffstat (limited to 'language/tibetan/original/src')
-rw-r--r-- | language/tibetan/original/src/makefile | 18 | ||||
-rw-r--r-- | language/tibetan/original/src/makefile.emx | 18 | ||||
-rw-r--r-- | language/tibetan/original/src/table.c | 259 | ||||
-rw-r--r-- | language/tibetan/original/src/table.h | 31 | ||||
-rw-r--r-- | language/tibetan/original/src/tfilt.c | 49 | ||||
-rw-r--r-- | language/tibetan/original/src/token.h | 50 | ||||
-rw-r--r-- | language/tibetan/original/src/tparse.c | 509 | ||||
-rw-r--r-- | language/tibetan/original/src/util.c | 131 |
8 files changed, 1065 insertions, 0 deletions
diff --git a/language/tibetan/original/src/makefile b/language/tibetan/original/src/makefile new file mode 100644 index 0000000000..8bc3e9f27c --- /dev/null +++ b/language/tibetan/original/src/makefile @@ -0,0 +1,18 @@ +OBJECTS = tfilt.o tparse.o util.o table.o + +all: tfilt + +tfilt: $(OBJECTS) + cc -o tfilt $(OBJECTS) + +tfilt.o: tfilt.c table.h token.h + +tparse.o: tparse.c table.h token.h + +util.o: util.c table.h token.h + +table.o: table.c table.h + +clean: + rm -f $(OBJECTS) core tfilt + diff --git a/language/tibetan/original/src/makefile.emx b/language/tibetan/original/src/makefile.emx new file mode 100644 index 0000000000..15a48b1340 --- /dev/null +++ b/language/tibetan/original/src/makefile.emx @@ -0,0 +1,18 @@ +OBJECTS = tfilt.o tparse.o util.o table.o
+
+all: tfilt.exe
+
+tfilt.exe: $(OBJECTS)
+ gcc -o tfilt.exe $(OBJECTS)
+
+tfilt.o: tfilt.c table.h token.h
+
+tparse.o: tparse.c table.h token.h
+
+util.o: util.c table.h token.h
+
+table.o: table.c table.h
+
+clean:
+ rm -f $(OBJECTS) core tfilt
+
diff --git a/language/tibetan/original/src/table.c b/language/tibetan/original/src/table.c new file mode 100644 index 0000000000..59cd6d2049 --- /dev/null +++ b/language/tibetan/original/src/table.c @@ -0,0 +1,259 @@ +/* + * Copyright 1987 Jeff Sparkes + * Department of Computer Science + * Memorial University of Newfoundland + * St. John's, Nfld. + * garfield!jeff1, jeff1@garfield.mun.cdn + * + * Permission is granted to distribute and/or modify this code, provided + * this copyright notice remains intact. + * If you use it, let me know. If change it let me know. If you + * make money from it, send me a share. + */ + +#include "table.h" + +/* + * This table is used to convert ascii representations of + * Tibetan words into the TeX font change commands to get the + * proper glyphs. + */ + +/* + * The base characters are found in the first 32 positions. + * The plus indicates a vowel. The second column is the name of the + * character. + * Note: this table has been rearranged + * so that shorter strings are found first. The second field is + * for alphabetical order. + */ + +struct tab base_table[] = { + { "k+", "ka", 0 }, + { "kh+", "kha", 1 }, + { "g+", "ga", 2 }, + { "n+", "na", 11 }, + { "ng+", "nga", 3 }, + { "c+", "ca", 4 }, + { "ch+", "cha", 5 }, + { "j+", "ja", 6 }, + { "ny+", "nya", 7 }, + { "t+", "ta", 8 }, + { "th+", "tha", 9 }, + { "d+", "da", 10 }, + { "p+", "pa", 12 }, + { "ph+", "pha", 13 }, + { "b+", "ba", 14 }, + { "m+", "ma", 15 }, + { "ts+", "tsa", 16 }, + { "tsh+", "tsha", 17 }, + { "dz+", "dza", 18 }, + { "w+", "wa", 19 }, + { "z+", "za", 21 }, + { "zh+", "zha", 20 }, + { "'+", "achung", 22 }, + { "y+", "ya", 23 }, + { "r+", "ra", 24 }, + { "l+", "la", 25 }, + { "s+", "sa", 27 }, + { "sh+", "sha", 26 }, + { "h+", "ha", 28 }, + { "+", "a", 29 }, + { "", "", -1 }, +}; + +/* + * A fix table contains the fix char, the base character that it modifies + * and the character number of the actual glyph in the font. There are + * different tables for super and sub fixes. The only difference in + * the way that they are treated is where the fix char is looked for. + */ + +struct fix superfixes[] = { + { 'r', "rka", 0, 30 }, + { 'r', "rga", 2, 31 }, + { 'r', "rnga", 3, 32 }, + { 'r', "rja", 6, 33 }, + { 'r', "rnya", 7, 34 }, + { 'r', "rta", 8, 35 }, + { 'r', "rda", 10, 36 }, + { 'r', "rna", 11, 37 }, + { 'r', "rba", 14, 38 }, + { 'r', "rma", 15, 39 }, + { 'r', "rtsa", 16, 40 }, + { 'r', "rdza", 18, 41 }, + { 'l', "lka", 0, 42 }, + { 'l', "lga", 2, 43 }, + { 'l', "lnga", 3, 44 }, + { 'l', "lca", 4, 45 }, + { 'l', "lja", 6, 46 }, + { 'l', "lta", 8, 47 }, + { 'l', "lda", 10, 48 }, + { 'l', "lpa", 12, 49 }, + { 'l', "lba", 14, 50 }, + { 'l', "lha", 28, 51 }, + { 's', "ska", 0, 52 }, + { 's', "sga", 2, 53 }, + { 's', "snga", 3, 54 }, + { 's', "snya", 7, 55 }, + { 's', "sta", 8, 56 }, + { 's', "sda", 10, 57 }, + { 's', "sna", 11, 58 }, + { 's', "spa", 12, 59 }, + { 's', "sba", 14, 60 }, + { 's', "sma", 15, 61 }, + { 's', "stsa", 16, 62 }, + { 'r', "rkya", 80, 107}, + { 'r', "rgya", 82, 108}, + { 's', "skya", 80, 109}, + { 's', "skra", 87, 110}, + { 's', "sgya", 82, 111}, + { 's', "sgra", 89, 112}, + { 's', "spya", 83, 113}, + { 's', "spra", 94, 114}, + { 's', "sbya", 85, 115}, + { 's', "sbra", 96, 116}, + { 'r', "rmya", 86, 117}, + { 's', "smya", 86, 118}, + { 's', "smra", 97, 119}, + { 0, "", -1, -1 }, +}; + +struct fix subfixes[] = { + { 'y', "kya", 0, 80 }, + { 'y', "khya", 1, 81 }, + { 'y', "gya", 2, 82 }, + { 'y', "pya", 12, 83 }, + { 'y', "phya", 13, 84 }, + { 'y', "bya", 14, 85 }, + { 'y', "mya", 15, 86 }, + { 'r', "kra", 0, 87 }, + { 'r', "khra", 1, 88 }, + { 'r', "gra", 2, 89 }, + { 'r', "tra", 8, 90 }, + { 'r', "thra", 9, 91 }, + { 'r', "dra", 10, 92 }, + { 'r', "nra", 11, 93 }, + { 'r', "pra", 12, 94 }, + { 'r', "phra", 13, 95 }, + { 'r', "bra", 14, 96 }, + { 'r', "mra", 15, 97 }, + { 'r', "shra", 26, 98 }, + { 'r', "sra", 27, 99 }, + { 'r', "hra", 28, 100 }, + { 'l', "kla", 0, 101 }, + { 'l', "gla", 2, 102 }, + { 'l', "bla", 14, 103 }, + { 'l', "zla", 21, 104 }, + { 'l', "rla", 24, 105 }, + { 'l', "sla", 27, 106 }, + { 0, "", -1, -1 }, +}; + +/* + * The following are a table of special characters. + * The second argument is a TeX command. Remember that the default font + * is \tibetan, and you must switch back after if you`ve switched over to + * the special font (\tibsp). + */ +struct special special[] = { +/* + * the first part of this table is to produce all the wazur combinations; + * the wazur characters are stored in the main font (\tibetan) and not in + * the special font (\tibsp). + */ + { "kwa", "\\char63", 63 }, + { "khwa", "\\char64", 64 }, + { "gwa", "\\char65", 65 }, + { "grwa", "\\char66", 66 }, + { "rgwa", "\\char67", 67 }, + { "nywa", "\\char68", 68 }, + { "dwa", "\\char69", 69 }, + { "tshwa", "\\char70", 70 }, + { "rtswa", "\\char71", 71 }, + { "zhwa", "\\char72", 72 }, + { "zwa", "\\char73", 73 }, + { "rwa", "\\char74", 74 }, + { "lwa", "\\char75", 75 }, + { "shwa", "\\char76", 76 }, + { "hwa", "\\char77", 77 }, + { "phywa", "\\char78", 78 }, + { "cwa", "\\char79", 79 }, + { "twa", "\\char120", 120 }, + { "tswa", "\\char121", 121 }, + { "swa", "\\char122", 122 }, +/* + * next come the five aspirates with the "ha" subjoined. + * "lha" is processed separately above, since it is really + * a "ha" with a "la" superfix. + * + * the retroflex "dxha" uses an "x" following the "d" to + *indicate that it is reversed. + */ + { "dha", "\\tibsp\\char20\\tibetan", 148 }, + { "gha", "\\tibsp\\char21\\tibetan", 149 }, + { "dxha", "\\tibsp\\char22\\tibetan", 150 }, + { "bha", "\\tibsp\\char23\\tibetan", 151 }, + { "dzha", "\\tibsp\\char24\\tibetan", 152 }, + +/* + * next comes the six retroflex consonants. they are indicated + * by using an "x" following the consonant modified to show that + * they are reversed. + */ + { "thxa", "\\tibsp\\char25\\tibetan", 153 }, + { "txa", "\\tibsp\\char26\\tibetan", 154 }, + { "dxa", "\\tibsp\\char27\\tibetan", 155 }, + { "nxa", "\\tibsp\\char28\\tibetan", 156 }, + { "kshxa", "\\tibsp\\char29\\tibetan", 157 }, + { "shxa", "\\tibsp\\char30\\tibetan", 158 }, +/* + * next come the numbers. + * + */ + { "0", "\\tibsp\\char0\\tibetan", 128 }, + { "1", "\\tibsp\\char1\\tibetan", 129 }, + { "2", "\\tibsp\\char2\\tibetan", 130 }, + { "3", "\\tibsp\\char3\\tibetan", 131 }, + { "4", "\\tibsp\\char4\\tibetan", 132 }, + { "5", "\\tibsp\\char5\\tibetan", 133 }, + { "6", "\\tibsp\\char6\\tibetan", 134 }, + { "7", "\\tibsp\\char7\\tibetan", 135 }, + { "8", "\\tibsp\\char8\\tibetan", 136 }, + { "9", "\\tibsp\\char9\\tibetan", 137 }, +/* + * here are a couple of odd characters with the "u" vowel + * + */ + { "tsu", "\\tibsp\\char14\\tibetan", 16 }, + { "cu", "\\tibsp\\char13\\tibetan", 4 }, +/* + * here are the "tsa," "tsha," and "dza" characters + * generated by using the modified vowels with the stroke + * above the references included + */ + { "tse", "\\tibsp\\accent120\\tibetan\\char4", 16 }, + { "tsi", "\\tibsp\\accent119\\tibetan\\char4", 16 }, + { "tso", "\\tibsp\\accent118\\tibetan\\char4", 16 }, + + { "tshe", "\\tibsp\\accent120\\tibetan\\char5", 17 }, + { "tshi", "\\tibsp\\accent119\\tibetan\\char5", 17 }, + { "tsho", "\\tibsp\\accent118\\tibetan\\char5", 17 }, + + { "dze", "\\tibsp\\accent120\\tibetan\\char6", 18 }, + { "dzi", "\\tibsp\\accent119\\tibetan\\char6", 18 }, + { "dzo", "\\tibsp\\accent118\\tibetan\\char6", 18 }, +/* + * here are some punctuation characters. the "tsheg" and the + * "shad" are automatically generated as word and sentence + * boundaries. they may also be acessed as special characters. + * The "tsheg" may be got at with a + * "," character in the text. The "swasti" is the word with the + * TeX escape, but should be finished with a "/". + * Thus: "\swasti/" + */ + + { ",", "\\tibsp\\char114\\tibetan", 114 }, + { "\\swasti", "\\tibsp\\char116\\tibetan", 116 }, + { 0, "" }, +}; diff --git a/language/tibetan/original/src/table.h b/language/tibetan/original/src/table.h new file mode 100644 index 0000000000..ca48761777 --- /dev/null +++ b/language/tibetan/original/src/table.h @@ -0,0 +1,31 @@ +/* + * Copyright 1987 Jeff Sparkes + * Department of Computer Science + * Memorial University of Newfoundland + * St. John's, Nfld. + * garfield!jeff1, jeff1@garfield.mun.cdn + * + * Permission is granted to distribute and/or modify this code, provided + * this copyright notice remains intact. + * If you use it, let me know. If change it let me know. If you + * make money from it, send me a share. + */ + +struct fix { + char fix_char; + char *doc; + short base_char; + short char_num; +}; + +struct tab { + char *glyph; + char *doc; + short char_num; +}; + +struct special { + char *word; + char *cmd; + short char_num; +}; diff --git a/language/tibetan/original/src/tfilt.c b/language/tibetan/original/src/tfilt.c new file mode 100644 index 0000000000..58cc447229 --- /dev/null +++ b/language/tibetan/original/src/tfilt.c @@ -0,0 +1,49 @@ +/* + * Copyright 1987 Jeff Sparkes + * Department of Computer Science + * Memorial University of Newfoundland + * St. John's, Nfld. + * garfield!jeff1, jeff1@garfield.mun.cdn + * + * Permission is granted to distribute and/or modify this code, provided + * this copyright notice remains intact. + * If you use it, let me know. If change it let me know. If you + * make money from it, send me a share. + */ + +#include <stdio.h> +#include "table.h" +#include "token.h" + +main(argc, argv) + int argc; + char **argv; +{ + char c; + + if (argc != 2) { + fprintf(stderr, "usage: %s input_file\n", argv[0]); + exit(11); + } + if ((input = fopen(argv[1], "r")) == NULL) { + perror(argv[1]); + exit(12); + } + /* + * Now the hard part begins. + */ + + printf("\\font\\tibetan=tib\\font\\tibsp=tibsp "); + while ((c = getc(input)) != EOF) { + if (c == '%') { + if ((c = getc(input)) == '%') + tparse(); + else if (c == EOF) + exit(0); + else + putchar('%'); + } else + putchar(c); + } + exit(0); +} diff --git a/language/tibetan/original/src/token.h b/language/tibetan/original/src/token.h new file mode 100644 index 0000000000..c9d9e7d5a8 --- /dev/null +++ b/language/tibetan/original/src/token.h @@ -0,0 +1,50 @@ +/* + * Copyright 1987 Jeff Sparkes + * Department of Computer Science + * Memorial University of Newfoundland + * St. John's, Nfld. + * garfield!jeff1, jeff1@garfield.mun.cdn + * + * Permission is granted to distribute and/or modify this code, provided + * this copyright notice remains intact. + * If you use it, let me know. If change it let me know. If you + * make money from it, send me a share. + */ + +/* + * Input file. I didn't know where else to put it. + */ +FILE *input; + +/* + * A token returned by the parser. + */ +struct token { + char str[1024]; + char vowel; + char special; + int char_num; +}; + +/* + * Vowel flags + */ +#define V_NONE 000 +#define V_A 001 +#define V_E 002 +#define V_I 004 +#define V_O 010 +#define V_U 020 +#define SPECIAL 127 + +/* + * Flags to match different tables. + */ + +#define BASE 0 +#define SUPER 1 +#define SUB 2 +#define ERROR -1 + + +int tword(); diff --git a/language/tibetan/original/src/tparse.c b/language/tibetan/original/src/tparse.c new file mode 100644 index 0000000000..f2cac5c912 --- /dev/null +++ b/language/tibetan/original/src/tparse.c @@ -0,0 +1,509 @@ +/* + * Copyright 1987 Jeff Sparkes + * Department of Computer Science + * Memorial University of Newfoundland + * St. John's, Nfld. + * garfield!jeff1, jeff1@garfield.mun.cdn + * + * Permission is granted to distribute and/or modify this code, provided + * this copyright notice remains intact. + * If you use it, let me know. If change it let me know. If you + * make money from it, send me a share. + */ + +#include <stdio.h> +#include <ctype.h> +#include "token.h" +#include "table.h" + +#define SENTENCE 12 +#define WORD 13 +#define PARAGRAPH 14 +#define SENTENCE2 15 +#define SENTENCE3 16 + +#define Getc(x) x = nextchar(); if (x == 0) return WORD; else if (x == -1) goto top; +#define Ungetc(c) current_char-- + +static int current_char, current; +static char current_word[100]; +static int blank_flag = 0, blank_next = 0; +static int slashes, slashes_next; +char word_out, nextchar(), pending_punct; +int word_count, pos = 0; + +struct token token[10]; +extern struct tab base_table[]; +extern struct fix superfixes[], subfixes[]; +extern struct special special[]; + +tparse() +{ + char c; + int tok, i, j; + + for (i = 0; i < 10; i++) { + for (j = 0; j < 10; j++) + token[i].str[j] = 0; + token[i].char_num = 0; + token[i].vowel = V_NONE; + token[i].special = 0; + } + printf("\\bgroup\\tibetan "); + printf("\\def\\u#1{\\vtop{\\baselineskip0pt\\hbox{#1}\\hbox{\\tibsp\\char123}}}"); + printf("\\hyphenpenalty=10000\\parindent=0pt "); + printf("\\newbox\\fillerbox\\setbox\\fillerbox\\hbox{\\vrule height0.4cm depth0.4cm width0pt}\\def\\filler{\\copy\\fillerbox}"); + while (1) { + /* + * If we get a %, check for another immediately following. + * This is the end of tibetan mode. Otherwise, it is just a + * comment, but I figure it should be left in, just in case + * some one needs to look at the filter output. + */ + + for (i=0; i<100; i++) + current_word[i] = 0; + c = getc(input); + while (isspace(c)) { + char c1; + if (c == '\n') { + c1 = getc(input); + if (c1 == '\n') { + output_special(PARAGRAPH); + break; + } else + ungetc(c1, input); + } c = getc(input); + } + while (isspace(c) || c == '#') { + if (c == '#') + blank_next = 1; + c = getc(input); + } + ungetc(c, input); + if (fscanf(input, "%s", current_word) == EOF) { + printf("Missing %%%%\n"); + exit(1); + } + current_char = 0; + if (current_word[0] == '%') { + if (current_word[1] == '%') { + output_pending_punct(); + printf("\\egroup "); + return; + } else { + printf("%% %s", current_word + 1); + while ((c = getc(input)) != '\n') + putchar(c); + putchar('\n'); + } + } current = -1; + tok = 0; + tok = tword(); + output(current); + if (tok != 0) + output_special(tok); + } +} +/* + * Parse the word, as designated by white space. The tokens are put into an + * array so that some tokens can affect previous ones. The argument is the + * number of the current token in array. + */ +tword() +{ + char c, c1, s[10]; + int ind = 0; + int i, mtch; + +top: + ind = 0; + c = Getc(c); + while (1) { + /* + * Check for end of word delimiters. If it's also end of + * sentence, then do the appropriate thing. + */ + switch (c) { + + case '#': + /* don't output the word separator */ + blank_next = 1; + return(WORD); + case '/': + slashes_next = 0; + c1 = nextchar(); + while (c1 == '/') { + slashes_next++; + c1 = nextchar(); + } + /* + * If the slashes are at the end of a word, + * keep the count in slashes_next, and + * return an end of sentence. + */ + if (isspace(c1) || c1 == 0 || c1 == -1) { + return (SENTENCE); + } + /* + * Otherwise, the slashes are at the beginning + * so output them now. + */ + output_pending_punct(); + for (i=0; i<=slashes_next; i++) + printf("\\tibsp\\char115\\tibetan"); + c = c1; + slashes_next = 0; + continue; + case '!': + output(current); + return (SENTENCE2); + case '|': + output(current); + return (SENTENCE3); + case '%': + Ungetc(c); + return (0); + case '\n': + return (WORD); + default: + break; + } + + if (isspace(c)) { + return (WORD); + } current++; + /* + * If we've found a superfix, parse the next token. If it is + * a token that the superfix can modify, then use the + * modified char_num, otherwise the superfix is merely a + * vowel-less base character + */ + if (super(c)) { + int cur; + + if ((c1 = current_word[current_char++]) == 0) { + Ungetc(c1); + goto not_super; + } + if (sub(c1) || (c == 's' && c1 == 'h') || + (vowel(c1) != V_NONE)) { + Ungetc(c1); + goto not_super; + } + if (!isalpha(c1)) { + Ungetc(c1); + goto not_super; + } + Ungetc(c1); + sprintf(s, "%c", c); + cur = current; + /* fix so that next_char doesn't overwrite with special */ + token[current].char_num = 0; + tword(); + /* + * For some reason, // at the end get bypassed + */ + while(!isalpha(current_word[current_char])) + current_char--; + current_char++; + if ((token[cur].char_num = + match(SUPER, s, token[cur+1].char_num)) + != -1) { + int j; + + sprintf(token[cur].str, "%c%s", c, token[cur + 1].str); + token[cur+1].str[0] = 0; + token[cur].vowel = token[cur+1].vowel; + token[cur+1].char_num = -1; + token[cur+1].special = 0; + token[cur+1].vowel = V_NONE; + return (tword()); + } else { + token[cur].char_num = match(BASE, s, -1); + strcat(token[cur].str, s); + token[cur].vowel = V_NONE; + return (tword()); + } + } +not_super: + mtch = 0; + while (1) { + /* + * Match the g.y case. + */ + if (c == '.') { + token[current].str[ind] = 0; + token[current].vowel = V_A; + return (tword()); + } + /* + * Check for a subfix.. + */ + if (sub(c)) { + int t, t1; + sprintf(s, "%c", c); + t = match(SUB, s, token[current].char_num); + if (t != ERROR) { + c1 = Getc(c1); + if ((t1 = vowel(c1)) == V_NONE) { + Ungetc(c1); + Ungetc(c); + token[current].vowel = V_NONE; + return(tword()); + } else { + token[current].vowel = t1; + token[current].char_num = t; + strcat(token[current].str, s); + return (tword()); + } + } + + } + token[current].vowel = vowel(c); + /* + * We've matched the a+ glyph. + */ + if (mtch == 0 && token[current].vowel != V_NONE) { + if (ind == 0) { + /* + * We've matched a single vowel + * glyph. + */ + return (tword()); + } + token[current].str[ind++] = c; + token[current].str[ind] = 0; + break; + /* + * We've hit a vowel, which is the end of the + * glyph. + */ + } else if (token[current].vowel != V_NONE) { + token[current].str[ind] = 0; + return (tword()); + /* + * Check to see if what we have so far + the + * next is a glyph. If not, then this + * character is the beginning of the next + * one. + */ + } else { + int n; + token[current].str[ind++] = c; + token[current].str[ind] = 0; + if ((n = match(BASE, token[current].str, -1)) != ERROR) { + token[current].char_num = n; + mtch++; + } else if (mtch != 0) { + token[current].str[--ind] = 0; + Ungetc(c); + return (tword()); + } else { + bad_word(); + return (0); + } + } + c = Getc(c); + } + } +} + +output(count) + int count; +{ + int i, shift, cn, ch; + char fs[20]; + + /* + * Indicate that output has occurred. + */ + output_pending_punct(); + blank_flag = blank_next; + blank_next = 0; + slashes = slashes_next; + slashes_next = 0; + word_out = 1; + for (i = 0; i <= count; i++) { + /* + * Check for a single vowel glyph. The output is different + * for a single vowel since it has nothing to modify. + */ + shift = 0; + if (token[i].special == SPECIAL) { + printf("%s%%\n", token[i].str); + continue; + } + if (token[i].char_num > 127) { + cn = token[i].char_num - 128; + strcpy(fs, "\\tibsp"); + } else { + cn = token[i].char_num; + strcpy(fs, "\\tibetan"); + } + if (token[i].str[0] == 0) + if (token[i].vowel != V_NONE) + shift = 1; + else + continue; + /* save the character so that we can find the last one */ + ch = token[i].char_num; + switch (token[i].vowel) { + case V_A: + case V_NONE: + if (shift) + printf("\\char29"); + else + printf("\\char%d", cn); + break; + case V_E: + if (shift) + printf("\\tibsp\\accent127\\tibetan\\char29"); + else + printf("\\tibsp\\accent127%s\\char%d", fs, cn); + break; + case V_I: + if (shift) + printf("\\tibsp\\accent126\\tibetan\\char29"); + else + printf("\\tibsp\\accent126%s\\char%d", fs, cn); + break; + case V_O: + if (shift) + printf("\\tibsp\\accent125\\tibetan\\char29"); + else + printf("\\tibsp\\accent125%s\\char%d", fs, cn); + break; + case V_U: + if (shift) + printf("\\u{\\char29}"); + else + printf("\\u{\\char%d}", cn); + break; + default: + break; + } + } + for (i = 0; i < 10; i++) { + int j; + for (j = 0; j < 10; j++) + token[i].str[j] = 0; + token[i].char_num = -1; + token[i].vowel = V_NONE; + token[i].special = 0; + } +} + +output_special(c) + char c; +{ + /* + * Don't output any special markers unless output has done something + * since the last time we've been called. + */ + if (word_out) { + switch (c) { + case SENTENCE: + if (pending_punct == 0 || pending_punct == WORD) + pending_punct = SENTENCE; + break; + case SENTENCE2: + if (pending_punct == 0 || pending_punct == WORD) + pending_punct = SENTENCE2; + break; + case SENTENCE3: + if (pending_punct == 0 || pending_punct == WORD) + pending_punct = SENTENCE3; + break; + case WORD: + if (pending_punct == 0) + pending_punct = WORD; + break; + + case PARAGRAPH: + output_pending_punct(); + printf("\n\n"); + break; + default: + break; + } + } +} + +output_pending_punct() +{ + int i; + + switch (pending_punct) { + /* this controls the amount of space at the end of sentences */ + case SENTENCE: + for (i=0; i<slashes; i++) + printf("\\tibsp\\char115\\tibetan"); + printf("\\filler\\tibsp\\char115\\hskip1cm plus1cm minus.5cm\\tibetan\n"); + break; + case SENTENCE2: + printf("\\filler\\tibsp\\char121\\hskip1cm plus1cm minus.5cm\\tibetan\n"); + break; + case SENTENCE3: + printf("\\filler\\hskip1cm plus1cm minus.5cm\\tibetan\n"); + break; + case WORD: + if (blank_flag) { + printf("\\filler\\tenrm\\ \\tibetan\n"); + blank_flag = 0; + } else + printf("\\filler\\tibsp\\char114\\tenrm\\ \\tibetan\n"); + break; + default: + break; + } + pending_punct = 0; +} + +char +nextchar() +{ + int i; + + i = 0; + while (special[i].word != NULL) { + if (strncmp(special[i].word, current_word + current_char, strlen(special[i].word)) == 0) { + current_char += strlen(special[i].word); + if (current == -1) { + current = 0; + token[current].char_num = special[i].char_num; + token[current].special = SPECIAL; + strcpy(token[current].str, special[i].cmd); + token[current].vowel = vowel(special[i].word[ + strlen(special[i].word)+1]); + current++; + return (-1); + } + if (token[current].char_num == -1) { + token[current].char_num = special[i].char_num; + token[current].special = SPECIAL; + strcpy(token[current].str, special[i].cmd); + token[current].vowel = vowel(special[i].word[ + strlen(special[i].word+1)]); + current++; + return (-1); + } else { + current++; + token[current].char_num = special[i].char_num; + token[current].special = SPECIAL; + strcpy(token[current].str, special[i].cmd); + token[current].vowel = vowel(special[i].word[ + strlen(special[i].word+1)]); + current++; + return (-1); + } + } + i++; + } + return (current_word[current_char++]); +} + +bad_word() +{ + fprintf(stderr, "bad character in word <%s>\n", current_word); +} diff --git a/language/tibetan/original/src/util.c b/language/tibetan/original/src/util.c new file mode 100644 index 0000000000..f5984f8746 --- /dev/null +++ b/language/tibetan/original/src/util.c @@ -0,0 +1,131 @@ +/* + * Copyright 1987 Jeff Sparkes + * Department of Computer Science + * Memorial University of Newfoundland + * St. John's, Nfld. + * garfield!jeff1, jeff1@garfield.mun.cdn + * + * Permission is granted to distribute and/or modify this code, provided + * this copyright notice remains intact. + * If you use it, let me know. If change it let me know. If you + * make money from it, send me a share. + */ + +#include <stdio.h> +#include <ctype.h> +#include "token.h" +#include "table.h" + +extern struct tab base_table[]; +extern struct fix superfixes[], subfixes[]; + +/* + * Look up m_str in the table. If m_char isn't -1, see if the m_str can + * modify m_char. + */ +match(table, m_str, m_char) + int table; + char *m_str; + int m_char; +{ + struct tab *base = base_table; + struct fix *super = superfixes, *sub = subfixes; + int i = 0, miss; + int len, j; + + switch (table) { + case BASE: + while (base[i].char_num != -1) { + miss = 0; + len = strlen(m_str); + for (j = 0; j < len; j++) { + if (base[i].glyph[j] != '+') { + if (m_str[j] != base[i].glyph[j]) { + miss = 1; + break; + } + } else if (vowel(m_str[j]) == V_NONE) { + miss = 1; + break; + } + } + if (!miss) + return (base[i].char_num); + i++; + } + return (ERROR); + break; + case SUPER: + while (super[i].char_num != -1) { + if (super[i].fix_char == m_str[0]) + if (super[i].base_char == m_char) + return (super[i].char_num); + i++; + } + return (ERROR); + case SUB: + while (sub[i].char_num != -1) { + if (sub[i].fix_char == m_str[0]) + if (sub[i].base_char == m_char) + return (sub[i].char_num); + i++; + } + return (ERROR); + } +} + + + + +super(c) + char c; +{ + switch (c) { + case 'r': + case 'l': + case 's': + return (1); + default: + return (0); + } +} + +sub(c) + char c; +{ + switch (c) { + case 'w': + case 'y': + case 'r': + case 'l': + return (1); + default: + return (0); + } +} + +vowel(c) + char c; +{ + switch (c) { + case 'a': + return (V_A); + case 'e': + return (V_E); + case 'i': + return (V_I); + case 'o': + return (V_O); + case 'u': + return (V_U); + default: + return (V_NONE); + } +} + +error(s, pos) + char *s; + int pos; +{ + printf("%s at %d\n", s, pos); +} |