!+ ! FIX_CRLFS.TPU - Routine to turn CRLFs into line breaks ! and remove leading CRs and trailing CRLFs !- PROCEDURE decus$fix_crlfs LOCAL the_range; on_error if (error <> TPU$_STRNOTFOUND) then MESSAGE ("Error (" + STR (error) + ") at line " + STR (error_line)); return; endif; endon_error; ! ! First remove the CRLFs. If they are not at the EOL, add a line break. ! MESSAGE ("Removing CR/LF's from current buffer..."); POSITION (BEGINNING_OF (CURRENT_BUFFER)); loop the_range := SEARCH (ASCII(13) + ASCII(10), forward); exitif (the_range = 0); ERASE (the_range); POSITION (BEGINNING_OF (the_range)); if (CURRENT_CHARACTER <> "") then SPLIT_LINE; endif; endloop; ! ! Next remove naked LFs. If they are not at the EOL, add a line break. ! POSITION (BEGINNING_OF (CURRENT_BUFFER)); loop the_range := SEARCH (ASCII(10), forward); exitif (the_range = 0); ERASE (the_range); POSITION (BEGINNING_OF (the_range)); if (CURRENT_CHARACTER <> "") then SPLIT_LINE; endif; endloop; ! ! Finally, remove naked CRs. If they are not at the BOL, add a line break. ! POSITION (BEGINNING_OF (CURRENT_BUFFER)); loop the_range := SEARCH (ASCII(13), forward); exitif (the_range = 0); POSITION (END_OF (the_range)); if (CURRENT_OFFSET <> 0) then SPLIT_LINE; endif; ERASE (the_range); endloop; MESSAGE (''); ENDPROCEDURE;