ref: 823c03a103b26313b269816e689ba38c81ef6d40
parent: e9b8b9f929b637fbb9b42d1720f702e8779226a0
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Jul 3 11:07:40 EDT 2014
hyph: .hcode should behave like .tr ".hcode abcd" assigns the hyphenation code of b to a and d to c. Note that ".hcode a b" no longer works.
--- a/hyph.c
+++ b/hyph.c
@@ -169,12 +169,19 @@
void tr_hcode(char **args)
{
- int i = 1;
- while (i + 1 <= NARGS && args[i + 1] && hcode_n < NHCODES) {
- strcpy(hcodesrc[hcode_n], args[i++]);
- strcpy(hcodedst[hcode_n], args[i++]);
- dict_put(&hcodedict, hcodesrc[hcode_n], hcode_n);
- hcode_n++;
+ char c1[GNLEN], c2[GNLEN];
+ char *s = args[1];
+ int i;
+ while (s && charread(&s, c1) >= 0 && charread(&s, c2) >= 0) {
+ i = dict_get(&hcodedict, c1);
+ if (i >= 0) {
+ strcpy(hcodedst[i], c2);
+ } else if (hcode_n < NHCODES) {
+ strcpy(hcodesrc[hcode_n], c1);
+ strcpy(hcodedst[hcode_n], c2);
+ dict_put(&hcodedict, hcodesrc[hcode_n], hcode_n);
+ hcode_n++;
+ }
}
}