This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Another _doprnt fix for %L handling


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1cf9552bf1c77df8850de01d48e1057a27415314

commit 1cf9552bf1c77df8850de01d48e1057a27415314
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Jul 7 10:19:08 2017 +0930

    Another _doprnt fix for %L handling
    
    	* bfd.c (_doprnt): Replace "L" with "ll" when printing bfd_vma
    	as long long.  Move code replacing "ll" with "I64", and simplify.

Diff:
---
 bfd/ChangeLog |  5 +++++
 bfd/bfd.c     | 27 +++++++++++++++------------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index eda1e3e..4a3a3ac 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2017-07-07  Alan Modra  <amodra@gmail.com>
+
+	* bfd.c (_doprnt): Replace "L" with "ll" when printing bfd_vma
+	as long long.  Move code replacing "ll" with "I64", and simplify.
+
 2017-07-06  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* bfd.c (_doprnt): Convert 'L' to 'l' when setting wide_width
diff --git a/bfd/bfd.c b/bfd/bfd.c
index a119ac4..665f182 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -725,11 +725,17 @@ _doprnt (FILE *stream, const char *format, va_list ap)
 		  {
 		    /* L modifier for bfd_vma or bfd_size_type may be
 		       either long long or long.  */
-		    if ((BFD_ARCH_SIZE < 64 || BFD_HOST_64BIT_LONG)
-			&& sptr[-2] == 'L')
+		    if (sptr[-2] == 'L')
 		      {
-			wide_width = 1;
 			sptr[-2] = 'l';
+			if (BFD_ARCH_SIZE < 64 || BFD_HOST_64BIT_LONG)
+			  wide_width = 1;
+			else
+			  {
+			    sptr[-1] = 'l';
+			    *sptr++ = ptr[-1];
+			    *sptr = '\0';
+			  }
 		      }
 
 		    switch (wide_width)
@@ -742,17 +748,14 @@ _doprnt (FILE *stream, const char *format, va_list ap)
 			break;
 		      case 2:
 		      default:
-#if defined (__GNUC__) || defined (HAVE_LONG_LONG)
-# if defined (__MSVCRT__)
-			sptr--;
-			while (sptr[-1] == 'L' || sptr[-1] == 'l')
-			  sptr--;
-			*sptr++ = 'I';
-			*sptr++ = '6';
-			*sptr++ = '4';
+#if defined (__MSVCRT__)
+			sptr[-3] = 'I';
+			sptr[-2] = '6';
+			sptr[-1] = '4';
 			*sptr++ = ptr[-1];
 			*sptr = '\0';
-# endif
+#endif
+#if defined (__GNUC__) || defined (HAVE_LONG_LONG)
 			PRINT_TYPE (long long);
 #else
 			/* Fake it and hope for the best.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]