1<?php
2/*************************************************************************************
3 * c.php
4 * -----
5 * Author: Nigel McNie (nigel@geshi.org)
6 * Contributors:
7 *  - Jack Lloyd (lloyd@randombit.net)
8 *  - Michael Mol (mikemol@gmail.com)
9 * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/)
10 * Release Version: 1.0.9.1
11 * Date Started: 2004/06/04
12 *
13 * C language file for GeSHi.
14 *
15 * CHANGES
16 * -------
17 * 2009/01/22 (1.0.8.3)
18 *   -  Made keywords case-sensitive.
19 * 2008/05/23 (1.0.7.22)
20 *   -  Added description of extra language features (SF#1970248)
21 * 2004/XX/XX (1.0.4)
22 *   -  Added a couple of new keywords (Jack Lloyd)
23 * 2004/11/27 (1.0.3)
24 *   -  Added support for multiple object splitters
25 * 2004/10/27 (1.0.2)
26 *   -  Added support for URLs
27 * 2004/08/05 (1.0.1)
28 *   -  Added support for symbols
29 * 2004/07/14 (1.0.0)
30 *   -  First Release
31 *
32 * TODO (updated 2009/02/08)
33 * -------------------------
34 *  -  Get a list of inbuilt functions to add (and explore C more
35 *     to complete this rather bare language file
36 *
37 *************************************************************************************
38 *
39 *     This file is part of GeSHi.
40 *
41 *   GeSHi is free software; you can redistribute it and/or modify
42 *   it under the terms of the GNU General Public License as published by
43 *   the Free Software Foundation; either version 2 of the License, or
44 *   (at your option) any later version.
45 *
46 *   GeSHi is distributed in the hope that it will be useful,
47 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
48 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
49 *   GNU General Public License for more details.
50 *
51 *   You should have received a copy of the GNU General Public License
52 *   along with GeSHi; if not, write to the Free Software
53 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
54 *
55 ************************************************************************************/
56
57$language_data = array (
58    'LANG_NAME' => 'C',
59    'COMMENT_SINGLE' => array(1 => '//', 2 => '#'),
60    'COMMENT_MULTI' => array('/*' => '*/'),
61    'COMMENT_REGEXP' => array(
62        //Multiline-continued single-line comments
63        1 => '/\/\/(?:\\\\\\\\|\\\\\\n|.)*$/m',
64        //Multiline-continued preprocessor define
65        2 => '/#(?:\\\\\\\\|\\\\\\n|.)*$/m'
66        ),
67    'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
68    'QUOTEMARKS' => array("'", '"'),
69    'ESCAPE_CHAR' => '',
70    'ESCAPE_REGEXP' => array(
71        //Simple Single Char Escapes
72        1 => "#\\\\[\\\\abfnrtv\'\"?\n]#i",
73        //Hexadecimal Char Specs
74        2 => "#\\\\x[\da-fA-F]{2}#",
75        //Hexadecimal Char Specs
76        3 => "#\\\\u[\da-fA-F]{4}#",
77        //Hexadecimal Char Specs
78        4 => "#\\\\U[\da-fA-F]{8}#",
79        //Octal Char Specs
80        5 => "#\\\\[0-7]{1,3}#"
81        ),
82    'NUMBERS' =>
83        GESHI_NUMBER_INT_BASIC | GESHI_NUMBER_INT_CSTYLE | GESHI_NUMBER_BIN_PREFIX_0B |
84        GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX | GESHI_NUMBER_FLT_NONSCI |
85        GESHI_NUMBER_FLT_NONSCI_F | GESHI_NUMBER_FLT_SCI_SHORT | GESHI_NUMBER_FLT_SCI_ZERO,
86    'KEYWORDS' => array(
87        1 => array(
88            'if', 'return', 'while', 'case', 'continue', 'default',
89            'do', 'else', 'for', 'switch', 'goto'
90            ),
91        2 => array(
92            'null', 'false', 'break', 'true', 'function', 'enum', 'extern', 'inline'
93            ),
94        3 => array(
95            // assert.h
96            'assert',
97
98            //complex.h
99            'cabs', 'cacos', 'cacosh', 'carg', 'casin', 'casinh', 'catan',
100            'catanh', 'ccos', 'ccosh', 'cexp', 'cimag', 'cis', 'clog', 'conj',
101            'cpow', 'cproj', 'creal', 'csin', 'csinh', 'csqrt', 'ctan', 'ctanh',
102
103            //ctype.h
104            'digittoint', 'isalnum', 'isalpha', 'isascii', 'isblank', 'iscntrl',
105            'isdigit', 'isgraph', 'islower', 'isprint', 'ispunct', 'isspace',
106            'isupper', 'isxdigit', 'toascii', 'tolower', 'toupper',
107
108            //inttypes.h
109            'imaxabs', 'imaxdiv', 'strtoimax', 'strtoumax', 'wcstoimax',
110            'wcstoumax',
111
112            //locale.h
113            'localeconv', 'setlocale',
114
115            //math.h
116            'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'cosh', 'exp',
117            'fabs', 'floor', 'frexp', 'ldexp', 'log', 'log10', 'modf', 'pow',
118            'sin', 'sinh', 'sqrt', 'tan', 'tanh',
119
120            //setjmp.h
121            'longjmp', 'setjmp',
122
123            //signal.h
124            'raise',
125
126            //stdarg.h
127            'va_arg', 'va_copy', 'va_end', 'va_start',
128
129            //stddef.h
130            'offsetof',
131
132            //stdio.h
133            'clearerr', 'fclose', 'fdopen', 'feof', 'ferror', 'fflush', 'fgetc',
134            'fgetpos', 'fgets', 'fopen', 'fprintf', 'fputc', 'fputchar',
135            'fputs', 'fread', 'freopen', 'fscanf', 'fseek', 'fsetpos', 'ftell',
136            'fwrite', 'getc', 'getch', 'getchar', 'gets', 'perror', 'printf',
137            'putc', 'putchar', 'puts', 'remove', 'rename', 'rewind', 'scanf',
138            'setbuf', 'setvbuf', 'snprintf', 'sprintf', 'sscanf', 'tmpfile',
139            'tmpnam', 'ungetc', 'vfprintf', 'vfscanf', 'vprintf', 'vscanf',
140            'vsprintf', 'vsscanf',
141
142            //stdlib.h
143            'abort', 'abs', 'atexit', 'atof', 'atoi', 'atol', 'bsearch',
144            'calloc', 'div', 'exit', 'free', 'getenv', 'itoa', 'labs', 'ldiv',
145            'ltoa', 'malloc', 'qsort', 'rand', 'realloc', 'srand', 'strtod',
146            'strtol', 'strtoul', 'system',
147
148            //string.h
149            'memchr', 'memcmp', 'memcpy', 'memmove', 'memset', 'strcat',
150            'strchr', 'strcmp', 'strcoll', 'strcpy', 'strcspn', 'strerror',
151            'strlen', 'strncat', 'strncmp', 'strncpy', 'strpbrk', 'strrchr',
152            'strspn', 'strstr', 'strtok', 'strxfrm',
153
154            //time.h
155            'asctime', 'clock', 'ctime', 'difftime', 'gmtime', 'localtime',
156            'mktime', 'strftime', 'time',
157
158            //wchar.h
159            'btowc', 'fgetwc', 'fgetws', 'fputwc', 'fputws', 'fwide',
160            'fwprintf', 'fwscanf', 'getwc', 'getwchar', 'mbrlen', 'mbrtowc',
161            'mbsinit', 'mbsrtowcs', 'putwc', 'putwchar', 'swprintf', 'swscanf',
162            'ungetwc', 'vfwprintf', 'vswprintf', 'vwprintf', 'wcrtomb',
163            'wcscat', 'wcschr', 'wcscmp', 'wcscoll', 'wcscpy', 'wcscspn',
164            'wcsftime', 'wcslen', 'wcsncat', 'wcsncmp', 'wcsncpy', 'wcspbrk',
165            'wcsrchr', 'wcsrtombs', 'wcsspn', 'wcsstr', 'wcstod', 'wcstok',
166            'wcstol', 'wcstoul', 'wcsxfrm', 'wctob', 'wmemchr', 'wmemcmp',
167            'wmemcpy', 'wmemmove', 'wmemset', 'wprintf', 'wscanf',
168
169            //wctype.h
170            'iswalnum', 'iswalpha', 'iswcntrl', 'iswctype', 'iswdigit',
171            'iswgraph', 'iswlower', 'iswprint', 'iswpunct', 'iswspace',
172            'iswupper', 'iswxdigit', 'towctrans', 'towlower', 'towupper',
173            'wctrans', 'wctype'
174            ),
175        4 => array(
176            'auto', 'char', 'const', 'double',  'float', 'int', 'long',
177            'register', 'short', 'signed', 'sizeof', 'static', 'struct',
178            'typedef', 'union', 'unsigned', 'void', 'volatile', 'wchar_t',
179
180            'int8', 'int16', 'int32', 'int64',
181            'uint8', 'uint16', 'uint32', 'uint64',
182
183            'int_fast8_t', 'int_fast16_t', 'int_fast32_t', 'int_fast64_t',
184            'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t', 'uint_fast64_t',
185
186            'int_least8_t', 'int_least16_t', 'int_least32_t', 'int_least64_t',
187            'uint_least8_t', 'uint_least16_t', 'uint_least32_t', 'uint_least64_t',
188
189            'int8_t', 'int16_t', 'int32_t', 'int64_t',
190            'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t',
191
192            'intmax_t', 'uintmax_t', 'intptr_t', 'uintptr_t',
193            'size_t', 'off_t'
194            ),
195        ),
196    'SYMBOLS' => array(
197        '(', ')', '{', '}', '[', ']',
198        '+', '-', '*', '/', '%',
199        '=', '<', '>',
200        '!', '^', '&', '|',
201        '?', ':',
202        ';', ','
203        ),
204    'CASE_SENSITIVE' => array(
205        GESHI_COMMENTS => false,
206        1 => true,
207        2 => true,
208        3 => true,
209        4 => true,
210        ),
211    'STYLES' => array(
212        'KEYWORDS' => array(
213            1 => 'color: #b1b100;',
214            2 => 'color: #000000; font-weight: bold;',
215            3 => 'color: #000066;',
216            4 => 'color: #993333;'
217            ),
218        'COMMENTS' => array(
219            1 => 'color: #666666; font-style: italic;',
220            2 => 'color: #339933;',
221            'MULTI' => 'color: #808080; font-style: italic;'
222            ),
223        'ESCAPE_CHAR' => array(
224            0 => 'color: #000099; font-weight: bold;',
225            1 => 'color: #000099; font-weight: bold;',
226            2 => 'color: #660099; font-weight: bold;',
227            3 => 'color: #660099; font-weight: bold;',
228            4 => 'color: #660099; font-weight: bold;',
229            5 => 'color: #006699; font-weight: bold;',
230            'HARD' => '',
231            ),
232        'BRACKETS' => array(
233            0 => 'color: #009900;'
234            ),
235        'STRINGS' => array(
236            0 => 'color: #ff0000;'
237            ),
238        'NUMBERS' => array(
239            0 => 'color: #0000dd;',
240            GESHI_NUMBER_BIN_PREFIX_0B => 'color: #208080;',
241            GESHI_NUMBER_OCT_PREFIX => 'color: #208080;',
242            GESHI_NUMBER_HEX_PREFIX => 'color: #208080;',
243            GESHI_NUMBER_FLT_SCI_SHORT => 'color:#800080;',
244            GESHI_NUMBER_FLT_SCI_ZERO => 'color:#800080;',
245            GESHI_NUMBER_FLT_NONSCI_F => 'color:#800080;',
246            GESHI_NUMBER_FLT_NONSCI => 'color:#800080;'
247            ),
248        'METHODS' => array(
249            1 => 'color: #202020;',
250            2 => 'color: #202020;'
251            ),
252        'SYMBOLS' => array(
253            0 => 'color: #339933;'
254            ),
255        'REGEXPS' => array(
256            ),
257        'SCRIPT' => array(
258            )
259        ),
260    'URLS' => array(
261        1 => '',
262        2 => '',
263        3 => 'http://www.opengroup.org/onlinepubs/009695399/functions/{FNAMEL}.html',
264        4 => ''
265        ),
266    'OOLANG' => true,
267    'OBJECT_SPLITTERS' => array(
268        1 => '.',
269        2 => '::'
270        ),
271    'REGEXPS' => array(
272        ),
273    'STRICT_MODE_APPLIES' => GESHI_NEVER,
274    'SCRIPT_DELIMITERS' => array(
275        ),
276    'HIGHLIGHT_STRICT_BLOCK' => array(
277        ),
278    'TAB_WIDTH' => 4
279);
280