Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 May 2013 19:07:17 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r250470 - projects/flex-sf/contrib/flex
Message-ID:  <201305101907.r4AJ7HUn008223@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305101907.r4AJ7HUn008223>