chiark / gitweb /
Output processing.
[ypp-sc-tools.main.git] / pctb / structure.c
index 8919e0b07e9f69a909819d381c6faa0537f579e0..8141feb3db461c60099841db25d3a4954d018dec 100644 (file)
@@ -339,7 +339,7 @@ static void find_table_entry(Rect commod, int colno, Rect *cellr) {
   require_rectangle_r(*cellr, " o");
 }
 
-static void ocr_rectangle(Rect r, const OcrCellType ct) {
+static void ocr_rectangle(Rect r, const OcrCellType ct, FILE *tsv_output) {
   OcrResultGlyph *results, *res;
 
   int w= r.br.x - r.tl.x + 1;
@@ -364,10 +364,10 @@ static void ocr_rectangle(Rect r, const OcrCellType ct) {
 
   results= ocr(rd,ct,w,cols);
   for (res=results; res->s; res++)
-    printf("%s",res->s);
+    fputs(res->s,tsv_output);
 }
 
-void analyse(void) {
+void analyse(FILE *tsv_output) {
   Rect thisr, entryr;
   int page, tryrect, colno;
 
@@ -386,16 +386,17 @@ void analyse(void) {
       const char *tab= "";
       for (colno=0; colno<columns; colno++) {
        find_table_entry(thisr,colno,&entryr);
-       fputs(tab, stdout);
+       fputs(tab, tsv_output);
        ocr_rectangle(entryr,
                      colno<TEXT_COLUMNS
                      ? &ocr_celltype_text
-                     : &ocr_celltype_number);
+                     : &ocr_celltype_number,
+                     tsv_output);
        tab= "\t";
       }
-      fputs("\n", stdout);
-      sysassert(!ferror(stdout));
-      sysassert(!fflush(stdout));
+      fputs("\n", tsv_output);
+      sysassert(!ferror(tsv_output));
+      sysassert(!fflush(tsv_output));
     }
   }
 }