/* Merge parameters into a termcap entry string.
- Copyright (C) 1985, 1987, 1993, 1995, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 1985, 1987, 1993, 1995, 2000-2008, 2013 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
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., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Emacs config.h may rename various library functions such as malloc. */
#include <config.h>
-#include <setjmp.h>
+
#include "lisp.h" /* for xmalloc */
#include "tparam.h"
-
-#ifndef NULL
-#define NULL (char *) 0
-#endif
\f
/* Assuming STRING is the value of a termcap string entry
containing `%' constructs to expand parameters,
if (outlen == 0)
{
- if (min (PTRDIFF_MAX, SIZE_MAX) - 40 < len)
- goto out_of_memory;
outlen = len + 40;
- new = (char *) xmalloc (outlen);
+ new = xmalloc (outlen);
memcpy (new, outstring, offset);
}
else
{
- if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < outlen)
- goto out_of_memory;
- outlen *= 2;
- new = (char *) xrealloc (outstring, outlen);
+ new = xpalloc (outstring, &outlen, 1, -1, 1);
}
op = new + offset;
doup++, append_len_incr = strlen (up);
else
doleft++, append_len_incr = strlen (left);
- if (PTRDIFF_MAX - append_len < append_len_incr)
- {
- out_of_memory:
- xfree (new);
- memory_full (SIZE_MAX);
- }
+ if (INT_ADD_OVERFLOW (append_len, append_len_incr))
+ memory_full (SIZE_MAX);
append_len += append_len_incr;
}
}
break;
default:
- abort ();
+ emacs_abort ();
}
}
else
args[0] = atoi (argv[2]);
args[1] = atoi (argv[3]);
args[2] = atoi (argv[4]);
- tparam1 (argv[1], buf, "LEFT", "UP", args);
+ tparam1 (argv[1], buf, 50, "LEFT", "UP", args);
printf ("%s\n", buf);
return 0;
}