home *** CD-ROM | disk | FTP | other *** search
- Path: wuarchive!mailrus!uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!bbn.com!rsalz
- From: rsalz@uunet.uu.net (Rich Salz)
- Newsgroups: comp.sources.unix
- Subject: v20i022: POSIX 1003.1 #include file tester, Patch1
- Message-ID: <1981@prune.bbn.com>
- Date: 21 Sep 89 19:42:52 GMT
- Lines: 614
- Approved: rsalz@uunet.UU.NET
-
- Submitted-by: Barry Books <bbooks@aixsm.austin.ibm.com>
- Posting-number: Volume 20, Issue 22
- Archive-name: posix.h-tester.pch
- Patch-To: posix.h-tester: Volume 20, Issue 1
-
- The POSIX include file tester archive was truncated some where
- along the way. Here are the missing files along with one other
- to fix a typo.
-
- Thanks,
- Barry Books
-
-
- # This is a shell archive. Remove anything before this line,
- # then unpack it by saving it in a file and typing "sh file".
- # Contents: include1.0/ include1.0/types/ include1.0/types/wait
- # include1.0/typedef include1.0/typedef.awk include1.0/ctypes
- # include1.0/report.t include1.0/tr.testrig include1.0/functions
-
- echo mkdir - include1.0
- mkdir include1.0
- chmod u=rwx,g=rx,o=rx include1.0
-
- echo mkdir - include1.0/types
- mkdir include1.0/types
- chmod u=rwx,g=rx,o=rx include1.0/types
-
- echo x - include1.0/types/wait
- sed 's/^@//' > "include1.0/types/wait" <<'@//E*O*F include1.0/types/wait//'
-
- @//E*O*F include1.0/types/wait//
- chmod u=rw,g=r,o=r include1.0/types/wait
-
- echo x - include1.0/typedef
- sed 's/^@//' > "include1.0/typedef" <<'@//E*O*F include1.0/typedef//'
- #
- #**********************************************************************
- # THERE MUST BE A SPACE in the first character of the first line.
- #**********************************************************************
- #
- # NOTICE STATEMENT
- #
- # This code was developed by IBM Corporation. Copyright is disclaimed.
- #
- # IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS CODE. IN NO EVENT
- # WILL IBM BE LIABLE FOR ANY DAMAGES, LOST PROFITS, OR LOST SAVINGS.
- #
- # "@(#) This code was developed by IBM Corporation. "
- # "@(#) Copyright is disclaimed. "
- #
- #**********************************************************************
- # Written by: Barry Books
- #**********************************************************************
-
- #
- # copy the .h to a .c for C compiler
- TMP=`$MKTEMP`
- touch $TMP.c
- cp $1 $TMP.c
-
- # compile the file with _POSIX_SOURCE defined
- # put space around ( ) and *
- # change all white space to newline so one token per line
- # run awk to find typedefs
- cc -D _POSIX_SOURCE -E $TMP.c | sed 's/(/ ( /g; s/)/ ) /g; s/\*/ * /g' | tr -s " " "\012\012" | awk -f typedef.awk | ./report -t $1
-
- #clean up
- rm -f $TMP.c
- @//E*O*F include1.0/typedef//
- chmod u=rwx,g=rx,o=rx include1.0/typedef
-
- echo x - include1.0/typedef.awk
- sed 's/^@//' > "include1.0/typedef.awk" <<'@//E*O*F include1.0/typedef.awk//'
- #
- #**********************************************************************
- # THERE MUST BE A SPACE in the first character of the first line.
- #**********************************************************************
- #
- # NOTICE STATEMENT
- #
- # This code was developed by IBM Corporation. Copyright is disclaimed.
- #
- # IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS CODE. IN NO EVENT
- # WILL IBM BE LIABLE FOR ANY DAMAGES, LOST PROFITS, OR LOST SAVINGS.
- #
- # "@(#) This code was developed by IBM Corporation. "
- # "@(#) Copyright is disclaimed. "
- #
- #**********************************************************************
- # Written by: Barry Books
- #**********************************************************************
-
- # state machine to find typedefs
- # order is important
-
- BEGIN {
- STRUCT=0;
- OPEN = 0;
- SEMI = 0;
- SQRB = 0;
- TYPEDEF = 0;
- }
-
- #toss some keywords
- /unsigned/ {
- next;
- }
-
- /extern/ {
- SEMI = 0;
- next;
- }
-
- /signed/ {
- next;
- }
-
- /\(/ {
- next;
- }
-
- /\)/ {
- next;
- }
-
- #attempt to fix typedef thing[num]; problem
- #this didn't work
- /\[/ {
- SQRB += 1;
- }
-
- /\]/ {
- SQRB -= 1;
- }
-
- #keep track of braces
- /{/ {
- OPEN += 1;
- next;
- }
-
- /}/ {
- OPEN -= 1;
- next;
- }
-
- # semi colon is end of statement
- # save the names and the next token will print the results
- # this takes care of both cases
- # typedef thing;
- # typedef thing ;
- #this should have be done with sed to make everything
- # typedef thing ;
- # maybe next time
- /;/ {
- if ( OPEN > 0 )
- next;
- else
- {
- SEMI = 1;
- if ( length($1) > 1 )
- {
- TMPNAME=substr($1,1,length($1)-1);
- if ( TMPNAME !~ /]/ )
- NAME=TMPNAME;
- }
- }
- }
-
- # this matches everything
- # if its a typedef print the results and reset the flags
- /^/ {
- if ( TYPEDEF == 1 )
- {
- if ( SEMI == 1 )
- {
- printf("%s\n",NAME);
- SEMI = 0;
- TYPEDEF = 0;
- }
- else
- {
- if ( SQRB = 0 )
- NAME = $1;
- next;
- }
- }
- }
-
- #keep tract of these keywords
- /typedef/ {
- TYPEDEF=1;
- SEMI=0;
- next;
- }
-
- /struct/ {
- STRUCT=1;
- SEMI=0;
- next;
- }
-
-
- @//E*O*F include1.0/typedef.awk//
- chmod u=rw,g=r,o=r include1.0/typedef.awk
-
- echo x - include1.0/ctypes
- sed 's/^@//' > "include1.0/ctypes" <<'@//E*O*F include1.0/ctypes//'
- char
- double
- float
- int
- long
- short
- @//E*O*F include1.0/ctypes//
- chmod u=rw,g=r,o=r include1.0/ctypes
-
- echo x - include1.0/report.t
- sed 's/^@//' > "include1.0/report.t" <<'@//E*O*F include1.0/report.t//'
-
-
-
- Report on POSIX Include File Conformance
-
- Overview
- This document reports objects in include files which do not
- meet the POSIX 1003.1 specification. This is intended as a
- tool more than a conformance test and is distributed to aid
- in reaching a consensus on what should be and should not be
- included in a POSIX 1003.1 conforming include file.
-
- Requirements
- The standard specifies the contents of include files in two
- ways first by stating items which must be included and
- second allowing for other items as long as they meet certain
- criteria. No other objects are allowed when _POSIX_SOURCE
- is defined ( 1003.1 2.82. ). The following is a list of
- objects not specifically mentioned in the standard but still
- allowed.
- 1. All external identifiers that begin with an
- underscore are reserved ( POSIX 1003.1 2.8.1
- ).
- 2. All other identifiers that begin with an
- underscore and either an uppercase letter or
- another underscore are reserved ( POSIX
- 1003.1 2.8.1 ).
- 3. Namespaces reserved by the C Standard are also
- reserved ( POSIX 1003.1 2.8.1 ).
- 4. Types ending in _t are reserved ( POSIX 1003.1
- 2.6 ).
- 5. Implementations may add members to a structure or
- union ( POSIX 1003.1 2.8.2 ). These members
- must have either standard C types or types
- ending in _t ( implied by 4 ).
- 6. Additional macro definitions, beginning with E
- and a digit or E and an upper-case letter may
- also be specified by the implementation (
- ANSI 4.1.3 ).
- 7. Additional signals and pointers to undeclarable
- functions, with definitions beginning,
- respectively, with letters SIG and an upper-
- case letter or with SIG_ and an upper-case
- letter may also be specified by the
- implementation ( ANSI 4.7 ).
- 8. Headers may be included in any order and more
- than once with no effect different from being
- included only once, except for assert.h (
- ANSI 4.1.1 ).
-
- Interpreting The Results
- The results from each include file are divided into three
- categories: defines, structures and typedefs. If an include
- file is missing it is marked missing and the tests for that
- include file are skipped.
-
- Defines
- The defines section contains four columns. The "extra"
- column contains defines not allowed by the standard. These
- items should be moved outside the scope _POSIX_SOURCE
- feature test macro. The "other" column contains items not
- specifically mentioned for this particular include file but
- allowed by the standard. The "missing" column contains
- items required by the standard but not found in the include
- files. This column is used as a debugging aid as the test
- suites can find these problems quite easily. You should not
- find items in this column that are in your include files.
- The last column is the "macros" column. This column
- contains a list of functions that are defined as macros.
-
- Structures
- The structure section contains two columns. The first
- column contains any structures not specified by the POSIX
- 1003.1 or the ANSI C standard. The second column contains
- structure elements not allowed by the 1003.1 standard.
-
- Typedefs
- The typedef section is similar to the define section. The
- first column contains typedefs not allowed by the 1003.1
- standard. The next column contains typedefs required in
- other include files and the final column contains typedefs
- that are missing.
-
- @//E*O*F include1.0/report.t//
- chmod u=rw,g=r,o=r include1.0/report.t
-
- echo x - include1.0/tr.testrig
- sed 's/^@//' > "include1.0/tr.testrig" <<'@//E*O*F include1.0/tr.testrig//'
- #
- #**********************************************************************
- # THERE MUST BE A SPACE in the first character of the first line.
- #**********************************************************************
- #
- # NOTICE STATEMENT
- #
- # This code was developed by IBM Corporation. Copyright is disclaimed.
- #
- # IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS CODE. IN NO EVENT
- # WILL IBM BE LIABLE FOR ANY DAMAGES, LOST PROFITS, OR LOST SAVINGS.
- #
- # "@(#) This code was developed by IBM Corporation. "
- # "@(#) Copyright is disclaimed. "
- #
- #**********************************************************************
- # Written by: Barry Books
- #**********************************************************************
-
- # if your are missing tr
- awk '{ for (i = 1; i <= NF; i++ ) {print $i}}'
- @//E*O*F include1.0/tr.testrig//
- chmod u=rwx,g=rwx,o=rwx include1.0/tr.testrig
-
- echo x - include1.0/functions
- sed 's/^@//' > "include1.0/functions" <<'@//E*O*F include1.0/functions//'
- assert
- isalnum
- isalpha
- iscntrl
- isdigit
- isgraph
- islower
- isprint
- ispunct
- isspace
- isupper
- isxdigit
- tolower
- toupper
- setlocale
- localeconv
- acos
- asin
- atan
- atan2
- cos
- sin
- tan
- cosh
- sinh
- tanh
- exp
- frexp
- ldexp
- log
- log10
- modf
- pow
- sqrt
- ceil
- fabs
- floor
- fmod
- setjmp
- longjmp
- signal
- raise
- va_start
- va_arg
- va_end
- remove
- rename
- tmpfile
- tmpnam
- fclose
- fflush
- fopen
- freopen
- setbuf
- setvbuf
- fprintf
- fscanf
- printf
- scanf
- sprinf
- sscanf
- vfprintf
- vprintf
- vsprintf
- fgetc
- fgets
- fputc
- fputs
- getc
- getchar
- gets
- putc
- putchar
- puts
- ungetc
- fread
- fwrite
- fgetpos
- fseek
- fsetpos
- ftell
- rewind
- clearerr
- feof
- ferror
- perror
- atof
- atoi
- atol
- strtod
- strtol
- strtoul
- rand
- srand
- calloc
- free
- malloc
- realloc
- abort
- atexit
- exit
- getenv
- systems
- bsearch
- qsort
- abs
- div
- labs
- ldiv
- mblen
- mbtowc
- wctomb
- mbstowcs
- wcstombs
- memcpy
- memmove
- strcpy
- strncpy
- strcat
- strncat
- memcmp
- strcmp
- strcol
- strncmp
- strxfrm
- memchr
- strchr
- strcspan
- strpbrk
- strrchr
- strspn
- strstr
- strtok
- memset
- strerror
- strlen
- clock
- difftime
- mktime
- time
- asctime
- ctime
- gmtime
- localtime
- strftime
- access
- alarm
- asctime
- cfgetispeed
- cfgetospeed
- cfsetispeed
- cfsetospeed
- chdir
- chmod
- chown
- close
- closedir
- creat
- ctermid
- cuserid
- dup
- dup2
- execl
- execle
- execlp
- execv
- execve
- execvp
- _exit
- fcntl
- fdopen
- fileno
- fork
- fpathconf
- fstat
- getcwd
- getegid
- getenv
- geteuid
- getgid
- getgrgid
- getgrnam
- getgroups
- getlogin
- getpgrp
- getpid
- getppid
- getpwnam
- getpwuid
- getuid
- isatty
- kill
- link
- longjmp
- lseek
- mkdir
- mkfifo
- open
- opendir
- pathconf
- pause
- pipe
- read
- readdir
- rename
- rewinddir
- rmdir
- setgid
- setjmp
- setlocale
- setpgid
- setsid
- setuid
- sigaction
- sigaddset
- sigdelset
- sigemptyset
- sigfillset
- sigismember
- siglongjmp
- sigpending
- sigprocmask
- sigsetjmp
- sigsuspend
- sleep
- stat
- sysconf
- tcdrain
- tcflow
- tcflush
- tcgetattr
- tcgetpgrp
- time
- times
- ttyname
- tzset
- umask
- uname
- unlink
- utime
- wait
- waitpid
- write
-
- S_ISDIR
- S_ISCHR
- S_ISBLK
- S_ISREG
- S_ISFIFO
- WIFEXITED
- WEXITSTATUS
- WIFSIGNALED
- WTERMSIG
- WIFSTOPPED
- WSTOPSIG
- @//E*O*F include1.0/functions//
- chmod u=rw,g=r,o=r include1.0/functions
-
- echo Inspecting for damage in transit...
- temp=/tmp/shar$$; dtemp=/tmp/.shar$$
- trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
- cat > $temp <<\!!!
- 1 0 1 wait
- 33 170 1117 typedef
- 130 331 1993 typedef.awk
- 6 6 33 ctypes
- 83 540 4519 report.t
- 21 104 789 tr.testrig
- 255 254 1843 functions
- 529 1405 10295 total
- !!!
- wc include1.0/types/wait include1.0/typedef include1.0/typedef.awk include1.0/ctypes include1.0/report.t include1.0/tr.testrig include1.0/functions | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
- if [ -s $dtemp ]
- then echo "Ouch [diff of wc output]:" ; cat $dtemp
- else echo "No problems found."
- fi
- exit 0
-
- --
- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
- Use a domain-based address or give alternate paths, or you may lose out.
-