aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-11-17 12:39:48 +0100
committerEven Rouault <even.rouault@spatialys.com>2020-11-17 17:35:45 +0100
commita85e2aed1551f7964f65cc7b7c373e56803c1fd6 (patch)
treee71cc57a98f41b51ebc81f784817823a7959d7f9 /src
parenteac2b01309bdec2375062c55de5b7f039edc4a84 (diff)
downloadPROJ-a85e2aed1551f7964f65cc7b7c373e56803c1fd6.tar.gz
PROJ-a85e2aed1551f7964f65cc7b7c373e56803c1fd6.zip
cs2cs, cct, proj and geod: fflush(stdout) after each line to emit each result as soon as it is produced
This is needed when working with pipes, when stdout is not an interactive terminal, and thus the behaviour is to have it buffered as a regular file, whereas with an interactive terminal, each newline character causes an implicit flush.
Diffstat (limited to 'src')
-rw-r--r--src/apps/cct.cpp2
-rw-r--r--src/apps/cs2cs.cpp1
-rw-r--r--src/apps/geod.cpp1
-rw-r--r--src/apps/proj.cpp3
4 files changed, 7 insertions, 0 deletions
diff --git a/src/apps/cct.cpp b/src/apps/cct.cpp
index f7413872..fe566920 100644
--- a/src/apps/cct.cpp
+++ b/src/apps/cct.cpp
@@ -405,6 +405,8 @@ int main(int argc, char **argv) {
decimals_distances, point.xyzt.z,
point.xyzt.t, comment_delimiter, comment
);
+ if( fout == stdout )
+ fflush(stdout);
}
proj_destroy(P);
diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp
index 58c164c9..1a33d444 100644
--- a/src/apps/cs2cs.cpp
+++ b/src/apps/cs2cs.cpp
@@ -217,6 +217,7 @@ static void process(FILE *fid)
printf("%s", s);
else
printf("\n");
+ fflush(stdout);
}
}
diff --git a/src/apps/geod.cpp b/src/apps/geod.cpp
index 919430ca..35a8e826 100644
--- a/src/apps/geod.cpp
+++ b/src/apps/geod.cpp
@@ -124,6 +124,7 @@ process(FILE *fid) {
(void)fputs(rtodms(pline, al21, 0, 0), stdout);
}
(void)fputs(s, stdout);
+ fflush(stdout);
}
}
diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp
index 0bf98b3a..c9bd8950 100644
--- a/src/apps/proj.cpp
+++ b/src/apps/proj.cpp
@@ -171,6 +171,7 @@ static void process(FILE *fid) {
(void)fputs("\t<* * * * * *>", stdout);
}
(void)fputs(bin_in ? "\n" : s, stdout);
+ fflush(stdout);
}
}
@@ -286,6 +287,8 @@ static void vprocess(FILE *fid) {
(void)fputs(proj_rtodms(pline, facs.meridian_convergence, 0, 0), stdout);
(void)printf(" [ %.8f ]\n", facs.meridian_convergence * RAD_TO_DEG);
(void)printf("Max-min (Tissot axis a-b) scale error: %.5f %.5f\n\n", facs.tissot_semimajor, facs.tissot_semiminor);
+
+ fflush(stdout);
}
}