| 1012 | } |
| 1013 | |
| 1014 | FExecList *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 | |
| 1066 | bool C_ExecFile (const char *file) |
| 1067 | { |
no test coverage detected