[pdftex] Bug in str_in_str()?

Olaf Dietrich olaf at dtrx.de
Mon Mar 11 09:30:47 CET 2002


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];


BTW, is a more recent version of pdfTeX available for
download than the snapshot 20010806 at
<URL:ftp://ftp.muni.cz/pub/tex/local/cstug/thanh/pdftex/snapshots/>?
(I found the version 1.00a-pretest-20011114-ojmw as part of the
current pdfTeX-beta distribution, and a version
"1.00b-pretest-20020211" was mentioned recently in
de.comp.text.tex.)

Olaf



More information about the pdftex mailing list