[comp.lang.postscript] how to read stdin?

jesper@diku.dk (Jesper L. Lauritsen) (05/31/91)

Can someone tell me how to read standard input so CR LF does not get translated
to LF?
Thanks in advance.

--Jesper

--------------------
Jesper L. Lauritsen, systems programmer
ibtjll@vm.ibt.dk    (BITNET/EARN: IBTJLL AT DKIBT)
Center for Applied Datalogy, University of Copenhagen

maceache@fox.nstn.ns.ca (Tim Maceachern) (05/31/91)

jesper@diku.dk (Jesper L. Lauritsen) writes:

>Can someone tell me how to read standard input so CR LF does not get translated
>to LF?
>Thanks in advance.

>--Jesper

>--------------------
>Jesper L. Lauritsen, systems programmer
>ibtjll@vm.ibt.dk    (BITNET/EARN: IBTJLL AT DKIBT)
>Center for Applied Datalogy, University of Copenhagen

If this is possible, I'd like to hear the method as well.  It would be
a convenience to have this transparent input capability to allow users
to write printer-emulators.  I was unable to proceed on a project that
would simply print dumb-LP type PC documentation because CR/LF for normal
text is indistinquishable from CR alone for underlining.

By the way, this work was on a QMS 800 II

    Tim MacEachern     Software Kinetics Ltd.     Dartmouth, Nova Scotia
                     maceache@corp.nstn.ns.ca   or maceache@fox.nstn.ns.ca

vsarkela@csc.fi (06/04/91)

In article <1991May31.105841.13048@odin.diku.dk>, 
jesper@diku.dk (Jesper L. Lauritsen) writes:
> Can someone tell me how to read standard input so CR LF does not get translated
> to LF?
> Thanks in advance.
> 
> --Jesper
> 
> --------------------
> Jesper L. Lauritsen, systems programmer
> ibtjll@vm.ibt.dk    (BITNET/EARN: IBTJLL AT DKIBT)
> Center for Applied Datalogy, University of Copenhagen

We have used this filter when printing a file from a PC to postscript
printer on a ultrix machine. 


/* This is a simple filter, which puts carriage returns (13 dec, 015 oct, */
/*  0xD hex) before each new line (line feed = 10 dec, 012 oct, 0xA hex)  */
/*  and after control-d ( 4 dec) and strips any possible control-z's (DOS */
/*  end-of-file marks) off                                                                                                                        */

#include <stdio.h>

int
main(argc, argv)
int argc;
char *argv[];
{
        register int c;      /* incoming char */

        while ((c=getchar()) != EOF) {
                if(c == 26) continue; /* control-z */
                if(c == 4) {          /* control-d */
                        puts("\004\r");
                        continue;
                }
                if(c == '\n') {          /* line feed */
                        puts("\r");      /* puts appends newline */
                        continue;
                }
                putchar(c);
        }/* while */
        return(0);
}

-- Vesa Sarkela    Finnish Pulp and Paper Research Institute

jesper@diku.dk (Jesper L. Lauritsen) (06/13/91)

Thank you to everybody who replied to my question about how to stdin without
getting CR+LF translated to LF.
The replies defenitly did not agree, but I have my self done a litle additional
manual reading and some testing.
Data read by "read" or "readsting" *should* not undergo EOL translating.
But on several PostScript printers "read" and "readstring" does do EOL trans-
lating! On these printers I do not know how to avoid EOL translating.
I do not know if this is connected to any special PostScript versions or any
special brands of PostScript printers.

Again, thanks to everybody who replied to my question. My saved old artikels
and mail notes has turned into a mess so I hope you forgive me for not
thanking you personally.

--Jesper

---------------------
Jesper L. Lauritsen, systems programmer
Center for Applied Datalogy, University of Copenhagen
ibtjll@vm.ibt.dk