/* fat.cmd */

files = 'bool.h builtinbuf.h CursesW.h defines.h iostream.h libio.h minmax.h'
files = files||' parsestream.h procbuf.h RNG.h std.h streambuf.h'
files = files||' gen\SplayNode.ccP'

'@echo off'

if stream('getpagesize.h', 'C', 'QUERY EXISTS') == '' then do
  say 'Already done'
  exit
end

do i = 1 to words(files)
  file = word(files, i)
  say 'Patching' file
  'sed -f fat.sed >tmp' file
  if rc \= 0 then do
    say 'sed failed!'
    exit
  end
  'del' file
  'move tmp' file '>nul'
end

say 'Renaming files'
'ren _G_config.h _G_confi.h'
'ren AllocRing.h AllocRin.h'
'ren BitString.h BitStrin.h'
'ren builtinbuf.h builtinb.h'
'ren getpagesize.h getpages.h'
'ren Incremental.h Incremen.h'
'ren indstream.h indstrea.h'
'ren parsestream.h parsestr.h'
'ren stdiostream.h stdiostr.h'
'ren streambuf.h streambu.h'
'ren strstream.h strstrea.h'
'ren typemacros.h typemacr.h'
'ren gen\SplayNode.ccP SplayNod.ccP'
'ren gen\SplayNode.hP SplayNod.hP'

say 'Done'
