Skip to content

Add BSD extension functions to the C function list #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ Highlighting of class names in declarations is disabled by default. To enable se
let g:cpp_class_decl_highlight = 1
```

Highlighting of POSIX functions is disabled by default. To enable set
```vim
let g:cpp_posix_standard = 1
```

Highlighting of BSD extension functions is disabled by default. To enable set
```vim
let g:cpp_bsd_standard = 1
```

There are two ways to highlight template functions. Either
```vim
let g:cpp_experimental_simple_template_highlight = 1
Expand Down
52 changes: 52 additions & 0 deletions after/syntax/c.vim
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,56 @@ if exists('g:cpp_member_variable_highlight') && g:cpp_member_variable_highlight
hi def link cCustomMemVar Function
endif

" -----------------------------------------------------------------------------
" Highlight POSIX functions.
" -----------------------------------------------------------------------------
if exists('g:cpp_posix_standard') && g:cpp_posix_standard
syn keyword cPOSIXFunction socket accept bind connect getsockname
syn keyword cPOSIXFunction listen recv recvfrom recvmsg
syn keyword cPOSIXFunction send sendto sendmsg setsockopt socketpair
syn keyword cPOSIXFunction htonl htons ntohl ntohs
syn keyword cPOSIXFunction inet_ntop inet_pton getaddrinfo
syn keyword cPOSIXFunction poll select pselect
hi def link cPOSIXFunction Function
endif

" Highlight BSD extensions.
" -----------------------------------------------------------------------------
if exists('g:cpp_bsd_standard') && g:cpp_bsd_standard
syn keyword cBSDFunction err errx warn warnx verr verrx vwarn vwarnx
syn keyword cBSDFunction errc verrc warnc vwarnc
syn keyword cBSDFunction strtonum strtoi strtou
syn keyword cBSDFunction dehumanize_number expand_number
syn keyword cBSDFunction strlcat strlcpy strnstr wcslcat wcslcpy
syn keyword cBSDFunction vis nvis strvis stravis strnvis strvisx
syn keyword cBSDFunction strnvisx strenvisx svis snvis strsvis
syn keyword cBSDFunction strsnvis strsvisx strsnvisx strsenvisx
syn keyword cBSDFunction unvis strunvis strnunvis strunvisx strnunvisx
syn keyword cBSDFunction arc4random arc4random_buf arc4random_uniform
syn keyword cBSDFunction arc4random_stir arc4random_addrrandom
syn keyword cBSDFunction be16dec be32dec be64dec le16dec le32dec le64dec
syn keyword cBSDFunction be16enc be32enc be64enc le16enc le32enc le64enc
syn keyword cBSDFunction bit_alloc bit_decl bit_clear bit_ffc bit_ffs
syn keyword cBSDFunction bit_nclear bit_nset bit_set bitstr_size
syn keyword cBSDFunction bit_test
syn keyword cBSDFunction sl_init sl_add sl_free sl_find sl_delete
syn keyword cBSDFunction closefrom bzero explicit_bzero
syn keyword cBSDFunction fgetln fgetwln flopen fmtcheck fparseln fpurge
syn keyword cBSDFunction funopen strmode
syn keyword cBSDFunction getbsize getmode setmode getpeereid
syn keyword cBSDFunction pidfile_open pidfile_write pidfile_close
syn keyword cBSDFunction pidfile_remove pidfile_fileno
syn keyword cBSDFunction getprogname setprogname nlist
syn keyword cBSDFunction setproctitle_init setproctitle
syn keyword cBSDFunction heapsort mergesort radixsort sradixsort
syn keyword cBSDFunction MD5Init MD5Update MD5Pad MD5Final MD5Transform
syn keyword cBSDFunction MD5End MD5File MD5FileChunk MD5Data
syn keyword cBSDFunction readpassphrase
syn keyword cBSDFunction reallocarray reallocf
syn keyword cBSDFunction timeradd timersub timerclear timerisset timercmp
syn keyword cBSDFunction timespecadd timespecsub timespecclear
syn keyword cBSDFunction timespecisset timespeccmp
endif
" -----------------------------------------------------------------------------
" Source: aftersyntaxc.vim
" -----------------------------------------------------------------------------
Expand Down Expand Up @@ -208,6 +258,7 @@ syn keyword cAnsiFunction UINTMAX_C INTMAX_C UINT64_C
syn keyword cAnsiFunction UINT32_C UINT16_C UINT8_C
syn keyword cAnsiFunction INT64_C INT32_C INT16_C INT8_C


" Common ANSI-standard Names
syn keyword cAnsiName PRId8 PRIi16 PRIo32 PRIu64
syn keyword cAnsiName PRId16 PRIi32 PRIo64 PRIuLEAST8
Expand Down Expand Up @@ -261,6 +312,7 @@ syn keyword cAnsiName and_eq compl or xor_eq
syn keyword cAnsiName bitand not or_eq

hi def link cAnsiFunction cFunction
hi def link cBSDFunction cFunction
hi def link cAnsiName cIdentifier
hi def link cFunction Function
hi def link cIdentifier Identifier
Expand Down
Loading