[Midnightbsd-cvs] src [12031] trunk/contrib/flex: fix a few compile issues

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Sep 11 22:18:14 EDT 2018


Revision: 12031
          http://svnweb.midnightbsd.org/src/?rev=12031
Author:   laffer1
Date:     2018-09-11 22:18:14 -0400 (Tue, 11 Sep 2018)
Log Message:
-----------
fix a few compile issues

Modified Paths:
--------------
    trunk/contrib/flex/buf.c
    trunk/contrib/flex/flex.skl
    trunk/contrib/flex/flexdef.h
    trunk/contrib/flex/flexint.h
    trunk/contrib/flex/libyywrap.c
    trunk/contrib/flex/main.c
    trunk/contrib/flex/scanflags.c

Modified: trunk/contrib/flex/buf.c
===================================================================
--- trunk/contrib/flex/buf.c	2018-09-12 02:16:01 UTC (rev 12030)
+++ trunk/contrib/flex/buf.c	2018-09-12 02:18:14 UTC (rev 12031)
@@ -90,11 +90,12 @@
  */
 struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
 {
-    char *dst, *src, *t;
+    char *dst, *t;
+    const char *src;
 
     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: trunk/contrib/flex/flex.skl
===================================================================
--- trunk/contrib/flex/flex.skl	2018-09-12 02:16:01 UTC (rev 12030)
+++ trunk/contrib/flex/flex.skl	2018-09-12 02:18:14 UTC (rev 12031)
@@ -194,6 +194,15 @@
 ]])
 
 /* First, we deal with  platform-specific or compiler-specific issues. */
+#if defined(__MidnightBSD__)
+#ifndef __STDC_LIMIT_MACROS
+#define       __STDC_LIMIT_MACROS
+#endif
+#include <sys/cdefs.h>
+#include <stdint.h>
+#else
+#define       __dead2
+#endif
 
 /* begin standard C headers. */
 %if-c-only
@@ -1029,7 +1038,9 @@
 %not-for-header
     m4_ifdef( [[M4_YY_NO_UNPUT]],,
     [[
+#ifndef YY_NO_UNPUT
     static void yyunput M4_YY_PARAMS( int c, char *buf_ptr  M4_YY_PROTO_LAST_ARG);
+#endif
     ]])
 %ok-for-header
 %endif
@@ -1807,9 +1818,11 @@
 %if-c-only
 m4_ifdef( [[M4_YY_NO_UNPUT]],,
 [[
+#ifndef YY_NO_UNPUT
     static void yyunput YYFARGS2( int,c, register char *,yy_bp)
 %endif
 %if-c++-only
+#ifndef YY_NO_UNPUT
     void yyFlexLexer::yyunput( int c, register char* yy_bp)
 %endif
 {
@@ -1851,11 +1864,11 @@
         --yylineno;
     }
 ]])
-
 	YY_G(yytext_ptr) = yy_bp;
 	YY_G(yy_hold_char) = *yy_cp;
 	YY_G(yy_c_buf_p) = yy_cp;
 }
+#endif		/* ifndef YY_NO_UNPUT */
 %if-c-only
 ]])
 %endif

Modified: trunk/contrib/flex/flexdef.h
===================================================================
--- trunk/contrib/flex/flexdef.h	2018-09-12 02:16:01 UTC (rev 12030)
+++ trunk/contrib/flex/flexdef.h	2018-09-12 02:18:14 UTC (rev 12031)
@@ -171,6 +171,8 @@
  */
 #define NUMDATALINES 10
 
+#define NUMCHARLINES 10
+
 /* transition_struct_out() definitions. */
 #define TRANS_STRUCT_PRINT_LENGTH 14
 

Modified: trunk/contrib/flex/flexint.h
===================================================================
--- trunk/contrib/flex/flexint.h	2018-09-12 02:16:01 UTC (rev 12030)
+++ trunk/contrib/flex/flexint.h	2018-09-12 02:18:14 UTC (rev 12031)
@@ -5,7 +5,8 @@
 
 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
 
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#if defined(__FreeBSD__) || \
+    (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
 
 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
  * if you want the limit (max/min) macros for int types. 

Modified: trunk/contrib/flex/libyywrap.c
===================================================================
--- trunk/contrib/flex/libyywrap.c	2018-09-12 02:16:01 UTC (rev 12030)
+++ trunk/contrib/flex/libyywrap.c	2018-09-12 02:18:14 UTC (rev 12031)
@@ -21,6 +21,8 @@
 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
 /*  PURPOSE. */
 
+int     yywrap (void);
+
 int     yywrap (void)
 {
 	return 1;

Modified: trunk/contrib/flex/main.c
===================================================================
--- trunk/contrib/flex/main.c	2018-09-12 02:16:01 UTC (rev 12030)
+++ trunk/contrib/flex/main.c	2018-09-12 02:18:14 UTC (rev 12031)
@@ -364,7 +364,7 @@
     output_chain = filter_create_int(NULL, filter_tee_header, headerfilename);
     if ( !(m4 = getenv("M4")))
         m4 = M4;
-    filter_create_ext(output_chain, m4, "-P", 0);
+    filter_create_ext(output_chain, m4, "-gP", 0);
     filter_create_int(output_chain, filter_fix_linedirs, NULL);
 
     /* For debugging, only run the requested number of filters. */
@@ -451,7 +451,7 @@
              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);

Modified: trunk/contrib/flex/scanflags.c
===================================================================
--- trunk/contrib/flex/scanflags.c	2018-09-12 02:16:01 UTC (rev 12030)
+++ trunk/contrib/flex/scanflags.c	2018-09-12 02:18:14 UTC (rev 12031)
@@ -62,7 +62,7 @@
     _sf_stk = (scanflags_t*) flex_alloc ( sizeof(scanflags_t) * (_sf_max = 32));
     if (!_sf_stk)
         lerrsf_fatal(_("Unable to allocate %ld of stack"),
-            (long)sizeof(scanflags_t));
+            (void *)(uintptr_t)sizeof(scanflags_t));
     _sf_stk[_sf_top_ix] = 0;
 }
 



More information about the Midnightbsd-cvs mailing list