summaryrefslogtreecommitdiff
path: root/src/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug.c')
-rw-r--r--src/debug.c36
1 files changed, 4 insertions, 32 deletions
diff --git a/src/debug.c b/src/debug.c
index 4a4e915d..fde6c499 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -248,7 +248,7 @@ trace_format (const char *fmt, ...)
char ch;
int d;
const char *s;
- int maxlen;
+ size_t maxlen;
va_start (args, fmt);
@@ -260,7 +260,7 @@ trace_format (const char *fmt, ...)
if (ch == '\0')
break;
- maxlen = INT_MAX;
+ maxlen = SIZE_MAX;
switch (*fmt++)
{
case 'B':
@@ -294,7 +294,7 @@ trace_format (const char *fmt, ...)
break;
}
- if (obstack_print (&trace, s, SIZE_MAX, &maxlen))
+ if (shipout_string_trunc (&trace, s, SIZE_MAX, &maxlen))
break;
}
@@ -364,7 +364,7 @@ trace_pre (const char *name, int id, macro_arguments *argv)
if (arg_argc (argv) > 1 && (debug_level & DEBUG_TRACE_ARGS))
{
- int len = max_debug_argument_length;
+ size_t len = max_debug_argument_length;
trace_format ("(");
arg_print (&trace, argv, 1,
(debug_level & DEBUG_TRACE_QUOTE) ? &curr_quote : NULL,
@@ -401,31 +401,3 @@ trace_post (const char *name, int id, macro_arguments *argv,
trace_format (" -> %l%B%r", expanded);
trace_flush ();
}
-
-/* Dump the string STR of length LEN to the obstack OBS. If LEN is
- SIZE_MAX, use strlen (STR) instead. If MAX_LEN is non-NULL,
- truncate the dump at MAX_LEN bytes and return true if MAX_LEN was
- reached; otherwise, return false and update MAX_LEN as
- appropriate. */
-bool
-obstack_print (struct obstack *obs, const char *str, size_t len, int *max_len)
-{
- int max = max_len ? *max_len : INT_MAX;
-
- if (len == SIZE_MAX)
- len = strlen (str);
- if (len < max)
- {
- obstack_grow (obs, str, len);
- max -= len;
- }
- else
- {
- obstack_grow (obs, str, max);
- obstack_grow (obs, "...", 3);
- max = 0;
- }
- if (max_len)
- *max_len = max;
- return max == 0;
-}