From 717c30120790e5b1d8b11231996f70f30a1dada8 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Mon, 19 Jun 2023 20:46:52 +0200 Subject: lxdrgen: fix decapitalization decapitalize() is typically called on snaketocamel() output, which always makes the first letter uppercase. --- tools/lxdrgen.awk | 7 ++++--- 1 file 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 +# Copyright (c) 2022 - 2023, Přemysl Eric Janouch # 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 } -- cgit v1.2.3-70-g09d2