This commit is contained in:
Marc Beninca 2025-08-02 20:20:19 +02:00
parent fa0c8dc894
commit 8caa6e6795
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -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 {