Initial revision

This commit is contained in:
ceriel
1987-03-31 12:14:08 +00:00
parent 8b90e3480a
commit e97f144bf4
3 changed files with 138 additions and 0 deletions

40
include/occam/prints.ocm Normal file
View File

@@ -0,0 +1,40 @@
proc prints(chan out, value fmt[], str[]) =
-- Like fprintf(out, fmt, str), with only %s or %<width>s in fmt[]
def otherwise=true:
var i, len:
seq
len:=fmt[byte 0]
i:=1
while i<=len
if
fmt[byte i] = '%'
var w:
seq
i:=i+1
w:=0
while (i<=len) and ('0'<=fmt[byte i]) and (fmt[byte i]<='9')
seq
w:=(w*10)+(fmt[byte i]-'0')
i:=i+1
if
i<=len
var key:
seq
key:=fmt[byte i]
if
key='s'
seq
seq i=[0 for w-str[byte 0]]
out ! ' '
seq i=[0 for str[byte 0]]
out ! str[byte i]
otherwise
out ! key
i:=i+1
otherwise
seq
out ! fmt[byte i]
i:=i+1
: