Skip to content

Commit

Permalink
update license and README.md, small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rfomin committed Dec 13, 2024
1 parent d77de20 commit fb64425
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 23 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.*`
Expand Down
41 changes: 30 additions & 11 deletions src/m_scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));

Expand All @@ -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;
}

Expand All @@ -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);
}
33 changes: 24 additions & 9 deletions src/m_scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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);
Expand Down

0 comments on commit fb64425

Please sign in to comment.