// Detect It Easy: detection rule file
// Author: horsicq <horsicq@gmail.com>

meta("compiler", "DMD");

function getVersion() {
    var nSection = ELF.getSectionNumber(".comment");

    if (nSection != -1) {
        var nOffset = ELF.findString(
            ELF.getSectionFileOffset(nSection),
            ELF.getSectionFileSize(nSection),
            "DMD v");

        if (nOffset != -1) {
            return ELF.getString(nOffset + 5, 20);
        }
    }

    return String();
}

function detect() {
    var versionString = getVersion();
    if (versionString) {
        bDetected = true;
        sVersion = versionString;
    }

    sLang = "D";

    return result();
}