summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrés M <andmarti1424@users.noreply.github.com>2018-05-31 13:35:43 -0300
committerGitHub <noreply@github.com>2018-05-31 13:35:43 -0300
commita7f9e7d9584c90862791d7c19d663841dd82ac9c (patch)
tree9dec4f01a137ca3d8001af7ecaf8b1a37721a94e /src
parentdd1646024b6feef6f88062ef638bcc149d9bd655 (diff)
parent04d28a7555405a15b3e93de769510b18c4a58c62 (diff)
Merge pull request #263 from immae/freeze
Send informational messages to stderr rather than the output when used in non-interactive mode
Diffstat (limited to 'src')
-rw-r--r--src/macros.h2
-rw-r--r--src/pipe.c10
-rw-r--r--src/tui.c12
3 files changed, 17 insertions, 7 deletions
diff --git a/src/macros.h b/src/macros.h
index 3bb1afa..486c846 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -103,10 +103,12 @@
#define CELL_NEGATIVE 17
#define DEFAULT 18
#define DEBUG_MSG 19
+#define VALUE_MSG 20
void ui_sc_msg(char * s, int type, ...);
#define sc_error(x, ...) ui_sc_msg(x, ERROR_MSG, ##__VA_ARGS__)
#define sc_debug(x, ...) ui_sc_msg(x, DEBUG_MSG, ##__VA_ARGS__)
#define sc_info(x, ...) ui_sc_msg(x, INFO_MSG, ##__VA_ARGS__)
+#define sc_value(x, ...) ui_sc_msg(x, VALUE_MSG, ##__VA_ARGS__)
#define RUNTIME ((current_tv.tv_sec - startup_tv.tv_sec) * 1000L + (current_tv.tv_usec - startup_tv.tv_usec) / 1000L)
diff --git a/src/pipe.c b/src/pipe.c
index 5ae89c2..30c2417 100644
--- a/src/pipe.c
+++ b/src/pipe.c
@@ -83,7 +83,7 @@ void getnum(int r0, int c0, int rn, int cn, FILE * fd) {
sprintf(line, "%.15g", p->v);
}
}
- sc_info("%s", line);
+ sc_value("%s", line);
if (brokenpipe) {
linelim = -1;
return;
@@ -106,7 +106,7 @@ void getnum(int r0, int c0, int rn, int cn, FILE * fd) {
void getformat(int col, FILE * fd) {
sprintf(line, "%d %d %d\n", fwidth[col], precision[col], realfmt[col]);
//write(fd, line, strlen(line));
- sc_info("%s", line);
+ sc_value("%s", line);
linelim = -1;
}
@@ -130,7 +130,7 @@ void getfmt(int r0, int c0, int rn, int cn, FILE * fd) {
for (c = c0, pp = ATBL(tbl, r, c); c <= cn; pp++, c++) {
*line = '\0';
if (*pp && (*pp)->format) sprintf(line, "%s", (*pp)->format);
- sc_info("%s", line);
+ sc_value("%s", line);
if (brokenpipe) {
linelim = -1;
return;
@@ -161,7 +161,7 @@ void getstring(int r0, int c0, int rn, int cn, FILE * fd) {
*line = '\0';
if (*pp && (*pp)->label)
sprintf(line, "%s", (*pp)->label);
- sc_info("%s", line);
+ sc_value("%s", line);
if (brokenpipe) {
linelim = -1;
return;
@@ -199,7 +199,7 @@ void getexp(int r0, int c0, int rn, int cn, FILE * fd) {
if (*line == '?')
*line = '\0';
}
- sc_info("%s", line);
+ sc_value("%s", line);
if (brokenpipe) {
linelim = -1;
return;
diff --git a/src/tui.c b/src/tui.c
index 737eb40..81998cd 100644
--- a/src/tui.c
+++ b/src/tui.c
@@ -239,9 +239,9 @@ void ui_sc_msg(char * s, int type, ...) {
}
wrefresh(input_win);
- } else if (get_conf_value("output") != NULL && fdoutput != NULL) {
+ } else if (type == VALUE_MSG && get_conf_value("output") != NULL && fdoutput != NULL) {
fwprintf(fdoutput, L"%s\n", t);
- } else {
+ } else if (type == VALUE_MSG) {
if (fwide(stdout, 0) >0)
//wprintf(L"wide %s\n", t);
wprintf(L"%s\n", t);
@@ -249,6 +249,14 @@ void ui_sc_msg(char * s, int type, ...) {
//printf("nowide %s\n", t);
printf("%s\n", t);
fflush(stdout);
+ } else {
+ if (fwide(stderr, 0) >0)
+ //wprintf(L"wide %s\n", t);
+ fwprintf(stderr, L"%s\n", t);
+ else
+ //printf("nowide %s\n", t);
+ fprintf(stderr, "%s\n", t);
+ fflush(stderr);
}
va_end(args);
return;