pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PATCH for review


From: John Darrington
Subject: Re: PATCH for review
Date: Fri, 24 Mar 2017 20:40:01 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

On Fri, Mar 24, 2017 at 12:30:20PM -0700, Ben Pfaff wrote:
     
     That adds a reference to html.at, but what's in html.at?

Ahh sorry.  Updated patch follows:


From fa1e2f50efc0b7b8a9436b40568eadf03feae9dc Mon Sep 17 00:00:00 2001
From: John Darrington <address@hidden>
Date: Fri, 24 Mar 2017 17:40:39 +0100
Subject: [PATCH] Html Driver: Fix bug when rendering small cells.

This fix avoids a bug where the driver would enter a tight loop when rendering 
cells
with zero height or width.
---
 NEWS                 |  3 +++
 src/output/html.c    | 10 ++++++----
 tests/automake.mk    |  1 +
 tests/output/html.at | 29 +++++++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 4 deletions(-)
 create mode 100644 tests/output/html.at

diff --git a/NEWS b/NEWS
index 5085b1fa..141723b7 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@ Please send PSPP bug reports to address@hidden
 
 Changes from 0.10.2 to 0.10.4:
 
+ * A bug which could cause the HTML driver to go into a tight loop
+   has been fixed.
+
  * An error in the FREQUENCIES procedure, where the word "Mean" was
    printed when "Variance" was appropriate has been fixed.
 
diff --git a/src/output/html.c b/src/output/html.c
index 8b16ffa7..fd6d40d1 100644
--- a/src/output/html.c
+++ b/src/output/html.c
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2009, 2010, 2011, 2012, 2013, 2014 Free 
Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2009, 2010, 2011, 2012, 2013, 2014, 2017 Free 
Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -407,7 +407,6 @@ html_output_table (struct html_driver *html, const struct 
table_item *item)
   for (y = 0; y < table_nr (t); y++)
     {
       int x;
-
       for (x = 0; x < table_nc (t); )
         {
           const struct cell_contents *c;
@@ -415,7 +414,7 @@ html_output_table (struct html_driver *html, const struct 
table_item *item)
 
           table_get_cell (t, x, y, &cell);
           if (y != cell.d[TABLE_VERT][0])
-            continue;
+            goto next_0;
 
           for (c = cell.contents; c < &cell.contents[cell.n_contents]; c++)
             {
@@ -432,6 +431,8 @@ html_output_table (struct html_driver *html, const struct 
table_item *item)
                                  strlen (c->footnotes[i]), " ", "<BR>");
                 }
             }
+
+       next_0:
           x = cell.d[TABLE_HORZ][1];
           table_cell_free (&cell);
         }
@@ -465,7 +466,7 @@ html_output_table (struct html_driver *html, const struct 
table_item *item)
 
           table_get_cell (t, x, y, &cell);
           if (x != cell.d[TABLE_HORZ][0] || y != cell.d[TABLE_VERT][0])
-            continue;
+            goto next_1;
 
           /* Output <TD> or <TH> tag. */
           is_header = (y < table_ht (t)
@@ -570,6 +571,7 @@ html_output_table (struct html_driver *html, const struct 
table_item *item)
           /* Output </TH> or </TD>. */
           fprintf (html->file, "</%s>\n", tag);
 
+       next_1:
           x = cell.d[TABLE_HORZ][1];
           table_cell_free (&cell);
         }
diff --git a/tests/automake.mk b/tests/automake.mk
index 0fe8a5f6..93b19d82 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -394,6 +394,7 @@ TESTSUITE_AT = \
        tests/math/randist.at \
        tests/output/ascii.at \
        tests/output/charts.at \
+       tests/output/html.at \
        tests/output/output.at \
        tests/output/paper-size.at \
        tests/output/render.at \
diff --git a/tests/output/html.at b/tests/output/html.at
new file mode 100644
index 00000000..9a048caa
--- /dev/null
+++ b/tests/output/html.at
@@ -0,0 +1,29 @@
+AT_BANNER([HTML driver])
+
+AT_SETUP([HTML bug])
+
+dnl Checks for a bug which caused the html driver to go into a tight loop.
+AT_DATA([foo.sps], [data list notable list /w l96_r l99_r l102_r *.
+begin data.
+15  0 0 0 
+ 1  1 1 1 
+ 2  1 1 2 
+ 1  1 2 1 
+ 1  1 2 2 
+ 1  2 1 1 
+ 4  2 2 1 
+ 2  2 2 2 
+end data.
+
+weight by w.
+
+crosstabs
+       /tables=l96_r by l99_r by l102_r
+       /format=avalue table pivot
+       /statistics=none
+       /cell=count.
+])
+
+AT_CHECK([pspp -O format=html foo.sps], [0], [ignore])
+
+AT_CLEANUP
\ No newline at end of file
-- 
2.11.0


-- 
Avoid eavesdropping.  Send strong encrypted email.
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]