unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Santiago Calandrino via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 57362@debbugs.gnu.org
Subject: bug#57362: [PATCH] Fix string padding in gdb-mi
Date: Tue, 23 Aug 2022 12:26:22 -0300	[thread overview]
Message-ID: <878rnf560z.fsf@disroot.org> (raw)

[-- 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


             reply	other threads:[~2022-08-23 15:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 15:26 Santiago Calandrino via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-08-24 11:55 ` bug#57362: [PATCH] Fix string padding in gdb-mi Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878rnf560z.fsf@disroot.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=57362@debbugs.gnu.org \
    --cc=san@disroot.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).