unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57362: [PATCH] Fix string padding in gdb-mi
@ 2022-08-23 15:26 Santiago Calandrino via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-08-24 11:55 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Santiago Calandrino via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-08-23 15:26 UTC (permalink / raw)
  To: 57362

[-- Attachment #1: Type: text/plain, Size: 274 bytes --]

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.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-string-padding-in-gdb-mi.patch --]
[-- Type: text/x-patch, Size: 2870 bytes --]

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-24 11:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-23 15:26 bug#57362: [PATCH] Fix string padding in gdb-mi Santiago Calandrino via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-08-24 11:55 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).