;*; Updated on 06-Dec-91 at 10:26 AM by Michele Tonti; edit time: 0:00:28
;*************************** AMUS Program Label ******************************
; Filename: LFCRLF.M68                                      Date: 12/6/91
; Category: UTIL         Hash Code: 563-465-400-247      Version:
; Initials: KUNI/AM      Name: RENE S HOLLAN
; Company: UDISCO LTD.                             Telephone #: 5144818107
; Related Files:
; Min. Op. Sys.:                               Expertise Level:
; Special:
; Description: Convert LFs in input file to CRLFs in output file.
;
;
;*****************************************************************************
;*************************************************************************
;*                                                                       *
;*                      LFCRLF   COMMAND PROGRAM - Ver. 1.0              *
;*                                                                       *
;*************************************************************************
;
;                                   NOTICE
;
;All    rights   reserved.  This software is the property of UDISCO LTD.  and
;the material contained herein is  the   proprietary   property   and   trade
;secrets    of    UDISCO  LTD.,  embodying  substantial  creative efforts and
;confidential information, ideas and expressions, no part of  which  may   be
;reproduced   or  transmitted  in  any  form  or  by  any  means, electronic,
;mechanical,  or  otherwise,  including  photocopying  or  input  into    any
;information   storage  or  retrieval  system  without  the  express  written
;permission of UDISCO LTD.
;
;Permission to copy and use is granted to AMUS members for non commercial
;purposes only.
;
;
;       LFCRLF:         Program to convert input files with LFs to output
;               files with CRLFs.
;
;       Author: Rene S. Hollan
;
;       COPYRIGHT (C) 1986 - Udisco Ltd., Montreal, Canada.
;
; Edit History
; ------------
;
; [100] 18 Sept. 1986
;       Coding starts. /RSH
;
;

       SEARCH  SYS
       SEARCH  SYSSYM

LF      =       10.                     ; line feed
CR      =       13.                     ; carriage return

OFINI
OFDEF   IDDB,D.DDB                      ; input DDB
OFDEF   ODDB,D.DDB                      ; output DDB
OFSIZ   IMPSIZ                          ; impure area size

VMAJOR=1                                ; major version
VMINOR=0                                ; minor version
VSUB=0                                  ; sub version
VEDIT=100.                              ; edit version

LFCRLF: PHDR    -1,,PH$REU!PH$REE       ; program header
       GETIMP  IMPSIZ,A0               ; A0 --> impure area
       BYP                             ; skip blanks
       MOV     A2,A3                   ; save input line pointer
       FSPEC   IDDB(A0)                ; FSPEC input DDB
       BYP                             ; skip blanks
       TRM                             ; are we at end of line?
       BNE     10$                     ; not yet

5$:     MOV     A3,A2                   ; restore file name

10$:    FSPEC   ODDB(A0),LST            ; FSPEC output DDB
       INIT    ODDB(A0)                ; and INIT it
       INIT    IDDB(A0)                ; INIT input DDB

       OPENI   IDDB(A0)                ; open input file
       OPENO   ODDB(A0)                ; open output file

20$:    FILINB  IDDB(A0)                ; get number of rows
       TST     IDDB+D.SIZ(A0)          ; end of file?
       BEQ     90$                     ; yup!

       MOVB    D1,D0                   ; D0 = byte
       ANDB    #177,D0                 ; strip parity
       CMPB    D0,#LF                  ; is it a line feed?
       BNE     30$                     ; nope

       MOVB    D1,D0                   ; save byte
       MOVB    #CR,D1                  ; send a CR
       FILOTB  ODDB(A0)                ; ...
       MOVB    D0,D1                   ; restore byte

30$:    FILOTB  ODDB(A0)                ; output byte
       BR      20$

90$:    CLOSE   IDDB(A0)                ; close files
       CLOSE   ODDB(A0)                ; ...
       EXIT

       END