32 srcFileNode.AssembleRealPath(path, lang::Inclusion::Include);
41 Lox_Info(
"Reading source file: {}", path )
46 }
catch (std::exception&) {
57 constexpr integer writeBufferPadSize= 20;
58 writeBuffer.
_(
Fill(0, writeBufferPadSize));
59 char* writeBufferStart= writeBuffer.
VBuffer();
60 char* wb = writeBufferStart + writeBufferPadSize;
65 if (
app.machine.GetExitCode().Integral() )
73 bool fileChanged =
false;
76 size_t lineStartRemaining = mfc.
Remaining();
77 while (!mfc.
IsEOF()) {
78 char c= char( mfc.
Next<
NC>() );
79 if (c ==
'\n') { *wb++=
'\n'; lineNo++; lineStartRemaining= mfc.
Remaining();
continue; }
80 if (c !=
'#' ) { *wb++= c;
continue; }
98 if (c ==
'#' ) { *wb++=
'#'; *wb++=
'#';
continue;}
111 if ( !isalpha(c) &&
String(
".%^_<").IndexOf(c) < 0 ) {
120 int colNo= int(lineStartRemaining - mfc.
Remaining() - 2);
123 {
auto exclIt= exclamations.begin();
124 for (; exclIt!=exclamations.end(); ++exclIt )
125 if ( (*exclIt)->Matches(lineNo, colNo ) )
127 if (exclIt != exclamations.end()) {
135 bool suppressedAnchor;
136 linkString.
Reset(c); {
137 bool foundEnd=
false;
140 if ( c ==
'\\') { linkString.
_<
NC>(c); linkString.
_<
NC>(char(mfc.
Next()));
continue; }
141 if ( c ==
'\"') { foundEnd=
true;
break;}
142 if ( c ==
'\n') { lineNo++;
break; }
144 if (linkString.
Length() == 511 ) {
145 Lox_Warning(
"Found unterminated XLink pattern {!Q} in HTML file {}:{}:{}",
146 linkString, path, lineNo, colNo )
157 for (
auto lsC : linkString )
160 Lox_Warning(
"Found unterminated XLink pattern {!Q} in replacement source file {}:{}:{}",
161 linkString, path, lineNo -1, colNo )
165 if (suppressedAnchor)
170 if (verbosity >= Verbosity::Info)
171 Lox_Info(
"Found XLink pattern {!Q} in replacement source file {}:{}:{}",
172 linkString, path, lineNo, colNo )
186 "Write buffer overflow detected" )
187 writeBuffer.
SetLength(wb - writeBufferStart);
192 writeBuffer.
_<
NC>(
"#")._<NC>(
"\"");
193 if ( suppressedAnchor )
194 writeBuffer.
_<
NC>(
"%");
195 writeBuffer.
_<
NC>(linkString)._<NC>(
"\"");
208 entityPath= node.Name();
213 writeBuffer.
_<
NC>(
"\\ref " )
216 ._<NC>(entityDisplay)
224 dxl.Stats.ReplSourceFileLines.fetch_add(lineNo);
227 if ( fileChanged &&
app.cli.DryRun != cli::DryRunModes::Application) {
228 Lox_Verbose(
"Writing replacement source file: {}", path )
231 tempPath << path <<
".tmp";
233 if ( !outFile.is_open() ) {
239 "Write buffer overflow detected" )
240 outFile.write(writeBuffer.
Buffer() + writeBufferPadSize, wb - writeBufferStart - writeBufferPadSize);
243 if ( outFile.fail() ) {
251 std::filesystem::rename(tempPath.
Terminate(), path.Terminate(), ec);
252 if ( ec.value() != 0 ) {