star-hitran

Load line-by-line data from the HITRAN database
git clone git://git.meso-star.fr/star-hitran.git
Log | Files | Refs | README | LICENSE

commit 1973963f37a44dea6c27fce8f47cae76fff99dd9
parent f29a857f1516a02c966794ab80624bdce62ef1dd
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon,  5 Jan 2026 15:53:37 +0100

Change the behavior of the -h option of shtr

Do not display the brief help message, but use a user-readable format
for memory usage.

Diffstat:
Msrc/shtr_main.c | 16++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/shtr_main.c b/src/shtr_main.c @@ -35,7 +35,7 @@ struct args { char* lines; int verbose; /* Verbosity level */ - int quit; /* Quit the application */ + int human_readable; }; static const struct args ARGS_DEFAULT = {0}; @@ -68,10 +68,7 @@ args_init(struct args* args, int argc, char** argv) while((opt = getopt(argc, argv, "hl:m:v")) != -1) { switch(opt) { - case 'h': - usage(stdout); - args->quit = 1; - goto exit; + case 'h': args->human_readable = 1; break; case 'l': args->lines = optarg; break; case 'm': args->molparam = optarg; break; case 'v': args->verbose += (args->verbose < 3); break; @@ -190,8 +187,12 @@ cmd_run(const struct cmd* cmd) sz = MEM_ALLOCATED_SIZE(&cmd->allocator); - size_to_cstr(sz, SIZE_ALL, NULL, buf, sizeof(buf)); - printf("%s\n", buf); + if(!cmd->args.human_readable) { + printf("memory usage: %lu\n", (unsigned long)sz); + } else { + size_to_cstr(sz, SIZE_ALL, NULL, buf, sizeof(buf)); + printf("memory usage: %s\n", buf); + } exit: if(molparam) SHTR(isotope_metadata_ref_put(molparam)); @@ -213,7 +214,6 @@ main(int argc, char** argv) res_T res = RES_OK; if((res = args_init(&args, argc, argv)) != RES_OK) goto error; - if(args.quit) goto exit; if((res = cmd_init(&cmd, &args)) != RES_OK) goto error; if((res = cmd_run(&cmd)) != RES_OK) goto error;