Changes in uspace/lib/bithenge/src/script.c [6cd10ac:b7fd2a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/bithenge/src/script.c
r6cd10ac rb7fd2a0 99 99 /** Rather than constantly checking return values, the parser uses this 100 100 * to indicate whether an error has occurred. */ 101 int error;101 errno_t error; 102 102 103 103 /** The list of named transforms. */ … … 148 148 149 149 /** Note that an error has occurred if error is not EOK. */ 150 static void error_errno(state_t *state, int error)150 static void error_errno(state_t *state, errno_t error) 151 151 { 152 152 // Don't overwrite a previous error. … … 276 276 state->buffer_pos++; 277 277 state->token = TOKEN_INTEGER; 278 int rc = bithenge_parse_int(state->buffer +278 errno_t rc = bithenge_parse_int(state->buffer + 279 279 state->old_buffer_pos, &state->token_int); 280 280 error_errno(state, rc); … … 520 520 static bithenge_expression_t *parse_term(state_t *state) 521 521 { 522 int rc;522 errno_t rc; 523 523 if (state->token == TOKEN_TRUE || state->token == TOKEN_FALSE) { 524 524 bool val = state->token == TOKEN_TRUE; … … 630 630 static bithenge_expression_t *parse_postfix_expression(state_t *state) 631 631 { 632 int rc;632 errno_t rc; 633 633 bithenge_expression_t *expr = parse_term(state); 634 634 while (state->error == EOK) { … … 737 737 break; 738 738 } 739 int rc = bithenge_binary_expression(&expr, op, expr, expr2);739 errno_t rc = bithenge_binary_expression(&expr, op, expr, expr2); 740 740 if (rc != EOK) { 741 741 expr = NULL; … … 797 797 798 798 if (num_params) { 799 int rc = bithenge_param_wrapper(&result, result, params);799 errno_t rc = bithenge_param_wrapper(&result, result, params); 800 800 if (rc != EOK) { 801 801 error_errno(state, rc); … … 813 813 { 814 814 bithenge_node_t *node; 815 int rc = bithenge_new_empty_internal_node(&node);815 errno_t rc = bithenge_new_empty_internal_node(&node); 816 816 if (rc != EOK) { 817 817 error_errno(state, rc); … … 869 869 870 870 bithenge_transform_t *if_xform; 871 int rc = bithenge_if_transform(&if_xform, expr, true_xform,871 errno_t rc = bithenge_if_transform(&if_xform, expr, true_xform, 872 872 false_xform); 873 873 if (rc != EOK) { … … 893 893 next_token(state); 894 894 bithenge_node_t *node; 895 int rc = bithenge_new_boolean_node(&node, true);895 errno_t rc = bithenge_new_boolean_node(&node, true); 896 896 if (rc != EOK) { 897 897 error_errno(state, rc); … … 907 907 if (state->error == EOK) { 908 908 bithenge_expression_inc_ref(ref_expr); 909 int rc = bithenge_binary_expression(&expr,909 errno_t rc = bithenge_binary_expression(&expr, 910 910 BITHENGE_EXPRESSION_EQUALS, ref_expr, 911 911 expr); … … 947 947 while (state->error == EOK && num >= 1) { 948 948 num--; 949 int rc = bithenge_if_transform(&switch_xform, exprs[num],949 errno_t rc = bithenge_if_transform(&switch_xform, exprs[num], 950 950 xforms[num], switch_xform); 951 951 if (rc != EOK) { … … 987 987 988 988 bithenge_transform_t *repeat_xform; 989 int rc = bithenge_repeat_transform(&repeat_xform, xform, expr);989 errno_t rc = bithenge_repeat_transform(&repeat_xform, xform, expr); 990 990 if (rc != EOK) { 991 991 error_errno(state, rc); … … 1013 1013 1014 1014 bithenge_transform_t *do_while_xform; 1015 int rc = bithenge_do_while_transform(&do_while_xform, xform, expr);1015 errno_t rc = bithenge_do_while_transform(&do_while_xform, xform, expr); 1016 1016 if (rc != EOK) { 1017 1017 error_errno(state, rc); … … 1031 1031 1032 1032 bithenge_expression_t *in_expr; 1033 int rc = bithenge_in_node_expression(&in_expr);1033 errno_t rc = bithenge_in_node_expression(&in_expr); 1034 1034 if (rc != EOK) 1035 1035 error_errno(state, rc); … … 1061 1061 } 1062 1062 1063 int rc = bithenge_partial_transform(&xform, xform);1063 errno_t rc = bithenge_partial_transform(&xform, xform); 1064 1064 if (rc != EOK) { 1065 1065 error_errno(state, rc); … … 1130 1130 subxforms[num].transform = NULL; 1131 1131 bithenge_transform_t *result; 1132 int rc = bithenge_new_struct(&result, subxforms);1132 errno_t rc = bithenge_new_struct(&result, subxforms); 1133 1133 if (rc != EOK) { 1134 1134 error_errno(state, rc); … … 1153 1153 1154 1154 bithenge_transform_t *xform; 1155 int rc;1155 errno_t rc; 1156 1156 if (state->in_node_used) 1157 1157 rc = bithenge_expression_transform(&xform, expr); … … 1211 1211 if (xforms) { 1212 1212 xforms[0] = result; 1213 int rc = bithenge_new_composed_transform(&result, xforms, num);1213 errno_t rc = bithenge_new_composed_transform(&result, xforms, num); 1214 1214 if (rc != EOK) { 1215 1215 error_errno(state, rc); … … 1244 1244 bithenge_transform_t *barrier = NULL; 1245 1245 if (state->error == EOK) { 1246 int rc = bithenge_new_barrier_transform(&barrier,1246 errno_t rc = bithenge_new_barrier_transform(&barrier, 1247 1247 state->num_params); 1248 1248 if (rc != EOK) { … … 1259 1259 1260 1260 if (state->error == EOK) { 1261 int rc = bithenge_barrier_transform_set_subtransform(barrier,1261 errno_t rc = bithenge_barrier_transform_set_subtransform(barrier, 1262 1262 xform); 1263 1263 xform = NULL; … … 1321 1321 * @return EOK on success, EINVAL on syntax error, or an error code from 1322 1322 * errno.h. */ 1323 int bithenge_parse_script(const char *filename, bithenge_transform_t **out)1323 errno_t bithenge_parse_script(const char *filename, bithenge_transform_t **out) 1324 1324 { 1325 1325 state_t state; … … 1328 1328 parse_definition(&state); 1329 1329 *out = get_named_transform(&state, "main"); 1330 int rc = state.error;1330 errno_t rc = state.error; 1331 1331 state_destroy(&state); 1332 1332 if (rc == EOK && !*out) {
Note:
See TracChangeset
for help on using the changeset viewer.