Fix bug #7716 with PNG image support libraries on Windows.
[bpt/emacs.git] / src / tparam.c
index 0548c72..dcf79a3 100644 (file)
@@ -1,5 +1,6 @@
 /* Merge parameters into a termcap entry string.
-   Copyright (C) 1985, 87, 93, 95, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1987, 1993, 1995, 2000, 2001, 2002, 2003, 2004,
+                 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -13,8 +14,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 /* Emacs config.h may rename various library functions such as malloc.  */
 #ifdef HAVE_CONFIG_H
@@ -22,11 +23,9 @@ Boston, MA 02111-1307, USA.  */
 #endif
 
 #ifdef emacs
+#include <setjmp.h>
 #include "lisp.h"              /* for xmalloc */
 #else
-#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
-#define bcopy(s, d, n) memcpy ((d), (s), (n))
-#endif
 
 #ifdef STDC_HEADERS
 #include <stdlib.h>
@@ -36,6 +35,11 @@ char *malloc ();
 char *realloc ();
 #endif
 
+/* Do this after the include, in case string.h prototypes bcopy.  */
+#if (defined(HAVE_STRING_H) || defined(STDC_HEADERS)) && !defined(bcopy)
+#define bcopy(s, d, n) memcpy ((d), (s), (n))
+#endif
+
 #endif /* not emacs */
 
 #ifndef NULL
@@ -138,7 +142,9 @@ tparam1 (string, outstring, len, up, left, argp)
   int outlen = 0;
 
   register int tem;
-  int *old_argp = argp;
+  int *old_argp = argp;                 /* can move */
+  int *fixed_argp = argp;               /* never moves */
+  int explicit_param_p = 0;             /* set by %p */
   int doleft = 0;
   int doup = 0;
 
@@ -163,7 +169,7 @@ tparam1 (string, outstring, len, up, left, argp)
              outlen *= 2;
              new = (char *) xrealloc (outstring, outlen);
            }
-         
+
          op = new + offset;
          outend = new + outlen;
          outstring = new;
@@ -174,7 +180,10 @@ tparam1 (string, outstring, len, up, left, argp)
       if (c == '%')
        {
          c = *p++;
-         tem = *argp;
+         if (explicit_param_p)
+           explicit_param_p = 0;
+         else
+           tem = *argp;
          switch (c)
            {
            case 'd':           /* %d means output in decimal.  */
@@ -197,7 +206,10 @@ tparam1 (string, outstring, len, up, left, argp)
              *op++ = tem % 10 + '0';
              argp++;
              break;
-
+            case 'p':           /* %pN means use param N for next subst.  */
+             tem = fixed_argp[(*p++) - '1'];
+             explicit_param_p = 1;
+             break;
            case 'C':
              /* For c-100: print quotient of value by 96, if nonzero,
                 then do like %+.  */
@@ -328,3 +340,6 @@ main (argc, argv)
 }
 
 #endif /* DEBUG */
+
+/* arch-tag: 83f7b5ac-a808-4f75-b87a-123de009b402
+   (do not change this comment) */