svn commit: r250470 - projects/flex-sf/contrib/flex
Jung-uk Kim
jkim at FreeBSD.org
Fri May 10 19:07:18 UTC 2013
Author: jkim
Date: Fri May 10 19:07:17 2013
New Revision: 250470
URL: http://svnweb.freebsd.org/changeset/base/250470
Log:
Do not use log10(3) to get rid of libm dependency. It is really not useful.
Modified:
projects/flex-sf/contrib/flex/buf.c
projects/flex-sf/contrib/flex/flexdef.h
projects/flex-sf/contrib/flex/main.c
Modified: projects/flex-sf/contrib/flex/buf.c
==============================================================================
--- projects/flex-sf/contrib/flex/buf.c Fri May 10 18:43:36 2013 (r250469)
+++ projects/flex-sf/contrib/flex/buf.c Fri May 10 19:07:17 2013 (r250470)
@@ -94,7 +94,7 @@ struct Buf *buf_linedir (struct Buf *buf
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"));
Modified: projects/flex-sf/contrib/flex/flexdef.h
==============================================================================
--- projects/flex-sf/contrib/flex/flexdef.h Fri May 10 18:43:36 2013 (r250469)
+++ projects/flex-sf/contrib/flex/flexdef.h Fri May 10 19:07:17 2013 (r250470)
@@ -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
Modified: projects/flex-sf/contrib/flex/main.c
==============================================================================
--- projects/flex-sf/contrib/flex/main.c Fri May 10 18:43:36 2013 (r250469)
+++ projects/flex-sf/contrib/flex/main.c Fri May 10 19:07:17 2013 (r250470)
@@ -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);
More information about the svn-src-projects
mailing list