solstice

Compute collected power and efficiencies of a solar plant
git clone git://git.meso-star.com/solstice.git
Log | Files | Refs | README | LICENSE

commit df567bc59be67a1ec20f2d8625fb5899e9f3625b
parent c064e03a9bf1df81a7d2ff5acc66c321647c6481
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 23 Nov 2016 09:32:56 +0100

Fix an issue in solstice_parser_find_entity

If the submitted entity name referenced an invalid sub-entity in a valid
entity, the function returned the last valid entity rather than NULL.

Diffstat:
Msrc/parser/solstice_parser.c | 4++--
Msrc/parser/test_solstice_parser2.c | 2++
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/parser/solstice_parser.c b/src/parser/solstice_parser.c @@ -2991,8 +2991,7 @@ solstice_parser_find_entity res = str_set(&str, name); if(res != RES_OK) { - fprintf(stderr, "%s: could not copy the input string.\n", - FUNC_NAME); + fprintf(stderr, "%s: could not copy the input string.\n", FUNC_NAME); goto error; } res = str_reserve(&str_tk, str_len(&str)); @@ -3011,6 +3010,7 @@ solstice_parser_find_entity pientity = htable_str2sols_find(htable, &str_tk); if(!pientity) { tk = NULL; + entity = NULL; } else { tk = strtok(NULL, "."); entity = darray_entity_data_get(&parser->entities) + *pientity; diff --git a/src/parser/test_solstice_parser2.c b/src/parser/test_solstice_parser2.c @@ -191,6 +191,8 @@ main(int argc, char** argv) CHECK(entity3, entity1b); entity3 = solstice_parser_find_entity(parser, "lvl 0.lvl1b.lvl2"); CHECK(entity3, entity2); + entity3 = solstice_parser_find_entity(parser,"lvl 0.lvl1b.bad_name"); + CHECK(entity3, NULL); sun = solstice_parser_get_sun(parser); NCHECK(sun, NULL);