From 192e367fad12c40b55b664c6500457679bbfea46 Mon Sep 17 00:00:00 2001 From: Ole <> Date: Thu, 5 Dec 2024 14:19:36 +0100 Subject: [PATCH] Fix bugs. Add suggestions to style guide. --- README.md | 4 ++++ src/src/load.cpp | 13 ++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0b1723c..0d5a1ef 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,10 @@ The goal of this section is to improve the readability of the code and reduce co - braces after a function declaration or a control flow statement go on a new line; - first-level braces at the beginning of a line appear in the first column; - closing braces appear in the same column as their counterpart. +- spaces...: + - ... around binary operators; + - ... after commas; + - ... before opening parentheses and after closing parentheses. If you use vim, the default C formatting should be fine (':h C-indenting'). diff --git a/src/src/load.cpp b/src/src/load.cpp index a2811f5..845c845 100644 --- a/src/src/load.cpp +++ b/src/src/load.cpp @@ -267,8 +267,9 @@ int load( char *file) // getcwd(path, 255); // getcwd(temp, sizeof(temp)) ? std::string( temp ) : std::string("") - GetCurrentDir( path, 255 ); - warning("Current working directory: %s\n", path); + if (GetCurrentDir(path, 255) != NULL) { + warning("Current working directory: %s\n", path); + } // warning("Current working directory: %s\n", std::filesystem::current_path()); /* error("Can't open \"%s\"", "rate_file");*/ warning("Can not open ratefile: %s", file); @@ -410,11 +411,6 @@ int create_output_fn_dir() { char buffer_sup_fn_dest [1024]; sprintf (buffer_sup_fn_dest, "%s%s", buffer_output_dir, rate_file_name); FILE *source = fopen(rate_file_name, "rb"); - FILE *destination = fopen(buffer_sup_fn_dest, "wb"); - // copy the .sup-file (rate_file_name) into the subfolder: - char buffer_sup_fn_dest[1024]; - sprintf (buffer_sup_fn_dest, "%s%s", buffer_output_dir, rate_file_base_name); - FILE *source = fopen(rate_file_name, "rb"); if (source == NULL) { Rprintf("Could not open source (rate) file: %s\n", strerror(errno)); } @@ -422,8 +418,7 @@ int create_output_fn_dir() { if (destination == NULL) { stop("Could not open destination file: %s\n", strerror(errno)); } - >>>>>>> main - char buffer[1024]; + char buffer[1024]; size_t bytes_read; while ((bytes_read = fread(buffer, 1, sizeof(buffer), source)) > 0) { fwrite(buffer, 1, bytes_read, destination);