diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/tbl/ti.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/tbl/ti.c')
-rwxr-xr-x | sys/src/cmd/tbl/ti.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/sys/src/cmd/tbl/ti.c b/sys/src/cmd/tbl/ti.c new file mode 100755 index 000000000..ef995bbb3 --- /dev/null +++ b/sys/src/cmd/tbl/ti.c @@ -0,0 +1,75 @@ +/* ti.c: classify line intersections */ +# include "t.h" +/* determine local environment for intersections */ + +int +interv(int i, int c) +{ + int ku, kl; + + if (c >= ncol || c == 0) { + if (dboxflg) { + if (i == 0) + return(BOT); + if (i >= nlin) + return(TOP); + return(THRU); + } + if (c >= ncol) + return(0); + } + ku = i > 0 ? lefdata(i - 1, c) : 0; + if (i + 1 >= nlin && allh(i)) + kl = 0; + else + kl = lefdata(allh(i) ? i + 1 : i, c); + if (ku == 2 && kl == 2) + return(THRU); + if (ku == 2) + return(TOP); + if (kl == BOT) + return(2); + return(0); +} + + +int +interh(int i, int c) +{ + int kl, kr; + + if (fullbot[i] == '=' || (dboxflg && (i == 0 || i >= nlin - 1))) { + if (c == ncol) + return(LEFT); + if (c == 0) + return(RIGHT); + return(THRU); + } + if (i >= nlin) + return(0); + kl = c > 0 ? thish (i, c - 1) : 0; + if (kl <= 1 && i > 0 && allh(up1(i))) + kl = c > 0 ? thish(up1(i), c - 1) : 0; + kr = thish(i, c); + if (kr <= 1 && i > 0 && allh(up1(i))) + kr = c > 0 ? thish(up1(i), c) : 0; + if (kl == '=' && kr == '=') + return(THRU); + if (kl == '=') + return(LEFT); + if (kr == '=') + return(RIGHT); + return(0); +} + + +int +up1(int i) +{ + i--; + while (instead[i] && i > 0) + i--; + return(i); +} + + |