static void time_overflow (void) NO_RETURN;
static int tm_diff (struct tm *, struct tm *);
-static void find_field (Lisp_Object, Lisp_Object, Lisp_Object,
- EMACS_INT *, Lisp_Object, EMACS_INT *);
static void update_buffer_properties (EMACS_INT, EMACS_INT);
-static Lisp_Object region_limit (int);
-static size_t emacs_nmemftime (char *, size_t, const char *,
- size_t, const struct tm *, int, int);
-static void general_insert_function (void (*) (const char *, EMACS_INT),
- void (*) (Lisp_Object, EMACS_INT,
- EMACS_INT, EMACS_INT,
- EMACS_INT, int),
- int, ptrdiff_t, Lisp_Object *);
-static Lisp_Object subst_char_in_region_unwind (Lisp_Object);
-static Lisp_Object subst_char_in_region_unwind_1 (Lisp_Object);
-static void transpose_markers (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT,
- EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT);
static Lisp_Object Qbuffer_access_fontify_functions;
static Lisp_Object Fuser_full_name (Lisp_Object);
Return the number found, and store them in a vector in VEC
of length LEN. */
-static int
-overlays_around (EMACS_INT pos, Lisp_Object *vec, int len)
+static ptrdiff_t
+overlays_around (EMACS_INT pos, Lisp_Object *vec, ptrdiff_t len)
{
Lisp_Object overlay, start, end;
struct Lisp_Overlay *tail;
EMACS_INT startpos, endpos;
- int idx = 0;
+ ptrdiff_t idx = 0;
for (tail = current_buffer->overlays_before; tail; tail = tail->next)
{
else
{
EMACS_INT posn = XINT (position);
- int noverlays;
+ ptrdiff_t noverlays;
Lisp_Object *overlay_vec, tem;
struct buffer *obuf = current_buffer;
(Lisp_Object format_string, Lisp_Object timeval, Lisp_Object universal)
{
time_t value;
- int size;
+ ptrdiff_t size;
int usec;
int ns;
struct tm *tm;
Vlocale_coding_system, 1);
/* This is probably enough. */
- size = SBYTES (format_string) * 6 + 50;
+ size = SBYTES (format_string);
+ if (size <= (STRING_BYTES_BOUND - 50) / 6)
+ size = size * 6 + 50;
BLOCK_INPUT;
tm = ut ? gmtime (&value) : localtime (&value);
while (1)
{
char *buf = (char *) alloca (size + 1);
- int result;
+ size_t result;
buf[0] = '\1';
BLOCK_INPUT;
SBYTES (format_string),
tm, ut, ns);
UNBLOCK_INPUT;
+ if (STRING_BYTES_BOUND <= result)
+ string_overflow ();
size = result + 1;
}
}
from adjoining text, if those properties are sticky. */)
(Lisp_Object character, Lisp_Object count, Lisp_Object inherit)
{
- register char *string;
- register EMACS_INT stringlen;
- register int i;
+ int i, stringlen;
register EMACS_INT n;
int c, len;
unsigned char str[MAX_MULTIBYTE_LENGTH];
+ char string[4000];
CHECK_CHARACTER (character);
CHECK_NUMBER (count);
if (BUF_BYTES_MAX / len < XINT (count))
buffer_overflow ();
n = XINT (count) * len;
- stringlen = min (n, 256 * len);
- string = (char *) alloca (stringlen);
+ stringlen = min (n, sizeof string - sizeof string % len);
for (i = 0; i < stringlen; i++)
string[i] = str[i % len];
- while (n >= stringlen)
+ while (n > stringlen)
{
QUIT;
if (!NILP (inherit))
insert (string, stringlen);
n -= stringlen;
}
- if (n > 0)
- {
- if (!NILP (inherit))
- insert_and_inherit (string, n);
- else
- insert (string, n);
- }
+ if (!NILP (inherit))
+ insert_and_inherit (string, n);
+ else
+ insert (string, n);
return Qnil;
}
RETURN_UNGCPRO (string);
}
-/* pWIDE is a conversion for printing large decimal integers (possibly with a
- trailing "d" that is ignored). pWIDElen is its length. signed_wide and
- unsigned_wide are signed and unsigned types for printing them. Use widest
- integers if available so that more floating point values can be converted. */
-#ifdef PRIdMAX
-# define pWIDE PRIdMAX
-enum { pWIDElen = sizeof PRIdMAX - 2 }; /* Don't count trailing "d". */
-typedef intmax_t signed_wide;
-typedef uintmax_t unsigned_wide;
-#else
-# define pWIDE pI
-enum { pWIDElen = sizeof pI - 1 };
-typedef EMACS_INT signed_wide;
-typedef EMACS_UINT unsigned_wide;
-#endif
-
DEFUN ("format", Fformat, Sformat, 1, MANY, 0,
doc: /* Format a string out of a format-string and arguments.
The first argument is a format control string.
printed representation. The padding, if any, normally goes on the
left, but it goes on the right if the - flag is present. The padding
character is normally a space, but it is 0 if the 0 flag is present.
-The - flag takes precedence over the 0 flag.
+The 0 flag is ignored if the - flag is present, or the format sequence
+is something other than %d, %e, %f, and %g.
For %e, %f, and %g sequences, the number after the "." in the
precision specifier says how many decimal places to show; if zero, the
precision is no more than DBL_USEFUL_PRECISION_MAX.
On all practical hosts, %f is the worst case. */
SPRINTF_BUFSIZE =
- sizeof "-." + (DBL_MAX_10_EXP + 1) + USEFUL_PRECISION_MAX
+ sizeof "-." + (DBL_MAX_10_EXP + 1) + USEFUL_PRECISION_MAX,
+
+ /* Length of pM (that is, of pMd without the
+ trailing "d"). */
+ pMlen = sizeof pMd - 2
};
verify (0 < USEFUL_PRECISION_MAX);
/* Copy of conversion specification, modified somewhat.
At most three flags F can be specified at once. */
- char convspec[sizeof "%FFF.*d" + pWIDElen];
+ char convspec[sizeof "%FFF.*d" + pMlen];
/* Avoid undefined behavior in underlying sprintf. */
if (conversion == 'd' || conversion == 'i')
/* Create the copy of the conversion specification, with
any width and precision removed, with ".*" inserted,
- and with pWIDE inserted for integer formats. */
+ and with pM inserted for integer formats. */
{
char *f = convspec;
*f++ = '%';
|| conversion == 'o' || conversion == 'x'
|| conversion == 'X')
{
- memcpy (f, pWIDE, pWIDElen);
- f += pWIDElen;
+ memcpy (f, pMd, pMlen);
+ f += pMlen;
zero_flag &= ~ precision_given;
}
*f++ = conversion;
/* For float, maybe we should use "%1.0f"
instead so it also works for values outside
the integer range. */
- signed_wide x;
+ printmax_t x;
if (INTEGERP (args[n]))
x = XINT (args[n]);
else
double d = XFLOAT_DATA (args[n]);
if (d < 0)
{
- x = TYPE_MINIMUM (signed_wide);
+ x = TYPE_MINIMUM (printmax_t);
if (x < d)
x = d;
}
else
{
- x = TYPE_MAXIMUM (signed_wide);
+ x = TYPE_MAXIMUM (printmax_t);
if (d < x)
x = d;
}
else
{
/* Don't sign-extend for octal or hex printing. */
- unsigned_wide x;
+ uprintmax_t x;
if (INTEGERP (args[n]))
x = XUINT (args[n]);
else
x = 0;
else
{
- x = TYPE_MAXIMUM (unsigned_wide);
+ x = TYPE_MAXIMUM (uprintmax_t);
if (d < x)
x = d;
}
environbuf = 0;
initial_tz = 0;
- Qbuffer_access_fontify_functions
- = intern_c_string ("buffer-access-fontify-functions");
- staticpro (&Qbuffer_access_fontify_functions);
+ DEFSYM (Qbuffer_access_fontify_functions, "buffer-access-fontify-functions");
DEFVAR_LISP ("inhibit-field-text-motion", Vinhibit_field_text_motion,
doc: /* Non-nil means text motion commands don't notice fields. */);
defsubr (&Sregion_beginning);
defsubr (&Sregion_end);
- staticpro (&Qfield);
- Qfield = intern_c_string ("field");
- staticpro (&Qboundary);
- Qboundary = intern_c_string ("boundary");
+ DEFSYM (Qfield, "field");
+ DEFSYM (Qboundary, "boundary");
defsubr (&Sfield_beginning);
defsubr (&Sfield_end);
defsubr (&Sfield_string);