Converting DOS text files

Melinda Shore shore at mtxinu.COM
Fri Oct 19 11:27:22 AEST 1990


In article <4339 at rsiatl.UUCP> jgd at rsiatl.UUCP (John G. DeArmond) writes:
>While one could (successfully) argue that a system() or fork() system
>call would be more expensive than processing small files a byte at a time,
>for typical files, this would not be the case.  And for machines that
>process I/O system calls slowly (NCR towers come to mind), even small
>files would seriously degrade performance, especially if you are doing
>a lot of them.

I'm not going to get into whether or not the program was great code,
but it's worth pointing out that using stdio *is* a reasonably
efficient general-case approach.  Remember that the library is doing
i/o buffering for you in BUFSIZ chunks, which allows you to do
what looks like single-character processing on top of buffered i/o.
Also, underneath it all, the OS is not going to be doing a disk
read for every read() - that's what the buffer cache is all about.
(It may do a memory/memory copy, but that's another matter.)
Anyway, the point is that you shouldn't be afraid to use stdio
if you're worried about efficiency.

I never use the system() library routine on SCO.  Well, I never use
it anyway (it gets the shell involved and does more than I usually
want done), but it seems to me that it's particularly to be avoided
with SCO because of the way it resets certain signal handlers, in
particular SIGCLD.  You can avoid doing the copy yourself if the
files are on the same filesystem by doing something like
	link(oldfile, newfile);
	unlink(oldfile);
If the files are on different filesystems somebody is going to
have to do the copy, whether it's mv or you do it yourself.  Again,
stdio will handle the buffering for you and doing getc()/putc()
kinds of things isn't inherently inefficient.
-- 
Melinda Shore                                 shore at mtxinu.com
mt Xinu                              ..!uunet!mtxinu.com!shore



More information about the Comp.unix.sysv386 mailing list