-
Notifications
You must be signed in to change notification settings - Fork 6
/
iocccsize.h
107 lines (84 loc) · 2.31 KB
/
iocccsize.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* iocccsize - IOCCC Source Size Tool
*
* Public Domain 1992, 2015, 2018, 2019, 2021 by Anthony Howe. All rights released.
* With IOCCC mods in 2019-2024 by chongo (Landon Curt Noll) ^oo^
*/
#if !defined(INCLUDE_IOCCCSIZE_H)
# define INCLUDE_IOCCCSIZE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <sys/types.h>
/*
* standard truth :-)
*/
#if !defined(BOOL_IS_DEFINED)
#define BOOL_IS_DEFINED
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
/* have a C99 compiler - we should expect to have <stdbool.h> */
#include <stdbool.h>
#elif !defined(__cplusplus)
/* do not have a C99 compiler - fake a <stdbool.h> header file */
typedef unsigned char bool;
#undef true
#define true ((bool)(1))
#undef false
#define false ((bool)(0))
#endif
#endif
#ifndef IOCCCSIZE_VERSION
#define IOCCCSIZE_VERSION "NOTE: IOCCCSIZE_VERSION is set in soup/version.h"
#endif
#ifndef WORD_BUFFER_SIZE
#define WORD_BUFFER_SIZE 16
#endif
/*
* For an historical NOTE on Rule 2 sizes, see:
*
* https://www.ioccc.org/faq.html#size_rule
*/
#ifndef RULE_2A_SIZE
#define RULE_2A_SIZE 4993 /* IOCCC Rule 2a */
#endif
#ifndef RULE_2B_SIZE
#define RULE_2B_SIZE 2503 /* IOCCC Rule 2b */
#endif
#if defined(MKIOCCCENTRY_USE)
#undef DIGRAPHS /* digraphs count a 1 for Rule 2b */
#else
#define DIGRAPHS /* digraphs count a 2 for Rule 2b */
#endif
#if defined(MKIOCCCENTRY_USE)
#undef TRIGRAPHS /* trigraphs count a 1 for Rule 2b */
#else
#define TRIGRAPHS /* trigraphs count a 3 for Rule 2b */
#endif
/*
* rule_count() processing results
*/
typedef struct
{
off_t rule_2a_size; /* official IOCCC Rule 2a calculated size */
size_t rule_2b_size; /* official IOCCC Rule 2b calculated size */
size_t keywords; /* keyword count - for -v mode */
bool char_warning; /* true ==> found high-bit or non-ASCII character */
bool nul_warning; /* true ==> found NUL */
bool trigraph_warning; /* true ==> found an unknown Tri-Graph */
bool wordbuf_warning; /* true ==> word buffer overflow detected */
bool ungetc_warning; /* true ==> ungetc called too many times */
} RuleCount;
/*
* external functions
*/
extern RuleCount rule_count(FILE *fp_in);
extern bool is_reserved(const char *string);
/*
* global variables
*/
extern char const * const iocccsize_version;
#ifdef __cplusplus
}
#endif
#endif /* INCLUDE_IOCCCSIZE_H */