Skip to content

Commit

Permalink
1. upgrade m4 to version 1.4.19
Browse files Browse the repository at this point in the history
2. remove some legacy code and files
3. create temporary files in TEMP (nor in curdir)
  • Loading branch information
yjh-styx committed Dec 10, 2021
1 parent 5cc9da4 commit 960f82d
Show file tree
Hide file tree
Showing 173 changed files with 11,053 additions and 6,137 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-D_DEBUG)
endif()

# next line needed for compile in C (nor CPP) mode (ucrt headers bug)
add_definitions(-Dinline=__inline)

This comment has been minimized.

Copy link
@egorpugin

egorpugin Jan 11, 2022

Hi,

Can you point me what's the issue with this?

# next line needed for VS2017 only
add_definitions(-Drestrict=__restrict)

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W3 /MD /Od /Zi /EHsc")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /GL /Od /Oi /Gy /Zi /EHsc")

Expand Down
2 changes: 1 addition & 1 deletion VS2017/common_lib/common_lib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
<ClInclude Include="..\..\common\misc\getopt.h" />
<ClInclude Include="..\..\common\misc\getopt_int.h" />
<ClInclude Include="..\..\common\misc\gettext.h" />
<ClInclude Include="..\..\common\misc\gl_hash_map.h">
<ClInclude Include="..\..\common\misc\gl_hash_map.h" />
<ClInclude Include="..\..\common\misc\gl_map.h" />
<ClInclude Include="..\..\common\misc\gl_xmap.h" />
<ClInclude Include="..\..\common\misc\glthread\lock.h" />
Expand Down
2 changes: 1 addition & 1 deletion VS2019/common_lib/common_lib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<ClInclude Include="..\..\common\misc\getopt_int.h" />
<ClInclude Include="..\..\common\misc\getprogname.h" />
<ClInclude Include="..\..\common\misc\gettext.h" />
<ClInclude Include="..\..\common\misc\gl_hash_map.h">
<ClInclude Include="..\..\common\misc\gl_hash_map.h" />
<ClInclude Include="..\..\common\misc\gl_map.h" />
<ClInclude Include="..\..\common\misc\gl_xmap.h" />
<ClInclude Include="..\..\common\misc\glthread\lock.h" />
Expand Down
3 changes: 1 addition & 2 deletions bison/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
extern char* _stpcpy(char *yydest, const char *yysrc);

#include <stdio.h>
extern FILE* fopen_unixlike(const char* file, const char* mode);
#define fopen fopen_unixlike
#define fopen(n,m) _fsopen(n,m,_SH_DENYNO)

extern int strverscmp(const char* s1, const char* s2);

Expand Down
9 changes: 2 additions & 7 deletions bison/src/derivation.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */

#include <config.h>
//#include <config.h>
#include "../../misc/config.h"

#include "derivation.h"
#include "glyphs.h"
Expand All @@ -43,12 +44,6 @@ struct derivation
int color;
};

static inline const void *
gl_list_get_first (gl_list_t list)
{
return gl_list_get_at (list, 0);
}

static derivation d_dot = { -1, NULL, -1, NULL, -1 };

derivation *
Expand Down
7 changes: 3 additions & 4 deletions bison/src/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <sys/types.h>
//#include <unistd.h>
#include <xstrndup.h>
#include <mbstring.h>

