lxdrgen: fix decapitalization

decapitalize() is typically called on snaketocamel() output,
which always makes the first letter uppercase.
This commit is contained in:
Přemysl Eric Janouch 2023-06-19 20:46:52 +02:00
parent 091f92bab3
commit 717c301207
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,6 @@
# lxdrgen.awk: an XDR-derived code generator for network protocols.
#
# Copyright (c) 2022, Přemysl Eric Janouch <p@janouch.name>
# Copyright (c) 2022 - 2023, Přemysl Eric Janouch <p@janouch.name>
# SPDX-License-Identifier: 0BSD
#
# Usage: env LC_ALL=C awk -f lxdrgen.awk -f lxdrgen-{c,go,mjs}.awk \
@ -28,9 +28,10 @@ function snaketocamel(s) {
}
function decapitalize(s) {
if (match(s, /[[:upper:]][[:lower:]]/)) {
if (match(s, /^[[:upper:]][[:lower:]]/))
return tolower(substr(s, 1, 1)) substr(s, 2)
}
if (match(s, /^[[:upper:]]$/))
return tolower(s)
return s
}