ULTRIX 4.5 nawk has a weird bug where it seems to sometimes "forget" the
length of $0 after it has been modified, when assigning the modified
value directly to a named variable. For example:
% echo x | nawk '{ $0 = "hello"; x = $0; print x "rld"; }'
hrld
% echo xx | nawk '{ $0 = "hello"; x = $0; print x "rld"; }'
herld
The bug does not occur if there is an intervening assignment to any of
the field variables, or if the assignment is made slightly more complex,
or if any other variable is used:
% echo x | nawk '{ $0 = "hello"; $1 = $1; x = $0; print x "rld"; }'
hellorld
% echo x | nawk '{ $0 = "hello"; x = "" $0; print x "rld"; }'
hellorld
% nawk 'BEGIN { z = "hello"; x = z; print x "rld"; }' z=x
hellorld
So there are many easy workarounds.
}
current_l10n = !sub(/^[&]/, "", $1);
- startline = NR
- ident = $1
+ startline = NR;
+ ident = $1;
- $1 = ""
- collected = ""
+ $1 = collected = "";
}
ident != "" {
- sub(/^[ \t]*/, "")
- if (collected) {
- collected = collected "\n" $0
- } else {
- collected = $0
- }
+ sub(/^[ \t]*/, "");
- endline = NR
+ sep = collected != "" ? "\n" : "";
+ collected = collected sep $0;
+ endline = NR;
}
END {