bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#57362: [PATCH] Fix string padding in gdb-mi


From: Santiago Calandrino
Subject: bug#57362: [PATCH] Fix string padding in gdb-mi
Date: Tue, 23 Aug 2022 12:26:22 -0300

Hello, I recently updated my Emacs following the master branch and
encountered a bug in gdb introduced in commit f6356dc88d23 which breaks
some of its buffers. I've attempted to fix it with this patch. Let me
know if I made any mistakes since it is my first contribution.


>From 7c80780f4ca0bad2af3d137f4ee919eb0d3e9019 Mon Sep 17 00:00:00 2001
From: Santiago Calandrino <san@disroot.org>
Date: Mon, 22 Aug 2022 12:01:44 -0300
Subject: [PATCH] Fix string padding in gdb-mi

In commit f6356dc88d23eb405aa6d8bd9dd5f669f1bc45ee local padding
function gdp-pad-string was replaced with string-pad from subr-x. The
problem is that calls to string-pad use negative integers which result
in errors that prevent text to be displayed on gdb information
buffers. Now padding is stored as positive integers and calls to
string-pad check if they should be right aligned.

* lisp/progmodes/gdb-mi.el (gdb-table): Fix string padding in gdb-mi.

Copyright-paperwork-exempt: yes
---
 lisp/progmodes/gdb-mi.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index c256198b3c..f2b4aa1054 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -2944,7 +2944,7 @@ gdb-mark-line
 
 (defun gdb-pad-string (string padding)
   (declare (obsolete string-pad "29.1"))
-  (string-pad string padding nil t))
+  (string-pad string (abs padding) nil (natnump padding)))
 
 ;; gdb-table struct is a way to programmatically construct simple
 ;; tables. It help to reliably align columns of data in GDB buffers
@@ -2962,8 +2962,7 @@ gdb-table-add-row
 calling `gdb-table-string'."
   (let ((rows (gdb-table-rows table))
         (row-properties (gdb-table-row-properties table))
-        (column-sizes (gdb-table-column-sizes table))
-        (right-align (gdb-table-right-align table)))
+        (column-sizes (gdb-table-column-sizes table)))
     (when (not column-sizes)
       (setf (gdb-table-column-sizes table)
             (make-list (length row) 0)))
@@ -2973,9 +2972,7 @@ gdb-table-add-row
           (append row-properties (list properties)))
     (setf (gdb-table-column-sizes table)
           (cl-mapcar (lambda (x s)
-                         (let ((new-x
-                                (max (abs x) (string-width (or s "")))))
-                           (if right-align new-x (- new-x))))
+                       (max (abs x) (string-width (or s ""))))
                        (gdb-table-column-sizes table)
                        row))
     ;; Avoid trailing whitespace at eol
@@ -2991,7 +2988,10 @@ gdb-table-string
       (lambda (row properties)
         (apply #'propertize
                (mapconcat #'identity
-                          (cl-mapcar (lambda (s x) (string-pad s x nil t))
+                          (cl-mapcar (lambda (s x)
+                                       (string-pad
+                                        s x nil
+                                        (not (gdb-table-right-align table))))
                                      row column-sizes)
                           sep)
                properties))
-- 
2.37.1


reply via email to

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