On AIX 7.2 awk, the sub and gsub functions have a bug when the
replacement string contains a "\1" character. The substituted
strings have \1 characters replaced with amperands, for example:
aix72% awk 'BEGIN { s="x"; sub("x","\1",s); sub("\1","x",s); print s; }'
&
Very strange. The problem is internal to (g)sub, there is no
problem using "\1" characters in other contexts -- including
with the other arguments to (g)sub. It should be fine to use
"\2" instead which avoids this particular bug.
-# Copyright © 2021, 2023 Nick Bowler
+# Copyright © 2021, 2023-2024 Nick Bowler
#
# Generate a C string table based on an input string specification file.
#
#
# Generate a C string table based on an input string specification file.
#
# strings[ident] = val.
function finish_string_input(strings, ident, val, n, tmpval)
{
# strings[ident] = val.
function finish_string_input(strings, ident, val, n, tmpval)
{
- gsub(/\\\\/, "\1", val);
+ gsub(/\\\\/, "\2", val);
if (endline > startline)
val = val "\n";
gsub(/\\\n/, "", val);
tmpval = ""
while ((n = match(val, /\\[^abtnvfr]/)) > 0) {
if (endline > startline)
val = val "\n";
gsub(/\\\n/, "", val);
tmpval = ""
while ((n = match(val, /\\[^abtnvfr]/)) > 0) {
- tmpval = tmpval substr(val, 1, n-1)
- val = substr(val, n+1)
+ tmpval = tmpval substr(val, 1, n-1);
+ val = substr(val, n+1);
# Escape special characters
# Escape special characters
- gsub(/"/, bs"\"", tmpval)
- gsub(/\t/, bs"t", tmpval)
- gsub(/\n/, bs"n", tmpval)
- gsub("\1", bs bs, tmpval)
+ gsub(/"/, bs"\"", tmpval);
+ gsub(/\t/, bs"t", tmpval);
+ gsub(/\n/, bs"n", tmpval);
+ gsub("\2", bs bs, tmpval);
- strings[ident] = tmpval
+ strings[ident] = tmpval;
if (!current_l10n) {
nol10n[tmpval] = 1;
}
if (!current_l10n) {
nol10n[tmpval] = 1;
}