|
|
1.1 root 1: /* The Plum Hall Validation Suite for C
2: * Unpublished copyright (c) 1986-1991, Chiron Systems Inc and Plum Hall Inc.
3: * VERSION: 4
4: * DATE: 1993-01-01
5: * The "ANSI" mode of this suite corresponds to official ANSI C, X3.159-1989.
6: * As per your license agreement, your distribution is not to be moved or copied outside the Designated Site
7: * without specific permission from Plum Hall Inc.
8: */
9:
10: #define LIB_TEST 1
11: #include "defs.h"
12: #if !ANSI || !HAS_PROTOTYPES
13: #define SKIP41 1
14: #endif
15:
16: #include "flags.h"
17: #ifndef SKIP41
18:
19: static void d4_1_1();
20: static void d4_1a();
21: static void d4_1_2();
22: #ifndef FREESTANDING
23: void d4_1_3();
24: #endif /* FREESTANDING */
25: void d41_4a();
26: void d41_4b();
27: void d4_1_5();
28: static void d4_1_6();
29: #ifndef FREESTANDING
30: extern int atoi(const char *);
31: #endif /* FREESTANDING */
32:
33: /*
34: * 4.1 - Introduction
35: * This file is not relevant to pre ANSI C compilers.
36: */
37: void d4_1()
38: {
39: Filename = "d41.c";
40: d4_1_1();
41: d4_1_2();
42: #ifndef FREESTANDING
43: d4_1_3();
44: #endif /* FREESTANDING */
45: d41_4a();
46: d41_4b();
47: d4_1_5();
48: d4_1_6();
49: #ifndef FREESTANDING
50: /* test various methods of library call here,
51: * before including the headers.
52: */
53: /* implicit declaration */
54: {
55: int i;
56: i = atoi("4");
57: iequals(__LINE__, i, 4);
58: }
59:
60: /* explicit declaration */
61: {
62: int i;
63: extern int atoi(const char *);
64: i = atoi("4");
65: iequals(__LINE__, i, 4);
66:
67: /* using its header */
68: d4_1a();
69: }
70: #endif /* FREESTANDING */
71: }
72:
73:
74: #ifndef FREESTANDING
75: #include <stdlib.h>
76: #endif /* FREESTANDING */
77:
78: static void d4_1a()
79: {
80: #ifndef FREESTANDING
81: {
82: /* by use of the associated header */
83: int i;
84:
85: i = atoi("5");
86: iequals(__LINE__, i, 5);
87:
88: i = (atoi)("7");
89: iequals(__LINE__, i, 7);
90:
91: #undef atoi
92: i = atoi("6");
93: iequals(__LINE__, i, 6);
94: }
95: #endif /* FREESTANDING */
96:
97: }
98:
99:
100: /*
101: * 4.1.1 - Definitions of terms
102: */
103: static void d4_1_1()
104: {
105: /* definitions of "string", "letter", and "decimal-point character" */
106: }
107:
108: /*
109: * 4.1.2 - Headers
110: */
111: #ifndef SKIP41_2
112: int near, far, cdecl, unix, vax; /* non-reserved names */
113: int globaldef, asm, fortran, pascal, entry; /* non-reserved names */
114: int environ, i386, i387, exception; /* etc. */ /* non-reserved names */
115: #define value (Be sure that any dummy names used in headers are valid.)
116: #define filename (A conforming implementation cannot just copy the library synopsis.)
117: #define stream (One possible technique is to have NO dummy names in headers.)
118: #define nmemb (If headers have this problem, they can be altered manually to proceed with testing.)
119: /* make sure that all of the specified headers exist */
120: #ifndef FREESTANDING
121: #include <assert.h>
122: #include <ctype.h>
123: #include <errno.h>
124: #endif /* FREESTANDING */
125: #include <float.h> /* required even in FREESTANDING */
126: #include <limits.h> /* required even in FREESTANDING */
127: #include <stdarg.h> /* required even in FREESTANDING */
128: #include <stddef.h> /* required even in FREESTANDING */
129: #ifndef FREESTANDING
130: #include <locale.h>
131: #include <math.h>
132: #include <setjmp.h>
133: #include <signal.h>
134: #include <stdio.h>
135: #include <stdlib.h>
136: #include <string.h>
137: #include <time.h>
138: #endif /* FREESTANDING */
139:
140: /* check that another order and multiple includes are OK */
141: #ifndef FREESTANDING
142: #include <time.h>
143: #include <string.h>
144: #include <stdlib.h>
145: #include <stdio.h>
146: #endif /* FREESTANDING */
147: #include <stddef.h> /* required even in FREESTANDING */
148: #include <limits.h> /* required even in FREESTANDING */
149: #include <float.h> /* required even in FREESTANDING */
150: #include <stdarg.h> /* required even in FREESTANDING */
151: #ifndef FREESTANDING
152: #include <signal.h>
153: #include <setjmp.h>
154: #include <math.h>
155: #include <locale.h>
156: #include <ctype.h>
157: #include <assert.h>
158: #include <errno.h>
159: #endif /* FREESTANDING */
160: #endif /* SKIP41_2 */
161: static void d4_1_2()
162: {
163: #ifndef SKIP41_2
164: int _ok = 8703; /* ANSI8703: internal id's of underscore + lowercase letter now OK */
165: int UNIX = 2;
166: int VAX = 3;
167: int _near = 4;
168: int _far = 5;
169:
170: iequals(__LINE__, _ok, 8703);
171: iequals(__LINE__, UNIX, 2);
172: iequals(__LINE__, VAX, 3);
173: iequals(__LINE__, _near, 4);
174: iequals(__LINE__, _far, 5);
175: #endif /* SKIP41_2 */
176: }
177: /*
178: * 4.1.6 - Use of library functions.
179: */
180: static void d4_1_6()
181: {
182: #ifndef SKIP416
183: #ifndef FREESTANDING
184: /* All library functions must be accessible as real
185: * functions, whether implemented as macros or not.
186: * Each of these routines is supposed to have an underlying
187: * real function. Make sure that it exists. The definitions
188: * are supposed to occur in the standard header files.
189: */
190: /* <ctype.h> */
191: checkthat(__LINE__, isalnum != 0);
192: checkthat(__LINE__, isalpha != 0);
193: checkthat(__LINE__, iscntrl != 0);
194: checkthat(__LINE__, isdigit != 0);
195: checkthat(__LINE__, isgraph != 0);
196: checkthat(__LINE__, islower != 0);
197: checkthat(__LINE__, isprint != 0);
198: checkthat(__LINE__, ispunct != 0);
199: checkthat(__LINE__, isspace != 0);
200: checkthat(__LINE__, isupper != 0);
201: checkthat(__LINE__, isxdigit != 0);
202: checkthat(__LINE__, tolower != 0);
203: checkthat(__LINE__, toupper != 0);
204: #undef isalnum
205: #undef isalpha
206: #undef iscntrl
207: #undef isdigit
208: #undef isgraph
209: #undef islower
210: #undef isprint
211: #undef ispunct
212: #undef isspace
213: #undef isupper
214: #undef isxdigit
215: #undef tolower
216: #undef toupper
217:
218: {
219: int isalnum(int);
220: int isalpha(int);
221: int iscntrl(int);
222: int isdigit(int);
223: int isgraph(int);
224: int islower(int);
225: int isprint(int);
226: int ispunct(int);
227: int isspace(int);
228: int isupper(int);
229: int isxdigit(int);
230: int tolower(int);
231: int toupper(int);
232: }
233:
234: /* <locale.h> */
235: checkthat(__LINE__, setlocale != 0);
236: #if ANSI8709
237: checkthat(__LINE__, localeconv != 0);
238: #endif
239: #undef setlocale
240: #undef localeconv
241: {
242: char *setlocale(int, const char *);
243: #if ANSI8709
244: struct lconv *localeconv(void);
245: #endif
246: }
247:
248: /* <math.h> */
249: checkthat(__LINE__, acos != 0);
250: checkthat(__LINE__, asin != 0);
251: checkthat(__LINE__, atan != 0);
252: checkthat(__LINE__, atan2 != 0);
253: checkthat(__LINE__, cos != 0);
254: checkthat(__LINE__, sin != 0);
255: checkthat(__LINE__, tan != 0);
256: checkthat(__LINE__, cosh != 0);
257: checkthat(__LINE__, sinh != 0);
258: checkthat(__LINE__, tanh != 0);
259: checkthat(__LINE__, exp != 0);
260: checkthat(__LINE__, frexp != 0);
261: checkthat(__LINE__, ldexp != 0);
262: checkthat(__LINE__, log != 0);
263: checkthat(__LINE__, log10 != 0);
264: checkthat(__LINE__, modf != 0);
265: checkthat(__LINE__, pow != 0);
266: checkthat(__LINE__, sqrt != 0);
267: checkthat(__LINE__, ceil != 0);
268: checkthat(__LINE__, fabs != 0);
269: checkthat(__LINE__, floor != 0);
270: checkthat(__LINE__, fmod != 0);
271:
272: #undef acos
273: #undef asin
274: #undef atan
275: #undef atan2
276: #undef cos
277: #undef sin
278: #undef tan
279: #undef cosh
280: #undef sinh
281: #undef tanh
282: #undef exp
283: #undef frexp
284: #undef ldexp
285: #undef log
286: #undef log10
287: #undef modf
288: #undef pow
289: #undef sqrt
290: #undef ceil
291: #undef fabs
292: #undef floor
293: #undef fmod
294:
295: {
296: double acos(double);
297: double asin(double);
298: double atan(double);
299: double atan2(double, double);
300: double cos(double);
301: double sin(double);
302: double tan(double);
303: double cosh(double);
304: double sinh(double);
305: double tanh(double);
306: double exp(double);
307: double frexp(double, int *);
308: double ldexp(double, int);
309: double log(double);
310: double log10(double);
311: double modf(double, double *);
312: double pow(double, double);
313: double sqrt(double);
314: double ceil(double);
315: double fabs(double);
316: double floor(double);
317: double fmod(double, double);
318: }
319:
320: /* <setjmp.h> */
321: /* ANSI8706 now setjmp must be a macro - see 4.6 P3 */
322: checkthat(__LINE__, longjmp != 0);
323: #undef longjmp
324: {
325: void longjmp(jmp_buf, int);
326: }
327:
328: /* <signal.h> */
329: checkthat(__LINE__, signal != 0);
330: checkthat(__LINE__, raise != 0);
331: #undef signal
332: #undef raise
333: {
334: void (*signal(int, void (*)(int)))(int);
335: int raise(int);
336: }
337:
338:
339: /* <stdio.h> */
340: checkthat(__LINE__, remove != 0);
341: checkthat(__LINE__, rename != 0);
342: checkthat(__LINE__, tmpfile != 0);
343: checkthat(__LINE__, tmpnam != 0);
344: checkthat(__LINE__, fclose != 0);
345: checkthat(__LINE__, fflush != 0);
346: checkthat(__LINE__, fopen != 0);
347: checkthat(__LINE__, freopen != 0);
348: checkthat(__LINE__, setbuf != 0);
349: checkthat(__LINE__, setvbuf != 0);
350: checkthat(__LINE__, fprintf != 0);
351: checkthat(__LINE__, fscanf != 0);
352: checkthat(__LINE__, printf != 0);
353: checkthat(__LINE__, scanf != 0);
354: checkthat(__LINE__, sprintf != 0);
355: checkthat(__LINE__, sscanf != 0);
356: checkthat(__LINE__, vfprintf != 0);
357: checkthat(__LINE__, vprintf != 0);
358: checkthat(__LINE__, vsprintf != 0);
359: checkthat(__LINE__, fgetc != 0);
360: checkthat(__LINE__, fgets != 0);
361: checkthat(__LINE__, fputc != 0);
362: checkthat(__LINE__, fputs != 0);
363: checkthat(__LINE__, gets != 0);
364: checkthat(__LINE__, getc != 0);
365: checkthat(__LINE__, getchar != 0);
366: checkthat(__LINE__, puts != 0);
367: checkthat(__LINE__, putc != 0);
368: checkthat(__LINE__, putchar != 0);
369: checkthat(__LINE__, ungetc != 0);
370: checkthat(__LINE__, fread != 0);
371: checkthat(__LINE__, fwrite != 0);
372: checkthat(__LINE__, fgetpos != 0);
373: checkthat(__LINE__, fseek != 0);
374: checkthat(__LINE__, fsetpos != 0);
375: checkthat(__LINE__, ftell != 0);
376: checkthat(__LINE__, rewind != 0);
377: checkthat(__LINE__, clearerr != 0);
378: checkthat(__LINE__, feof != 0);
379: checkthat(__LINE__, ferror != 0);
380: checkthat(__LINE__, perror != 0);
381:
382: #undef remove
383: #undef rename
384: #undef tmpfile
385: #undef tmpnam
386: #undef fclose
387: #undef fflush
388: #undef fopen
389: #undef freopen
390: #undef setbuf
391: #undef setvbuf
392: #undef fprintf
393: #undef fscanf
394: #undef printf
395: #undef scanf
396: #undef sprintf
397: #undef sscanf
398: #undef vfprintf
399: #undef vprintf
400: #undef vsprintf
401: #undef fgetc
402: #undef fgets
403: #undef fputc
404: #undef fputs
405: #undef getc
406: #undef getchar
407: #undef gets
408: #undef putc
409: #undef putchar
410: #undef puts
411: #undef ungetc
412: #undef fread
413: #undef fwrite
414: #undef fgetpos
415: #undef fseek
416: #undef fsetpos
417: #undef ftell
418: #undef rewind
419: #undef clearerr
420: #undef feof
421: #undef ferror
422: #undef perror
423:
424: {
425: int remove(const char *);
426: int rename(const char *, const char *);
427: FILE *tmpfile(void);
428: char *tmpnam(char *);
429: int fclose(FILE *);
430: int fflush(FILE *);
431: FILE *fopen(const char *, const char *);
432: FILE *freopen(const char *, const char *, FILE *);
433: void setbuf(FILE *, char *);
434: int setvbuf(FILE *, char *, int, size_t);
435: int fprintf(FILE *, const char *, ...);
436: int fscanf(FILE *, const char *, ...);
437: int printf(const char *, ...);
438: int scanf(const char *, ...);
439: int sprintf(char *, const char *, ...);
440: int sscanf(const char *, const char *, ...);
441: int vfprintf(FILE *, const char *, va_list);
442: int vprintf(const char *, va_list);
443: int vsprintf(char *, const char *, va_list);
444: int fgetc(FILE *);
445: char *fgets(char *, int, FILE *);
446: int fputc(int, FILE *);
447: int fputs(const char *, FILE *);
448: int getc(FILE *);
449: int getchar(void);
450: char *gets(char *);
451: int putc(int, FILE *);
452: int putchar(int);
453: int puts(const char *);
454: int ungetc(int, FILE *);
455: size_t fread(void *, size_t, size_t, FILE *);
456: size_t fwrite(const void *, size_t, size_t, FILE *);
457: int fgetpos(FILE *, fpos_t *);
458: int fseek(FILE *, long, int);
459: int fsetpos(FILE *, const fpos_t *);
460: long ftell(FILE *);
461: void rewind(FILE *);
462: void clearerr(FILE *);
463: int feof(FILE *);
464: int ferror(FILE *);
465: void perror(const char *);
466: }
467:
468: /* <stdlib.h> */
469: checkthat(__LINE__, atof != 0);
470: checkthat(__LINE__, atoi != 0);
471: checkthat(__LINE__, atol != 0);
472: checkthat(__LINE__, strtod != 0);
473: checkthat(__LINE__, strtol != 0);
474: checkthat(__LINE__, strtoul != 0);
475: checkthat(__LINE__, rand != 0);
476: checkthat(__LINE__, srand != 0);
477: checkthat(__LINE__, calloc != 0);
478: checkthat(__LINE__, free != 0);
479: checkthat(__LINE__, malloc != 0);
480: checkthat(__LINE__, realloc != 0);
481: checkthat(__LINE__, abort != 0);
482: checkthat(__LINE__, atexit != 0);
483: checkthat(__LINE__, exit != 0);
484: checkthat(__LINE__, getenv != 0);
485: checkthat(__LINE__, system != 0);
486: checkthat(__LINE__, bsearch != 0);
487: checkthat(__LINE__, qsort != 0);
488: checkthat(__LINE__, abs != 0);
489: checkthat(__LINE__, div != 0);
490: checkthat(__LINE__, labs != 0);
491: checkthat(__LINE__, ldiv != 0);
492: #if WIDE_CHARS
493: checkthat(__LINE__, mblen != 0);
494: checkthat(__LINE__, mbtowc != 0);
495: checkthat(__LINE__, wctomb != 0);
496: checkthat(__LINE__, mbstowcs != 0);
497: checkthat(__LINE__, wcstombs != 0);
498: #endif
499:
500: #undef atof
501: #undef atoi
502: #undef atol
503: #undef strtod
504: #undef strtol
505: #undef strtoul
506: #undef rand
507: #undef srand
508: #undef calloc
509: #undef free
510: #undef malloc
511: #undef realloc
512: #undef abort
513: #undef atexit
514: #undef exit
515: #undef getenv
516: #undef system
517: #undef bsearch
518: #undef qsort
519: #undef abs
520: #undef div
521: #undef labs
522: #undef ldiv
523: #undef mblen
524: #undef mbtowc
525: #undef wctomb
526: #undef mbstowcs
527: #undef wcstombs
528:
529: {
530: double atof(const char *);
531: int atoi(const char *);
532: long atol(const char *);
533: double strtod(const char *, char **);
534: long strtol(const char *, char **, int );
535: unsigned long strtoul(const char *, char **, int);
536: int rand(void);
537: void srand(unsigned int);
538: void *calloc(size_t, size_t);
539: void free(void *);
540: void *malloc(size_t);
541: void *realloc(void *, size_t);
542: void abort(void);
543: int atexit(void (*)(void));
544: void exit(int);
545: char *getenv(const char *);
546: int system(const char *);
547: void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
548: void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
549: int abs(int);
550: div_t div(int, int);
551: long labs(long);
552: ldiv_t ldiv(long, long);
553: #if WIDE_CHARS
554: int mblen(const char *, size_t);
555: int mbtowc(wchar_t *, const char *, size_t);
556: int wctomb(char *, wchar_t);
557: size_t mbstowcs(wchar_t *, const char *, size_t);
558: size_t wcstombs(char *, const wchar_t *, size_t);
559: #endif
560: }
561:
562: /* <string.h> */
563: checkthat(__LINE__, memcpy != 0);
564: checkthat(__LINE__, memmove != 0);
565: checkthat(__LINE__, strcpy != 0);
566: checkthat(__LINE__, strncpy != 0);
567: checkthat(__LINE__, strcat != 0);
568: checkthat(__LINE__, strncat != 0);
569: checkthat(__LINE__, memcmp != 0);
570: checkthat(__LINE__, strcmp != 0);
571: checkthat(__LINE__, strncmp != 0);
572: checkthat(__LINE__, strcoll != 0);
573: #if ANSI8612
574: checkthat(__LINE__, strxfrm != 0);
575: #endif
576: checkthat(__LINE__, memchr != 0);
577: checkthat(__LINE__, strchr != 0);
578: checkthat(__LINE__, strcspn != 0);
579: checkthat(__LINE__, strpbrk != 0);
580: checkthat(__LINE__, strrchr != 0);
581: checkthat(__LINE__, strspn != 0);
582: checkthat(__LINE__, strstr != 0);
583: checkthat(__LINE__, strtok != 0);
584: checkthat(__LINE__, memset != 0);
585: checkthat(__LINE__, strerror != 0);
586: checkthat(__LINE__, strlen != 0);
587: #undef memcpy
588: #undef memmove
589: #undef strcpy
590: #undef strncpy
591: #undef strcat
592: #undef strncat
593: #undef memcmp
594: #undef strcmp
595: #undef strncmp
596: #undef strcoll
597: #undef memchr
598: #undef strchr
599: #undef strcspn
600: #undef strpbrk
601: #undef strrchr
602: #undef strspn
603: #undef strstr
604: #undef strtok
605: #undef memset
606: #undef strerror
607: #undef strlen
608: {
609: void *memcpy(void *, const void *, size_t);
610: void *memmove(void *, const void *, size_t);
611: char *strcpy(char *, const char *);
612: char *strncpy(char *, const char *, size_t);
613: char *strcat(char *, const char *);
614: char *strncat(char *, const char *, size_t);
615: int memcmp(const void *, const void *, size_t);
616: int strcmp(const char *, const char *);
617: int strncmp(const char *, const char *, size_t);
618: #if ANSI8612
619: int strcoll(const char *, const char *);
620: size_t strxfrm(char *, const char *, size_t);
621: #else
622: size_t strcoll(char *, size_t, const char *);
623: #endif
624: void *memchr(const void *, int, size_t);
625: char *strchr(const char *, int);
626: size_t strcspn(const char *, const char *);
627: char *strpbrk(const char *, const char *);
628: char *strrchr(const char *, int);
629: size_t strspn(const char *, const char *);
630: char *strstr(const char *, const char *);
631: char *strtok(char *, const char *);
632: void *memset(void *, int, size_t);
633: char *strerror(int);
634: size_t strlen(const char *);
635: }
636:
637: /* <time.h> */
638: checkthat(__LINE__, clock != 0);
639: checkthat(__LINE__, difftime != 0);
640: checkthat(__LINE__, mktime != 0);
641: checkthat(__LINE__, time != 0);
642: checkthat(__LINE__, asctime != 0);
643: checkthat(__LINE__, ctime != 0);
644: checkthat(__LINE__, gmtime != 0);
645: checkthat(__LINE__, localtime != 0);
646: checkthat(__LINE__, strftime != 0);
647:
648: #undef clock
649: #undef difftime
650: #undef mktime
651: #undef time
652: #undef asctime
653: #undef ctime
654: #undef gmtime
655: #undef localtime
656: #undef strftime
657: {
658: clock_t clock(void);
659: double difftime(time_t, time_t);
660: time_t mktime(struct tm *);
661: time_t time(time_t *);
662: char *asctime(const struct tm *);
663: char *ctime(const time_t *);
664: struct tm *gmtime(const time_t *);
665: struct tm *localtime(const time_t *);
666: size_t strftime(char *, size_t, const char *, const struct tm *);
667: }
668: #endif /* FREESTANDING */
669: #endif /* SKIP416 */
670: }
671:
672: #else /* if SKIP41 */
673: void d4_1() { pr_skip("d4_1: SKIPPED ENTIRELY\n"); }
674: #endif /* SKIP41 */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.