| 1144 | } |
| 1145 | |
| 1146 | txScript* fxLoadScript(txMachine* the, txString path, txUnsigned flags) |
| 1147 | { |
| 1148 | txParser _parser; |
| 1149 | txParser* parser = &_parser; |
| 1150 | txParserJump jump; |
| 1151 | FILE* file = NULL; |
| 1152 | txString name = NULL; |
| 1153 | char map[C_PATH_MAX]; |
| 1154 | txScript* script = NULL; |
| 1155 | fxInitializeParser(parser, the, the->parserBufferSize, the->parserTableModulo); |
| 1156 | parser->firstJump = &jump; |
| 1157 | file = fopen(path, "r"); |
| 1158 | if (c_setjmp(jump.jmp_buf) == 0) { |
| 1159 | mxParserThrowElse(file); |
| 1160 | parser->path = fxNewParserSymbol(parser, path); |
| 1161 | fxParserTree(parser, file, (txGetter)fgetc, flags, &name); |
| 1162 | fclose(file); |
| 1163 | file = NULL; |
| 1164 | if (name) { |
| 1165 | mxParserThrowElse(c_realpath(fxCombinePath(parser, path, name), map)); |
| 1166 | parser->path = fxNewParserSymbol(parser, map); |
| 1167 | file = fopen(map, "r"); |
| 1168 | mxParserThrowElse(file); |
| 1169 | fxParserSourceMap(parser, file, (txGetter)fgetc, flags, &name); |
| 1170 | fclose(file); |
| 1171 | file = NULL; |
| 1172 | if ((parser->errorCount == 0) && name) { |
| 1173 | mxParserThrowElse(c_realpath(fxCombinePath(parser, map, name), map)); |
| 1174 | parser->path = fxNewParserSymbol(parser, map); |
| 1175 | } |
| 1176 | } |
| 1177 | fxParserHoist(parser); |
| 1178 | fxParserBind(parser); |
| 1179 | script = fxParserCode(parser); |
| 1180 | } |
| 1181 | if (file) |
| 1182 | fclose(file); |
| 1183 | #ifdef mxInstrument |
| 1184 | if (the->peakParserSize < parser->total) |
| 1185 | the->peakParserSize = parser->total; |
| 1186 | #endif |
| 1187 | fxTerminateParser(parser); |
| 1188 | return script; |
| 1189 | } |
| 1190 | |
| 1191 | /* DEBUG */ |
| 1192 |
no test coverage detected