Skip to content

Commit

Permalink
Merge pull request #102 from Burke-Lauenroth-Lab/bugfix_88-rSOILWAT2
Browse files Browse the repository at this point in the history
Bugfix 88 rSOILWAT2
- `LogError` writes to R console only if `fp` file pointer is not null
- this is a mechanism to implement quiet runs
  • Loading branch information
dschlaep committed Dec 7, 2017
2 parents 70f382c + b2cf53c commit 77d8a48
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void LogError(FILE *fp, const int mode, const char *fmt, ...) {

char outfmt[50 + strlen(fmt)]; /* to prepend err type str */
va_list args;
int check_eof;
int check_eof = 0;

va_start(args, fmt);

Expand All @@ -214,19 +214,19 @@ void LogError(FILE *fp, const int mode, const char *fmt, ...) {
strcat(outfmt, "\n");

#ifdef RSOILWAT
check_eof = TRUE;
REvprintf(outfmt, args);
if (fp != NULL) {
REvprintf(outfmt, args);
}

#else
check_eof = (EOF == vfprintf(fp, outfmt, args));
#endif

if (check_eof)
sw_error(0, "SYSTEM: Cannot write to FILE *fp in LogError()\n");

#ifndef RSOILWAT
if (check_eof)
sw_error(0, "SYSTEM: Cannot write to FILE *fp in LogError()\n");
fflush(fp);
#endif


logged = TRUE;
va_end(args);

Expand Down

0 comments on commit 77d8a48

Please sign in to comment.