[pdftex] Bug in str_in_str(), pdftex 1.10a-RC3
Olaf Dietrich
olaf at dtrx.de
Thu Jan 16 15:10:39 CET 2003
Some months ago I sent the following message to this list:
----- Forwarded message from Olaf Dietrich <olaf at dtrx.de> -----
Date: Mon, 11 Mar 2002 09:30:47 +0100
Subject: Bug in str_in_str()?
From: Olaf Dietrich <olaf at dtrx.de>
To: pdftex at tug.org
Is there possibly a bug in the str_in_str() function
in pdftexdir/pdftex.ch:1189 (snapshot 20010806)?
| function str_in_str(s, r: str_number; i: integer): boolean;
| {test equality of strings}
| label not_found; {loop exit}
| var j, k: pool_pointer; {running indices}
| @!result: boolean; {result of comparison}
| begin
| str_in_str := false;
| if length(s) < i + length(r) then
| return;
+ j := str_start[s];
+ k := i + str_start[r];
| while (j < str_start[s + 1]) and (k < str_start[r + 1]) do begin
| if str_pool[j] <> str_pool[k] then
| return;
| incr(j);
| incr(k);
| end;
| str_in_str := true;
| end;
|
| procedure literal(s: str_number; reset_origin, is_special, warn: boolean);
| var j: pool_pointer; {current character code position}
| begin
| j:=str_start[s];
| if is_special then begin
+ if not (str_in_str(s, "PDF:", 0) or str_in_str(s, "pdf:", 0)) then begin
| if warn then
| print_nl("Non-PDF special ignored!");
| return;
| end;
| j := j + length("PDF:");
+ if str_in_str(s, "direct:", length("PDF:")) then begin
| j := j + length("direct:");
| reset_origin := false;
| end
| else
| reset_origin := true;
| end;
The last marked (+) line seems to indicate that the comparison
should be performed with an offset of length("PDF:") in
the string s; however, the definition (first marked lines)
calculates this offset for the string r. The condition "if
length(s) < i + length(r) then return;" is another indicator,
that the intended implementation might be
! j := i + str_start[s];
! k := str_start[r];
[...]
----- End forwarded message -----
Han replied to me that this was indeed a bug that should
be corrected as described above - however this has never
happened (it's still in 1.10-RC3, pdftex.ch:1275).
Olaf
More information about the pdftex
mailing list