# include main (ac, av) char **av; { static i; if (ac == 1) sum ("-"); else for (i = 1; i < ac; i++) sum (av[i]); } sum (a) { static f; static total; if (cmpstr (a, "-")) f = STDIN; else f = open (a, READ); if (f < 0) { # ifdef unix perror (a); # else put (a); put (": Can't read\n"); # endif return; } total = 0; for (;;) { char buf [BUFSIZE]; static int j, n, *i; n = read (f, buf, BUFSIZE); if (n < 0) { # ifdef unix perror (a); # else put (a); put (": Read error\n"); # endif break; } if (n == 0) break; if (n & 1) /* odd no. of chars */ buf[n++] = 0; for (i = buf; i < &buf[n]; i++) total += *i; } print (total, a); if (f != STDIN) close (f); } print (a, b) unsigned a; char *b; { nprint (a); put (" "); put (b); put ("\n"); } put (a) { write (STDOUT, a, lenstr (a)); } nprint (a) { char buf [16]; static i; buf [itob (buf, a, 10)] = NULL; for (i = 5 - lenstr (buf); i > 0; i--) put (" "); put (buf); }