/* hpfs.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('getpages.h', 'C', 'QUERY EXISTS') == '' then do
  say 'Already done'
  exit
end

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

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

say 'Done'
