diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-11-17 12:39:48 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-11-17 17:27:50 +0100 |
| commit | c560b7957664c32e2465e8425abaccc5a6b2607d (patch) | |
| tree | dd247a657f4bfa93d7259cb73ea1bb94a6f90c15 /src | |
| parent | 7eda8aacb65ca0a14eddb5721b24bdcf89d36a4e (diff) | |
| download | PROJ-c560b7957664c32e2465e8425abaccc5a6b2607d.tar.gz PROJ-c560b7957664c32e2465e8425abaccc5a6b2607d.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.cpp | 2 | ||||
| -rw-r--r-- | src/apps/cs2cs.cpp | 1 | ||||
| -rw-r--r-- | src/apps/geod.cpp | 1 | ||||
| -rw-r--r-- | src/apps/proj.cpp | 3 |
4 files changed, 7 insertions, 0 deletions
diff --git a/src/apps/cct.cpp b/src/apps/cct.cpp index c482efc2..fa75267a 100644 --- a/src/apps/cct.cpp +++ b/src/apps/cct.cpp @@ -470,6 +470,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); } } |
