2 " Language: C Additions
3 " Maintainer: Mikhail Wolfson <mywolfson@gmail.com>
4 " URL: http://web.mit.edu/wolfsonm
5 " Last Change: 2010 Dec. 3
9 " 0.4 - updates and fixes to cDelimiter to fix break with foldmethod=syntax,
10 " entirely suggested and solved by Ivan Freitas
11 " <ivansichfreitas@gmail.com>
12 " 0.3 - updates and fixes to cUserFunctionPointer, thanks to
13 " Alexei <lxmzhv@gmail.com>
14 " 0.2 - change [] to operator
15 " 0.1 - initial upload, modification from vimscript#1201, Extended c.vim
18 " Common ANSI-standard functions
19 syn keyword cAnsiFunction MULU_ DIVU_ MODU_ MUL_ DIV_ MOD_
20 syn keyword cAnsiFunction main typeof
21 syn keyword cAnsiFunction open close read write lseek dup dup2
22 syn keyword cAnsiFunction fcntl ioctl
23 syn keyword cAnsiFunction wctrans towctrans towupper
24 syn keyword cAnsiFunction towlower wctype iswctype
25 syn keyword cAnsiFunction iswxdigit iswupper iswspace
26 syn keyword cAnsiFunction iswpunct iswprint iswlower
27 syn keyword cAnsiFunction iswgraph iswdigit iswcntrl
28 syn keyword cAnsiFunction iswalpha iswalnum wcsrtombs
29 syn keyword cAnsiFunction mbsrtowcs wcrtomb mbrtowc
30 syn keyword cAnsiFunction mbrlen mbsinit wctob
31 syn keyword cAnsiFunction btowc wcsfxtime wcsftime
32 syn keyword cAnsiFunction wmemset wmemmove wmemcpy
33 syn keyword cAnsiFunction wmemcmp wmemchr wcstok
34 syn keyword cAnsiFunction wcsstr wcsspn wcsrchr
35 syn keyword cAnsiFunction wcspbrk wcslen wcscspn
36 syn keyword cAnsiFunction wcschr wcsxfrm wcsncmp
37 syn keyword cAnsiFunction wcscoll wcscmp wcsncat
38 syn keyword cAnsiFunction wcscat wcsncpy wcscpy
39 syn keyword cAnsiFunction wcstoull wcstoul wcstoll
40 syn keyword cAnsiFunction wcstol wcstold wcstof
41 syn keyword cAnsiFunction wcstod ungetwc putwchar
42 syn keyword cAnsiFunction putwc getwchar getwc
43 syn keyword cAnsiFunction fwide fputws fputwc
44 syn keyword cAnsiFunction fgetws fgetwc wscanf
45 syn keyword cAnsiFunction wprintf vwscanf vwprintf
46 syn keyword cAnsiFunction vswscanf vswprintf vfwscanf
47 syn keyword cAnsiFunction vfwprintf swscanf swprintf
48 syn keyword cAnsiFunction fwscanf fwprintf zonetime
49 syn keyword cAnsiFunction strfxtime strftime localtime
50 syn keyword cAnsiFunction gmtime ctime asctime
51 syn keyword cAnsiFunction time mkxtime mktime
52 syn keyword cAnsiFunction difftime clock strlen
53 syn keyword cAnsiFunction strerror memset strtok
54 syn keyword cAnsiFunction strstr strspn strrchr
55 syn keyword cAnsiFunction strpbrk strcspn strchr
56 syn keyword cAnsiFunction memchr strxfrm strncmp
57 syn keyword cAnsiFunction strcoll strcmp memcmp
58 syn keyword cAnsiFunction strncat strcat strncpy
59 syn keyword cAnsiFunction strcpy memmove memcpy
60 syn keyword cAnsiFunction wcstombs mbstowcs wctomb
61 syn keyword cAnsiFunction mbtowc mblen lldiv
62 syn keyword cAnsiFunction ldiv div llabs
63 syn keyword cAnsiFunction labs abs qsort
64 syn keyword cAnsiFunction bsearch system getenv
65 syn keyword cAnsiFunction exit atexit abort
66 syn keyword cAnsiFunction realloc malloc free
67 syn keyword cAnsiFunction calloc srand rand
68 syn keyword cAnsiFunction strtoull strtoul strtoll
69 syn keyword cAnsiFunction strtol strtold strtof
70 syn keyword cAnsiFunction strtod atoll atol
71 syn keyword cAnsiFunction atoi atof perror
72 syn keyword cAnsiFunction ferror feof clearerr
73 syn keyword cAnsiFunction rewind ftell fsetpos
74 syn keyword cAnsiFunction fseek fgetpos fwrite
75 syn keyword cAnsiFunction fread ungetc puts
76 syn keyword cAnsiFunction putchar putc gets
77 syn keyword cAnsiFunction getchar getc fputs
78 syn keyword cAnsiFunction fputc fgets fgetc
79 syn keyword cAnsiFunction vsscanf vsprintf vsnprintf
80 syn keyword cAnsiFunction vscanf vprintf vfscanf
81 syn keyword cAnsiFunction vfprintf sscanf sprintf
82 syn keyword cAnsiFunction snprintf scanf printf
83 syn keyword cAnsiFunction fscanf fprintf setvbuf
84 syn keyword cAnsiFunction setbuf freopen fopen
85 syn keyword cAnsiFunction fflush fclose tmpnam
86 syn keyword cAnsiFunction tmpfile rename remove
87 syn keyword cAnsiFunction offsetof va_start va_end
88 syn keyword cAnsiFunction va_copy va_arg raise signal
89 syn keyword cAnsiFunction longjmp setjmp isunordered
90 syn keyword cAnsiFunction islessgreater islessequal isless
91 syn keyword cAnsiFunction isgreaterequal isgreater fmal
92 syn keyword cAnsiFunction fmaf fma fminl
93 syn keyword cAnsiFunction fminf fmin fmaxl
94 syn keyword cAnsiFunction fmaxf fmax fdiml
95 syn keyword cAnsiFunction fdimf fdim nextafterxl
96 syn keyword cAnsiFunction nextafterxf nextafterx nextafterl
97 syn keyword cAnsiFunction nextafterf nextafter nanl
98 syn keyword cAnsiFunction nanf nan copysignl
99 syn keyword cAnsiFunction copysignf copysign remquol
100 syn keyword cAnsiFunction remquof remquo remainderl
101 syn keyword cAnsiFunction remainderf remainder fmodl
102 syn keyword cAnsiFunction fmodf fmod truncl
103 syn keyword cAnsiFunction truncf trunc llroundl
104 syn keyword cAnsiFunction llroundf llround lroundl
105 syn keyword cAnsiFunction lroundf lround roundl
106 syn keyword cAnsiFunction roundf round llrintl
107 syn keyword cAnsiFunction llrintf llrint lrintl
108 syn keyword cAnsiFunction lrintf lrint rintl
109 syn keyword cAnsiFunction rintf rint nearbyintl
110 syn keyword cAnsiFunction nearbyintf nearbyint floorl
111 syn keyword cAnsiFunction floorf floor ceill
112 syn keyword cAnsiFunction ceilf ceil tgammal
113 syn keyword cAnsiFunction tgammaf tgamma lgammal
114 syn keyword cAnsiFunction lgammaf lgamma erfcl
115 syn keyword cAnsiFunction erfcf erfc erfl
116 syn keyword cAnsiFunction erff erf sqrtl
117 syn keyword cAnsiFunction sqrtf sqrt powl
118 syn keyword cAnsiFunction powf pow hypotl
119 syn keyword cAnsiFunction hypotf hypot fabsl
120 syn keyword cAnsiFunction fabsf fabs cbrtl
121 syn keyword cAnsiFunction cbrtf cbrt scalblnl
122 syn keyword cAnsiFunction scalblnf scalbln scalbnl
123 syn keyword cAnsiFunction scalbnf scalbn modfl
124 syn keyword cAnsiFunction modff modf logbl
125 syn keyword cAnsiFunction logbf logb log2l
126 syn keyword cAnsiFunction log2f log2 log1pl
127 syn keyword cAnsiFunction log1pf log1p log10l
128 syn keyword cAnsiFunction log10f log10 logl
129 syn keyword cAnsiFunction logf log ldexpl
130 syn keyword cAnsiFunction ldexpf ldexp ilogbl
131 syn keyword cAnsiFunction ilogbf ilogb frexpl
132 syn keyword cAnsiFunction frexpf frexp expm1l
133 syn keyword cAnsiFunction expm1f expm1 exp2l
134 syn keyword cAnsiFunction exp2f exp2 expl
135 syn keyword cAnsiFunction expf exp tanhl
136 syn keyword cAnsiFunction tanhf tanh sinhl
137 syn keyword cAnsiFunction sinhf sinh coshl
138 syn keyword cAnsiFunction coshf cosh atanhl
139 syn keyword cAnsiFunction atanhf atanh asinhl
140 syn keyword cAnsiFunction asinhf asinh acoshl
141 syn keyword cAnsiFunction acoshf acosh tanl
142 syn keyword cAnsiFunction tanf tan sinl
143 syn keyword cAnsiFunction sinf sin cosl
144 syn keyword cAnsiFunction cosf cos atan2l
145 syn keyword cAnsiFunction atan2f atan2 atanl
146 syn keyword cAnsiFunction atanf atan asinl
147 syn keyword cAnsiFunction asinf asin acosl
148 syn keyword cAnsiFunction acosf acos signbit
149 syn keyword cAnsiFunction isnormal isnan isinf
150 syn keyword cAnsiFunction isfinite fpclassify localeconv
151 syn keyword cAnsiFunction setlocale wcstoumax wcstoimax
152 syn keyword cAnsiFunction strtoumax strtoimax feupdateenv
153 syn keyword cAnsiFunction fesetenv feholdexcept fegetenv
154 syn keyword cAnsiFunction fesetround fegetround fetestexcept
155 syn keyword cAnsiFunction fesetexceptflag feraiseexcept fegetexceptflag
156 syn keyword cAnsiFunction feclearexcept toupper tolower
157 syn keyword cAnsiFunction isxdigit isupper isspace
158 syn keyword cAnsiFunction ispunct isprint islower
159 syn keyword cAnsiFunction isgraph isdigit iscntrl
160 syn keyword cAnsiFunction isalpha isalnum creall
161 syn keyword cAnsiFunction crealf creal cprojl
162 syn keyword cAnsiFunction cprojf cproj conjl
163 syn keyword cAnsiFunction conjf conj cimagl
164 syn keyword cAnsiFunction cimagf cimag cargl
165 syn keyword cAnsiFunction cargf carg csqrtl
166 syn keyword cAnsiFunction csqrtf csqrt cpowl
167 syn keyword cAnsiFunction cpowf cpow cabsl
168 syn keyword cAnsiFunction cabsf cabs clogl
169 syn keyword cAnsiFunction clogf clog cexpl
170 syn keyword cAnsiFunction cexpf cexp ctanhl
171 syn keyword cAnsiFunction ctanhf ctanh csinhl
172 syn keyword cAnsiFunction csinhf csinh ccoshl
173 syn keyword cAnsiFunction ccoshf ccosh catanhl
174 syn keyword cAnsiFunction catanhf catanh casinhl
175 syn keyword cAnsiFunction casinhf casinh cacoshl
176 syn keyword cAnsiFunction cacoshf cacosh ctanl
177 syn keyword cAnsiFunction ctanf ctan csinl
178 syn keyword cAnsiFunction csinf csin ccosl
179 syn keyword cAnsiFunction ccosf ccos catanl
180 syn keyword cAnsiFunction catanf catan casinl
181 syn keyword cAnsiFunction casinf casin cacosl
182 syn keyword cAnsiFunction cacosf cacos assert
183 syn keyword cAnsiFunction UINTMAX_C INTMAX_C UINT64_C
184 syn keyword cAnsiFunction UINT32_C UINT16_C UINT8_C
185 syn keyword cAnsiFunction INT64_C INT32_C INT16_C INT8_C
187 " Common ANSI-standard Names
188 syn keyword cAnsiName PRId8 PRIi16 PRIo32 PRIu64
189 syn keyword cAnsiName PRId16 PRIi32 PRIo64 PRIuLEAST8
190 syn keyword cAnsiName PRId32 PRIi64 PRIoLEAST8 PRIuLEAST16
191 syn keyword cAnsiName PRId64 PRIiLEAST8 PRIoLEAST16 PRIuLEAST32
192 syn keyword cAnsiName PRIdLEAST8 PRIiLEAST16 PRIoLEAST32 PRIuLEAST64
193 syn keyword cAnsiName PRIdLEAST16 PRIiLEAST32 PRIoLEAST64 PRIuFAST8
194 syn keyword cAnsiName PRIdLEAST32 PRIiLEAST64 PRIoFAST8 PRIuFAST16
195 syn keyword cAnsiName PRIdLEAST64 PRIiFAST8 PRIoFAST16 PRIuFAST32
196 syn keyword cAnsiName PRIdFAST8 PRIiFAST16 PRIoFAST32 PRIuFAST64
197 syn keyword cAnsiName PRIdFAST16 PRIiFAST32 PRIoFAST64 PRIuMAX
198 syn keyword cAnsiName PRIdFAST32 PRIiFAST64 PRIoMAX PRIuPTR
199 syn keyword cAnsiName PRIdFAST64 PRIiMAX PRIoPTR PRIx8
200 syn keyword cAnsiName PRIdMAX PRIiPTR PRIu8 PRIx16
201 syn keyword cAnsiName PRIdPTR PRIo8 PRIu16 PRIx32
202 syn keyword cAnsiName PRIi8 PRIo16 PRIu32 PRIx64
204 syn keyword cAnsiName PRIxLEAST8 SCNd8 SCNiFAST32 SCNuLEAST32
205 syn keyword cAnsiName PRIxLEAST16 SCNd16 SCNiFAST64 SCNuLEAST64
206 syn keyword cAnsiName PRIxLEAST32 SCNd32 SCNiMAX SCNuFAST8
207 syn keyword cAnsiName PRIxLEAST64 SCNd64 SCNiPTR SCNuFAST16
208 syn keyword cAnsiName PRIxFAST8 SCNdLEAST8 SCNo8 SCNuFAST32
209 syn keyword cAnsiName PRIxFAST16 SCNdLEAST16 SCNo16 SCNuFAST64
210 syn keyword cAnsiName PRIxFAST32 SCNdLEAST32 SCNo32 SCNuMAX
211 syn keyword cAnsiName PRIxFAST64 SCNdLEAST64 SCNo64 SCNuPTR
212 syn keyword cAnsiName PRIxMAX SCNdFAST8 SCNoLEAST8 SCNx8
213 syn keyword cAnsiName PRIxPTR SCNdFAST16 SCNoLEAST16 SCNx16
214 syn keyword cAnsiName PRIX8 SCNdFAST32 SCNoLEAST32 SCNx32
215 syn keyword cAnsiName PRIX16 SCNdFAST64 SCNoLEAST64 SCNx64
216 syn keyword cAnsiName PRIX32 SCNdMAX SCNoFAST8 SCNxLEAST8
217 syn keyword cAnsiName PRIX64 SCNdPTR SCNoFAST16 SCNxLEAST16
218 syn keyword cAnsiName PRIXLEAST8 SCNi8 SCNoFAST32 SCNxLEAST32
219 syn keyword cAnsiName PRIXLEAST16 SCNi16 SCNoFAST64 SCNxLEAST64
220 syn keyword cAnsiName PRIXLEAST32 SCNi32 SCNoMAX SCNxFAST8
221 syn keyword cAnsiName PRIXLEAST64 SCNi64 SCNoPTR SCNxFAST16
222 syn keyword cAnsiName PRIXFAST8 SCNiLEAST8 SCNu8 SCNxFAST32
223 syn keyword cAnsiName PRIXFAST16 SCNiLEAST16 SCNu16 SCNxFAST64
224 syn keyword cAnsiName PRIXFAST32 SCNiLEAST32 SCNu32 SCNxMAX
225 syn keyword cAnsiName PRIXFAST64 SCNiLEAST64 SCNu64 SCNxPTR
226 syn keyword cAnsiName PRIXMAX SCNiFAST8 SCNuLEAST8
227 syn keyword cAnsiName PRIXPTR SCNiFAST16 SCNuLEAST16
229 syn keyword cAnsiName errno environ
231 syn keyword cAnsiName STDC CX_LIMITED_RANGE
232 syn keyword cAnsiName STDC FENV_ACCESS
233 syn keyword cAnsiName STDC FP_CONTRACT
235 syn keyword cAnsiName AF_INET SOCK_STREAM INADDR_ANY AF_INET
236 syn keyword cAnsiName SOL_SOCKET SO_REUSEPORT SO_REUSEADDR
237 syn keyword cAnsiName SO_RCVTIMEO IPPROTO_TCP TCP_NODELAY
238 syn keyword cAnsiName SOCK_DGRAM POLLIN
240 syn keyword cAnsiName and bitor not_eq xor
241 syn keyword cAnsiName and_eq compl or xor_eq
242 syn keyword cAnsiName bitand not or_eq
244 hi def link cAnsiFunction cFunction
245 hi def link cAnsiName cIdentifier
248 syn match cOperator "\(<<\|>>\|[-+*/%&^|<>!=]\)="
249 syn match cOperator "<<\|>>\|&&\|||\|++\|--\|->"
250 syn match cOperator "[.!~*&%<>^|=,+-]"
251 syn match cOperator "/[^/*=]"me=e-1
252 syn match cOperator "/$"
253 syn match cOperator "&&\|||"
254 syn match cOperator "[][]"
257 syn keyword cDefined defined contained containedin=cDefine
258 hi def link cDefined cDefine
261 syn match cUserFunction "\<\h\w*\>\(\s\|\n\)*("me=e-1 contains=cType,cDelimiter,cDefine
262 syn match cUserFunctionPointer "(\s*\*\s*\h\w*\s*)\(\s\|\n\)*(" contains=cDelimiter,cOperator
264 hi def link cUserFunction cFunction
265 hi def link cUserFunctionPointer cFunction
268 syn match cDelimiter "[();\\]"
269 " foldmethod=syntax fix, courtesy of Ivan Freitas
270 syn match cBraces display "[{}]"
274 syn keyword cBoolean true false TRUE FALSE
278 hi def link cFunction Function
279 hi def link cIdentifier Identifier
280 hi def link cDelimiter Delimiter
281 " foldmethod=syntax fix, courtesy of Ivan Freitas
282 hi def link cBraces Delimiter
283 hi def link cBoolean Boolean