X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=lex.c;h=5673701157a7aaf1b47fd043d821054dcaa0e488;hp=bedaaa9db5e2c839e77a124fddc288fc88528398;hb=f76c1d2078400c8cef4f493b35099d80dc7c3c8f;hpb=4e35032a24c315a326715017295da4dee44f5ea6 diff --git a/lex.c b/lex.c index bedaaa9..5673701 100644 --- a/lex.c +++ b/lex.c @@ -20,11 +20,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include -#include -#include -#include -#include #include "gmqcc.h" /* @@ -249,7 +244,7 @@ static int lex_skipcmt(struct lex_file *file) { lex_addch(ch, file); while ((ch = lex_getch(file)) != '*') { if (ch == EOF) - return error(ERROR_LEX, "malformatted comment at line", ""); + return error(file, ERROR_LEX, "malformatted comment"); else lex_addch(ch, file); } @@ -344,40 +339,17 @@ void lex_reset(struct lex_file *file) { * recrusion. */ struct lex_file *lex_include(struct lex_file *lex, char *file) { - char *find = (char*)file; - /* - * strip for "" (quotes) .. they might be part of the current - * thing. Or possibly not. - */ - if (*find == '"') { - find++; - file++; - while (*find != '"' && *find != '\0') - find++; - - /* strip end "" (quotes) .. if they're actually there */ - if (*find != '\0') - *find = '\0'; - } - - /* - * Dissallow recrusive include: this could easily cause some breakage - * and instant OOM. - */ + util_strrq(file); if (strncmp(lex->name, file, strlen(lex->name)) == 0) { - error(ERROR_LEX, "%s:%d Source file cannot include itself\n", lex->name, lex->line-1); + error(lex, ERROR_LEX, "Source file cannot include itself\n"); exit (-1); } FILE *fp = fopen(file, "r"); if (!fp) { - error(ERROR_LEX, "%s:%d Include file `%s` doesn't exist\n", lex->name, lex->line, file); + error(lex, ERROR_LEX, "Include file `%s` doesn't exist\n", file); exit (-1); } - /* must free strdup */ - file --; - mem_d (file); - return lex_open(fp); }