tylerlong / google-code-prettify

Automatically exported from code.google.com/p/google-code-prettify
Apache License 2.0
0 stars 0 forks source link

[PATCH] C99 types highlighting #143

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The attached patch is a proposal for C99 types highlighting (uint8_t, uint32_t, 
etc.) so that these types get highlighted just like the standard C types (int, 
float, etc).

I believe a few other types (not necessarily C99) should be considered, such as 
time_t, div_t, ldiv_t, lldiv_t... but the current ones are certainly the most 
widespread.

Original issue reported on code.google.com by sam@hocevar.net on 19 Mar 2011 at 3:26

Attachments:

GoogleCodeExporter commented 9 years ago
If I were to reclassify int, float, etc. as types and change it so that *_t 
tokens are classified as types, would that address this?  Or do you want all of 
these recognized as keywords?

Original comment by mikesamuel@gmail.com on 21 Mar 2011 at 5:33

GoogleCodeExporter commented 9 years ago
You're right, I believe the types option is far superior! I like having int, 
float etc. coloured differently than if, for, return etc.

Original comment by sam@hocevar.net on 21 Mar 2011 at 5:43

GoogleCodeExporter commented 9 years ago
Ok.  I'll fix that then.

Do you know of any list of words that are commonly type names?

For example, I've seen a lot of codebases use bool, wchar, and uint32 often 
defined without an _t suffix. 

Original comment by msam...@google.com on 21 Mar 2011 at 6:10

GoogleCodeExporter commented 9 years ago
I can compile a reasonable list together with source information and will get 
back to you.

Original comment by sam@hocevar.net on 21 Mar 2011 at 6:18

GoogleCodeExporter commented 9 years ago
Here is the list. I hope I haven't missed any important ones.

C and C++ types:
char double enum float int long short signed struct union unsigned void

GCC extension for AltiVec:
vector

C and C++ qualifiers:
auto const extern register static volatile

C and C++ keywords:
break case continue default do else for goto if return sizeof switch
typedef while

C99 types:
_Bool _Complex _Imaginary

C99 qualifiers:
inline restrict

C++ keywords:
asm bool catch class const_cast delete dynamic_cast explicit export false
friend inline mutable namespace new operator private protected public
reinterpret_cast static_cast template this throw true try typeid typename
using virtual

C99 types (from stdint.h and inttypes.h):
intptr_t uintptr_t int8_t int16_t int32_t int64_t uint8_t uint16_t
uint32_t uint64_t int_least8_t int_least16_t int_least32_t int_least64_t
uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_fast8_t
int_fast16_t int_fast32_t int_fast64_t uint_fast8_t uint_fast16_t
uint_fast32_t uint_fast64_t intmax_t uintmax_t

Common Unix types (from 
http://pubs.opengroup.org/onlinepubs/007908799/xsh/datatypes.html):
cc_t clock_t clockid_t dev_t DIR div_t FILE glob_t fpos_t gid_t iconv_t
id_t ino_t key_t ldiv_t mode_t mqd_t nfds_t nlink_t off_t pid_t pthread_attr_t
pthread_cond_t pthread_condattr_t pthread_key_t pthread_mutex_t
pthread_mutexattr_t pthread_once_t pthread_rwlock_t pthread_rwlockattr_t
pthread_t ptrdiff_t regex_t regmatch_t rlim_t sem_t sig_atomic_t sigset_t
size_t speed_t ssize_t suseconds_t tcflag_t time_t timer_t uid_t useconds_t
va_list wchar_t wctype_t wint_t wordexp_t

<sys/types.h> (from 
http://pubs.opengroup.org/onlinepubs/007908799/xsh/systypes.h.html):
blkcnt_t blksize_t fsblkcnt_t fsfilcnt_t

Original comment by sam@hocevar.net on 21 Mar 2011 at 10:05

GoogleCodeExporter commented 9 years ago
Attached is a possible patch for C types.  Do you have a shortish code snippet 
that exercises some of these that I could use as a testcase?

Original comment by mikesamuel@gmail.com on 4 Apr 2011 at 5:41

Attachments:

GoogleCodeExporter commented 9 years ago
Committed at revision 177.

Original comment by mikesamuel@gmail.com on 25 Apr 2011 at 4:40