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) {
|
function extract(string, type) {
|
||||||
if (type == "alias") {
|
if (type == "alias") {
|
||||||
split(string, array, "#=")
|
split(string, array, "#=")
|
||||||
return trim(array[2])
|
return strip(array[2])
|
||||||
} else if (type == "command") {
|
} else if (type == "command") {
|
||||||
split(string, array, "#/")
|
split(string, array, "#/")
|
||||||
return trim(array[2])
|
return strip(array[2])
|
||||||
} else if (type == "doc") {
|
} else if (type == "doc") {
|
||||||
split(string, array, "#")
|
split(string, array, "#")
|
||||||
return trim(array[2])
|
return strip(array[2])
|
||||||
} else if (type == "function") {
|
} else if (type == "function") {
|
||||||
split(string, array, "(")
|
split(string, array, "(")
|
||||||
return trim(array[1])
|
return strip(array[1])
|
||||||
} else if (type == "module") {
|
} else if (type == "module") {
|
||||||
split(string, array, "#\\.")
|
split(string, array, "#\\.")
|
||||||
return trim(array[2])
|
return strip(array[2])
|
||||||
} else if (type == "shebang") {
|
} else if (type == "shebang") {
|
||||||
split(string, array, "#!")
|
split(string, array, "#!")
|
||||||
return trim(array[2])
|
return strip(array[2])
|
||||||
} else if ((type == "constant") || (type == "variable")) {
|
} else if ((type == "constant") || (type == "variable")) {
|
||||||
split(string, array, "=")
|
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) {
|
function strip_first(string, sep, tmp) {
|
||||||
tmp = string
|
tmp = string
|
||||||
sub(sep, "", tmp)
|
sub(sep, "", tmp)
|
||||||
return trim(tmp)
|
return strip(tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
function strip_from(string, sep, tmp) {
|
function strip_from(string, sep, tmp) {
|
||||||
split(string, tmp, sep)
|
split(string, tmp, sep)
|
||||||
return trim(tmp[1])
|
return strip(tmp[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
function strip_function(string, tmp) {
|
function strip_function(string, tmp) {
|
||||||
|
@ -77,13 +84,6 @@ function strip_value(string, tmp) {
|
||||||
return strip_from(string, "=")
|
return strip_from(string, "=")
|
||||||
}
|
}
|
||||||
|
|
||||||
function trim(string) {
|
|
||||||
text = string
|
|
||||||
sub("^[\t ]*", "", text)
|
|
||||||
sub("[\t ]*$", "", text)
|
|
||||||
return text
|
|
||||||
}
|
|
||||||
|
|
||||||
# → begin
|
# → begin
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue