MCPcopy Create free account
hub / github.com/ZDoom/Raze / C_ParseExecFile

Function C_ParseExecFile

source/common/console/c_dispatch.cpp:1014–1064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1012}
1013
1014FExecList *C_ParseExecFile(const char *file, FExecList *exec)
1015{
1016 char cmd[4096];
1017
1018 FileReader fr;
1019
1020 if ( (fr.OpenFile(file)) )
1021 {
1022 while (fr.Gets(cmd, countof(cmd)-1))
1023 {
1024 // Comments begin with //
1025 char *stop = cmd + strlen(cmd) - 1;
1026 char *comment = cmd;
1027 int inQuote = 0;
1028
1029 if (*stop == '\n')
1030 *stop-- = 0;
1031
1032 while (comment < stop)
1033 {
1034 if (*comment == '\"')
1035 {
1036 inQuote ^= 1;
1037 }
1038 else if (!inQuote && *comment == '/' && *(comment + 1) == '/')
1039 {
1040 break;
1041 }
1042 comment++;
1043 }
1044 if (comment == cmd)
1045 { // Comment at line beginning
1046 continue;
1047 }
1048 else if (comment < stop)
1049 { // Comment in middle of line
1050 *comment = 0;
1051 }
1052 if (exec == NULL)
1053 {
1054 exec = new FExecList;
1055 }
1056 exec->AddCommand(cmd, file);
1057 }
1058 }
1059 else
1060 {
1061 Printf ("Could not open \"%s\"\n", file);
1062 }
1063 return exec;
1064}
1065
1066bool C_ExecFile (const char *file)
1067{

Callers 3

D_MultiExecFunction · 0.85
AddCommandMethod · 0.85
C_ExecFileFunction · 0.85

Calls 4

PrintfFunction · 0.85
OpenFileMethod · 0.45
GetsMethod · 0.45
AddCommandMethod · 0.45

Tested by

no test coverage detected