.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SLICE 1" .TH SLICE 1 "2020-11-29" "EN Tools" "EN Tools" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Slice \-\- Extract pre\-defined slices from an ASCII file .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBslice\fR [\fB\-v\fR] [\fB\-y\fR \fIoutputpolicy\fR] [\fB\-o\fR \fIsliceterm\fR:\fIoutputfile\fR[@\fIchmodcmd\fR][#\fIoutputpolicy\fR] ..] [\fIinputfile\fR] .PP \&\fBslice\fR [\fB\-V\fR] [\fB\-h\fR] .SH "VERSION" .IX Header "VERSION" \&\f(CW@SLICE_VERSION\fR@ .SH "DESCRIPTION" .IX Header "DESCRIPTION" .SS "Input Principle" .IX Subsection "Input Principle" The \fIslice\fR program reads \fIinputfile\fR (or from \fI\s-1STDIN\s0\fR if \fIinputfile\fR is not given or equal ``\f(CW\*(C`\-\*(C'\fR'') and divides its already prepared \s-1ASCII\s0 contents into possibly overlapping areas, called \fIslices\fR. These slices are determined by enclosing blocks defined by begin and end delimiters which have to be \fIalready\fR in the file. These block delimiters use the syntax .PP .Vb 1 \& [NAME: ... :NAME] .Ve .PP or alternatively (if there is no misinterpretation possible, i.e. no overlapping or stacked slices) .PP .Vb 1 \& [NAME: ... :] .Ve .PP The \fI\s-1NAME\s0\fR identifier has to match against the regular expression ``\f(CW\*(C`[_A\-Z0\-9]+\*(C'\fR'', i.e. \fI\s-1NAME\s0\fR is a string consisting only of uppercase letters, digits or underscore characters. .PP There can be as many such slice definitions as you like and there can be more than one slice with the same name. The resulting slice is the union of all equal named slices. Actually use this to spread a big slice over disjunct peaces of \fIinputfile\fR. .SS "Output Selection Scheme" .IX Subsection "Output Selection Scheme" The final output data gets calculated by a slice term consisting of slice names and set theory operators. The following syntax is recognized (in order of \s-1\fBLR\s0\fR\|(1) grammar parsing) for slice terms: .ie n .IP "\s-1SLICE_TERM\s0 ::= ""NAME""" 4 .el .IP "\s-1SLICE_TERM\s0 ::= \f(CWNAME\fR" 4 .IX Item "SLICE_TERM ::= NAME" The slice \s-1NAME\s0 itself. This name has to match against the regex ``\f(CW\*(C`[_A\-Z0\-9*{}]+\*(C'\fR''. Here two cases are possible: \f(CW\*(C`NAME\*(C'\fR is either a plain slice name consisting only of uppercase letters, digits or an underscore character. Or it is a wildcarded slice name indicated by an asterisk character. .Sp The first variant just expands to the union of all slices named exactly \&\f(CW\*(C`NAME\*(C'\fR. The second variant expands to the union of all slices which match against the wildcard pattern \f(CW\*(C`NAME\*(C'\fR. Here the asterisk has the semantical meaning of none or any number of characters. There is one special case, when the asterisk is immediately followed by characters enclosed within braces, it means none or any number of characters, but not this sequence of characters. .ie n .IP "\s-1SLICE_TERM\s0 ::= ""!NAME"" | ""~NAME""" 4 .el .IP "\s-1SLICE_TERM\s0 ::= \f(CW!NAME\fR | \f(CW~NAME\fR" 4 .IX Item "SLICE_TERM ::= !NAME | ~NAME" The \fBcomplement\fR of slice \s-1NAME\s0 (i.e. ALL\eNAME). .Sp In formula: {x in \s-1ALL:\s0 x \fBnot\fR in \s-1NAME\s0} .ie n .IP "\s-1SLICE_TERM\s0 ::= ""NAME1xNAME2"", ""NAME1^NAME2""" 4 .el .IP "\s-1SLICE_TERM\s0 ::= \f(CWNAME1xNAME2\fR, \f(CWNAME1^NAME2\fR" 4 .IX Item "SLICE_TERM ::= NAME1xNAME2, NAME1^NAME2" The \fBexclusive-or\fR relation between slice \s-1NAME1\s0 and slice \s-1NAME2.\s0 In set theory also called \fBsymmetric difference\fR: (NAME1uNAME2)\e(NAME1nNAME2) or alternatively (NAME1n!NAME2)u(!NAME1nNAME2). .Sp In formula: {x in \s-1ALL:\s0 (x in \s-1NAME1\s0 or x in \s-1NAME2\s0) and not (x in \s-1NAME1\s0 and x in \&\s-1NAME2\s0)}. .ie n .IP "\s-1SLICE_TERM\s0 ::= ""NAME1\eNAME2"", ""NAME1\-NAME2""" 4 .el .IP "\s-1SLICE_TERM\s0 ::= \f(CWNAME1\eNAME2\fR, \f(CWNAME1\-NAME2\fR" 4 .IX Item "SLICE_TERM ::= NAME1NAME2, NAME1-NAME2" The \fBdifference\fR of slice \s-1NAME1\s0 and slice \s-1NAME2,\s0 i.e. \s-1NAME1\s0 minus \s-1NAME2.\s0 .Sp In formula: {x in \s-1ALL:\s0 x in \s-1NAME1\s0 \fBand\fR x \fBnot\fR in \s-1NAME2\s0} .ie n .IP "\s-1SLICE_TERM\s0 ::= ""NAME1nNAME2"" | ""NAME1%NAME2""" 4 .el .IP "\s-1SLICE_TERM\s0 ::= \f(CWNAME1nNAME2\fR | \f(CWNAME1%NAME2\fR" 4 .IX Item "SLICE_TERM ::= NAME1nNAME2 | NAME1%NAME2" The \fBintersection\fR of slice \s-1NAME1\s0 and slice \s-1NAME2.\s0 .Sp In formula: {x in \s-1ALL:\s0 x in \s-1NAME1\s0 \fBand\fR x in \s-1NAME2\s0} .ie n .IP "\s-1SLICE_TERM\s0 ::= ""NAME1uNAME2"", ""NAME1+NAME2""" 4 .el .IP "\s-1SLICE_TERM\s0 ::= \f(CWNAME1uNAME2\fR, \f(CWNAME1+NAME2\fR" 4 .IX Item "SLICE_TERM ::= NAME1uNAME2, NAME1+NAME2" The \fBunion\fR of slice \s-1NAME1\s0 and slice \s-1NAME2.\s0 .Sp In formula: {x in \s-1ALL:\s0 x in \s-1NAME1\s0 \fBor\fR x in \s-1NAME2\s0} .ie n .IP "\s-1SLICE_TERM\s0 ::= ""("" \s-1SLICE_TERM\s0 "")""" 4 .el .IP "\s-1SLICE_TERM\s0 ::= \f(CW(\fR \s-1SLICE_TERM\s0 \f(CW)\fR" 4 .IX Item "SLICE_TERM ::= ( SLICE_TERM )" A grouped slice term. Use this to force a different order of evaluation. By default, all operators are left-associative, except complement which is right-associative. Operators are listed below from lowest to highest precedence: .Sp .Vb 1 \& \- u x n ! .Ve .SS "Advanced Selection: Slice Levels" .IX Subsection "Advanced Selection: Slice Levels" Because slices can be overlapping and stacked, a definition level is assigned to each slice while the input is parsed. These levels range from 1 to the maximum encountered (the level 0 is the whole file, i.e. \f(CW\*(C`ALL\*(C'\fR). When a slice begins, it is assigned the lowest free level, beginning with level 1. As long as one level is in use, it cannot be assigned again until the end delimiter of the corresponding slice is seen. .PP An example: .PP .Vb 1 \& [A:[B::B]:A][C:[D:[E::C]:D][F::E]:F] \& \& 3 E\-\-\-\-\-\-\-\-\-\-\-E \& 2 B\-\-B D\-\-\-\-\-\-\-\-D \& 1 A\-\-\-\-\-\-\-\-A C\-\-\-\-\-\-\-\-C F\-\-\-\-\-F \& 0 .Ve .PP Here slice A is assigned level 1. Then B is assigned level 2 because level 1 is still in use by A. Then the end of B is reached, level 2 is freed. Then the end of A is reached and level 1 is also free now, so C is assigned level 1 again. Now only level 1 is in use, so D is assigned level 2. Then E is assigned level 3. Then the end of C is seen and level 1 freed. Then the end of D is seen and level 2 is freed. Now F begins and because only level 3 is in use, it gets level 1 assigned. Then the end of E frees level 3 and the end of F frees level 1. Finally no levels are still in use. This indicates that the slicing is correct. .PP If there are any used levels left at the end of this process this indicates an input error and \fIslice\fR responds with an error message displaying the still open slices. .PP This complicated level mechanism is needed for granular set operations where particular slices should be included or excluded only. So, to make life easier, a few pseudo-slices are automatically defined: .ie n .IP """DEFn""" 4 .el .IP "\f(CWDEFn\fR" 4 .IX Item "DEFn" The union of all user-defined slices at exactly level n (0 <= n <= oo). .ie n .IP """UNDEFn""" 4 .el .IP "\f(CWUNDEFn\fR" 4 .IX Item "UNDEFn" The union of all \fBnon\fR\-user\-defined slices at exactly level n (0 <= n <= oo). This actually is just \f(CW\*(C`!DEFn\*(C'\fR. .ie n .IP """DEF""" 4 .el .IP "\f(CWDEF\fR" 4 .IX Item "DEF" The union of all user-defined slices at \fBall\fR levels, beginning at level \&\fB1\fR. This actually is the union of all \f(CW\*(C`DEFn\*(C'\fR slices. .ie n .IP """UNDEF""" 4 .el .IP "\f(CWUNDEF\fR" 4 .IX Item "UNDEF" The union of all \fBnon\fR\-user\-defined slices at \fBall\fR levels, beginning with \&\fB1\fR. This actually is just \f(CW\*(C`!DEF\*(C'\fR. .ie n .IP """ALL""" 4 .el .IP "\f(CWALL\fR" 4 .IX Item "ALL" The whole file. This actually is just \f(CW\*(C`UNDEF0\*(C'\fR, because at level 0 there are no user defined slices, so all is undefined. .ie n .IP "\fI\s-1NAME\s0\fR""@""" 4 .el .IP "\fI\s-1NAME\s0\fR\f(CW@\fR" 4 .IX Item "NAME@" This is the slice \fI\s-1NAME\s0\fR minus the union of all \f(CW\*(C`DEFn\*(C'\fR slices with min(\s-1NAME\s0) <= n <= oo. Here min(\s-1NAME\s0) is the lowest level plus one where \fI\s-1NAME\s0\fR ever occurred. You can read this as ``\s-1NAME\s0 without all other slices at higher levels which overwrite it''. This sounds a little bit crazy, but actually is the most important construct. Try to understand it or your slice terms become very complicated. .SH "OPTIONS" .IX Header "OPTIONS" .IP "[\fB\-y\fR \fIoutputpolicy\fR]" 4 .IX Item "[-y outputpolicy]" This flag changes output policy depending on events: \f(CW\*(C`u\*(C'\fR when an undefined set is encountered, \f(CW\*(C`w\*(C'\fR for an unmatched wildcard set, \f(CW\*(C`z\*(C'\fR when output is empty and \f(CW\*(C`s\*(C'\fR if it only consists of whitespace characters. Each letter is followed by a digit telling which action is bound to such events: \f(CW0\fR to ignore such events, \f(CW1\fR to display a warning message and continue, \f(CW2\fR to skip concerned file and continue, and \f(CW3\fR to abort with an error message. .Sp This flag consists of one or more events specifications, and default is \&\f(CW\*(C`u0w0s0z0\*(C'\fR. .IP "[\fB\-o\fR \fIsliceterm\fR:\fIoutputfile\fR[@\fIchmodcmd\fR][#\fIoutputpolicy\fR] ..]" 4 .IX Item "[-o sliceterm:outputfile[@chmodcmd][#outputpolicy] ..]" This redirects the output to a file. Usually the whole file will be send to \&\f(CW\*(C`STDOUT\*(C'\fR (same as \f(CW\*(C`ALL:\-\*(C'\fR). You can use this option \fImore than once\fR to output to more than one file while the corresponding \fIsliceterm\fR determines which output data will be included into each output file. .Sp The optional \fIchmodcmd\fR string is intended for specifying options for the \&\fIchmod\fR command, which is applied to \fIoutputfile\fR after writing. For instance use ``\f(CW\*(C`a+r\*(C'\fR'' to make sure the file is readable by a webserver of ``\f(CW\*(C`u+x\*(C'\fR'' to create a file with the execution bit set (usually used for \s-1SSI\s0 files on a webserver with the \f(CW\*(C`XBitHack\*(C'\fR option available). .Sp The optional \fIoutputpolicy\fR string allows changing output policy for only this output file without changing its global meaning. See above for more information about output policy. .Sp Be careful here: When you use parenthesis or asterisks inside \fIsliceterm\fR you have to make sure it is really passed to \fIslice\fR this way, i.e. usually you have to escape these characters from interpolation by the used shell. Do this either by adding backslashes in front of these characters or just surround the complete option argument with single quotes (''). .IP "\fB\-v\fR" 4 .IX Item "-v" This sets verbose mode where some processing information will be given on the console for debugging purpose. .IP "\fB\-V\fR" 4 .IX Item "-V" Displays the version identification string. .IP "\fB\-h\fR" 4 .IX Item "-h" Displays the usage page. .SH "SPECIAL FEATURE" .IX Header "SPECIAL FEATURE" Sometimes it can be very useful to be able to provide command line options directly within the input file, for instance to setup one or more \fB\-o\fR options. For this \fIslice\fR recognizes lines of the form .PP .Vb 1 \& %!slice OPTIONS .Ve .PP in the input file and automatically adds \s-1OPTIONS\s0 to the argument line options. These lines have to start in column 0. .PP Example: .PP .Vb 1 \& %!slice \-oTOC:contents.txt .Ve .SH "EXAMPLE" .IX Header "EXAMPLE" Assume the following simple multi-language article file \fIarticle.src\fR, written in \s-1HTML:\s0 .PP .Vb 5 \& \& \& [EN:Titlepage:][DE:Titelseite:] \& \& \& \&
\&

[EN:The Title itself:][DE:Der Titel selbst:]

\&
\& \&
\& [EN:...English Abstract...:] \& [DE:...Deutsche Zusammenfassung...:] \&
\& \& [EN:...English Text...:] \& [DE:...Deutscher Text...:] \& \& \& .Ve .PP The command .PP .Vb 1 \& slice \-o ENuUNDEF:article.html.en \-o DEuUNDEF:article.html.de .Ve .PP then creates the following to files: .IP "\fIarticle.html.en\fR:" 4 .IX Item "article.html.en:" .Vb 5 \& \& \& Titlepage \& \& \& \&
\&

The Title itself

\&
\& \&
\& ...English Abstract... \&
\& \& ...English Text... \& \& .Ve .IP "\fIarticle.html.de\fR:" 4 .IX Item "article.html.de:" .Vb 5 \& \& \& Titelseite \& \& \& \&
\&

Der Titel selbst

\&
\& \&
\& ...Deutsche Zusammenfassung... \&
\& \& ...Deutscher Text... \& \& .Ve .SH "RESTRICTION" .IX Header "RESTRICTION" The current implementation only handles anonymous end delimiters ``\f(CW\*(C`:]\*(C'\fR'' correct in clear cases where no mis-interpretation is possible, i.e. when no overlapping occurs. For instance in .PP .Vb 1 \& ...[A:...[B:...:A]...:]... .Ve .PP the end delimiter is not correctly assign to the `B' slice. So, be careful when using anonymous end delimiters in overlapping situations. Pure stacking like .PP .Vb 1 \& ...[A:...[B:...:]...:]... .Ve .PP is allowed and handled correctly, but only when you interpret this as .PP .Vb 1 \& ...[A:...[B:...:B]...:A]... .Ve .SH "COPYRIGHT" .IX Header "COPYRIGHT" .Vb 2 \& Copyright (c) 1997\-2002 Ralf S. Engelschall. \& Copyright (c) 1999\-2002 Denis Barbier. .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Slice Home: http://www.engelschall.com/sw/slice/ .SH "AUTHORS" .IX Header "AUTHORS" .Vb 3 \& Ralf S. Engelschall \& rse@engelschall.com \& www.engelschall.com \& \& Denis Barbier \& barbier@engelschall.com .Ve