# $Id: wc.pliant,v 1.0 2002/02/11 17:03:00 dada Exp $ # http://dada.perl.it/shootout/ module "/pliant/language/unsafe.pli" module "/pliant/language/context.pli" module "/pliant/language/stream.pli" module "/pliant/language/os.pli" gvar Str line := "" gvar Address Buf gvar Int ReadSize := 4096 gvar Int i gvar Int nl := 0 gvar Int nw := 0 gvar Int nc := 0 gvar Char ch gvar Int j gvar CBool state := false gvar CBool ok gvar Int ReadCount gvar Int s := os_GetStdHandle -10 Buf := memory_allocate ReadSize+1 null ok := os_ReadFile s Buf ReadSize ReadCount null while ok and ReadCount > 0 line set Buf ReadCount false nc := nc + (line len) i := 0 while i<line:len ch := line:i if ch="[lf]" nl += 1 if ch=" " or ch="[tab]" or ch="[lf]" state := false eif state = false nw += 1 state := true i += 1 ok := os_ReadFile s Buf ReadSize ReadCount null console nl " " nw " " nc eol