home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume20 / posix.h-tester.pch < prev    next >
Text File  |  1989-10-15  |  13KB  |  617 lines

  1. Subject:  v20i022:  POSIX 1003.1 #include file tester, Patch1
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Barry Books <bbooks@aixsm.austin.ibm.com>
  7. Posting-number: Volume 20, Issue 22
  8. Archive-name: posix.h-tester
  9. Patch-To: posix.h-tester: Volume 20, Issue 1
  10.  
  11. The POSIX include file tester archive was truncated some where
  12. along the way.  Here are the missing files along with one other
  13. to fix a typo.
  14.  
  15. Thanks,
  16. Barry Books
  17.                 
  18.  
  19. # This is a shell archive.  Remove anything before this line,
  20. # then unpack it by saving it in a file and typing "sh file".
  21. # Contents:  include1.0/ include1.0/types/ include1.0/types/wait
  22. #    include1.0/typedef include1.0/typedef.awk include1.0/ctypes
  23. #    include1.0/report.t include1.0/tr.testrig include1.0/functions
  24.  
  25. echo mkdir - include1.0
  26. mkdir include1.0
  27. chmod u=rwx,g=rx,o=rx include1.0
  28.  
  29. echo mkdir - include1.0/types
  30. mkdir include1.0/types
  31. chmod u=rwx,g=rx,o=rx include1.0/types
  32.  
  33. echo x - include1.0/types/wait
  34. sed 's/^@//' > "include1.0/types/wait" <<'@//E*O*F include1.0/types/wait//'
  35.  
  36. @//E*O*F include1.0/types/wait//
  37. chmod u=rw,g=r,o=r include1.0/types/wait
  38.  
  39. echo x - include1.0/typedef
  40. sed 's/^@//' > "include1.0/typedef" <<'@//E*O*F include1.0/typedef//'
  41.  #
  42. #**********************************************************************
  43. # THERE MUST BE A SPACE in the first character of the first line.
  44. #**********************************************************************
  45. #
  46. #            NOTICE STATEMENT
  47. #
  48. # This code was developed by IBM Corporation.  Copyright is disclaimed.
  49. #
  50. # IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS CODE.  IN NO EVENT
  51. # WILL IBM BE LIABLE FOR ANY DAMAGES, LOST PROFITS, OR LOST SAVINGS.
  52. #
  53. #    "@(#) This code was developed by IBM Corporation. "
  54. #    "@(#) Copyright is disclaimed. "
  55. #
  56. #**********************************************************************
  57. #  Written by:  Barry Books
  58. #**********************************************************************
  59.  
  60.  #
  61. # copy the .h to a .c for C compiler
  62. TMP=`$MKTEMP`
  63. touch $TMP.c
  64. cp $1 $TMP.c
  65.  
  66. # compile the file with _POSIX_SOURCE defined
  67. # put space around ( ) and *
  68. # change all white space to newline so one token per line
  69. # run awk to find typedefs
  70. 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
  71.  
  72. #clean up
  73. rm -f $TMP.c
  74. @//E*O*F include1.0/typedef//
  75. chmod u=rwx,g=rx,o=rx include1.0/typedef
  76.  
  77. echo x - include1.0/typedef.awk
  78. sed 's/^@//' > "include1.0/typedef.awk" <<'@//E*O*F include1.0/typedef.awk//'
  79.  #
  80. #**********************************************************************
  81. # THERE MUST BE A SPACE in the first character of the first line.
  82. #**********************************************************************
  83. #
  84. #            NOTICE STATEMENT
  85. #
  86. # This code was developed by IBM Corporation.  Copyright is disclaimed.
  87. #
  88. # IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS CODE.  IN NO EVENT
  89. # WILL IBM BE LIABLE FOR ANY DAMAGES, LOST PROFITS, OR LOST SAVINGS.
  90. #
  91. #    "@(#) This code was developed by IBM Corporation. "
  92. #    "@(#) Copyright is disclaimed. "
  93. #
  94. #**********************************************************************
  95. #  Written by:  Barry Books
  96. #**********************************************************************
  97.  
  98. # state machine to find typedefs
  99. # order is important
  100.  
  101. BEGIN {
  102.     STRUCT=0;
  103.     OPEN = 0;
  104.     SEMI = 0;
  105.     SQRB = 0;
  106.     TYPEDEF = 0;
  107. }
  108.  
  109. #toss some keywords
  110. /unsigned/    {
  111.     next;
  112.     }
  113.  
  114. /extern/    {
  115.     SEMI = 0;
  116.     next;
  117.     }
  118.  
  119. /signed/    {
  120.     next;
  121.     }
  122.  
  123. /\(/    {
  124.     next;
  125.     }
  126.  
  127. /\)/    {
  128.     next;
  129.     }
  130.  
  131. #attempt to fix typedef thing[num]; problem
  132. #this didn't work
  133. /\[/    {
  134.         SQRB += 1;
  135.     }
  136.  
  137. /\]/    {
  138.         SQRB -= 1;
  139.     }
  140.  
  141. #keep track of braces
  142. /{/    {
  143.         OPEN += 1;
  144.         next;
  145.     }
  146.  
  147. /}/    {
  148.         OPEN -= 1;
  149.         next;
  150.     }
  151.  
  152. # semi colon is end of statement
  153. # save the names and the next token will print the results
  154. # this takes care of both cases
  155. # typedef thing;
  156. # typedef thing ;
  157. #this should have be done with sed to make everything
  158. # typedef thing ;
  159. # maybe next time
  160. /;/    {
  161.         if ( OPEN > 0 )
  162.             next;
  163.         else
  164.         {
  165.             SEMI = 1;
  166.             if ( length($1) > 1 )
  167.             {
  168.                 TMPNAME=substr($1,1,length($1)-1);
  169.                 if ( TMPNAME !~ /]/ )
  170.                     NAME=TMPNAME;
  171.             }
  172.         }
  173.     }
  174.  
  175. # this matches everything
  176. # if its a typedef print the results and reset the flags
  177. /^/    {
  178.         if ( TYPEDEF == 1 )
  179.         {
  180.             if ( SEMI == 1 )
  181.             {
  182.                 printf("%s\n",NAME);
  183.                 SEMI = 0;
  184.                 TYPEDEF = 0;
  185.             }
  186.             else
  187.             {
  188.                 if ( SQRB = 0 )
  189.                     NAME = $1;
  190.                 next;
  191.             }
  192.         }
  193.     }
  194.  
  195. #keep tract of these keywords
  196. /typedef/    {
  197.     TYPEDEF=1;
  198.     SEMI=0;
  199.     next;
  200.     }
  201.  
  202. /struct/    {
  203.     STRUCT=1;
  204.     SEMI=0;
  205.     next;
  206.     }
  207.  
  208.  
  209. @//E*O*F include1.0/typedef.awk//
  210. chmod u=rw,g=r,o=r include1.0/typedef.awk
  211.  
  212. echo x - include1.0/ctypes
  213. sed 's/^@//' > "include1.0/ctypes" <<'@//E*O*F include1.0/ctypes//'
  214. char
  215. double
  216. float
  217. int
  218. long
  219. short
  220. @//E*O*F include1.0/ctypes//
  221. chmod u=rw,g=r,o=r include1.0/ctypes
  222.  
  223. echo x - include1.0/report.t
  224. sed 's/^@//' > "include1.0/report.t" <<'@//E*O*F include1.0/report.t//'
  225.  
  226.  
  227.  
  228.                       Report on POSIX Include File Conformance
  229.  
  230.           Overview
  231.             This document reports objects in include files which do  not
  232.             meet  the POSIX 1003.1 specification.  This is intended as a
  233.             tool more than a conformance test and is distributed to  aid
  234.             in  reaching a consensus on what should be and should not be
  235.             included in a POSIX 1003.1 conforming include file.
  236.  
  237.           Requirements
  238.             The standard specifies the contents of include files in  two
  239.             ways  first  by  stating  items  which  must be included and
  240.             second allowing for other items as long as they meet certain
  241.             criteria.   No  other objects are allowed when _POSIX_SOURCE
  242.             is defined ( 1003.1 2.82. ).  The following  is  a  list  of
  243.             objects not specifically mentioned in the standard but still
  244.             allowed.
  245.                  1. All external identifiers that  begin  with  an
  246.                       underscore  are reserved ( POSIX 1003.1 2.8.1
  247.                       ).
  248.                  2.  All  other  identifiers  that  begin  with  an
  249.                       underscore  and either an uppercase letter or
  250.                       another  underscore  are  reserved  (   POSIX
  251.                       1003.1 2.8.1 ).
  252.                  3. Namespaces reserved by the C Standard are  also
  253.                       reserved ( POSIX 1003.1 2.8.1 ).
  254.                  4. Types ending in _t are reserved ( POSIX  1003.1
  255.                       2.6 ).
  256.                  5. Implementations may add members to a structure or
  257.                       union  (  POSIX 1003.1 2.8.2 ). These members
  258.                       must have either standard C  types  or  types
  259.                       ending in _t ( implied by 4 ).
  260.                  6. Additional macro definitions, beginning with  E
  261.                       and a digit or E and an upper-case letter may
  262.                       also be specified  by  the  implementation  (
  263.                       ANSI 4.1.3 ).
  264.                  7. Additional signals and pointers to  undeclarable
  265.                       functions,    with   definitions   beginning,
  266.                       respectively, with letters SIG and an  upper-
  267.                       case  letter  or  with SIG_ and an upper-case
  268.                       letter  may  also   be   specified   by   the
  269.                       implementation ( ANSI 4.7 ).
  270.                  8. Headers may be included in any order  and  more
  271.                       than once with no effect different from being
  272.                       included only once,  except  for  assert.h  (
  273.                       ANSI 4.1.1 ).
  274.  
  275.           Interpreting The Results
  276.             The results from each include file are  divided  into  three
  277.             categories:  defines, structures and typedefs. If an include
  278.             file is missing it is marked missing and the tests for  that
  279.             include file are skipped.
  280.  
  281.             Defines
  282.             The defines section  contains  four  columns.   The  "extra"
  283.             column  contains defines not allowed by the standard.  These
  284.             items should  be  moved  outside   the  scope  _POSIX_SOURCE
  285.             feature  test  macro.  The "other" column contains items not
  286.             specifically mentioned for this particular include file  but
  287.             allowed  by  the  standard.   The  "missing" column contains
  288.             items required by the standard but not found in the  include
  289.             files.   This  column is used as a debugging aid as the test
  290.             suites can find these problems quite easily.  You should not
  291.             find  items  in  this column that are in your include files.
  292.             The  last  column  is  the  "macros"  column.   This  column
  293.             contains a list of functions that are defined as macros.
  294.  
  295.             Structures
  296.             The structure  section  contains  two  columns.   The  first
  297.             column  contains  any  structures not specified by the POSIX
  298.             1003.1 or the ANSI C standard.  The second  column  contains
  299.             structure elements not allowed by the 1003.1 standard.
  300.  
  301.             Typedefs
  302.             The typedef section is similar to the define  section.   The
  303.             first  column  contains  typedefs  not allowed by the 1003.1
  304.             standard.  The next column  contains  typedefs  required  in
  305.             other  include  files and the final column contains typedefs
  306.             that are missing.
  307.  
  308. @//E*O*F include1.0/report.t//
  309. chmod u=rw,g=r,o=r include1.0/report.t
  310.  
  311. echo x - include1.0/tr.testrig
  312. sed 's/^@//' > "include1.0/tr.testrig" <<'@//E*O*F include1.0/tr.testrig//'
  313.  #
  314. #**********************************************************************
  315. # THERE MUST BE A SPACE in the first character of the first line.
  316. #**********************************************************************
  317. #
  318. #            NOTICE STATEMENT
  319. #
  320. # This code was developed by IBM Corporation.  Copyright is disclaimed.
  321. #
  322. # IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS CODE.  IN NO EVENT
  323. # WILL IBM BE LIABLE FOR ANY DAMAGES, LOST PROFITS, OR LOST SAVINGS.
  324. #
  325. #    "@(#) This code was developed by IBM Corporation. "
  326. #    "@(#) Copyright is disclaimed. "
  327. #
  328. #**********************************************************************
  329. #  Written by:  Barry Books
  330. #**********************************************************************
  331.  
  332. # if your are missing tr
  333. awk '{ for (i = 1; i <= NF; i++ ) {print $i}}'
  334. @//E*O*F include1.0/tr.testrig//
  335. chmod u=rwx,g=rwx,o=rwx include1.0/tr.testrig
  336.  
  337. echo x - include1.0/functions
  338. sed 's/^@//' > "include1.0/functions" <<'@//E*O*F include1.0/functions//'
  339. assert
  340. isalnum
  341. isalpha
  342. iscntrl
  343. isdigit
  344. isgraph
  345. islower
  346. isprint
  347. ispunct
  348. isspace
  349. isupper
  350. isxdigit
  351. tolower
  352. toupper
  353. setlocale
  354. localeconv
  355. acos
  356. asin
  357. atan
  358. atan2
  359. cos
  360. sin
  361. tan
  362. cosh
  363. sinh
  364. tanh
  365. exp
  366. frexp
  367. ldexp
  368. log
  369. log10
  370. modf
  371. pow
  372. sqrt
  373. ceil
  374. fabs
  375. floor
  376. fmod
  377. setjmp
  378. longjmp
  379. signal
  380. raise
  381. va_start
  382. va_arg
  383. va_end
  384. remove
  385. rename
  386. tmpfile
  387. tmpnam
  388. fclose
  389. fflush
  390. fopen
  391. freopen
  392. setbuf
  393. setvbuf
  394. fprintf
  395. fscanf
  396. printf
  397. scanf
  398. sprinf
  399. sscanf
  400. vfprintf
  401. vprintf
  402. vsprintf
  403. fgetc
  404. fgets
  405. fputc
  406. fputs
  407. getc
  408. getchar
  409. gets
  410. putc
  411. putchar
  412. puts
  413. ungetc
  414. fread
  415. fwrite
  416. fgetpos
  417. fseek
  418. fsetpos
  419. ftell
  420. rewind
  421. clearerr
  422. feof
  423. ferror
  424. perror
  425. atof
  426. atoi
  427. atol
  428. strtod
  429. strtol
  430. strtoul
  431. rand
  432. srand
  433. calloc
  434. free
  435. malloc
  436. realloc
  437. abort
  438. atexit
  439. exit
  440. getenv
  441. systems
  442. bsearch
  443. qsort
  444. abs
  445. div
  446. labs
  447. ldiv
  448. mblen
  449. mbtowc
  450. wctomb
  451. mbstowcs
  452. wcstombs
  453. memcpy
  454. memmove
  455. strcpy
  456. strncpy
  457. strcat
  458. strncat
  459. memcmp
  460. strcmp
  461. strcol
  462. strncmp
  463. strxfrm
  464. memchr
  465. strchr
  466. strcspan
  467. strpbrk
  468. strrchr
  469. strspn
  470. strstr
  471. strtok
  472. memset
  473. strerror
  474. strlen
  475. clock
  476. difftime
  477. mktime
  478. time
  479. asctime
  480. ctime
  481. gmtime
  482. localtime
  483. strftime
  484. access
  485. alarm
  486. asctime
  487. cfgetispeed
  488. cfgetospeed
  489. cfsetispeed
  490. cfsetospeed
  491. chdir
  492. chmod
  493. chown
  494. close
  495. closedir
  496. creat
  497. ctermid
  498. cuserid
  499. dup
  500. dup2
  501. execl
  502. execle
  503. execlp
  504. execv
  505. execve
  506. execvp
  507. _exit
  508. fcntl
  509. fdopen
  510. fileno
  511. fork
  512. fpathconf
  513. fstat
  514. getcwd
  515. getegid
  516. getenv
  517. geteuid
  518. getgid
  519. getgrgid
  520. getgrnam
  521. getgroups
  522. getlogin
  523. getpgrp
  524. getpid
  525. getppid
  526. getpwnam
  527. getpwuid
  528. getuid
  529. isatty
  530. kill
  531. link
  532. longjmp
  533. lseek
  534. mkdir
  535. mkfifo
  536. open
  537. opendir
  538. pathconf
  539. pause
  540. pipe
  541. read
  542. readdir
  543. rename
  544. rewinddir
  545. rmdir
  546. setgid
  547. setjmp
  548. setlocale
  549. setpgid
  550. setsid
  551. setuid
  552. sigaction
  553. sigaddset
  554. sigdelset
  555. sigemptyset
  556. sigfillset
  557. sigismember
  558. siglongjmp
  559. sigpending
  560. sigprocmask
  561. sigsetjmp
  562. sigsuspend
  563. sleep
  564. stat
  565. sysconf
  566. tcdrain
  567. tcflow
  568. tcflush
  569. tcgetattr
  570. tcgetpgrp
  571. time
  572. times
  573. ttyname
  574. tzset
  575. umask
  576. uname
  577. unlink
  578. utime
  579. wait
  580. waitpid
  581. write
  582.  
  583. S_ISDIR
  584. S_ISCHR
  585. S_ISBLK
  586. S_ISREG
  587. S_ISFIFO
  588. WIFEXITED
  589. WEXITSTATUS
  590. WIFSIGNALED
  591. WTERMSIG
  592. WIFSTOPPED
  593. WSTOPSIG
  594. @//E*O*F include1.0/functions//
  595. chmod u=rw,g=r,o=r include1.0/functions
  596.  
  597. echo Inspecting for damage in transit...
  598. temp=/tmp/shar$$; dtemp=/tmp/.shar$$
  599. trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
  600. cat > $temp <<\!!!
  601.        1       0       1 wait
  602.       33     170    1117 typedef
  603.      130     331    1993 typedef.awk
  604.        6       6      33 ctypes
  605.       83     540    4519 report.t
  606.       21     104     789 tr.testrig
  607.      255     254    1843 functions
  608.      529    1405   10295 total
  609. !!!
  610. 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
  611. if [ -s $dtemp ]
  612. then echo "Ouch [diff of wc output]:" ; cat $dtemp
  613. else echo "No problems found."
  614. fi
  615. exit 0
  616.  
  617.