aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2021-07-20 04:39:26 +0000
committerWarner Losh <imp@FreeBSD.org>2021-07-22 02:03:35 +0000
commitacf9cf323f8d0c844ea4a0fedeb596871794a078 (patch)
tree64bf42d3c74ab15d876b4ba65eff9422b4e11db6 /contrib
parent51221b68fb5578be90b266fbb53d2848acaee045 (diff)
downloadsrc-acf9cf323f8d0c844ea4a0fedeb596871794a078.tar.gz
src-acf9cf323f8d0c844ea4a0fedeb596871794a078.zip
awk: Issue a warning for old hex behavior.
Since FreeBSD has allowed "0x" hex strings to be converted to integers for a long time, and since upstream has killed that behavior, warn about this issue. This will allow us to deprecate this behavior for 14.0 while giving our users of 12.x and 13.x fair warning. Sponsored by: Netflix
Diffstat (limited to 'contrib')
-rw-r--r--contrib/one-true-awk/lib.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/contrib/one-true-awk/lib.c b/contrib/one-true-awk/lib.c
index 6bfe5e8eaad9..c2da07a7ba62 100644
--- a/contrib/one-true-awk/lib.c
+++ b/contrib/one-true-awk/lib.c
@@ -798,11 +798,16 @@ bool is_valid_number(const char *s, bool trailing_stuff_ok,
* where hex strings were treated as numbers in nawk the whole time it has been
* in FreeBSD (since 2001). The POSIX 2001 through 2004 standards mandated this
* behavior and the current standard allows it. Deviate from upstream by restoring
- * the prior FreeBSD behavior.
+ * the prior FreeBSD behavior, but warning that it differs.
*/
-#if 0
// no hex floating point, sorry
if (s[0] == '0' && tolower(s[1]) == 'x')
+#ifdef __FreeBSD__
+ { static int warned = 0; /* Only warn the first time */
+ if (warned++ == 0)
+ WARNING("Script depends on old '0x' hex conversion behavior");
+ }
+#else
return false;
#endif