!+ ! FIX_CRLF.TPU - Routine to turn CRLFs into line breaks ! and remove leading CRs and trailing CRLFs ! ! Taken from DECUS tape, modified to be a stand-alone procedure ! B. Z. Lederman 15-Jul-1987 !- PROCEDURE fix_crlf LOCAL the_range, save_position, crlf_count ; ON_ERROR IF (ERROR <> TPU$_STRNOTFOUND) THEN MESSAGE ("Error (" + STR(ERROR) + ") at line " + STR(ERROR_LINE)); RETURN; ENDIF; ENDON_ERROR; MESSAGE ("Converting s in buffer"); crlf_count := 0; ! ! Remove naked CRs. ! POSITION (BEGINNING_OF (main_buffer)); LOOP the_range := SEARCH (ASCII(13), FORWARD); EXITIF (the_range = 0); POSITION (END_OF (the_range)); ERASE (the_range); crlf_count := crlf_count+1; ENDLOOP; MESSAGE (FAO ("Removed s at !UL positions", crlf_count)); ENDPROCEDURE input_file := GET_INFO (COMMAND_LINE, 'FILE_NAME'); main_buffer := CREATE_BUFFER ('MAIN', input_file); fix_crlf; WRITE_FILE (main_buffer, input_file); QUIT;