Alien-flex
view release on metacpan or search on metacpan
patch/flex-2.6.4.diff view on Meta::CPAN
+#: src/main.c:1571
+#, c-format
+msgid "Variable trailing context rules entail a large performance penalty\n"
+msgstr ""
+"ÐÑавила коÑÑÑ Ð¼Ð°ÑÑÑ Ð·Ð°Ð¼Ð¸ÐºÐ°ÑÑий конÑекÑÑ Ð·Ð¼ÑÐ½Ð½Ð¾Ñ Ð´Ð¾Ð²Ð¶Ð¸Ð½Ð¸ знаÑно знижÑÑÑÑ "
+"пÑодÑкÑивнÑÑÑÑ\n"
+
+#: src/main.c:1583
+msgid "REJECT cannot be used with -f or -F"
+msgstr "REJECT не може бÑÑи викоÑиÑÑано Ñазом з -f або -F"
+
+#: src/main.c:1586
+#, c-format
+msgid "%option yylineno cannot be used with REJECT"
+msgstr "%option yylineno не може бÑÑи викоÑиÑÑано з REJECT"
+
+#: src/main.c:1589
+msgid "variable trailing context rules cannot be used with -f or -F"
+msgstr ""
+"ÐÑавила коÑÑÑ Ð¼Ð°ÑÑÑ Ð·Ð°Ð¼Ð¸ÐºÐ°ÑÑий конÑекÑÑ Ð·Ð¼ÑÐ½Ð½Ð¾Ñ Ð´Ð¾Ð²Ð¶Ð¸Ð½Ð¸ не можÑÑÑ Ð±ÑÑи "
+"викоÑиÑÑÐ°Ð½Ñ Ð· -f or -F"
+
+#: src/main.c:1714
+#, c-format
+msgid "%option yyclass only meaningful for C++ scanners"
+msgstr "%option yyclass Ð¼Ð°Ñ ÑÐµÐ½Ñ ÑÑлÑки Ð´Ð»Ñ ÑканеÑÑв C++"
+
+#: src/main.c:1801
+#, c-format
+msgid "Usage: %s [OPTIONS] [FILE]...\n"
+msgstr "ÐикоÑиÑÑаннÑ: %s [ÐÐÐ ÐÐÐТРÐ] [ФÐÐÐ]â¦\n"
+
+#: src/main.c:1804
+#, fuzzy, c-format
+msgid ""
+"Generates programs that perform pattern-matching on text.\n"
+"\n"
+"Table Compression:\n"
+" -Ca, --align trade off larger tables for better memory alignment\n"
+" -Ce, --ecs construct equivalence classes\n"
+" -Cf do not compress tables; use -f representation\n"
+" -CF do not compress tables; use -F representation\n"
+" -Cm, --meta-ecs construct meta-equivalence classes\n"
+" -Cr, --read use read() instead of stdio for scanner input\n"
+" -f, --full generate fast, large scanner. Same as -Cfr\n"
+" -F, --fast use alternate table representation. Same as -CFr\n"
+" -Cem default compression (same as --ecs --meta-ecs)\n"
+"\n"
+"Debugging:\n"
+" -d, --debug enable debug mode in scanner\n"
+" -b, --backup write backing-up information to %s\n"
+" -p, --perf-report write performance report to stderr\n"
+" -s, --nodefault suppress default rule to ECHO unmatched text\n"
+" -T, --trace %s should run in trace mode\n"
+" -w, --nowarn do not generate warnings\n"
+" -v, --verbose write summary of scanner statistics to stdout\n"
+" --hex use hexadecimal numbers instead of octal in debug "
+"outputs\n"
+"\n"
+"Files:\n"
+" -o, --outfile=FILE specify output filename\n"
+" -S, --skel=FILE specify skeleton file\n"
+" -t, --stdout write scanner on stdout instead of %s\n"
+" --yyclass=NAME name of C++ class\n"
+" --header-file=FILE create a C header file in addition to the "
+"scanner\n"
+" --tables-file[=FILE] write tables to FILE\n"
+"\n"
+"Scanner behavior:\n"
+" -7, --7bit generate 7-bit scanner\n"
+" -8, --8bit generate 8-bit scanner\n"
+" -B, --batch generate batch scanner (opposite of -I)\n"
+" -i, --case-insensitive ignore case in patterns\n"
+" -l, --lex-compat maximal compatibility with original lex\n"
+" -X, --posix-compat maximal compatibility with POSIX lex\n"
+" -I, --interactive generate interactive scanner (opposite of -B)\n"
+" --yylineno track line count in yylineno\n"
+"\n"
+"Generated code:\n"
+" -+, --c++ generate C++ scanner class\n"
+" -Dmacro[=defn] #define macro defn (default defn is '1')\n"
+" -L, --noline suppress #line directives in scanner\n"
+" -P, --prefix=STRING use STRING as prefix instead of \"yy\"\n"
+" -R, --reentrant generate a reentrant C scanner\n"
+" --bison-bridge scanner for bison pure parser.\n"
+" --bison-locations include yylloc support.\n"
+" --stdinit initialize yyin/yyout to stdin/stdout\n"
+" --nounistd do not include <unistd.h>\n"
+" --noFUNCTION do not generate a particular FUNCTION\n"
+"\n"
+"Miscellaneous:\n"
+" -c do-nothing POSIX option\n"
+" -n do-nothing POSIX option\n"
+" -?\n"
+" -h, --help produce this help message\n"
+" -V, --version report %s version\n"
+msgstr ""
+"ÐенеÑÑÑ Ð¿ÑогÑами, Ñо знаÑ
одÑÑÑ Ñаблони Ñ ÑекÑÑÑ.\n"
+"\n"
+"СÑиÑÐ½ÐµÐ½Ð½Ñ ÑаблиÑÑ:\n"
+" -Ca, --align виÑÑвнÑÑи ÑаблиÑÑ Ñ Ð¿Ð°Ð¼'ÑÑÑ Ð·Ð±ÑлÑÑивÑи ÑозмÑÑ\n"
+" ÑÑ
елеменÑÑв\n"
+" -Ce, --ecs ÑÑвоÑÑваÑи клаÑи еквÑваленÑноÑÑÑ\n"
+" -Cf не ÑÑиÑкаÑи ÑаблиÑÑ; викоÑиÑÑовÑваÑи -f пÑедÑÑавленнÑ\n"
+" -CF не ÑÑиÑкаÑи ÑаблиÑÑ; викоÑиÑÑовÑваÑи -F пÑедÑÑавленнÑ\n"
+" -Cm, --meta-ecs ÑÑвоÑÑваÑи клаÑи меÑа-еквÑваленÑноÑÑÑ\n"
+" -Cr, --read викоÑиÑÑаÑи read() замÑÑÑÑ stdio Ñк\n"
+" вÑ
ÑÐ´Ð½Ñ Ð´Ð°Ð½Ñ ÑканеÑа\n"
+" -f, --full ÑÑвоÑиÑи Ñвидкий, великий ÑканеÑ. Теж Ñаме, Ñо -Cfr\n"
+" -F, --fast заÑÑоÑÑваÑи алÑÑеÑнаÑивний Ð¾Ð¿Ð¸Ñ ÑаблиÑÑ.\n"
+" Теж Ñаме, Ñо -CFr\n"
+" -Cem ÑÑепÑÐ½Ñ ÑÑиÑÐ½ÐµÐ½Ð½Ñ Ð·Ð° замовÑÑваннÑм\n"
+" (Ñеж Ñаме, Ñо --ecs --meta-ecs)\n"
+"\n"
+"ÐалагодженнÑ:\n"
+" -d, --debug ÑвÑмкнÑÑи Ñежим Ð½Ð°Ð»Ð°Ð³Ð¾Ð´Ð¶ÐµÐ½Ð½Ñ ÑканеÑа\n"
+" -b, --backup запиÑаÑи ÑезеÑÐ²Ð½Ñ ÐºÐ¾Ð¿ÑÑ Ð´Ð¾ %s\n"
+" -p, --perf-report запиÑаÑи звÑÑ Ð¿Ñо пÑодÑкÑивнÑÑÑÑ Ð´Ð¾ stderr\n"
+" -s, --nodefault пÑипиниÑи вивÑд ÑекÑÑÑ (ECHO до stdout)\n"
+" Ñо не збÑгаÑÑÑÑÑ Ð· жодним пÑавилом\n"
+" -T, --trace %s повинен запÑÑкаÑиÑÑ Ñ ÑÐµÐ¶Ð¸Ð¼Ñ ÑÑаÑÑваннÑ\n"
+" -w, --nowarn не видаваÑи попеÑедженÑ\n"
+" -v, --verbose запиÑаÑи пÑдÑÑÐ¼ÐºÐ¾Ð²Ñ ÑÑаÑиÑÑÐ¸ÐºÑ ÑканеÑа до stdout\n"
+"\n"
+"Файли:\n"
+" -o, --outfile=ФÐÐРвказаÑи Ñм'Ñ Ð²Ð¸Ñ
Ñдного Ñайла\n"
+" -S, --skel=ФÐÐРвказаÑи Ñайл каÑкаÑÑ\n"
+" -t, --stdout запиÑаÑи ÑÐºÐ°Ð½ÐµÑ Ð´Ð¾ stdout замÑÑÑÑ %s\n"
+" --yyclass=ÐÐ'Я Ñм'Ñ ÐºÐ»Ð°ÑÑ C++\n"
+" --header-file=ФÐÐÐ ÑÑвоÑиÑи C Ñайл заголовок ÑканеÑа\n"
+" --tables-file[=ФÐÐÐ] запиÑаÑи ÑаблиÑÑ Ñ Ð¤ÐÐÐ\n"
+"\n"
+"ÐоведÑнка ÑканеÑа:\n"
+" -7, --7bit ÑÑвоÑиÑи 7-бÑÑний ÑканеÑ\n"
+" -8, --8bit ÑÑвоÑиÑи 8-бÑÑний ÑканеÑ\n"
+" -B, --batch ÑÑвоÑиÑи пакеÑний ÑканеÑ\n"
+" (пÑоÑилежна за влаÑÑивоÑÑÑми до опÑÑÑ -I)\n"
+" -i, --case-insensitive ÑгноÑÑваÑи ÑегÑÑÑÑ ÑимволÑв Ñ ÑаблонаÑ
\n"
+" -l, --lex-compat макÑималÑна ÑÑмÑÑнÑÑÑÑ Ð· оÑигÑналÑним lex\n"
+" -X, --posix-compat макÑималÑна ÑÑмÑÑнÑÑÑÑ Ð· POSIX lex\n"
+" -I, --interactive ÑÑвоÑиÑи ÑнÑеÑакÑивний ÑканеÑ\n"
+" (пÑоÑилежна за влаÑÑивоÑÑÑми до опÑÑÑ -B)\n"
+" --yylineno вÑдÑлÑдковÑваÑи ÑиÑло ÑÑдкÑв Ñ yylineno\n"
+"\n"
+"ÐенеÑаÑÑÑ ÐºÐ¾Ð´Ñ:\n"
+" -+, --c++ ÑÑвоÑиÑи C++ ÐºÐ»Ð°Ñ ÑканеÑа\n"
+" -Dmacro[=defn] #define macro defn (за замовÑÑваннÑм defn='1')\n"
+" -L, --noline не ÑÑвоÑÑваÑи #line диÑекÑиви Ð´Ð»Ñ ÑканеÑа\n"
+" -P, --prefix=РЯÐÐРвикоÑиÑÑаÑи РЯÐÐÐ Ñк пÑеÑÑÐºÑ Ð·Ð°Ð¼ÑÑÑÑ Â«yy»\n"
+" -R, --reentrant генеÑÑваÑи ÑеенÑеÑабелÑний C-ÑканеÑ\n"
+" --bison-bridge ÑÐºÐ°Ð½ÐµÑ ÑÑлÑки Ð´Ð»Ñ bison аналÑзаÑоÑÑ\n"
+" --bison-locations додаÑи пÑдÑÑÐ¸Ð¼ÐºÑ yylloc\n"
+" --stdinit ÑнÑÑÑалÑзÑваÑи yyin/yyout до stdin/stdout\n"
+" --noansi-definitions визнаÑÐµÐ½Ð½Ñ ÑÑнкÑÑй Ñ Ð·Ð°ÑÑаÑÑÐ»Ð¾Ð¼Ñ ÑÑилÑ\n"
+" --noansi-prototypes поÑожнÑй ÑпиÑок паÑамеÑÑÑв Ñ Ð¿ÑоÑоÑипаÑ
\n"
+" --nounistd не додаваÑи <unistd.h>\n"
+" --noФУÐÐЦÐЯ не генеÑÑваÑи Ð·Ð°Ð´Ð°Ð½Ñ ÑÑнкÑÑÑ Ð¤Ð£ÐÐЦÐЯ\n"
+"\n"
+"ÐнÑе:\n"
+" -Ñ Ð½ÐµÐ´ÑÑÑий POSIX паÑамеÑÑ\n"
+" -n недÑÑÑий POSIX паÑамеÑÑ\n"
+" -?\n"
+" -h, --help показаÑи ÑÑ Ð´Ð¾Ð²ÑдкÑ\n"
+" -V, --version показаÑи веÑÑÑÑ %s\n"
+
+#: src/misc.c:64
+msgid "allocation of sko_stack failed"
+msgstr "не вдалоÑÑ Ð¾ÑÑимаÑи памâÑÑÑ Ð¿Ñд sko_stack"
+
+#: src/misc.c:100
+#, c-format
+msgid "name \"%s\" ridiculously long"
+msgstr "Ñм'Ñ Â«%s» занадÑо довге"
+
+#: src/misc.c:149 src/misc.c:162
+msgid "memory allocation failed in allocate_array()"
+msgstr "помилка видÑÐ»ÐµÐ½Ð½Ñ Ð¿Ð°Ð¼'ÑÑÑ Ñ allocate_array()"
+
+#: src/misc.c:212
+#, c-format
+msgid "bad character '%s' detected in check_char()"
+msgstr "check_char() виÑвив недопÑÑÑимий Ñимвол «%s»"
+
+#: src/misc.c:217
+#, c-format
+msgid "scanner requires -8 flag to use the character %s"
patch/flex-2.6.4.diff view on Meta::CPAN
@@ -246,6 +277,16 @@
`char[]'. */
#undef YYTEXT_POINTER
+/* Define to 1 if on MINIX. */
+#undef _MINIX
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+ this defined. */
+#undef _POSIX_1_SOURCE
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+#undef _POSIX_SOURCE
+
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
diff --git a/src/filter.c b/src/filter.c
index 71f3635..a7e69ec 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -47,10 +47,9 @@ struct filter *filter_create_ext (struct filter *chain, const char *cmd,
va_list ap;
/* allocate and initialize new filter */
- f = malloc(sizeof(struct filter));
+ f = calloc(sizeof(struct filter), 1);
if (!f)
- flexerror(_("malloc failed (f) in filter_create_ext"));
- memset (f, 0, sizeof (*f));
+ flexerror(_("calloc failed (f) in filter_create_ext"));
f->filter_func = NULL;
f->extra = NULL;
f->next = NULL;
@@ -100,10 +99,9 @@ struct filter *filter_create_int (struct filter *chain,
struct filter *f;
/* allocate and initialize new filter */
- f = malloc(sizeof(struct filter));
+ f = calloc(sizeof(struct filter), 1);
if (!f)
- flexerror(_("malloc failed in filter_create_int"));
- memset (f, 0, sizeof (*f));
+ flexerror(_("calloc failed in filter_create_int"));
f->next = NULL;
f->argc = 0;
f->argv = NULL;
@@ -230,8 +228,7 @@ int filter_tee_header (struct filter *chain)
* header file at the same time.
*/
- const int readsz = 512;
- char *buf;
+ char buf[512];
int to_cfd = -1;
FILE *to_c = NULL, *to_h = NULL;
bool write_header;
@@ -283,10 +280,7 @@ int filter_tee_header (struct filter *chain)
fprintf (to_c, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n",
outfilename ? outfilename : "<stdout>");
- buf = malloc((size_t) readsz);
- if (!buf)
- flexerror(_("malloc failed in filter_tee_header"));
- while (fgets (buf, readsz, stdin)) {
+ while (fgets (buf, sizeof buf, stdin)) {
fputs (buf, to_c);
if (write_header)
fputs (buf, to_h);
@@ -328,6 +322,13 @@ int filter_tee_header (struct filter *chain)
return 0;
}
+static bool is_blank_line (const char *str)
+{
+ while (isspace(*str))
+ str++;
+ return (*str == '\0');
+}
+
/** Adjust the line numbers in the #line directives of the generated scanner.
* After the m4 expansion, the line numbers are incorrect since the m4 macros
* can add or remove lines. This only adjusts line numbers for generated code,
@@ -336,8 +337,8 @@ int filter_tee_header (struct filter *chain)
*/
int filter_fix_linedirs (struct filter *chain)
{
- char *buf;
- const size_t readsz = 512;
+ char buf[512];
+ const size_t readsz = sizeof buf;
int lineno = 1;
bool in_gen = true; /* in generated code */
bool last_was_blank = false;
@@ -345,10 +346,6 @@ int filter_fix_linedirs (struct filter *chain)
if (!chain)
return 0;
- buf = malloc(readsz);
- if (!buf)
- flexerror(_("malloc failed in filter_fix_linedirs"));
-
while (fgets (buf, (int) readsz, stdin)) {
regmatch_t m[10];
@@ -391,7 +388,7 @@ int filter_fix_linedirs (struct filter *chain)
/* Adjust the line directives. */
in_gen = true;
snprintf (buf, readsz, "#line %d \"%s\"\n",
- lineno, filename);
+ lineno + 1, filename);
}
else {
/* it's a #line directive for code we didn't write */
@@ -403,9 +400,7 @@ int filter_fix_linedirs (struct filter *chain)
}
/* squeeze blank lines from generated code */
- else if (in_gen
- && regexec (®ex_blank_line, buf, 0, NULL,
patch/flex-2.6.4.diff view on Meta::CPAN
@@ -1420,9 +1420,9 @@ void gentabs (void)
yytbl_data_compress (yynxt_tbl);
if (yytbl_data_fwrite (&tableswr, yynxt_tbl) < 0)
flexerror (_("Could not write yynxt_tbl"));
- yytbl_data_destroy (yynxt_tbl);
- yynxt_tbl = NULL;
}
+ yytbl_data_destroy (yynxt_tbl);
+ yynxt_tbl = NULL;
/* End generating yy_nxt */
/* Begin generating yy_chk */
@@ -1454,9 +1454,9 @@ void gentabs (void)
yytbl_data_compress (yychk_tbl);
if (yytbl_data_fwrite (&tableswr, yychk_tbl) < 0)
flexerror (_("Could not write yychk_tbl"));
- yytbl_data_destroy (yychk_tbl);
- yychk_tbl = NULL;
}
+ yytbl_data_destroy (yychk_tbl);
+ yychk_tbl = NULL;
/* End generating yy_chk */
free(acc_array);
diff --git a/src/gettext.h b/src/gettext.h
index ea67f30..3f62961 100644
--- a/src/gettext.h
+++ b/src/gettext.h
@@ -20,7 +20,7 @@
#define _LIBGETTEXT_H 1
/* NLS can be disabled through the configure --disable-nls option. */
-#if ENABLE_NLS
+#ifdef ENABLE_NLS
/* Get declarations of GNU message catalog functions. */
# include <libintl.h>
diff --git a/src/libfl.pc.in b/src/libfl.pc.in
new file mode 100644
index 0000000..8d4240c
--- /dev/null
+++ b/src/libfl.pc.in
@@ -0,0 +1,8 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+
+Name: libfl
+Description: Flex (the fast lexical analyzer) support library
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lfl
diff --git a/src/main.c b/src/main.c
index e5eac44..a4047d7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -117,7 +117,7 @@ struct yytbl_writer tableswr;
char *program_name = "flex";
static const char outfile_template[] = "lex.%s.%s";
-static const char backing_name[] = "lex.backup";
+static const char *backing_name = "lex.backup";
static const char tablesfile_template[] = "lex.%s.tables";
/* From scan.l */
@@ -197,7 +197,7 @@ int flex_main (int argc, char *argv[])
/* Wrapper around flex_main, so flex_main can be built as a library. */
int main (int argc, char *argv[])
{
-#if ENABLE_NLS
+#if defined(ENABLE_NLS) && ENABLE_NLS
#if HAVE_LOCALE_H
setlocale (LC_MESSAGES, "");
setlocale (LC_CTYPE, "");
@@ -648,6 +648,7 @@ void flexend (int exit_status)
"yyget_extra",
"yyget_in",
"yyget_leng",
+ "yyget_column",
"yyget_lineno",
"yyget_lloc",
"yyget_lval",
@@ -670,6 +671,7 @@ void flexend (int exit_status)
"yyset_debug",
"yyset_extra",
"yyset_in",
+ "yyset_column",
"yyset_lineno",
"yyset_lloc",
"yyset_lval",
@@ -994,7 +996,7 @@ void flexinit (int argc, char **argv)
flex_init_regex();
/* Enable C++ if program name ends with '+'. */
- program_name = basename (argv[0]);
+ program_name = argv[0];
if (program_name != NULL &&
program_name[strlen (program_name) - 1] == '+')
@@ -1033,6 +1035,11 @@ void flexinit (int argc, char **argv)
backing_up_report = true;
break;
+ case OPT_BACKUP_FILE:
+ backing_up_report = true;
+ backing_name = arg;
+ break;
+
case OPT_DONOTHING:
break;
@@ -1201,7 +1208,7 @@ void flexinit (int argc, char **argv)
break;
case OPT_VERSION:
- printf (_("%s %s\n"), program_name, flex_version);
+ printf ("%s %s\n", (C_plus_plus ? "flex++" : "flex"), flex_version);
FLEX_EXIT (0);
case OPT_WARN:
@@ -1394,6 +1401,14 @@ void flexinit (int argc, char **argv)
//buf_strdefine (&userdef_buf, "YY_NO_SET_LINENO", "1");
buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LINENO",0);
break;
+ case OPT_NO_YYGET_COLUMN:
+ //buf_strdefine (&userdef_buf, "YY_NO_GET_COLUMN", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_COLUMN",0);
+ break;
+ case OPT_NO_YYSET_COLUMN:
+ //buf_strdefine (&userdef_buf, "YY_NO_SET_COLUMN", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_COLUMN",0);
+ break;
case OPT_NO_YYGET_IN:
//buf_strdefine (&userdef_buf, "YY_NO_GET_IN", "1");
buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_IN",0);
@@ -1817,7 +1832,8 @@ void usage (void)
" -t, --stdout write scanner on stdout instead of %s\n"
" --yyclass=NAME name of C++ class\n"
" --header-file=FILE create a C header file in addition to the scanner\n"
- " --tables-file[=FILE] write tables to FILE\n" "\n"
+ " --tables-file[=FILE] write tables to FILE\n"
+ " --backup-file=FILE write backing-up information to FILE\n" "\n"
"Scanner behavior:\n"
" -7, --7bit generate 7-bit scanner\n"
" -8, --8bit generate 8-bit scanner\n"
@@ -1844,6 +1860,6 @@ void usage (void)
" -?\n"
" -h, --help produce this help message\n"
" -V, --version report %s version\n"),
- backing_name, program_name, outfile_path, program_name);
+ backing_name, "flex", outfile_path, "flex");
}
diff --git a/src/misc.c b/src/misc.c
index ef27833..745e6a8 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -116,15 +116,14 @@ void add_action (const char *new_text)
int len = (int) strlen (new_text);
while (len + action_index >= action_size - 10 /* slop */ ) {
- int new_size = action_size * 2;
- if (new_size <= 0)
+ if (action_size > INT_MAX / 2)
/* Increase just a little, to try to avoid overflow
* on 16-bit machines.
*/
action_size += action_size / 8;
else
- action_size = new_size;
+ action_size = action_size * 2;
action_array =
reallocate_character_array (action_array,
@@ -141,20 +140,24 @@ void add_action (const char *new_text)
void *allocate_array (int size, size_t element_size)
{
- void *mem;
-#if HAVE_REALLOCARRAY
- /* reallocarray has built-in overflow detection */
- mem = reallocarray(NULL, (size_t) size, element_size);
+ void *new_array;
+#if HAVE_REALLOCARR
+ new_array = NULL;
+ if (reallocarr(&new_array, (size_t) size, element_size))
+ flexfatal (_("memory allocation failed in allocate_array()"));
#else
+# if HAVE_REALLOCARRAY
+ new_array = reallocarray(NULL, (size_t) size, element_size);
+# else
+ /* Do manual overflow detection */
size_t num_bytes = (size_t) size * element_size;
- mem = (size && SIZE_MAX / (size_t) size < element_size) ? NULL :
+ new_array = (size && SIZE_MAX / (size_t) size < element_size) ? NULL :
malloc(num_bytes);
+# endif
+ if (!new_array)
+ flexfatal (_("memory allocation failed in allocate_array()"));
#endif
- if (!mem)
- flexfatal (_
- ("memory allocation failed in allocate_array()"));
-
- return mem;
+ return new_array;
}
@@ -659,17 +662,22 @@ char *readable_form (int c)
( run in 1.834 second using v1.01-cache-2.11-cpan-df04353d9ac )