[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
missing return causes m4-1.4.5 to FAIL 079.regexp and 082.patsubst
From: |
Russell Ruby |
Subject: |
missing return causes m4-1.4.5 to FAIL 079.regexp and 082.patsubst |
Date: |
Tue, 25 Jul 2006 11:24:30 -0700 |
This is probably the umpteenth report/fix of this same problem and has
reached the point of being tagged as spam by your filters.. :)
However - hopefully I will soon have more as 1.4.5 is having lots of problems
on SunOS 4.1.4 (M4 1.4.4 was completely clean - build and test) and thus will
be sending more reports/fixes relevant for SunOS 4.1.4.
The problem below is an algorithm mishap in nature.
With the simple fix below - Linux Slackware M4.1.4.5 has no "make check"
failures.
russell ruby - address@hidden
==============
m4-1.4.5
Linux Slackware current ( 10.2+ )
gcc (GCC) 3.4.6
===============
========
FAILURE: tests 079.regexp and 082.patsubst
Examples:
NOTE GRATUITOUS "\001" IN OUTPUT BELOW: (079.regexp failure)
flux: cat - | ./src/m4 | od -c
regexp(`abc', `b', `\1\')
stdin:1: ./src/m4: Warning: sub-expression 1 not present
stdin:1: ./src/m4: Warning: trailing \ ignored in replacement
0000000 001 \n
0000002
NOTE GRATUITOUS "\370 \005 \b \001" IN OUTPUT BELOW: (082.regexp failure)
flux objdir-debug: cat - | ./src/m4 | od -c
patsubst(`GNUs not Unix', `[A-Z][a-z]+')
patsubst(`GNUs not Unix', `not', `NOT\')
stdin:2: ./src/m4: Warning: trailing \ ignored in replacement
0000000 G N n o t \n G N U s N O T
0000020 370 005 \b 001 U n i x \n
0000032
==============
CAUSE AND FIX:
Both these failures occur because function "./m4-1.45/src/builtin:substitute"
erroneously continues processing past the '\0' termination of a
replacement text string if a '\' is the last character before the terminating
'\0' in its representation as a "C" language string. It finally terminates
when it encounters the next '\0' in its romp past the end of the string,
assuming that the next '\0' is not likewise preceded by a '\'.
This is cured by inserting a return statement at line 1660 of
"m4-1.45/src/builtin:substitute". The lack of the "return" forces
"substitute" to continue with loop, processing additional characters
past the end of the replacement string text. The is the source and fix
of the failure for both test cases.
flux src: diff --context=5 builtin.c.vanilla builtin.c
*** builtin.c.vanilla 2006-07-14 13:15:46.000000000 -0700
--- builtin.c 2006-07-23 22:50:23.000000000 -0700
***************
*** 1655,1664 ****
--- 1655,1665 ----
break;
case '\0':
M4ERROR ((warning_status, 0, "\
Warning: trailing \\ ignored in replacement"));
+ return;
break;
default:
obstack_1grow (obs, ch);
break;
- missing return causes m4-1.4.5 to FAIL 079.regexp and 082.patsubst,
Russell Ruby <=