Skip to content

Commit 368bc91

Browse files
committed
init compileEnv to fix crash with unicode
remove \r from tip text
1 parent ff8875b commit 368bc91

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

vdc/dmdserver/dmd

vdc/dmdserver/dmdinit.d

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,63 @@ void dmdSetupParams(const ref Options opts)
400400
global.filePath.setDim(0);
401401
foreach(i; opts.stringImportDirs)
402402
global.filePath.push(toStringz(i));
403+
404+
dmdSetupCompileEnv();
405+
}
406+
407+
void dmdSetupCompileEnv()
408+
{
409+
import dmd.common.charactertables;
410+
411+
global.compileEnv.previewIn = global.params.previewIn;
412+
global.compileEnv.transitionIn = global.params.v.vin;
413+
global.compileEnv.ddocOutput = global.params.ddoc.doOutput;
414+
415+
final switch(global.params.cIdentifierTable)
416+
{
417+
case CLIIdentifierTable.C99:
418+
global.compileEnv.cCharLookupTable = IdentifierCharLookup.forTable(IdentifierTable.C99);
419+
break;
420+
421+
case CLIIdentifierTable.C11:
422+
case CLIIdentifierTable.default_:
423+
// ImportC is defined against C11, not C23.
424+
// If it was C23 this needs to be changed to UAX31 instead.
425+
global.compileEnv.cCharLookupTable = IdentifierCharLookup.forTable(IdentifierTable.C11);
426+
break;
427+
428+
case CLIIdentifierTable.UAX31:
429+
global.compileEnv.cCharLookupTable = IdentifierCharLookup.forTable(IdentifierTable.UAX31);
430+
break;
431+
432+
case CLIIdentifierTable.All:
433+
global.compileEnv.cCharLookupTable = IdentifierCharLookup.forTable(IdentifierTable.LR);
434+
break;
435+
}
436+
437+
final switch(global.params.dIdentifierTable)
438+
{
439+
case CLIIdentifierTable.C99:
440+
global.compileEnv.dCharLookupTable = IdentifierCharLookup.forTable(IdentifierTable.C99);
441+
break;
442+
443+
case CLIIdentifierTable.C11:
444+
global.compileEnv.dCharLookupTable = IdentifierCharLookup.forTable(IdentifierTable.C11);
445+
break;
446+
447+
case CLIIdentifierTable.UAX31:
448+
global.compileEnv.dCharLookupTable = IdentifierCharLookup.forTable(IdentifierTable.UAX31);
449+
break;
450+
451+
case CLIIdentifierTable.All:
452+
case CLIIdentifierTable.default_:
453+
// @@@DEPRECATED_2.119@@@
454+
// Change the default to UAX31,
455+
// this is a breaking change as C99 (what D used for ~23 years),
456+
// has characters that are not in UAX31.
457+
global.compileEnv.dCharLookupTable = IdentifierCharLookup.forTable(IdentifierTable.LR);
458+
break;
459+
}
403460
}
404461

405462
// initialization that are necessary before restarting an analysis (which might run

vdc/dmdserver/semvisitor.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2343,7 +2343,7 @@ string symbol2ExpansionLine(Dsymbol sym)
23432343
{
23442344
string type = symbol2ExpansionType(sym);
23452345
string tip = tipForObject(sym);
2346-
return type ~ ":" ~ tip.replace("\n", "\a");
2346+
return type ~ ":" ~ tip.replace("\n", "\a").replace("\r", "");
23472347
}
23482348

23492349
string[string] initSymbolProperties(int kind)

0 commit comments

Comments
 (0)