mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-10 11:23:15 +00:00
Quote special characters occurring in the value of
Estimated hours taken: 0.25 util/mkinit.c: Quote special characters occurring in the value of MR_runtime_flags written to the `_init.c' file. tests/hard_coded/Mmakefile: Test case.
This commit is contained in:
@@ -274,7 +274,11 @@ MLFLAGS-needs_init = --include-initialization-code --extra-inits
|
||||
# unless we increase the heap size from the default 4M.
|
||||
# The sizes specified here (70 Mb and 20 Mb respectively)
|
||||
# are sufficient for running these tests on 64-bit systems.
|
||||
MLFLAGS-integer_test = --runtime-flags "--heap-size 70000"
|
||||
# The setting of `--mdb-out' tests the quoting of runtime
|
||||
# options containing special characters.
|
||||
|
||||
MLFLAGS-integer_test = \
|
||||
--runtime-flags "--heap-size 70000 --mdb-out \"mdb\\mdb out\""
|
||||
MLFLAGS-rational_test = --runtime-flags "--heap-size 20000"
|
||||
|
||||
# no_fully_strict is expected to fail (it calls error/1).
|
||||
|
||||
@@ -789,6 +789,7 @@ output_main(void)
|
||||
{
|
||||
const char *aditi_load_func;
|
||||
String_List *list_tmp;
|
||||
char *options_str;
|
||||
|
||||
if (aditi) {
|
||||
aditi_load_func = "MR_do_load_aditi_rl_code";
|
||||
@@ -802,7 +803,22 @@ output_main(void)
|
||||
printf(" MR_runtime_flags = \"");
|
||||
for (list_tmp = runtime_flags;
|
||||
list_tmp != NULL; list_tmp = list_tmp->next) {
|
||||
fputs(list_tmp->data, stdout);
|
||||
for (options_str = list_tmp->data;
|
||||
*options_str != '\0'; options_str++) {
|
||||
if (*options_str == '\n') {
|
||||
putchar('\\');
|
||||
putchar('n');
|
||||
} else if (*options_str == '\t') {
|
||||
putchar('\\');
|
||||
putchar('t');
|
||||
} else if (*options_str == '"' ||
|
||||
*options_str == '\\') {
|
||||
putchar('\\');
|
||||
putchar(*options_str);
|
||||
} else {
|
||||
putchar(*options_str);
|
||||
}
|
||||
}
|
||||
putchar(' ');
|
||||
}
|
||||
printf("\";\n");
|
||||
|
||||
Reference in New Issue
Block a user