Skip to content

Commit

Permalink
Use 'ustring_wrap_buf' where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanoBilenchi committed Jan 17, 2023
1 parent eba9c81 commit 339bee4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
36 changes: 18 additions & 18 deletions src/reader/functional/cowl_functional.y
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,38 @@
if (strcmp(s, "memory exhausted") == 0) {
COWL_HANDLE_MEM_ERROR();
} else {
cowl_handle_syntax_error(ustring_wrap(s, strlen(s)), stream,
cowl_handle_syntax_error(ustring_wrap_buf(s), stream,
(CowlErrorLoc) { .line = yylloc->last_line });
}
}

#ifdef YYNOMEM
#define COWL_ERROR_MEM YYNOMEM
#else
#define COWL_ERROR_MEM do { \
COWL_HANDLE_MEM_ERROR(); \
YYABORT; \
#define COWL_ERROR_MEM do { \
COWL_HANDLE_MEM_ERROR(); \
YYABORT; \
} while (0)
#endif

#define COWL_ERROR(CODE) do { \
if ((CODE) == COWL_ERR_MEM) { \
COWL_ERROR_MEM; \
} else { \
COWL_HANDLE_ERROR(CODE); \
YYERROR; \
} \
#define COWL_ERROR(CODE) do { \
if ((CODE) == COWL_ERR_MEM) { \
COWL_ERROR_MEM; \
} else { \
COWL_HANDLE_ERROR(CODE); \
YYERROR; \
} \
} while (0)

#define COWL_VEC_PUSH(T, VEC, OBJ) do { \
if (cowl_vector_push(VEC, OBJ)) COWL_ERROR_MEM; \
#define COWL_VEC_PUSH(T, VEC, OBJ) do { \
if (cowl_vector_push(VEC, OBJ)) COWL_ERROR_MEM; \
} while (0)

#define COWL_VEC_FINALIZE(VEC) do { \
if (VEC) { \
cowl_vector_release(VEC); \
if (cowl_vector_shrink(VEC)) COWL_ERROR_MEM; \
} \
#define COWL_VEC_FINALIZE(VEC) do { \
if (VEC) { \
cowl_vector_release(VEC); \
if (cowl_vector_shrink(VEC)) COWL_ERROR_MEM; \
} \
} while (0)
}

Expand Down
4 changes: 2 additions & 2 deletions test/tests/cowl_iri_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool cowl_test_iri_get_ns(void) {
for (unsigned i = 0; i < ulib_array_count(tests); ++i) {
char const *iri_str = tests[i][0];
char const *ns_str = tests[i][1];
CowlIRI *iri = cowl_iri_from_string(ustring_wrap(iri_str, strlen(iri_str)));
CowlIRI *iri = cowl_iri_from_string(ustring_wrap_buf(iri_str));
CowlString *ns = cowl_iri_get_ns(iri);
utest_assert_string(cowl_string_get_cstring(ns), ==, ns_str);
cowl_iri_release(iri);
Expand All @@ -53,7 +53,7 @@ bool cowl_test_iri_get_rem(void) {
for (unsigned i = 0; i < ulib_array_count(tests); ++i) {
char const *iri_str = tests[i][0];
char const *rem_str = tests[i][1];
CowlIRI *iri = cowl_iri_from_string(ustring_wrap(iri_str, strlen(iri_str)));
CowlIRI *iri = cowl_iri_from_string(ustring_wrap_buf(iri_str));
CowlString *rem = cowl_iri_get_rem(iri);
utest_assert_string(cowl_string_get_cstring(rem), ==, rem_str);
cowl_iri_release(iri);
Expand Down

0 comments on commit 339bee4

Please sign in to comment.