diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-12-30 04:46:17 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-12-30 04:46:17 +0400 |
commit | 4ed9cea8ce210588f374fabeb75e0d70364f5b08 (patch) | |
tree | 0b49736042792b533e6c65f0dee610aa67b7189d /source/blender/editors/space_text/text_format.h | |
parent | 1fd05207256c13ea9a7c10db2ac6afc9334586dd (diff) |
code cleanup: text editor formatting enums were named crypticly, also add asserts if the continuation values are wrong (which can happen with buffer overflows on formatting).
Diffstat (limited to 'source/blender/editors/space_text/text_format.h')
-rw-r--r-- | source/blender/editors/space_text/text_format.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/editors/space_text/text_format.h b/source/blender/editors/space_text/text_format.h index dc7f35f8eaf..e5c3db4f121 100644 --- a/source/blender/editors/space_text/text_format.h +++ b/source/blender/editors/space_text/text_format.h @@ -41,6 +41,20 @@ typedef struct FlattenString { int pos, len; } FlattenString; +/* format continuation flags (stored just after the NULL terminator) */ +enum { + FMT_CONT_NOP = 0, /* no continuation */ + FMT_CONT_QUOTESINGLE = (1 << 0), /* single quotes */ + FMT_CONT_QUOTEDOUBLE = (1 << 1), /* double quotes */ + FMT_CONT_TRIPLE = (1 << 2), /* triplets of quotes: """ or ''' */ + FMT_CONT_QUOTESINGLE_TRIPLE = (FMT_CONT_TRIPLE | FMT_CONT_QUOTESINGLE), + FMT_CONT_QUOTEDOUBLE_TRIPLE = (FMT_CONT_TRIPLE | FMT_CONT_QUOTEDOUBLE), + FMT_CONT_COMMENT_C = (1 << 3), /* multi-line comments, OSL only (C style) */ + FMT_CONT_COMMENT_CXX = (1 << 4), /* single-line comments, OSL only (C++ style) */ +}; +#define FMT_CONT_ALL \ + (FMT_CONT_QUOTESINGLE | FMT_CONT_QUOTEDOUBLE | FMT_CONT_TRIPLE | FMT_CONT_COMMENT_C | FMT_CONT_COMMENT_CXX) + int flatten_string(struct SpaceText *st, FlattenString *fs, const char *in); void flatten_string_free(FlattenString *fs); int flatten_string_strlen(FlattenString *fs, const char *str); |