star-phor-input

File format for describing photoreactor configurations
git clone https://www.edstar.cnrs.fr/git/star-phor-input.git
Log | Files | Refs | README | LICENSE

commit 53b20438bcb538904857945febd60be357ea0626
parent a895f87231647defdc62e0e07b3dd2f75e834c59
Author: Eduardo Fontana Lazzari <edufonlaz@gmail.com>
Date:   Wed, 19 Mar 2025 10:27:01 +0100

Refactor input file line increments during parsing

Move them before exit/error blocks with return checks and error
handling, rather than within the exit blocks.

Diffstat:
Msrc/sphin_brdf.c | 4+++-
Msrc/sphin_sensor.c | 4+++-
Msrc/sphin_source.c | 8++++++--
Msrc/sphin_surface.c | 4+++-
Msrc/sphin_volume.c | 8++++++--
5 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/sphin_brdf.c b/src/sphin_brdf.c @@ -135,8 +135,10 @@ parse_brdf default: FATAL("Unreachable code\n"); break; } + res = txtrdr_read_line(txtrdr); + if (RES_OK != res) { goto error; } + exit: - txtrdr_read_line(txtrdr); *out_brdf = brdf; return res; error: diff --git a/src/sphin_sensor.c b/src/sphin_sensor.c @@ -117,8 +117,10 @@ parse_response_function token = strtok_r(NULL, " \t", &token_ptr); if (NULL != token) { res = RES_BAD_ARG; goto error; } + res = txtrdr_read_line(txtrdr); + if (RES_OK != res) { goto error; } + exit: - txtrdr_read_line(txtrdr); return res; error: goto exit; diff --git a/src/sphin_source.c b/src/sphin_source.c @@ -150,8 +150,10 @@ parse_direction_distribution } else { res = RES_BAD_ARG; goto error; } + res = txtrdr_read_line(txtrdr); + if (RES_OK != res) { goto error; } + exit: - txtrdr_read_line(txtrdr); return res; error: goto exit; @@ -210,8 +212,10 @@ parse_flux_density } else { res = RES_BAD_ARG; goto error; } + res = txtrdr_read_line(txtrdr); + if (RES_OK != res) { goto error; } + exit: - txtrdr_read_line(txtrdr); return res; error: goto exit; diff --git a/src/sphin_surface.c b/src/sphin_surface.c @@ -156,8 +156,10 @@ parse_geometry res = darray_sphin_geometry_ptr_push_back(&surface->geometries, &geom); if (RES_OK != res) { goto error; } + res = txtrdr_read_line(txtrdr); + if (RES_OK != res) { goto error; } + exit: - txtrdr_read_line(txtrdr); return res; error: goto exit; diff --git a/src/sphin_volume.c b/src/sphin_volume.c @@ -140,8 +140,10 @@ parse_geometry res = darray_sphin_geometry_ptr_push_back(&volume->geometries, &geom); if (RES_OK != res) { goto error; } + res = txtrdr_read_line(txtrdr); + if (RES_OK != res) { goto error; } + exit: - txtrdr_read_line(txtrdr); return res; error: goto exit; @@ -189,8 +191,10 @@ parse_ka token = strtok_r(NULL, " \t", &token_ptr); if (NULL != token) { res = RES_BAD_ARG; goto error; } + res = txtrdr_read_line(txtrdr); + if (RES_OK != res) { goto error; } + exit: - txtrdr_read_line(txtrdr); return res; error: goto exit;