#! /bin/sh /usr/share/dpatch/dpatch-run
## 131_sprintf.dpatch by Michael Tautschnig <mt@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fixes incompatible use of sprintf as a strcat replacement

diff -urN binutils-h8300-hms-2.16.1.orig/gas/itbl-ops.c binutils-h8300-hms-2.16.1/gas/itbl-ops.c
--- binutils-h8300-hms-2.16.1.orig/gas/itbl-ops.c	2005-03-03 01:29:53.000000000 +0000
+++ binutils-h8300-hms-2.16.1/gas/itbl-ops.c	2009-01-06 07:59:56.000000000 +0000
@@ -620,14 +620,14 @@
 	  if (r)
 	    strcat (s, r->name);
 	  else
-	    sprintf (s, "%s$%lu", s, value);
+	    sprintf (s + strlen(s), "$%lu", value);
 	  break;
 	case e_addr:
 	  /* Use assembler's symbol table to find symbol.  */
 	  /* FIXME!! Do we need this?  If so, what about relocs??  */
 	  /* If not a symbol, fall through to IMMED.  */
 	case e_immed:
-	  sprintf (s, "%s0x%lx", s, value);
+	  sprintf (s + strlen(s), "0x%lx", value);
 	  break;
 	default:
 	  return 0;		/* error; invalid field spec */
diff -urN binutils-h8300-hms-2.16.1.orig/opcodes/or32-opc.c binutils-h8300-hms-2.16.1/opcodes/or32-opc.c
--- binutils-h8300-hms-2.16.1.orig/opcodes/or32-opc.c	2004-11-19 12:38:55.000000000 +0000
+++ binutils-h8300-hms-2.16.1/opcodes/or32-opc.c	2009-01-06 08:03:31.000000000 +0000
@@ -979,7 +979,7 @@
 {
   int regnum = or32_extract(param_ch, encoding, insn);
   
-  sprintf (disassembled, "%sr%d", disassembled, regnum);
+  sprintf (disassembled + strlen(disassembled), "r%d", regnum);
 }
 
 /* Print immediate. Used only by print_insn.  */
@@ -997,12 +997,12 @@
   if (letter_signed (param_ch))
     {
       if (imm < 0)
-        sprintf (disassembled, "%s%d", disassembled, imm);
+        sprintf (disassembled + strlen(disassembled), "%d", imm);
       else
-        sprintf (disassembled, "%s0x%x", disassembled, imm);
+        sprintf (disassembled + strlen(disassembled), "0x%x", imm);
     }
   else
-    sprintf (disassembled, "%s%#x", disassembled, imm);
+    sprintf (disassembled + strlen(disassembled), "%#x", imm);
 }
 
 /* Disassemble one instruction from insn to disassemble.
@@ -1036,14 +1036,14 @@
               if (strchr (opcode->encoding, *s))
                 or32_print_immediate (*s, opcode->encoding, insn);
               else
-                sprintf (disassembled, "%s%c", disassembled, *s);
+                sprintf (disassembled + strlen(disassembled), "%c", *s);
             }
         }
     }
   else
     {
       /* This used to be %8x for binutils.  */
-      sprintf (disassembled, "%s.word 0x%08lx", disassembled, insn);
+      sprintf (disassembled + strlen(disassembled), ".word 0x%08lx", insn);
     }
 
   return insn_len (insn);
