diff --git a/README.md b/README.md index 25e8a10aa..95517f638 100644 --- a/README.md +++ b/README.md @@ -178,10 +178,9 @@ Copyright: © 2023 Andrew Apted. License: [MIT](https://opensource.org/licenses/MIT) -Files: `src/u_scanner.*` +Files: `src/m_scanner.*` Copyright: - © 2010 Braden "Blzut3" Obrzut; - © 2019 Fernando Carmona Varo. + © 2015 Braden "Blzut3" Obrzut. License: [BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) Files: `src/v_flextran.*` diff --git a/src/m_scanner.c b/src/m_scanner.c index e2570d4f2..eca0fce69 100644 --- a/src/m_scanner.c +++ b/src/m_scanner.c @@ -2,15 +2,30 @@ // Copyright (c) 2015, Braden "Blzut3" Obrzut // Copyright (c) 2024, Roman Fomin // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * The names of its contributors may be used to endorse or promote +// products derived from this software without specific prior written +// permission. // -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. #include "m_scanner.h" @@ -620,10 +635,10 @@ void SC_Rewind(scanner_t *s) // Only can rewind one step. CopyState(&s->nextstate, &s->state); CopyState(&s->state, &s->prevstate); - s->scanpos = s->state.scanpos; s->line = s->prevstate.tokenline; s->logicalpos = s->prevstate.tokenlinepos; + s->scanpos = s->prevstate.scanpos; } boolean SC_TokensLeft(scanner_t *s) @@ -651,7 +666,7 @@ double SC_GetDecimal(scanner_t *s) return s->state.decimal; } -scanner_t *SC_Open(const char *type, const char* data, int length) +scanner_t *SC_Open(const char *scriptname, const char *data, int length) { scanner_t *s = calloc(1, sizeof(*s)); @@ -664,7 +679,7 @@ scanner_t *SC_Open(const char *type, const char* data, int length) CheckForWhitespace(s); s->state.scanpos = s->scanpos; - s->scriptname = M_StringDuplicate(type); + s->scriptname = M_StringDuplicate(scriptname); return s; } @@ -682,6 +697,10 @@ void SC_Close(scanner_t *s) { free(s->nextstate.string); } + if (s->scriptname) + { + free((char *)s->scriptname); + } free(s->data); free(s); } diff --git a/src/m_scanner.h b/src/m_scanner.h index f88ccb5d6..a3b65a4fe 100644 --- a/src/m_scanner.h +++ b/src/m_scanner.h @@ -2,15 +2,30 @@ // Copyright (c) 2015, Braden "Blzut3" Obrzut // Copyright (c) 2024, Roman Fomin // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// * The names of its contributors may be used to endorse or promote +// products derived from this software without specific prior written +// permission. // -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. #include "doomtype.h" @@ -36,7 +51,7 @@ enum TK_NoToken = -1 }; -scanner_t *SC_Open(const char *type, const char* data, int length); +scanner_t *SC_Open(const char *scriptname, const char *data, int length); void SC_Close(scanner_t *s); const char *SC_GetString(scanner_t *s);