From e5bde10056fab271ec252bdf833119e1d109121d Mon Sep 17 00:00:00 2001 From: q-posev Date: Fri, 3 Dec 2021 19:23:01 +0100 Subject: [PATCH] alternative way to check for EOF with fgets while reading --- src/templates_text/templator_text.org | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/templates_text/templator_text.org b/src/templates_text/templator_text.org index e408510..3259c73 100644 --- a/src/templates_text/templator_text.org +++ b/src/templates_text/templator_text.org @@ -1059,7 +1059,7 @@ trexio_exit_code trexio_text_write_$group_dset$(trexio_t* const file, rc = fprintf(f, "$group_dset_format_printf$\n", $group_dset_sparse_indices_printf$, - value_sparse[i]); + *(value_sparse + i)); if(rc <= 0) { fclose(f); @@ -1110,7 +1110,7 @@ trexio_exit_code trexio_text_read_$group_dset$(trexio_t* const file, /* Build the name of the file with sparse data. The $group_dset$.txt is limited to 256 symbols for the moment. What are the chances that it will exceed? - */ + ,*/ const char $group_dset$_file_name[256] = "/$group_dset$.txt"; /* The full path to the destination TXT file with sparse data. This will include TREXIO directory name. */ char file_full_path[TREXIO_MAX_FILENAME_LENGTH]; @@ -1127,27 +1127,29 @@ trexio_exit_code trexio_text_read_$group_dset$(trexio_t* const file, /* Specify the line length in order to offset properly. For example, for 4-index quantities the line_length is 69 because 10 per index + 4 spaces + 24 for floating point value + 1 for the new line char - */ + ,*/ const uint64_t line_length = $group_dset_sparse_line_length$L; fseek(f, (long) offset_file * line_length, SEEK_SET); /* Read the data from the file and check the return code of fprintf to verify that > 0 bytes have been read or reached EOF */ int rc; + char buffer[1024]; for (uint64_t i=0L; i