#include "complain.h"
#include "files.h"
Expand Down Expand Up @@ -138,8 +139,7 @@ concat2 (char const *str1, char const *str2)
FILE *
xfopen (const char *name, const char *mode)
{
//FILE *res = fopen_safer (name, mode);
FILE *res = fopen (name, mode);
FILE *res = fopen/*_safer*/ (name, mode);
if (!res)
error (EXIT_FAILURE, get_errno (),
_("%s: cannot open"), quotearg_colon (name));
Expand Down Expand Up @@ -352,7 +352,6 @@ compute_exts_from_src (const char *ext)
'foo_tab' -> *BASE = 'foo_tab', *TAB = NULL, *EXT = NULL
'foo' -> *BASE = 'foo', *TAB = NULL, *EXT = NULL. */
#include <mbstring.h>

static void
file_name_split (const char *file_name,
Expand Down Expand Up @@ -524,7 +523,7 @@ output_file_name_check (char **file_name, bool source)
if (conflict)
{
free (*file_name);
*file_name = _strdup ("/dev/null");
*file_name = _strdup (/*"/dev/null"*/"NUL");
}
else
{
Expand Down
10 changes: 8 additions & 2 deletions bison/src/glyphs.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <stdbool.h>
#include <string.h>
#include <mbswidth.h>
#include <unicodeio.h>
//#include <unicodeio.h>


glyph_buffer_t arrow;
Expand All @@ -51,14 +51,16 @@ typedef struct
} callback_arg_t;


#if 0
static long
on_success (const char *buf, size_t buflen, void *callback_arg)
{
callback_arg_t *arg = (callback_arg_t *) callback_arg;
assert (buflen + 1 < sizeof *arg->pbuf);
*strncpy(*arg->pbuf, buf, buflen) = '\0';
*stpncpy (*arg->pbuf, buf, buflen) = '\0';
return 1;
}
#endif

static long
on_failure (unsigned code, const char *msg,
Expand All @@ -75,7 +77,11 @@ glyph_set (glyph_buffer_t *glyph, int *width,
unsigned code, const char *fallback)
{
callback_arg_t arg = { glyph, fallback };
#if 0
int res = unicode_to_mb (code, on_success, on_failure, &arg);
#else
int res = on_failure(code, "iconv function not available", &arg);
#endif
*width = mbswidth (*glyph, 0);
return res;
}
Expand Down
101 changes: 13 additions & 88 deletions bison/src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
//#include <spawn-pipe.h>
#include <timevar.h>
//#include <wait-process.h>
#include <process.h>

#include "complain.h"
#include "files.h"
Expand Down Expand Up @@ -717,90 +718,6 @@ muscles_output (FILE *out)
/*---------------------------.
| Call the skeleton parser. |
`---------------------------*/
#include <process.h>
#include <io.h>
static const char letters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
/* Generate a temporary file name based on TMPL. TMPL must match the
rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed
does not exist at the time of the call to mkstemp. TMPL is
overwritten with the result. */
static FILE* mkstempFILE (char *tmpl, const char *mode)
{
int len;
char *XXXXXX;
static unsigned long long value;
unsigned long long random_time_bits;
unsigned int count;
FILE* fd = NULL;
int r;

/* A lower bound on the number of temporary files to attempt to
generate. The maximum total number of temporary file names that
can exist for a given template is 62**6. It should never be
necessary to try all these combinations. Instead if a reasonable
number of names is tried (we define reasonable as 62**3) fail to
give the system administrator the chance to remove the problems. */
#define ATTEMPTS_MIN (62 * 62 * 62)

/* The number of times to attempt to generate a temporary file. To
conform to POSIX, this must be no smaller than TMP_MAX. */
#if ATTEMPTS_MIN < TMP_MAX
unsigned int attempts = TMP_MAX;
#else
unsigned int attempts = ATTEMPTS_MIN;
#endif

len = strlen (tmpl);
if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX"))
{
return NULL;
}

/* This is where the Xs start. */
XXXXXX = &tmpl[len - 6];

/* Get some more or less random data but unique per process */
{
static unsigned long long g_value;
g_value = _getpid();
g_value += 100;
random_time_bits = (((unsigned long long)234546 << 32)
| (unsigned long long)g_value);
}
value += random_time_bits ^ (unsigned long long)122434;

for (count = 0; count < attempts; value += 7777, ++count)
{
unsigned long long v = value;

/* Fill in the random bits. */
XXXXXX[0] = letters[v % 62];
v /= 62;
XXXXXX[1] = letters[v % 62];
v /= 62;
XXXXXX[2] = letters[v % 62];
v /= 62;
XXXXXX[3] = letters[v % 62];
v /= 62;
XXXXXX[4] = letters[v % 62];
v /= 62;
XXXXXX[5] = letters[v % 62];

/* file doesn't exist */
if (r = _access(tmpl, 0) == -1)
{
fd = fopen (tmpl, mode);
if (fd)
{
return fd;
}
}
}

/* We got out of the loop because we ran out of combinations to try. */
return NULL;
}

extern int
main_m4 (int argc, char *const *argv, FILE* in, FILE* out);
Expand All @@ -810,8 +727,8 @@ output_skeleton (void)
{
FILE *m4_in = NULL;
FILE *m4_out = NULL;
char m4_in_file_name[] = "~m4_in_temp_file_XXXXXX";
char m4_out_file_name[] = "~m4_out_temp_file_XXXXXX";
char m4_in_file_name[/*MAX_PATH*/260];
char m4_out_file_name[/*MAX_PATH*/260];
char const *argv[11];

/* Compute the names of the package data dir and skeleton files. */
Expand Down Expand Up @@ -896,7 +813,11 @@ output_skeleton (void)
if (trace_flag & trace_muscles)
muscles_output (stderr);
{
m4_in = mkstempFILE(m4_in_file_name, "wb+");
char* p = _tempnam(NULL, "~m4_in_");
if (!p)
error (EXIT_FAILURE, get_errno (),
"_tempnam");
m4_in = fopen(strcpy(m4_in_file_name, p), "wb+");
if (!m4_in)
error (EXIT_FAILURE, get_errno (),
"fopen");
Expand All @@ -911,7 +832,11 @@ output_skeleton (void)
/* Read and process m4's output. */
timevar_push (tv_m4);
{
m4_out = mkstempFILE(m4_out_file_name, "wb+");
char *p = _tempnam(NULL, "~m4_out_");
if (!m4_out_file_name)
error (EXIT_FAILURE, get_errno (),
"_tempnam");
m4_out = fopen(strcpy(m4_out_file_name, p), "wb+");
if (!m4_out)
error (EXIT_FAILURE, get_errno (),
"fopen");
Expand Down
3 changes: 2 additions & 1 deletion bison/src/parse-simulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */

#include <config.h>
//#include <config.h>
#include "../../misc/config.h"

#include "parse-simulation.h"

Expand Down
2 changes: 1 addition & 1 deletion bison/src/print-xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ print_html (void)
int status
= execute (argv[0],
argv[0], argv,
// /* directory */ NULL,
/* directory */ NULL,
/* ignore_sigpipe */ false,
/* null_stdin, null_stdout, null_stderr */ true, true, true,
/* slave_process */ true, /* exit_on_error */ false,
Expand Down
5 changes: 5 additions & 0 deletions buildVS2022.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mkdir CMakeBuildVS2022
cd CMakeBuildVS2022
cmake .. -G "Visual Studio 17 2022"
cmake --build . --config "Release" --target package
cd ..
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### version 2.5.25
* upgrade win_bison to version 3.8.2
* upgrade m4 to version 1.4.19

### version 2.5.24
* upgrade win_bison to version 3.7.4
Expand Down
4 changes: 4 additions & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ file(GLOB SOURCE_FILES
"m4/*.h"
"m4/lib/*.c"
"m4/lib/*.h"
"m4/lib/malloc/*.c"
"m4/lib/malloc/*.h"
)
# exclude some source files
list(REMOVE_ITEM SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/m4/lib/regexec.c")
list(REMOVE_ITEM SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/m4/lib/regcomp.c")
list(REMOVE_ITEM SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/m4/lib/regex_internal.c")
list(REMOVE_ITEM SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/m4/lib/malloc/dynarray-skeleton.c")

# Add library to build.
add_library(${PROJECT_NAME} STATIC
Expand Down
Loading

0 comments on commit 960f82d

Please sign in to comment.