From: Ben Pfaff Date: Tue, 6 Jan 2026 20:14:54 +0000 (-0800) Subject: fixes X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e76ee68f9ca464724377fc9be6b0b16a0d93eff7;p=pspp fixes --- diff --git a/rust/pspp/src/output/drivers/html.rs b/rust/pspp/src/output/drivers/html.rs index eaa623f6b0..a057364a4e 100644 --- a/rust/pspp/src/output/drivers/html.rs +++ b/rust/pspp/src/output/drivers/html.rs @@ -322,8 +322,10 @@ where writeln!(&mut self.writer, "") } - fn put_border(dst: &mut String, style: BorderStyle, border_name: &str) { - if let Some(css_style) = style.stroke.as_css() { + fn put_border(dst: &mut String, style: Option, border_name: &str) { + if let Some(style) = style + && let Some(css_style) = style.stroke.as_css() + { write!(dst, "border-{border_name}: {css_style}").unwrap(); if style.color != Color::BLACK { write!(dst, " {}", style.color.display_css()).unwrap(); diff --git a/rust/pspp/src/output/drivers/text/text_line.rs b/rust/pspp/src/output/drivers/text/text_line.rs index 9d1019c465..f93dda5d8e 100644 --- a/rust/pspp/src/output/drivers/text/text_line.rs +++ b/rust/pspp/src/output/drivers/text/text_line.rs @@ -322,7 +322,7 @@ impl TextLine { impl Display for TextLine { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(&self.string) + f.write_str(self.string.trim_end()) } } diff --git a/rust/pspp/src/output/pivot/output.rs b/rust/pspp/src/output/pivot/output.rs index e918401cef..b4d1db2885 100644 --- a/rust/pspp/src/output/pivot/output.rs +++ b/rust/pspp/src/output/pivot/output.rs @@ -302,9 +302,9 @@ impl PivotTable { .rev() .filter(|(dimension, _)| !dimension.is_empty()) .map(|(dimension, &layer_index)| { - // Append `:` to the name of the dimension, preserving all the styling. + // Append `: ` to the name of the dimension, preserving all the styling. let name = dimension.root.name(); - let text = format!("{}:", name.display(self).without_suffixes()); + let text = format!("{}: ", name.display(self).without_suffixes()); let name = Value::new_user_text(text).with_styling(name.styling.clone()); self.create_aux_table( diff --git a/rust/pspp/src/output/render.rs b/rust/pspp/src/output/render.rs index 301eb0186a..69676343b2 100644 --- a/rust/pspp/src/output/render.rs +++ b/rust/pspp/src/output/render.rs @@ -671,24 +671,23 @@ impl Page { bb: Rect2, bg: Color, ) { - const NO_BORDER: BorderStyle = BorderStyle::none(); let styles = EnumMap::from_fn(|a: Axis2| { let b = !a; if !is_rule(coord[a]) { - [NO_BORDER, NO_BORDER] + [None, None] } else if is_rule(coord[b]) { let first = if coord[b] > 0 { let mut e = coord; e[b] -= 1; self.get_rule(a, e) } else { - NO_BORDER + None }; let second = if coord[b] / 2 < self.table.n()[b] { self.get_rule(a, coord) } else { - NO_BORDER + None }; [first, second] @@ -698,10 +697,14 @@ impl Page { } }); - device.draw_line(bb.translate(ofs), styles, bg); + if styles.values().any(|[a, b]| a.is_some() || b.is_some()) { + const NO_BORDER: BorderStyle = BorderStyle::none(); + let styles = styles.map(|_, [a, b]| [a.unwrap_or(NO_BORDER), b.unwrap_or(NO_BORDER)]); + device.draw_line(bb.translate(ofs), styles, bg); + } } - fn get_rule(&self, a: Axis2, coord: CellPos) -> BorderStyle { + fn get_rule(&self, a: Axis2, coord: CellPos) -> Option { let coord = CellPos::from_fn(|a| coord[a] / 2); self.table.table.get_rule(a, coord) } @@ -893,8 +896,9 @@ fn measure_rule(device: &dyn Device, table: &Table, a: Axis2, z: usize) -> isize // Determine the types of rules that are present. let mut rules = EnumMap::default(); for w in 0..table.n[b] { - let stroke = table.get_rule(a, CellPos::for_axis((a, z), w)).stroke; - rules[stroke] = true; + if let Some(border) = table.get_rule(a, CellPos::for_axis((a, z), w)) { + rules[border.stroke] = true; + } } // Turn off [Stroke::None] because it has width 0 and we needn't bother. diff --git a/rust/pspp/src/output/table.rs b/rust/pspp/src/output/table.rs index c9bd0ee2eb..228c76d9a7 100644 --- a/rust/pspp/src/output/table.rs +++ b/rust/pspp/src/output/table.rs @@ -368,8 +368,8 @@ impl Table { } } - pub fn get_rule(&self, axis: Axis2, pos: CellPos) -> BorderStyle { - self.rules[axis][[pos.x, pos.y]].map_or(BorderStyle::none(), |b| self.borders[b]) + pub fn get_rule(&self, axis: Axis2, pos: CellPos) -> Option { + self.rules[axis][[pos.x, pos.y]].map(|b| self.borders[b]) } pub fn put(&mut self, region: CellRect, inner: CellInner) { diff --git a/rust/pspp/src/spv/testdata/legacy17.expected b/rust/pspp/src/spv/testdata/legacy17.expected index 721c6b55a2..fcc6c531dd 100644 --- a/rust/pspp/src/spv/testdata/legacy17.expected +++ b/rust/pspp/src/spv/testdata/legacy17.expected @@ -1,10 +1,10 @@ - Coefficients[a]  + Coefficients[a]  ╭───────────────┬────────────────────────────┬─────────────────────────┬──────┬────╮ -│ │ Unstandardized Coefficients│Standardized Coefficients│ │ │ -│ ├────────────┬───────────────┼─────────────────────────┤ │ │ -│Model │ B │ Std. Error │ Beta │ t │Sig.│ +│ │ Unstandardized Coefficients│Standardized Coefficients│ │ │ +│ ├────────────┬───────────────┼─────────────────────────┤ │ │ +│Model │ B │ Std. Error │ Beta │ t │Sig.│ ├───────────────┼────────────┼───────────────┼─────────────────────────┼──────┼────┤ -│1.00 (Constant)│ 59.146│ 18.854│ │ 3.137│.016│ -│ Variable A│ -.664│ .585│ -.395│-1.136│.293│ +│1.00 (Constant)│ 59.146│ 18.854│ │ 3.137│.016│ +│ Variable A│ -.664│ .585│ -.395│-1.136│.293│ ╰───────────────┴────────────┴───────────────┴─────────────────────────┴──────┴────╯ a. Dependent Variable: A