diff --git a/lenses/getcap.aug b/lenses/getcap.aug index e5f62cd6a..a20c0e766 100644 --- a/lenses/getcap.aug +++ b/lenses/getcap.aug @@ -26,12 +26,15 @@ module Getcap = let empty = Util.empty (* field must not contain ':' unless quoted or '\'-escaped *) + let nfield = /[^:\\\n#|]+/ + (* let field = /[^:\\\n]+/ *) let field = /([^:\\\n]|\\\\.)+|[^:\n]*(\"[^\n]+\"[^:\n]*)+/ let sep = del /:([ \t]*\\\\\n[ \t]*:)?/ ":\\\n\t:" - let name = [ label "name" . store field ] + let nsep = Util.del_str "|" + let name = [ label "name" . store nfield ] let capability = [ label "capability" . store field ] - let record = [ label "record" . name . sep . capability . ( sep . capability )* . Sep.colon . eol ] + let record = [ seq "record" . name . ( nsep . name )* . sep . capability . ( sep . capability )* . Sep.colon . eol ] let lns = ( empty | comment | record )* diff --git a/lenses/tests/test_getcap.aug b/lenses/tests/test_getcap.aug index 330d3f7e3..37843b117 100644 --- a/lenses/tests/test_getcap.aug +++ b/lenses/tests/test_getcap.aug @@ -6,6 +6,20 @@ module Test_getcap = :abc%xyz:abc^frap:abc$@:\ :tc=more: " + +test Getcap.lns get getcap = + { "1" + { "name" = "example" } + { "name" = "an example of binding multiple values to names" } + { "capability" = "foo%bar" } + { "capability" = "foo^blah" } + { "capability" = "foo@" } + { "capability" = "abc%xyz" } + { "capability" = "abc^frap" } + { "capability" = "abc$@" } + { "capability" = "tc=more" } + } + (* Taken from the standard /etc/login.conf *) let login_conf = "# Default allowed authentication styles auth-defaults:auth=passwd,skey: @@ -37,164 +51,15 @@ default:\ :tc=auth-ftp-defaults: " - (* Example from rtadvd.conf(5) *) - let rtadvd_conf = "default:\ - :chlim#64:raflags#0:rltime#1800:rtime#0:retrans#0:\ - :pinfoflags=\"la\":vltime#2592000:pltime#604800:mtu#0: -ef0:\ - :addr=\"2001:db8:ffff:1000::\":prefixlen#64:tc=default: -" - - (* Sample /etc/printcap *) - let printcap = "# $OpenBSD: printcap,v 1.1 2014/07/12 03:52:39 deraadt Exp $ - -lp|local line printer:\ - :lp=/dev/lp:sd=/var/spool/output:lf=/var/log/lpd-errs: - -rp|remote line printer:\ - :lp=:rm=printhost:rp=lp:sd=/var/spool/output:lf=/var/log/lpd-errs: -" - - (* Sample termcap entry with escaped ':''s *) - let termcap = "vt420pc|DEC VT420 w/PC keyboard:\ - :@7=\E[4~:F1=\E[23~:F2=\E[24~:F3=\E[11;2~:F4=\E[12;2~:\ - :F5=\E[13;2~:F6=\E[14;2~:F7=\E[15;2~:F8=\E[17;2~:\ - :F9=\E[18;2~:FA=\E[19;2~:FB=\E[20;2~:FC=\E[21;2~:\ - :FD=\E[23;2~:FE=\E[24;2~:FF=\E[23~:FG=\E[24~:FH=\E[25~:\ - :FI=\E[26~:FJ=\E[28~:FK=\E[29~:FL=\E[31~:FM=\E[32~:\ - :FN=\E[33~:FO=\E[34~:FP=\E[35~:FQ=\E[36~:FR=\E[23;2~:\ - :FS=\E[24;2~:FT=\E[25;2~:FU=\E[26;2~:FV=\E[28;2~:\ - :FW=\E[29;2~:FX=\E[31;2~:FY=\E[32;2~:FZ=\E[33;2~:\ - :Fa=\E[34;2~:Fb=\E[35;2~:Fc=\E[36;2~:\ - :S6=USR_TERM\:vt420pcdos\::k1=\E[11~:k2=\E[12~:\ - :k3=\E[13~:k4=\E[14~:k5=\E[15~:k6=\E[17~:k7=\E[18~:\ - :k8=\E[19~:k9=\E[20~:k;=\E[21~:kD=\177:kh=\E[H:\ - :..px=\EP1;1|%?%{16}%p1%>%t%{0}%e%{21}%p1%>%t%{1}%e%{25}%p1%>%t%{2}%e%{27}%p1%>%t%{3}%e%{30}%p1%>%t%{4}%e%{5}%;%p1%+%d/%p2%s\E\\:\ - :tc=vt420: -" - - let termcap2 = "tws-generic|dku7102|Bull Questar tws terminals:\ - :am:es:hs:mi:ms:xn:xo:xs@:\ - :co#80:it#8:li#24:ws#80:\ - :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:LE=\E[%dD:\ - :RI=\E[%dC:UP=\E[%dA:al=\E[L:bl=^G:bt=\E[Z:cd=\E[J:ce=\E[K:\ - :cl=\E[2J:cm=\E[%i%d;%df:cr=^M:ct=\E[3g:dc=\E[P:dl=\E[M:\ - :do=^J:ds=\EPY99\:98\E\\\E[0;98v\E[2J\E[v:ei=\E[4l:\ - :fs=\E[v:ho=\E[H:i1=\E[?=h\Ec\E`\E[?>h\EPY99\:98\E\\\\:\ - :i2=\Eb\E[?;12;18;?h\EPY99\:98\E\\\\:\ - :ts=\EPY99\:98\E\\\E[0;98v\E[2;7m:ue=\E[m:up=\E[A:\ - :us=\E[0;4m:ve=\E[r:vi=\E[1r: -" - -test Getcap.lns get termcap2 = - { "record" - { "name" = "tws-generic|dku7102|Bull Questar tws terminals" } - { "capability" = "am" } - { "capability" = "es" } - { "capability" = "hs" } - { "capability" = "mi" } - { "capability" = "ms" } - { "capability" = "xn" } - { "capability" = "xo" } - { "capability" = "xs@" } - { "capability" = "co#80" } - { "capability" = "it#8" } - { "capability" = "li#24" } - { "capability" = "ws#80" } - { "capability" = "AL=\E[%dL" } - { "capability" = "DC=\E[%dP" } - { "capability" = "DL=\E[%dM" } - { "capability" = "DO=\E[%dB" } - { "capability" = "LE=\E[%dD" } - { "capability" = "RI=\E[%dC" } - { "capability" = "UP=\E[%dA" } - { "capability" = "al=\E[L" } - { "capability" = "bl=^G" } - { "capability" = "bt=\E[Z" } - { "capability" = "cd=\E[J" } - { "capability" = "ce=\E[K" } - { "capability" = "cl=\E[2J" } - { "capability" = "cm=\E[%i%d;%df" } - { "capability" = "cr=^M" } - { "capability" = "ct=\E[3g" } - { "capability" = "dc=\E[P" } - { "capability" = "dl=\E[M" } - { "capability" = "do=^J" } - { "capability" = "ds=\EPY99\:98\E\\E[0;98v\E[2J\E[v" } - { "capability" = "ei=\E[4l" } - { "capability" = "fs=\E[v" } - { "capability" = "ho=\E[H" } - { "capability" = "i1=\E[?=h\Ec\E`\E[?>h\EPY99\:98\E\\" } - { "capability" = "i2=\Eb\E[?