@@ -461,7 +461,14 @@ RcOptions parseWindresOptions(ArrayRef<const char *> ArgsArr,
461
461
// done this double escaping) probably is confined to cases like these
462
462
// quoted string defines, and those happen to work the same across unix
463
463
// and windows.
464
- std::string Unescaped = unescape (Arg->getValue ());
464
+ //
465
+ // If GNU windres is executed with --use-temp-file, it doesn't use
466
+ // popen() to invoke the preprocessor, but uses another function which
467
+ // actually preserves tricky characters better. To mimic this behaviour,
468
+ // don't unescape arguments here.
469
+ std::string Value = Arg->getValue ();
470
+ if (!InputArgs.hasArg (WINDRES_use_temp_file))
471
+ Value = unescape (Value);
465
472
switch (Arg->getOption ().getID ()) {
466
473
case WINDRES_include_dir:
467
474
// Technically, these are handled the same way as e.g. defines, but
@@ -475,17 +482,19 @@ RcOptions parseWindresOptions(ArrayRef<const char *> ArgsArr,
475
482
break ;
476
483
case WINDRES_define:
477
484
Opts.PreprocessArgs .push_back (" -D" );
478
- Opts.PreprocessArgs .push_back (Unescaped );
485
+ Opts.PreprocessArgs .push_back (Value );
479
486
break ;
480
487
case WINDRES_undef:
481
488
Opts.PreprocessArgs .push_back (" -U" );
482
- Opts.PreprocessArgs .push_back (Unescaped );
489
+ Opts.PreprocessArgs .push_back (Value );
483
490
break ;
484
491
case WINDRES_preprocessor_arg:
485
- Opts.PreprocessArgs .push_back (Unescaped );
492
+ Opts.PreprocessArgs .push_back (Value );
486
493
break ;
487
494
}
488
495
}
496
+ // TODO: If --use-temp-file is set, we shouldn't be unescaping
497
+ // the --preprocessor argument either, only splitting it.
489
498
if (InputArgs.hasArg (WINDRES_preprocessor))
490
499
Opts.PreprocessCmd =
491
500
unescapeSplit (InputArgs.getLastArgValue (WINDRES_preprocessor));
0 commit comments