



." rename *.cpp to  *.c  and   *.hpp to *.h file " cr

."  2025-10-25" cr


: crlf" ( -- c-addr, u )
  0x0d char>"
  0x0a char>"  Join"
;

variable tab_count_modifier
variable tab_count
  
0 tab_count !

 variable case_flag
 0 case_flag  !

variable src_stream         \ source file stream id

variable dst_stream         \ destination file stream id


0x500 sizeof(char) * value sizeof(buffer)
create buffer
sizeof(buffer) 1 + allot
 
 
variable line_length
variable line_start 
variable line_end
variable type_leading 
variable dummy_line 
0 value front_char 
0 value last_char 

 variable fileCount
 variable lineCount
 variable charCount

: leading_rubbish
  line_length @
  IF
     begin

       line_start @ @char
       CASE
         0x09 OF  1 ENDOF
         0x20 OF  1 ENDOF
         0
       ENDCASE
       IF   sizeof(char) line_start +!    -1 line_length +!                false ELSE true THEN
       
       line_length @ IF ELSE drop true THEN 
       
       
     until
  THEN
;
: trailing_rubbish
  line_length @
  IF
 
    
        line_start @  line_length @  1 -   sizeof(char) *  +
    begin
      dup @char
      CASE

      bl  
      OF  
        dup 0 swap !char 
       sizeof(char) -   \ move ptr back one
       -1 line_length +!  \ decrement line length
       line_length @ 
      ENDOF

     0x09 
      OF  
        dup 0 swap !char 
       sizeof(char) -   \ move ptr back one
       -1 line_length +!  \ decrement line length
       line_length @ 
      ENDOF
      
      1
     ENDCASE
     
    UNTIL
    drop
  THEN
;



: get_last ( --   last char before EOL )
  line_start @ line_end !
  0 to last_char 
  begin
    line_end @ @char dup
    IF 
      to last_char
      sizeof(char) line_end +!
      false 
    ELSE 
      drop
       true
    THEN
  until
;

: send-to-file ( c-addr , u -- )

." -- " cr


  2dup 0 DO
    dup @char .hex sizeof(char) + 
    LOOP drop cr
    


    s">achar"
    
      2dup 0 DO
    dup @byte .hex 1 + 
    LOOP drop cr
  
 
   dst_stream @
   file=buffer
   drop
   

;
 

 : send-to-file ( c-addr , u -- )

 

    s">achar"
 
 
   dst_stream @
   file=buffer
   drop
   

;
 

: process ( c-addr , u --)
 
   2na: src
  
   
    src    2dup   type ."   "      
 	 src   s" pp" join"       2dup   type ."   "   
 
     rename-file   .hex cr
 
 

;

  

: dir ( c-addr , u -- )
  file.find=open   dup
  begin                \ enter loop with ( search-id, search-id ) 
      dup -1 =   0=    \ test for no file found  (search-id, bool)
    while              \ jumps over the repeat if  bool  is zero/false
      dup              \ search-id  search-id 
      file.found@name  \ get name of found file (search-id, c-addr, u)  
      process          \ display name (search-id)
      file.find=next   \ go get next file (a new search-id)
  repeat
                       \ search-id  -1
  drop file.find=close \ give search resources back !
;

 s" *.c"  dir      
