Delila Program: emptytest

emptytest program

Documentation for the emptytest program is below, with links to related programs in the "see also" section.

{   version = 2.03; (* of emptytest.p 2005 Sep 13}

(* begin module describe.emptytest *)
(*
name
   emptytest: Test for file empty

synopsis
   emptytest(empty: in, notempty: in, output: out)

files

   empty:  an empty file.  There should be no characters in this file.
      You can create it under Unix with:
         echo -n "" > empty
      or if there is none before,
         touch empty

   notempty:  any file with at least one character

      You can create it under Unix with:
         echo -n "some text" > empty

description

   The GPC compiler has a serious bug in it.  When one resets an empty
   file, it is not eof.

   In contrast, the p2c translator/compiler works perfectly.

   So this program provides a routine, emptyfile, that tests for eof
   and responds properly.  The method is to count the actual number of
   characters in the file.

examples

Results from p2c:

----  emptytest: -------------------------
empty file is eof ......... OK!
notempty file is not eof .. OK!
----  test emptyfile:
lines = 0
chars = 0
empty file is empty
lines = 0
chars = 1
notempty file is not empty
------------------------------------------

So p2c works perfectly.

Results from GPC:

----  emptytest: -------------------------
empty file is not eof ..... OOPS!
notempty file is not eof .. OK!
----  test emptyfile:
lines = 1
chars = 0
empty file is empty
lines = 0
chars = 1
notempty file is not empty
------------------------------------------

So GPC failed to detect the eof correctly and thought that there was
one line in the empty file.  FORTUNATELY counting characters works.

There are at least three ways to test for a file in Unix:

  ls -l
  wc
  file

These can be used to PROVE that the file is empty.  A script,
emptyunixtests, can be used to check the files.  The results are:

version = 1.00 of emptyunixtests 2005 Sep 13
tests for empty file:

% ls -l empty
-rw-------   1 toms     delila         0 Jan 27  2005 empty

% wc empty
       0       0       0 empty

% file empty
empty:          empty file

------
tests for notempty file:

% ls -l notempty
-rw-------   1 toms     delila        29 Sep 13 19:04 notempty

% wc notempty
       1       5      29 notempty

documentation

see also

   GPC discussion, patch given:
   http://www.gnu-pascal.de/crystal/gpc/en/mail11285.html

   GPC Gnu Pascal Compiler:
   http://www.ccrnp.ncifcrf.gov/~toms/pascalgpc.html

   P2C Pascal Translator and Compiler:
   http://www.ccrnp.ncifcrf.gov/~toms/pascalp2c.html

   The alist program was messed up by this bug:
   http://www.lecb.ncifcrf.gov/~toms/delila/alist.html

   Three tests for files named empty and notempty
   determine if the files are empty or not:
   emptyunixtests

   empty file:
   empty

   not empty file:
   notempty

author

   Thomas Dana Schneider

bugs

technical notes

*)
(* end module describe.emptytest *)
{This manual page was created by makman 1.44}
{created by htmlink 1.55}
National Cancer Institute    National Institutes of Health    Health and Human Services    USA Gov - Official Web Portal    Viewing Files    Accessibility