diff options
| author | tb <> | 2024-12-27 11:17:48 +0000 |
|---|---|---|
| committer | tb <> | 2024-12-27 11:17:48 +0000 |
| commit | c0ac38c8c9e36d18575006b55c8e70e3ab70978c (patch) | |
| tree | 6acc1cf9b306fbd9d5cfb1f6102aef66fef31bf3 /src | |
| parent | 07a60b34d3827f191dcafe3f9c3803b7c3417649 (diff) | |
| download | openbsd-c0ac38c8c9e36d18575006b55c8e70e3ab70978c.tar.gz openbsd-c0ac38c8c9e36d18575006b55c8e70e3ab70978c.tar.bz2 openbsd-c0ac38c8c9e36d18575006b55c8e70e3ab70978c.zip | |
parse test file: add helper to skip to end of line
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/mlkem/parse_test_file.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/regress/lib/libcrypto/mlkem/parse_test_file.c b/src/regress/lib/libcrypto/mlkem/parse_test_file.c index 4138e82b67..19f03439e2 100644 --- a/src/regress/lib/libcrypto/mlkem/parse_test_file.c +++ b/src/regress/lib/libcrypto/mlkem/parse_test_file.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: parse_test_file.c,v 1.2 2024/12/26 05:51:41 tb Exp $ */ | 1 | /* $OpenBSD: parse_test_file.c,v 1.3 2024/12/27 11:17:48 tb Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> |
| @@ -446,6 +446,13 @@ parse_instruction_get_cbs(struct parse *p, size_t idx, CBS *out) | |||
| 446 | return 1; | 446 | return 1; |
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | static void | ||
| 450 | parse_line_skip_to_end(struct parse *p) | ||
| 451 | { | ||
| 452 | if (!CBS_skip(&p->cbs, CBS_len(&p->cbs))) | ||
| 453 | parse_errx(p, "CBS_skip"); | ||
| 454 | } | ||
| 455 | |||
| 449 | static int | 456 | static int |
| 450 | CBS_peek_bytes(CBS *cbs, CBS *out, size_t len) | 457 | CBS_peek_bytes(CBS *cbs, CBS *out, size_t len) |
| 451 | { | 458 | { |
| @@ -462,7 +469,7 @@ parse_peek_string_cbs(struct parse *p, const char *str) | |||
| 462 | size_t len = strlen(str); | 469 | size_t len = strlen(str); |
| 463 | 470 | ||
| 464 | if (!CBS_peek_bytes(&p->cbs, &cbs, len)) | 471 | if (!CBS_peek_bytes(&p->cbs, &cbs, len)) |
| 465 | parse_errx(p, "CBS_peek_data"); | 472 | parse_errx(p, "CBS_peek_bytes"); |
| 466 | 473 | ||
| 467 | return CBS_mem_equal(&cbs, (const uint8_t *)str, len); | 474 | return CBS_mem_equal(&cbs, (const uint8_t *)str, len); |
| 468 | } | 475 | } |
| @@ -526,8 +533,7 @@ parse_empty_or_comment_line(struct parse *p) | |||
| 526 | return 1; | 533 | return 1; |
| 527 | } | 534 | } |
| 528 | if (parse_peek_string_cbs(p, "#")) { | 535 | if (parse_peek_string_cbs(p, "#")) { |
| 529 | if (!CBS_skip(&p->cbs, CBS_len(&p->cbs))) | 536 | parse_line_skip_to_end(p); |
| 530 | parse_errx(p, "CBS_skip"); | ||
| 531 | return 1; | 537 | return 1; |
| 532 | } | 538 | } |
| 533 | return 0; | 539 | return 0; |
| @@ -543,10 +549,8 @@ parse_string_match_line(struct parse *p) | |||
| 543 | string_matches = parse_get_string_cbs(p, match(p)); | 549 | string_matches = parse_get_string_cbs(p, match(p)); |
| 544 | parse_state_set_int(p, string_matches); | 550 | parse_state_set_int(p, string_matches); |
| 545 | 551 | ||
| 546 | if (!string_matches) { | 552 | if (!string_matches) |
| 547 | if (!CBS_skip(&p->cbs, CBS_len(&p->cbs))) | 553 | parse_line_skip_to_end(p); |
| 548 | parse_errx(p, "CBS_skip"); | ||
| 549 | } | ||
| 550 | } | 554 | } |
| 551 | 555 | ||
| 552 | static int | 556 | static int |
