awk: Merge one true awk 20250804 bsd-feature branch

Merge in the latest one true awk to pick up two small bug fixes:

    Aug 04, 2025
            Fix incorrect divisor in rand() - it was returning
            even random numbers only. Thanks to Ozan Yigit.

            Fix a syntax issue with /= that caused constants to
            turn into variables [eg. 42 /= 7]. Thanks to Arnold
            Robbins.

Note: vendor/one-true-awk/4d5b3604b34b_1 was the merge tag.

Sponsored by:		Netflix
This commit is contained in:
Warner Losh 2025-08-18 13:05:48 -06:00
commit b45a181a74
3 changed files with 12 additions and 2 deletions

View file

@ -25,6 +25,14 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the
second edition of the AWK book was published in September 2023.
Aug 04, 2025
Fix incorrect divisor in rand() - it was returning
even random numbers only. Thanks to Ozan Yigit.
Fix a syntax issue with /= that caused constants to
turn into variables [eg. 42 /= 7]. Thanks to Arnold
Robbins.
Jan 14, 2025
Fix incorrect error line number issues. unput has
no business managing lineno. Thanks to Ozan Yigit.

View file

@ -22,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
const char *version = "version 20250116";
const char *version = "version 20250804";
#define DEBUG
#include <stdio.h>

View file

@ -1567,6 +1567,8 @@ Cell *assign(Node **a, int n) /* a[0] = a[1], a[0] += a[1], etc. */
xf *= yf;
break;
case DIVEQ:
if ((x->tval & CON) != 0)
FATAL("non-constant required for left side of /=");
if (yf == 0)
FATAL("division by zero in /=");
xf /= yf;
@ -2188,7 +2190,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis
/* random() returns numbers in [0..2^31-1]
* in order to get a number in [0, 1), divide it by 2^31
*/
u = (Awkfloat) random() / (0x7fffffffL + 0x1UL);
u = (Awkfloat) random() / RAND_MAX;
break;
case FSRAND:
if (isrec(x)) /* no argument provided */