32 srcFileNode.AssembleRealPath(path, lang::Inclusion::Include);
41 Lox_Info(
"Reading source file: {}", path )
44 if(errc != std::errc()) {
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;
76 while (!mfc.
IsEOF()) {
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>(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 )
155 for (
auto lsC : linkString )
158 Lox_Warning(
"Found unterminated XLink pattern {!Q} in replacement source file {}:{}:{}",
159 linkString, path, lineNo -1, colNo )
163 if (suppressedAnchor)
168 if (verbosity >= Verbosity::Info)
169 Lox_Info(
"Found XLink pattern {!Q} in replacement source file {}:{}:{}",
170 linkString, path, lineNo, colNo )
183 ALIB_ASSERT_ERROR(wb - writeBufferStart < writeBuffer.Capacity(),
"DXL/SREPL/JOB",
184 "Write buffer overflow detected" )
185 writeBuffer.SetLength(wb - writeBufferStart);
190 writeBuffer._<
NC>(
"#")._<NC>(
"\"");
191 if ( suppressedAnchor )
192 writeBuffer._<
NC>(
"%");
193 writeBuffer._<
NC>(linkString)._<NC>(
"\"");
206 entityPath= node.Name();
209 writeBuffer._<
NC>(
"\\ref " )
215 wb= writeBuffer.VBuffer() + writeBuffer.Length();
220 dxl.Stats.ReplSourceFileLines.fetch_add(lineNo);
223 if ( fileChanged && !
app.dryrun) {
224 Lox_Verbose(
"Writing replacement source file: {}", path )
227 tempPath << path <<
".tmp";
229 if ( !outFile.is_open() ) {
234 ALIB_ASSERT_ERROR(wb - writeBufferStart < writeBuffer.Capacity(),
"DXL/SREPL/JOB",
235 "Write buffer overflow detected" )
236 outFile.write(writeBuffer.Buffer() + writeBufferPadSize, wb - writeBufferStart - writeBufferPadSize);
239 if ( outFile.fail() ) {
247 std::filesystem::rename(tempPath.
Terminate(), path.Terminate(), ec);
248 if ( ec.value() != 0 ) {