31 srcFileNode.AssembleRealPath(path, lang::Inclusion::Include);
40 Lox_Info(
"Reading source file: {}", path )
45 }
catch (std::exception&) {
56 constexpr integer writeBufferPadSize= 20;
57 writeBuffer.
_(
Fill(0, writeBufferPadSize));
58 char* writeBufferStart= writeBuffer.
VBuffer();
59 char* wb = writeBufferStart + writeBufferPadSize;
64 if (
app.machine.GetExitCode().Integral() )
72 bool fileChanged =
false;
75 size_t lineStartRemaining = mfc.
Remaining();
76 while (!mfc.
IsEOF()) {
77 char c= char( mfc.
Next<
NC>() );
78 if (c ==
'\n') { *wb++=
'\n'; lineNo++; lineStartRemaining= mfc.
Remaining();
continue; }
79 if (c !=
'#' ) { *wb++= c;
continue; }
97 if (c ==
'#' ) { *wb++=
'#'; *wb++=
'#';
continue;}
110 if ( !isalpha(c) &&
String(
".%^_<").IndexOf(c) < 0 ) {
119 int colNo= int(lineStartRemaining - mfc.
Remaining() - 2);
122 {
auto exclIt= exclamations.begin();
123 for (; exclIt!=exclamations.end(); ++exclIt )
124 if ( (*exclIt)->Matches(lineNo, colNo ) )
126 if (exclIt != exclamations.end()) {
134 bool suppressedAnchor;
135 linkString.
Reset(c); {
136 bool foundEnd=
false;
139 if ( c ==
'\\') { linkString.
_<
NC>(c); linkString.
_<
NC>(char(mfc.
Next()));
continue; }
140 if ( c ==
'\"') { foundEnd=
true;
break;}
141 if ( c ==
'\n') { lineNo++;
break; }
143 if (linkString.
Length() == 511 ) {
144 Lox_Warning(
"Found unterminated XLink pattern {!Q} in HTML file {}:{}:{}",
145 linkString, path, lineNo, colNo )
156 for (
auto lsC : linkString )
159 Lox_Warning(
"Found unterminated XLink pattern {!Q} in replacement source file {}:{}:{}",
160 linkString, path, lineNo -1, colNo )
164 if (suppressedAnchor)
169 if (verbosity >= Verbosity::Info)
170 Lox_Info(
"Found XLink pattern {!Q} in replacement source file {}:{}:{}",
171 linkString, path, lineNo, colNo )
185 "Write buffer overflow detected" )
186 writeBuffer.
SetLength(wb - writeBufferStart);
191 writeBuffer.
_<
NC>(
"#")._<NC>(
"\"");
192 if ( suppressedAnchor )
193 writeBuffer.
_<
NC>(
"%");
194 writeBuffer.
_<
NC>(linkString)._<NC>(
"\"");
207 entityPath= node.Name();
212 writeBuffer.
_<
NC>(
"\\ref " )
215 ._<NC>(entityDisplay)
223 dxl.Stats.ReplSourceFileLines.fetch_add(lineNo);
226 if ( fileChanged &&
app.cli.DryRun != cli::DryRunModes::Application) {
227 Lox_Verbose(
"Writing replacement source file: {}", path )
230 tempPath << path <<
".tmp";
232 if ( !outFile.is_open() ) {
238 "Write buffer overflow detected" )
239 outFile.write(writeBuffer.
Buffer() + writeBufferPadSize, wb - writeBufferStart - writeBufferPadSize);
242 if ( outFile.fail() ) {
250 std::filesystem::rename(tempPath.
Terminate(), path.Terminate(), ec);
251 if ( ec.value() != 0 ) {