Util

Generic module providing useful primitives

Author: David Lutterkort

Summary
UtilGeneric module providing useful primitives
LicenseThis file is licensed under the LGPLv2+, like the rest of Augeas.
del_strDelete a string and default to it
del_wsDelete mandatory whitespace
del_ws_spcDelete mandatory whitespace, default to single space
del_ws_tabDelete mandatory whitespace, default to single tab
del_opt_wsDelete optional whitespace
eolDelete end of line, including optional trailing whitespace
indentDelete indentation, including leading whitespace
Comment and emptyThis is a general definition of comment and empty.
commentMap comments into “#comment” nodes
emptyMap empty lines, including empty comments
Split
Exclusions
stdexclExclusion for files that are commonly not wanted/needed

License

This file is licensed under the LGPLv2+, like the rest of Augeas.

del_str

let del_str (s:string) = del s s

Delete a string and default to it

Parameters

s:stringthe string to delete and default to

del_ws

let del_ws = del /[ \t]+/

Delete mandatory whitespace

del_ws_spc

let del_ws_spc = del_ws " "

Delete mandatory whitespace, default to single space

del_ws_tab

let del_ws_tab = del_ws "\t"

Delete mandatory whitespace, default to single tab

del_opt_ws

let del_opt_ws = del /[ \t]*/

Delete optional whitespace

eol

let eol = del /[ \t]*\n/ "\n"

Delete end of line, including optional trailing whitespace

indent

let indent = del /[ \t]*/ ""

Delete indentation, including leading whitespace

Comment and empty

This is a general definition of comment and empty.  It allows indentation for comments, removes the leading and trailing spaces of comments and stores them in nodes, except for empty comments which are ignored together with empty lines

comment

let comment = [ indent . label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n].*[^ \t\n]|[^ \t\n])/ . eol ]

Map comments into “#comment” nodes

empty

let empty = [ del /[ \t]*#?[ \t]*\n/ "\n" ]

Map empty lines, including empty comments

Split

Exclusions

stdexcl

let stdexcl = (
   excl "*~"
) . (excl "*.rpmnew") . (excl "*.rpmsave") . (excl "*.augsave") . (excl "*.augnew")

Exclusion for files that are commonly not wanted/needed

let del_str (s:string) = del s s
Delete a string and default to it
let del_ws = del /[ \t]+/
Delete mandatory whitespace
let del_ws_spc = del_ws " "
Delete mandatory whitespace, default to single space
let del_ws_tab = del_ws "\t"
Delete mandatory whitespace, default to single tab
let del_opt_ws = del /[ \t]*/
Delete optional whitespace
let eol = del /[ \t]*\n/ "\n"
Delete end of line, including optional trailing whitespace
let indent = del /[ \t]*/ ""
Delete indentation, including leading whitespace
let comment = [ indent . label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n].*[^ \t\n]|[^ \t\n])/ . eol ]
Map comments into “#comment” nodes
let empty = [ del /[ \t]*#?[ \t]*\n/ "\n" ]
Map empty lines, including empty comments
let stdexcl = (
   excl "*~"
) . (excl "*.rpmnew") . (excl "*.rpmsave") . (excl "*.augsave") . (excl "*.augnew")
Exclusion for files that are commonly not wanted/needed
Close