aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-06-19 20:46:52 +0200
committerPřemysl Eric Janouch <p@janouch.name>2023-06-28 16:24:59 +0200
commit717c30120790e5b1d8b11231996f70f30a1dada8 (patch)
treed6daeb91f0333c38f126360d942f01772d489818 /tools
parent091f92bab3907632016bb1bc5585830158e33dcf (diff)
downloadliberty-717c30120790e5b1d8b11231996f70f30a1dada8.tar.gz
liberty-717c30120790e5b1d8b11231996f70f30a1dada8.tar.xz
liberty-717c30120790e5b1d8b11231996f70f30a1dada8.zip
lxdrgen: fix decapitalization
decapitalize() is typically called on snaketocamel() output, which always makes the first letter uppercase.
Diffstat (limited to 'tools')
-rw-r--r--tools/lxdrgen.awk7
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/lxdrgen.awk b/tools/lxdrgen.awk
index effbc52..f77f19f 100644
--- a/tools/lxdrgen.awk
+++ b/tools/lxdrgen.awk
@@ -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
}