bug-m4
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

m4_shipout_int


From: akim
Subject: m4_shipout_int
Date: Sun, 14 Oct 2001 09:27:26 +0200
User-agent: Mutt/1.3.22i

I think m4_shipout_int is broken:

void
m4_shipout_int (struct obstack *obs, int val)
{
  char buf[128];

  sprintf(buf, "%d", val);
  obstack_grow (obs, buf, strlen (buf));
}

because it does not include the possibility to quote the result.
Up to now, we didn't care much, but now that the alphabets can be changed,
I think it ought to quote its result.  In fact, I'm tempted to make it
just like

void
m4_shipout_string (struct obstack *obs, const char *s, int len,
                   boolean quoted)
{
  if (s == NULL)
    s = "";

  if (len == 0)
    len = strlen(s);

  if (quoted)
    obstack_grow (obs, lquote.string, lquote.length);
  obstack_grow (obs, s, len);
  if (quoted)
    obstack_grow (obs, rquote.string, rquote.length);
}

and in fact, I'm also tempted by replacing it with something based
on ntoa/numb_obstack as can be found in modules/m4.c.  I guess there
would be some loss of performance, but then, if you consider it's
too expansive, anyway I would really like to see some m4_shipout_bigint
somewhere: I already use it in some of my modules, and it results in
a lot of code duplication.  That would garantee some common flavor to
all these macros.

?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]