
-- sprintf implemented using doprnt as a building block
-- Written by Adrian Cockcroft, adrian.cockcroft@gmail.com
-- doprnt and atov originally coded in 1988, updated in 2005

--** @module fmtout

#USE "doprnt.tce"

--{{{ sprintf variants
-- sprintf an int and two strings
PROC sprintf.iss ([]BYTE result, VAL []BYTE format, VAL INT i1, VAL []BYTE s2, s3)
  INITIAL INT flen IS 0: -- flen is how much of format has been used
  INITIAL INT rlen IS 0:  -- rlen is how much has been put into result
  SEQ
    doprnt.i(format,flen,result,rlen,i1)
    doprnt.s(format,flen,result,rlen,s2)
    doprnt.s(format,flen,result,rlen,s3)
:
-- sprintf length, two ints and a string
PROC sprintf.liis ([]BYTE result, INT rlen, VAL []BYTE format, VAL INT i1, i2, VAL []BYTE s3)
  INITIAL INT flen IS 0: -- flen is how much of format has been used
  SEQ
    rlen := 0
    doprnt.i(format,flen,result,rlen,i1)
    doprnt.i(format,flen,result,rlen,i2)
    doprnt.s(format,flen,result,rlen,s3)
:
--}}}


