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

Function CMDerror

Engine/source/console/CMDscan.cpp:2169–2250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

CMDscan.cppFile · 0.85

Calls 7

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

Tested by

no test coverage detected