summaryrefslogtreecommitdiffstats
path: root/contrib/flex
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2013-05-21 19:20:03 +0000
committerjkim <jkim@FreeBSD.org>2013-05-21 19:20:03 +0000
commit76b51e80cbd9d1da86f999b77fdabe84274b1676 (patch)
treeb9c0d452c5ef35e9b6a559d635e5d05d0fc19371 /contrib/flex
parentf35b94300055627286d77f0dd748057f5d98b5f0 (diff)
downloadFreeBSD-src-76b51e80cbd9d1da86f999b77fdabe84274b1676.zip
FreeBSD-src-76b51e80cbd9d1da86f999b77fdabe84274b1676.tar.gz
Do not use log10(3) to get rid of libm dependency. It is really not useful.
Diffstat (limited to 'contrib/flex')
-rw-r--r--contrib/flex/buf.c2
-rw-r--r--contrib/flex/flexdef.h4
-rw-r--r--contrib/flex/main.c2
3 files changed, 5 insertions, 3 deletions
diff --git a/contrib/flex/buf.c b/contrib/flex/buf.c
index fa713a6..d6efdac 100644
--- a/contrib/flex/buf.c
+++ b/contrib/flex/buf.c
@@ -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"));
diff --git a/contrib/flex/flexdef.h b/contrib/flex/flexdef.h
index 1f03d5a..d37a509 100644
--- a/contrib/flex/flexdef.h
+++ b/contrib/flex/flexdef.h
@@ -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
diff --git a/contrib/flex/main.c b/contrib/flex/main.c
index 57b1f67..43960da 100644
--- a/contrib/flex/main.c
+++ b/contrib/flex/main.c
@@ -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);
OpenPOWER on IntegriCloud