#include "full-write.h"
#include "quote.h"
#include "xstrtod.h"
+#include "xvasprintf.h"
/* Roll our own isfinite/isnan rather than using <math.h>, so that we don't
have to worry about linking -lm just for isfinite. */
&& 0 < step.value && step.value <= SEQ_FAST_STEP_LIMIT
&& !equal_width && !format_str && strlen (separator) == 1)
{
- char *s1;
- char *s2;
- if (all_digits_p (user_start))
- s1 = xstrdup (user_start);
- else if (asprintf (&s1, "%0.Lf", first.value) < 0)
- xalloc_die ();
- if (! isfinite (last.value))
- s2 = xstrdup ("inf"); /* Ensure "inf" is used. */
- else if (asprintf (&s2, "%0.Lf", last.value) < 0)
- xalloc_die ();
+ char *s1 = (all_digits_p (user_start)
+ ? xstrdup (user_start) : xasprintf ("%0.Lf", first.value));
+ /* Ensure "inf" is used. */
+ char *s2 = (! isfinite (last.value)
+ ? xstrdup ("inf") : xasprintf ("%0.Lf", last.value));
if (*s1 != '-' && *s2 != '-')
seq_fast (s1, s2, step.value);
#include "readutmp.h"
#include "hard-locale.h"
#include "quote.h"
+#include "xvasprintf.h"
#ifdef TTY_GROUP_NAME
# include <grp.h>
char x_idle[1 + IDLESTR_LEN + 1];
char x_pid[1 + INT_STRLEN_BOUND (pid_t) + 1];
char *x_exitstr;
- int err;
mesg[1] = state;
else
*x_exitstr = '\0';
- err = asprintf (&buf,
- "%-8s"
- "%s"
- " %-12s"
- " %-*s"
- "%s"
- "%s"
- " %-8s"
- "%s"
- ,
- user ? user : " .",
- include_mesg ? mesg : "",
- line,
- time_format_width,
- time_str,
- x_idle,
- x_pid,
- /* FIXME: it's not really clear whether the following
- field should be in the short_output. A strict reading
- of SUSv2 would suggest not, but I haven't seen any
- implementations that actually work that way... */
- comment,
- x_exitstr
+ buf = xasprintf ("%-8s"
+ "%s"
+ " %-12s"
+ " %-*s"
+ "%s"
+ "%s"
+ " %-8s"
+ "%s"
+ ,
+ user ? user : " .",
+ include_mesg ? mesg : "",
+ line,
+ time_format_width,
+ time_str,
+ x_idle,
+ x_pid,
+ /* FIXME: it's not really clear whether the following
+ field should be in the short_output. A strict reading
+ of SUSv2 would suggest not, but I haven't seen any
+ implementations that actually work that way... */
+ comment,
+ x_exitstr
);
- if (err == -1)
- xalloc_die ();
{
/* Remove any trailing spaces. */