summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buf.c21
-rw-r--r--src/config.h.in217
-rw-r--r--src/main.c3
-rw-r--r--src/scan.c2
-rw-r--r--src/scan.l1
-rw-r--r--src/skel.c2
6 files changed, 18 insertions, 228 deletions
diff --git a/src/buf.c b/src/buf.c
index fa713a6..7e05abc 100644
--- a/src/buf.c
+++ b/src/buf.c
@@ -36,13 +36,13 @@
/* Take note: The buffer object is sometimes used as a String buffer (one
* continuous string), and sometimes used as a list of strings, usually line by
* line.
- *
+ *
* The type is specified in buf_init by the elt_size. If the elt_size is
* sizeof(char), then the buffer should be treated as string buffer. If the
* elt_size is sizeof(char*), then the buffer should be treated as a list of
* strings.
*
- * Certain functions are only appropriate for one type or the other.
+ * Certain functions are only appropriate for one type or the other.
*/
/* global buffers. */
@@ -92,11 +92,16 @@ struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
{
char *dst, *t;
const char *src;
+ size_t tsz;
+
+ if (gen_line_dirs)
+ return 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 */
- 1); /* NUL */
+ tsz = strlen("#line \"\"\n") + /* constant parts */
+ 2 * strlen (filename) + /* filename with possibly all backslashes escaped */
+ (int) (1 + log10 (abs (lineno))) + /* line number */
+ 1; /* NUL */
+ t = malloc(tsz);
if (!t)
flexfatal (_("Allocation of buffer for line directive failed"));
for (dst = t + sprintf (t, "#line %d \"", lineno), src = filename; *src; *dst++ = *src++)
@@ -242,8 +247,8 @@ struct Buf *buf_append (buf, ptr, n_elem)
/* May need to alloc more. */
if (n_elem + buf->nelts > buf->nmax) {
- /* exact amount needed... */
- n_alloc = (n_elem + buf->nelts) * buf->elt_size;
+ /* exact count needed... */
+ n_alloc = n_elem + buf->nelts;
/* ...plus some extra */
if (((n_alloc * buf->elt_size) % 512) != 0
diff --git a/src/config.h.in b/src/config.h.in
deleted file mode 100644
index a008fe2..0000000
--- a/src/config.h.in
+++ /dev/null
@@ -1,217 +0,0 @@
-/* src/config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
- systems. This function is required for `alloca.c' support on those systems.
- */
-#undef CRAY_STACKSEG_END
-
-/* Define to 1 if using `alloca.c'. */
-#undef C_ALLOCA
-
-/* Define to 1 if translation of program messages to the user's native
- language is requested. */
-#undef ENABLE_NLS
-
-/* Define to 1 if you have `alloca', as a function or macro. */
-#undef HAVE_ALLOCA
-
-/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
- */
-#undef HAVE_ALLOCA_H
-
-/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the
- CoreFoundation framework. */
-#undef HAVE_CFLOCALECOPYCURRENT
-
-/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in
- the CoreFoundation framework. */
-#undef HAVE_CFPREFERENCESCOPYAPPVALUE
-
-/* Define if the GNU dcgettext() function is already present or preinstalled.
- */
-#undef HAVE_DCGETTEXT
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the `dup2' function. */
-#undef HAVE_DUP2
-
-/* Define to 1 if you have the `fork' function. */
-#undef HAVE_FORK
-
-/* Define if the GNU gettext() function is already present or preinstalled. */
-#undef HAVE_GETTEXT
-
-/* Define if you have the iconv() function and it works. */
-#undef HAVE_ICONV
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `isascii' function. */
-#undef HAVE_ISASCII
-
-/* Define to 1 if you have the <libintl.h> header file. */
-#undef HAVE_LIBINTL_H
-
-/* Define to 1 if you have the `m' library (-lm). */
-#undef HAVE_LIBM
-
-/* pthread library */
-#undef HAVE_LIBPTHREAD
-
-/* Define to 1 if you have the <limits.h> header file. */
-#undef HAVE_LIMITS_H
-
-/* Define to 1 if you have the <locale.h> header file. */
-#undef HAVE_LOCALE_H
-
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
- to 0 otherwise. */
-#undef HAVE_MALLOC
-
-/* Define to 1 if you have the <malloc.h> header file. */
-#undef HAVE_MALLOC_H
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the `memset' function. */
-#undef HAVE_MEMSET
-
-/* Define to 1 if you have the <netinet/in.h> header file. */
-#undef HAVE_NETINET_IN_H
-
-/* Define to 1 if you have the `pow' function. */
-#undef HAVE_POW
-
-/* Define to 1 if you have the <pthread.h> header file. */
-#undef HAVE_PTHREAD_H
-
-/* Define to 1 if your system has a GNU libc compatible `realloc' function,
- and to 0 otherwise. */
-#undef HAVE_REALLOC
-
-/* Define to 1 if you have the `regcomp' function. */
-#undef HAVE_REGCOMP
-
-/* Define to 1 if you have the <regex.h> header file. */
-#undef HAVE_REGEX_H
-
-/* Define to 1 if you have the `setlocale' function. */
-#undef HAVE_SETLOCALE
-
-/* Define to 1 if stdbool.h conforms to C99. */
-#undef HAVE_STDBOOL_H
-
-/* Define to 1 if you have the <stddef.h> header file. */
-#undef HAVE_STDDEF_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the `strchr' function. */
-#undef HAVE_STRCHR
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the `strtol' function. */
-#undef HAVE_STRTOL
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
-#undef HAVE_SYS_WAIT_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if you have the `vfork' function. */
-#undef HAVE_VFORK
-
-/* Define to 1 if you have the <vfork.h> header file. */
-#undef HAVE_VFORK_H
-
-/* Define to 1 if `fork' works. */
-#undef HAVE_WORKING_FORK
-
-/* Define to 1 if `vfork' works. */
-#undef HAVE_WORKING_VFORK
-
-/* Define to 1 if the system has the type `_Bool'. */
-#undef HAVE__BOOL
-
-/* Define to the sub-directory where libtool stores uninstalled libraries. */
-#undef LT_OBJDIR
-
-/* Define to the m4 executable name. */
-#undef M4
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* If using the C implementation of alloca, define if you know the
- direction of stack growth for your system; otherwise it will be
- automatically deduced at runtime.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown */
-#undef STACK_DIRECTION
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Version number of package */
-#undef VERSION
-
-/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
- `char[]'. */
-#undef YYTEXT_POINTER
-
-/* Define to empty if `const' does not conform to ANSI C. */
-#undef const
-
-/* Define to rpl_malloc if the replacement function should be used. */
-#undef malloc
-
-/* Define to `int' if <sys/types.h> does not define. */
-#undef pid_t
-
-/* Define to rpl_realloc if the replacement function should be used. */
-#undef realloc
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-#undef size_t
-
-/* Define as `fork' if `vfork' does not work. */
-#undef vfork
diff --git a/src/main.c b/src/main.c
index 8710702..336e25c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -474,7 +474,8 @@ void check_options ()
m4defs_buf.nelts = 0; /* memory leak here. */
/* Place a bogus line directive, it will be fixed in the filter. */
- outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");
+ if (gen_line_dirs)
+ outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");
/* Dump the user defined preproc directives. */
if (userdef_buf.elts)
diff --git a/src/scan.c b/src/scan.c
index b55df2d..0b032c2 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -4672,7 +4672,7 @@ static void yyensure_buffer_stack (void)
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
- num_to_alloc = 1; // After all that talk, this was set to 1 anyways...
+ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
diff --git a/src/scan.l b/src/scan.l
index 9eb857a..64ff49f 100644
--- a/src/scan.l
+++ b/src/scan.l
@@ -364,6 +364,7 @@ M4QEND "]]"
interactive interactive = option_sense;
lex-compat lex_compat = option_sense;
posix-compat posix_compat = option_sense;
+ line gen_line_dirs = option_sense;
main {
ACTION_M4_IFDEF( "M4""_YY_MAIN", option_sense);
/* Override yywrap */
diff --git a/src/skel.c b/src/skel.c
index ef657d3..26cc889 100644
--- a/src/skel.c
+++ b/src/skel.c
@@ -2561,7 +2561,7 @@ const char *skel[] = {
" * scanner will even need a stack. We use 2 instead of 1 to avoid an",
" * immediate realloc on the next call.",
" */",
- " num_to_alloc = 1; // After all that talk, this was set to 1 anyways...",
+ " num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */",
" YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc",
" (num_to_alloc * sizeof(struct yy_buffer_state*)",
" M4_YY_CALL_LAST_ARG);",