<ClCompile Include="sys_shared.c" />\r
<ClCompile Include="taskqueue.c" />\r
<ClCompile Include="thread_sdl.c" />\r
+ <ClCompile Include="token.c" />\r
<ClCompile Include="utf8lib.c" />\r
<ClCompile Include="vid_sdl.c" />\r
<ClCompile Include="vid_shared.c" />\r
<ClInclude Include="taskqueue.h" />\r
<ClInclude Include="thread.h" />\r
<ClInclude Include="timing.h" />\r
+ <ClInclude Include="token.h" />\r
<ClInclude Include="utf8lib.h" />\r
<ClInclude Include="vid.h" />\r
<ClInclude Include="view.h" />\r
<ClCompile Include="sys_shared.c" />\r
<ClCompile Include="taskqueue.c" />\r
<ClCompile Include="thread_sdl.c" />\r
+ <ClCompile Include="token.c" />\r
<ClCompile Include="utf8lib.c" />\r
<ClCompile Include="vid_sdl.c" />\r
<ClCompile Include="vid_shared.c" />\r
<ClInclude Include="taskqueue.h" />\r
<ClInclude Include="thread.h" />\r
<ClInclude Include="timing.h" />\r
+ <ClInclude Include="token.h" />\r
<ClInclude Include="utf8lib.h" />\r
<ClInclude Include="vid.h" />\r
<ClInclude Include="view.h" />\r
static inline qbool Json_Parse_Number(struct qjson_state_s *json)
{
int i, numsize;
- const unsigned char *in = json->state->pos;
+ const char *in = json->state->pos;
//char out[128];
qbool is_float = false;
qbool is_exp = false;
{
keyword_size = strlen(keyword_list[i]);
- if(!strncmp(keyword_list[i], (const char *)json->state->pos, keyword_size))
+ if(!strncmp(keyword_list[i], json->state->pos, keyword_size))
{
// Don't advance the entire length of the keyword or we might run into a valid token that'd go missed.
Parse_Next(json->state, keyword_size - 1);
svvm_cmds.o \
sys_shared.o \
taskqueue.o \
+ token.o \
vid_shared.o \
view.o \
wad.o \
*/
#include "darkplaces.h"
+#include "token.h"
#include "parser.h"
jmp_buf parse_error;
}
// Advance forward in the stream as many times as 'count', cleanly.
-void Parse_Next(struct qparser_state_s *state, size_t count)
+void Parse_Next(struct qparser_state_s *state, int count)
{
- state->col += count;
- state->pos += count;
+ const char *next = Token_Next(state->pos, count);
- if(!*state->pos)
+ if(next)
+ {
+ state->pos = next;
+ state->col += count;
+ }
+ else
Parse_Error(state, PARSE_ERR_EOF, NULL);
}
out = (qparser_state_t *)Z_Malloc(sizeof(qparser_state_t));
- out->buf = in;
+ out->buf = (const char *)in;
out->pos = NULL;
out->line = 1;
out->col = 1;
typedef struct qparser_state_s
{
const char *name;
- const unsigned char *buf;
- const unsigned char *pos;
+ const char *buf;
+ const char *pos;
int line, col, depth;
struct
extern jmp_buf parse_error;
void Parse_Error(struct qparser_state_s *state, qparser_err_t error, const char *expected);
-void Parse_Next(struct qparser_state_s *state, size_t count);
+void Parse_Next(struct qparser_state_s *state, int count);
char Parse_NextToken(struct qparser_state_s *state);
qparser_state_t *Parse_New(const unsigned char *in);
qparser_state_t *Parse_LoadFile(const char *file);
--- /dev/null
+/*
+Copyright (C) 2000-2021 Ashley Rose Hale (LadyHavoc)
+Copyright (C) 2021 David Knapp (Cloudwalk)
+
+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.
+
+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.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#include "darkplaces.h"
+#include "token.h"
+
+// Advance forward in the stream as many times as 'count', cleanly.
+const char *Token_Next(const char *data, int count)
+{
+ const char *out = data;
+ for (int i = 0; i < count; i++)
+ {
+ if (!*out)
+ break;
+ out++;
+ }
+
+ return out;
+}
--- /dev/null
+/*
+Copyright (C) 2021 David Knapp (Cloudwalk)
+
+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.
+
+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.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#include "qtypes.h"
+#include "qdefs.h"
+
+const char *Token_Next(const char *data, int count);