fbuf: New data structure for buffered file I/O.
[pspp] / src / output / ascii.c
index 636d9ecc4fc822ed949f35ddbcce291a2a686e65..5a4c8c7e5652bf68fa61f469a864aa06574d8e7b 100644 (file)
@@ -127,7 +127,15 @@ static const ucs4_t unicode_box_chars[N_BOX] =
 static inline int
 make_box_index (int left, int right, int top, int bottom)
 {
-  return ((right * RENDER_N_LINES + bottom) * RENDER_N_LINES + left) * RENDER_N_LINES + top;
+  int start_side = left;
+  int end_side = right;
+  if (render_direction_rtl ())
+    {
+      start_side = right;
+      end_side = left;
+    }
+
+  return ((end_side * RENDER_N_LINES + bottom) * RENDER_N_LINES + start_side) * RENDER_N_LINES + top;
 }
 
 /* How to emphasize text. */
@@ -449,7 +457,7 @@ ascii_output_table_item (struct ascii_driver *a,
       used = render_pager_draw_next (p, a->length - a->y);
       if (used == 0)
         {
-          assert (a->y > 0);
+          assert (a->y >= 0);
           ascii_close_page (a);
           if (!ascii_open_page (a))
             break;
@@ -492,7 +500,7 @@ ascii_submit (struct output_driver *driver,
 
       file_name = xr_draw_png_chart (chart_item, a->chart_file_name,
                                      a->chart_cnt++,
-                                    &a->fg, 
+                                    &a->fg,
                                     &a->bg);
       if (file_name != NULL)
         {
@@ -1092,7 +1100,7 @@ ascii_open_page (struct ascii_driver *a)
 
   if (a->file == NULL)
     {
-      a->file = fn_open (a->handle, a->append ? "a" : "w");
+      a->file = fn_fopen (a->handle, a->append ? "a" : "w");
       if (a->file != NULL)
         {
          if ( isatty (fileno (a->file)))