Do not use log10(3) to get rid of libm dependency. It is really not useful.

This commit is contained in:
Jung-uk Kim 2013-05-21 19:20:03 +00:00
parent 8acd331814
commit fd3b3c3ae6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=250876
3 changed files with 5 additions and 3 deletions

View file

@ -95,7 +95,7 @@ struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
t = flex_alloc (strlen ("#line \"\"\n") + /* constant parts */
2 * strlen (filename) + /* filename with possibly all backslashes escaped */
(int) (1 + log10 (abs (lineno))) + /* line number */
NUMCHARLINES + /* line number */
1); /* NUL */
if (!t)
flexfatal (_("Allocation of buffer for line directive failed"));

View file

@ -61,7 +61,6 @@ char *alloca ();
#include <setjmp.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#endif
#ifdef HAVE_ASSERT_H
#include <assert.h>
@ -171,6 +170,9 @@ char *alloca ();
*/
#define NUMDATALINES 10
/* Number of characters to print a line number, i.e., 1 + log10(INT_MAX) */
#define NUMCHARLINES 10
/* transition_struct_out() definitions. */
#define TRANS_STRUCT_PRINT_LENGTH 14

View file

@ -451,7 +451,7 @@ void check_options ()
char *str, *fmt = "#define %s %d\n";
size_t strsz;
str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(scname[i]) + (int)(1 + log10(i)) + 2);
str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(scname[i]) + NUMCHARLINES + 2);
if (!str)
flexfatal(_("allocation of macro definition failed"));
snprintf(str, strsz, fmt, scname[i], i - 1);