diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/n3.c | 8 | ||||
-rw-r--r-- | src/try.h | 27 | ||||
-rw-r--r-- | src/writer.c | 8 |
3 files changed, 29 insertions, 14 deletions
@@ -20,6 +20,7 @@ #include "serd_internal.h" #include "stack.h" #include "string_utils.h" +#include "try.h" #include "uri_utils.h" #include "serd/serd.h" @@ -41,13 +42,6 @@ _Pragma("clang diagnostic ignored \"-Wmissing-declarations\"") # define SERD_FALLTHROUGH #endif -#define TRY(st, exp) \ - do { \ - if (((st) = (exp))) { \ - return (st); \ - } \ - } while (0) - static bool fancy_syntax(const SerdReader* const reader) { diff --git a/src/try.h b/src/try.h new file mode 100644 index 00000000..82893887 --- /dev/null +++ b/src/try.h @@ -0,0 +1,27 @@ +/* + Copyright 2011-2021 David Robillard <d@drobilla.net> + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#ifndef SERD_TRY_H +#define SERD_TRY_H + +#define TRY(st, exp) \ + do { \ + if (((st) = (exp))) { \ + return (st); \ + } \ + } while (0) + +#endif // SERD_TRY_H diff --git a/src/writer.c b/src/writer.c index 5a605cd4..55136b98 100644 --- a/src/writer.c +++ b/src/writer.c @@ -21,6 +21,7 @@ #include "sink.h" #include "string_utils.h" #include "system.h" +#include "try.h" #include "uri_utils.h" #include "world.h" @@ -40,13 +41,6 @@ # define SERD_WARN_UNUSED_RESULT #endif -#define TRY(st, exp) \ - do { \ - if (((st) = (exp))) { \ - return (st); \ - } \ - } while (0) - typedef enum { CTX_NAMED, ///< Normal non-anonymous context CTX_BLANK, ///< Anonymous blank node |