Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] long long for printf on MinGW
@ 2006-10-11 11:21 Andrew STUBBS
  2006-10-11 13:03 ` Daniel Jacobowitz
  2006-10-11 20:28 ` Mark Kettenis
  0 siblings, 2 replies; 11+ messages in thread
From: Andrew STUBBS @ 2006-10-11 11:21 UTC (permalink / raw)
  To: GDB Patches

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

Hi,

Windows/MinGW printf does support printing of long long types, but it 
does not do using %lld etc.

This patch converts %ll (or %...ll) to %I64 as required by Windows.

GDB printf still won't accept I64 as input, but then this is not 
standard compliant so I don't think it really should.

:ADDPATCH printcmd.c:

Andrew Stubbs

[-- Attachment #2: printf.patch --]
[-- Type: text/plain, Size: 1673 bytes --]

2006-10-11  Andrew Stubbs  <andrew.stubbs@st.com>

	* printcmd.c (printf_command): Convert %lld to %I64d on MinGW.

Index: src/gdb/printcmd.c
===================================================================
--- src.orig/gdb/printcmd.c	2006-07-17 23:15:55.000000000 +0100
+++ src/gdb/printcmd.c	2006-10-11 11:28:29.000000000 +0100
@@ -1967,8 +1967,24 @@ printf_command (char *arg, int from_tty)
 		   *f);
 
 	  f++;
-	  strncpy (current_substring, last_arg, f - last_arg);
-	  current_substring += f - last_arg;
+#if defined (__MINGW32__)
+	  /* Windows' printf does support long long, but not the usual way.
+	     Convert %lld to %I64d.  */
+	  if (lcount > 1)
+	    {
+	      int length_before_ll = f - last_arg - 1 - lcount;
+	      strncpy (current_substring, last_arg, length_before_ll);
+	      strcpy (current_substring + length_before_ll, "I64");
+	      current_substring[length_before_ll + 3] =
+		last_arg[length_before_ll + lcount];
+	      current_substring += length_before_ll + 4;
+	    }
+	  else
+#endif
+	    {
+	      strncpy (current_substring, last_arg, f - last_arg);
+	      current_substring += f - last_arg;
+	    }
 	  *current_substring++ = '\0';
 	  last_arg = f;
 	  argclass[nargs_wanted++] = this_argclass;
@@ -2056,7 +2072,8 @@ printf_command (char *arg, int from_tty)
 	    error (_("long double not supported in printf"));
 #endif
 	  case long_long_arg:
-#if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
+#if defined (CC_HAS_LONG_LONG) && (defined (PRINTF_HAS_LONG_LONG) \
+				   || defined (__MINGW32__))
 	    {
 	      long long val = value_as_long (val_args[i]);
 	      printf_filtered (current_substring, val);

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

end of thread, other threads:[~2008-04-23 13:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-11 11:21 [PATCH] long long for printf on MinGW Andrew STUBBS
2006-10-11 13:03 ` Daniel Jacobowitz
2006-10-11 15:12   ` Andrew STUBBS
2008-04-22 19:41     ` Daniel Jacobowitz
2008-04-23 10:26       ` Andrew STUBBS
2008-04-23 12:18         ` Daniel Jacobowitz
2008-04-23 16:12           ` Andrew STUBBS
2006-10-11 20:28 ` Mark Kettenis
2006-10-11 20:44   ` Daniel Jacobowitz
2006-10-12 10:09   ` Andrew STUBBS
     [not found]     ` <200610151745.k9FHjvPa017960@elgar.sibelius.xs4all.nl>
2006-10-16  9:45       ` Andrew STUBBS

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox