diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-11-19 06:16:17 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-11-19 06:16:17 +0100 |
commit | 6f94a93c3e70d1d642c3ec870e3af2037b9c06c4 (patch) | |
tree | de746e6c2563a9c91b331d5d9785f400825f2fe9 /src | |
parent | preparation for tree simplification (diff) | |
download | mds-6f94a93c3e70d1d642c3ec870e3af2037b9c06c4.tar.gz mds-6f94a93c3e70d1d642c3ec870e3af2037b9c06c4.tar.bz2 mds-6f94a93c3e70d1d642c3ec870e3af2037b9c06c4.tar.xz |
missed a few macros
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/mds-kbdc/simplify-tree.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mds-kbdc/simplify-tree.c b/src/mds-kbdc/simplify-tree.c index 8a20caa..2b8c0bd 100644 --- a/src/mds-kbdc/simplify-tree.c +++ b/src/mds-kbdc/simplify-tree.c @@ -21,6 +21,27 @@ /** + * Wrapper around `asprintf` that makes sure that first + * argument gets set to `NULL` on error and that zero is + * returned on success rather than the number of printed + * characters + * + * @param VAR:char** The output parameter for the string + * @param ...:const char*, ... The format string and arguments + * @return :int Zero on success, -1 on error + */ +#define xasprintf(VAR, ...) \ + (asprintf(&(VAR), __VA_ARGS__) < 0 ? (VAR = NULL, -1) : 0) + + +/** + * Pointer to the beginning of the current line + */ +#define LINE \ + (source_code.lines[line_i]) + + +/** * Add an error the to error list * * @param ERROR_IS_IN_FILE:int Whether the error is in the layout code @@ -74,4 +95,6 @@ int simplify_tree(mds_kbdc_tree_t** restrict tree, mds_kbdc_parse_error_t*** res #undef NEW_ERROR +#undef LINE +#undef xasprintf |