Do not use log10(3) to get rid of libm dependency. It is really not useful.
This commit is contained in:
parent
8acd331814
commit
fd3b3c3ae6
@ -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"));
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user