Re: pdftosrc seg faults

2003-01-26 Thread Olaf Weber
Reinhard Kotucha writes:
 Olaf Weber [EMAIL PROTECTED] writes:

 Does the following change fix this?

 Yes, thank you.  But I have to provide the stream object number,
 though the usage message says that it's optional.

[...]

 I suppose that it should be optional. If it is omitted, pdftosrc
 should behave as if stream-object-number is 0.  In this case 
 it should look for /SourceFile.  But srcStream.isStream(SourceFile)
 is always 0. (pdftosrc.cc, line 85)

The reason it is always 0 is becayse there is no SourceObject in the
Catalog.  To put the SourceObject there, use \pdfcatalog instead of
\immediate\pdfcatalog (it's not entirely clear to why the latter
doesn't work).  And then you need to make sure there's something in
the pdf at all.  So a corrected example would be:

\pdfcompresslevel=0
\immediate\pdfobj stream
  attr {/Type /SourceFile /SourceName (\jobname.src)}
  file {\jobname.tex}
\pdfcatalog{/SourceObject \the\pdflastobj\space 0 R}
Hello world!
\bye


At that point you'll also discover that pdftosrc writes its output to
a garbage file name, which turns out to be a use-after-free problem.
The full patch now becomes:

--- pdftosrc.cc-2002-12-20 19:47:27.0 +0100
+++ pdftosrc.cc 2003-01-26 14:58:25.0 +0100
@@ -61,7 +61,6 @@
 }
 fileName = new GString(argv[1]);
 globalParams = new GlobalParams();
-xref = NULL;
 doc = new PDFDoc(fileName);
 if (!doc-isOk()) {
 fprintf(stderr, Invalid PDF file\n);
@@ -72,6 +71,7 @@
 if (argc = 4)
 objgen = atoi(argv[3]);
 }
+xref = doc-getXRef();
 catalogDict.initNull();
 xref-getCatalog(catalogDict);
 if (!catalogDict.isDict(Catalog)) {
@@ -92,7 +92,8 @@
 exit(1);
 }
 outname = srcName.getString()-getCString();
-srcName.free();
+// We cannot free srcName, as objname shares its string.
+// srcName.free();
 }
 else {
 xref-fetch(objnum, objgen, srcStream);
@@ -110,7 +111,7 @@
 outname = buf;
 }
 if (!(outfile = fopen(outname, wb))) {
-fprintf(stderr, Cannot open file for writting\n);
+fprintf(stderr, Cannot open file \%s\ for writing\n, outname);
 exit(1);
 }
 s = srcStream.getStream();



-- 
Olaf Weber

   (This space left blank for technical reasons.)




[pdftex] Re: pdftosrc seg faults

2003-01-26 Thread Reinhard Kotucha
 Olaf == Olaf Weber [EMAIL PROTECTED] writes:

 The full patch now becomes:

Thanks!

   Reinhard

-- 

Reinhard Kotucha Phone: +49-511-27060390
Marschnerstr. 25
D-30167 Hannover  mailto:[EMAIL PROTECTED]

Microsoft isn't the answer. Microsoft is the question, and the answer is NO.






Re: [pdftex] pdftosrc seg faults

2003-01-23 Thread John Culleton
On Wednesday 22 January 2003 22:06, Reinhard Kotucha wrote:
 Hi,
 when I run pdftosrc on a pdf file made from the input file

 --
 \pdfcompresslevel=0
 \immediate\pdfobj stream
   attr {/Type /SourceFile /SourceName (\jobname.src)}
   file {\jobname.tex}
 \immediate\pdfcatalog{/SourceObject \the\pdflastobj\space 0 R}

 \bye
 --

 pdftosrc aborts with a segmentation fault.

-- 
Have you tried ps2ascii? Despite the name it works on pdf too. 

John Culleton
Subscribe now to Self Publisher's Newsletter! 
No hassle! Send email to mailto:[EMAIL PROTECTED]. 



pdftosrc seg faults

2003-01-22 Thread Reinhard Kotucha
Hi,
when I run pdftosrc on a pdf file made from the input file

--
\pdfcompresslevel=0
\immediate\pdfobj stream
  attr {/Type /SourceFile /SourceName (\jobname.src)}
  file {\jobname.tex}
\immediate\pdfcatalog{/SourceObject \the\pdflastobj\space 0 R}

\bye
--

pdftosrc aborts with a segmentation fault.

I'm using pdftex 1.10a, pdftosrc 2.01 and teTeX-2.0-rc1 under Linux.

The pdf file doesn't look bad and I can extract the with a Perl script
someone posted to this list abt. two years ago.

Regards,
  Reinhard

-- 

Reinhard Kotucha Phone: +49-511-27060390
Marschnerstr. 25
D-30167 Hannover  mailto:[EMAIL PROTECTED]

Microsoft isn't the answer. Microsoft is the question, and the answer is NO.