MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / CMDerror

Function CMDerror

Engine/source/console/CMDscan.cpp:2172–2253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2170extern bool gConsoleSyntaxError;
2171
2172void CMDerror(const char *format, ...)
2173{
2174 Compiler::gSyntaxError = true;
2175
2176 const int BUFMAX = 1024;
2177 char tempBuf[BUFMAX];
2178 va_list args;
2179 va_start( args, format );
2180#ifdef TORQUE_OS_WIN
2181 _vsnprintf( tempBuf, BUFMAX, format, args );
2182#else
2183 vsnprintf( tempBuf, BUFMAX, format, args );
2184#endif
2185 va_end(args);
2186
2187 if(fileName)
2188 {
2189 Con::errorf(ConsoleLogEntry::Script, "%s Line: %d - %s", fileName, lineIndex, tempBuf);
2190
2191#ifndef NO_ADVANCED_ERROR_REPORT
2192 // dhc - lineIndex is bogus. let's try to add some sanity back in.
2193 int i,j,n;
2194 char c;
2195 int linediv = 1;
2196 // first, walk the buffer, trying to detect line ending type.
2197 // this is imperfect, if inconsistant line endings exist...
2198 for (i=0; i<scanIndex; i++)
2199 {
2200 c = scanBuffer[i];
2201 if (c=='\r' && scanBuffer[i+1]=='\n') linediv = 2; // crlf detected
2202 if (c=='\r' || c=='\n' || c==0) break; // enough for us to stop.
2203 }
2204 // grab some of the chars starting at the error location - lineending.
2205 i = 1; j = 0; n = 1;
2206 // find prev lineending
2207 while (n<BUFMAX-8 && i<scanIndex) // cap at file start
2208 {
2209 c = scanBuffer[scanIndex-i];
2210 if ((c=='\r' || c=='\n') && i>BUFMAX>>2) break; // at least get a little data
2211 n++; i++;
2212 }
2213 // find next lineending
2214 while (n<BUFMAX-8 && j<BUFMAX>>1) // cap at half-buf-size forward
2215 {
2216 c = scanBuffer[scanIndex+j];
2217 if (c==0) break;
2218 if ((c=='\r' || c=='\n') && j>BUFMAX>>2) break; // at least get a little data
2219 n++; j++;
2220 }
2221 if (i) i--; // chop off extra linefeed.
2222 if (j) j--; // chop off extra linefeed.
2223 // build our little text block
2224 if (i) dStrncpy(tempBuf,scanBuffer+scanIndex-i,i);
2225 dStrncpy(tempBuf+i,"##", 2); // bracketing.
2226 tempBuf[i+2] = scanBuffer[scanIndex]; // copy the halt character.
2227 dStrncpy(tempBuf+i+3,"##", 2); // bracketing.
2228 if (j) dStrncpy(tempBuf+i+5,scanBuffer+scanIndex+1,j); // +1 to go past current char.
2229 tempBuf[i+j+5] = 0; // null terminate

Callers 1

CMDscan.cppFile · 0.85

Calls 7

dStrncpyFunction · 0.85
getVariableFunction · 0.85
dSprintfFunction · 0.85
setVariableFunction · 0.85
setIntVariableFunction · 0.85
errorfFunction · 0.70
warnfFunction · 0.70

Tested by

no test coverage detected