Skip to content

Commit 482e3eb

Browse files
committed
Added support for patching existing systems to fix error scripts
1 parent 14100ac commit 482e3eb

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/lang/php/util/Utils.rsc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,4 +515,46 @@ public void removeNonFileLocs(str systemName, str systemVersion) {
515515
logMessage("Writing binary for <systemName>, version <systemVersion>",2);
516516
writeBinaryValueFile(binLoc, pt, compression=false);
517517
}
518+
}
519+
520+
public void patchBinaries() {
521+
for (systemName <- getProducts(), systemVersion <- getVersions(systemName)) {
522+
patchBinaries(systemName, systemVersion);
523+
}
524+
}
525+
526+
public void patchBinaries(str systemName) {
527+
for (systemVersion <- getVersions(systemName)) {
528+
patchBinaries(systemName, systemVersion);
529+
}
530+
}
531+
532+
public void patchBinaries(str systemName, str systemVersion) {
533+
pt = loadBinary(systemName, systemVersion);
534+
535+
// Find any locations of files that did not parse correctly
536+
errorLocs = { l | l <- pt.files, pt.files[l] is errscript };
537+
538+
if (size(errorLocs) == 0) {
539+
logMessage("No errored locations found for <systemName>, version <systemVersion>", 2);
540+
return;
541+
}
542+
543+
fixedLocs = { };
544+
545+
for (l <- errorLocs) {
546+
s = loadPHPFile(l);
547+
if (s is errscript) {
548+
logMessage("Unable to fix script at location <l> for <systemName>, version <systemVersion>", 2);
549+
} else {
550+
fixedLocs += l;
551+
pt.files[l] = s;
552+
logMessage("Fixed script at location <l> for <systemName>, version <systemVersion>", 2);
553+
}
554+
}
555+
556+
if (size(fixedLocs) > 0) {
557+
loc binLoc = parsedDir + "<systemName>-<systemVersion>.pt";
558+
writeBinaryValueFile(binLoc, pt, compression=false);
559+
}
518560
}

0 commit comments

Comments
 (0)