Skip to content

Commit 5d1eb0d

Browse files
committed
test
Signed-off-by: Lars-Peter Clausen <[email protected]>
1 parent e3f943f commit 5d1eb0d

File tree

3 files changed

+45
-11
lines changed

3 files changed

+45
-11
lines changed

driver/main.c

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,35 @@ static const char*my_tempfile(const char*str, FILE**fout)
321321
return pathbuf;
322322
}
323323

324+
#ifdef __MINGW32__
325+
static int run_cmd(const char *cmd)
326+
{
327+
char *cmd2;
328+
int len;
329+
int rc;
330+
331+
len = strlen(cmd) + 13;
332+
cmd2 = malloc(len);
333+
rc = snprintf(cmd2, len, "cmd /S /C \"%s\"", cmd);
334+
if (rc < 0)
335+
return rc;
336+
337+
if (verbose_flag)
338+
fprintf(stderr, "Executing: %s", cmd2);
339+
340+
rc = system(cmd2);
341+
free(cmd2);
342+
343+
return rc;
344+
}
345+
#else
346+
static int run_cmd(const char *cmd)
347+
{
348+
return system(cmd);
349+
}
350+
351+
#endif
352+
324353
static int t_version_only(void)
325354
{
326355
int rc;
@@ -329,15 +358,15 @@ static int t_version_only(void)
329358

330359
fflush(0);
331360
snprintf(tmp, sizeof tmp, "\"%s%civlpp\" -V", ivlpp_dir, sep);
332-
rc = system(tmp);
361+
rc = run_cmd(tmp);
333362
if (rc != 0) {
334363
fprintf(stderr, "Unable to get version from \"%s\"\n", tmp);
335364
}
336365

337366
fflush(0);
338367
snprintf(tmp, sizeof tmp, "\"%s%civl\" -V -C\"%s\" -C\"%s\"", base, sep,
339368
iconfig_path, iconfig_common_path);
340-
rc = system(tmp);
369+
rc = run_cmd(tmp);
341370
if (rc != 0) {
342371
fprintf(stderr, "Unable to get version from \"%s\"\n", tmp);
343372
}
@@ -388,7 +417,7 @@ static int t_preprocess_only(void)
388417
if (verbose_flag)
389418
printf("preprocess: %s\n", cmd);
390419

391-
rc = system(cmd);
420+
rc = run_cmd(cmd);
392421
remove(source_path);
393422
free(source_path);
394423

@@ -489,7 +518,7 @@ static int t_compile(void)
489518
printf("translate: %s\n", cmd);
490519

491520

492-
rc = system(cmd);
521+
rc = run_cmd(cmd);
493522
if ( ! getenv("IVERILOG_ICONFIG")) {
494523
remove(source_path);
495524
free(source_path);

ivlpp/lexor.lex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,7 @@ static void open_input_file(struct include_stack_t*isp)
21142114
return;
21152115
}
21162116

2117-
size_t cmdlen = strlen(vhdlpp_path);
2117+
size_t cmdlen = strlen(vhdlpp_path) + 12;
21182118
cmdlen += strlen(isp->path);
21192119
cmdlen += 8+strlen(vhdlpp_work);
21202120

@@ -2130,7 +2130,11 @@ static void open_input_file(struct include_stack_t*isp)
21302130
cmdlen += liblen;
21312131

21322132
char*cmd = malloc(cmdlen);
2133+
#ifdef __MINGW32__
2134+
snprintf(cmd, cmdlen, "cmd /S /C \"%s -w\"%s\"%s %s\"", vhdlpp_path, vhdlpp_work, libs, isp->path);
2135+
#else
21332136
snprintf(cmd, cmdlen, "%s -w\"%s\"%s %s", vhdlpp_path, vhdlpp_work, libs, isp->path);
2137+
#endif
21342138

21352139
if (verbose_flag) fprintf(stderr, "Invoke vhdlpp: %s\n", cmd);
21362140

pform.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3410,12 +3410,13 @@ int pform_parse(const char*path)
34103410
if (strcmp(path, "-") == 0) {
34113411
vl_input = stdin;
34123412
} else if (ivlpp_string) {
3413-
char*cmdline = (char*)malloc(strlen(ivlpp_string) +
3414-
strlen(path) + 4);
3415-
strcpy(cmdline, ivlpp_string);
3416-
strcat(cmdline, " \"");
3417-
strcat(cmdline, path);
3418-
strcat(cmdline, "\"");
3413+
size_t cmdlen = strlen(ivlpp_string) + strlen(path) + 16;
3414+
char*cmdline = (char*)malloc(cmdlen);
3415+
#ifdef __MINGW32__
3416+
snprintf(cmdline, cmdlen, "cmd /S /C \"%s \"%s\"\"", ivlpp_string, path);
3417+
#else
3418+
snprintf(cmdline, cmdlen, "%s \"%s\"", ivlpp_string, path);
3419+
#endif
34193420

34203421
if (verbose_flag)
34213422
cerr << "Executing: " << cmdline << endl<< flush;

0 commit comments

Comments
 (0)