aboutsummaryrefslogtreecommitdiff
path: root/unix/boot/spp/rpp/ratlibr/omatch.r
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /unix/boot/spp/rpp/ratlibr/omatch.r
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'unix/boot/spp/rpp/ratlibr/omatch.r')
-rw-r--r--unix/boot/spp/rpp/ratlibr/omatch.r48
1 files changed, 48 insertions, 0 deletions
diff --git a/unix/boot/spp/rpp/ratlibr/omatch.r b/unix/boot/spp/rpp/ratlibr/omatch.r
new file mode 100644
index 00000000..598a4e24
--- /dev/null
+++ b/unix/boot/spp/rpp/ratlibr/omatch.r
@@ -0,0 +1,48 @@
+include defs
+
+# omatch --- try to match a single pattern at pat (j)
+
+ integer function omatch (lin, i, pat, j)
+ character lin (MAXLINE), pat (MAXPAT)
+ integer i, j
+
+ integer bump
+ integer locate
+
+ omatch = NO
+ if (lin (i) == EOS)
+ return
+ bump = -1
+ if (pat (j) == CHAR) {
+ if (lin (i) == pat (j + 1))
+ bump = 1
+ }
+ else if (pat (j) == BOL) {
+ if (i == 1)
+ bump = 0
+ }
+ else if (pat (j) == ANY) {
+ if (lin (i) != NEWLINE)
+ bump = 1
+ }
+ else if (pat (j) == EOL) {
+ if (lin (i) == NEWLINE)
+ bump = 0
+ }
+ else if (pat (j) == CCL) {
+ if (locate (lin (i), pat, j + 1) == YES)
+ bump = 1
+ }
+ else if (pat (j) == NCCL) {
+ if (lin (i) != NEWLINE & locate (lin (i), pat, j + 1) == NO)
+ bump = 1
+ }
+ else
+ call error ("in omatch: can't happen.")
+ if (bump >= 0) {
+ i = i + bump
+ omatch = YES
+ }
+
+ return
+ end