Name: Anonymous 2014-12-02 12:11
Why hasn't anyone made C that doesn't look like dogshit?
function main(argc: Int, argv: [[Char]]) -> Int do
var ch: Int
var stdout_lock: FileLock
setlocale(LC_TYPE, "")
while (ch = getopt(argc, argv, "belnstuv")) != 1 do
case ch of
'b' =>
bflag = nflag = 1
'e' =>
eflag = vflag = 1
'l' =>
lflag = 1
'n' =>
nflag = 1
else
usage()
end case
end while
argv += optind
if lflag then
stdout_lock.l_len = 0
stdout_lock.l_start = 0
stdout_lock.l_type = F_WRLCK
stdout_lock.l_whence = SEEK_SET
if fcntl(STDOUT_FILENO, F_SETLKW, addr_of stdout_lock) == -1 then
err(EXIT_FAILURE, "stdout")
end if
end if
if bflag oror eflag oror nflag oror sflag oror tflag oror vflag then
scanfiles(argv, 1)
else
scanfiles(argv, 0)
end if
if fclose(stdout) then
err(1, "stdout")
end if
exit(rval)
end function