strip
This commit is contained in:
parent
fa0c8dc894
commit
8caa6e6795
1 changed files with 16 additions and 16 deletions
|
@ -36,37 +36,44 @@ function doc_reset() {
|
|||
function extract(string, type) {
|
||||
if (type == "alias") {
|
||||
split(string, array, "#=")
|
||||
return trim(array[2])
|
||||
return strip(array[2])
|
||||
} else if (type == "command") {
|
||||
split(string, array, "#/")
|
||||
return trim(array[2])
|
||||
return strip(array[2])
|
||||
} else if (type == "doc") {
|
||||
split(string, array, "#")
|
||||
return trim(array[2])
|
||||
return strip(array[2])
|
||||
} else if (type == "function") {
|
||||
split(string, array, "(")
|
||||
return trim(array[1])
|
||||
return strip(array[1])
|
||||
} else if (type == "module") {
|
||||
split(string, array, "#\\.")
|
||||
return trim(array[2])
|
||||
return strip(array[2])
|
||||
} else if (type == "shebang") {
|
||||
split(string, array, "#!")
|
||||
return trim(array[2])
|
||||
return strip(array[2])
|
||||
} else if ((type == "constant") || (type == "variable")) {
|
||||
split(string, array, "=")
|
||||
return trim(array[1])
|
||||
return strip(array[1])
|
||||
}
|
||||
}
|
||||
|
||||
function strip(string, tmp) {
|
||||
tmp = string
|
||||
sub("^[\t ]*", "", tmp)
|
||||
sub("[\t ]*$", "", tmp)
|
||||
return tmp
|
||||
}
|
||||
|
||||
function strip_first(string, sep, tmp) {
|
||||
tmp = string
|
||||
sub(sep, "", tmp)
|
||||
return trim(tmp)
|
||||
return strip(tmp)
|
||||
}
|
||||
|
||||
function strip_from(string, sep, tmp) {
|
||||
split(string, tmp, sep)
|
||||
return trim(tmp[1])
|
||||
return strip(tmp[1])
|
||||
}
|
||||
|
||||
function strip_function(string, tmp) {
|
||||
|
@ -77,13 +84,6 @@ function strip_value(string, tmp) {
|
|||
return strip_from(string, "=")
|
||||
}
|
||||
|
||||
function trim(string) {
|
||||
text = string
|
||||
sub("^[\t ]*", "", text)
|
||||
sub("[\t ]*$", "", text)
|
||||
return text
|
||||
}
|
||||
|
||||
# → begin
|
||||
BEGIN {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue