From 6a17f7edd5b5fcee5d03dea5356e72d8926daca9 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 30 Nov 2003 01:10:51 +0000 Subject: [PATCH] added comment support to COM_ReadAndTokenizeLine git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3669 d7cf8633-e32d-0410-b094-e92efae38249 --- common.c | 13 +++++++++++-- common.h | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common.c b/common.c index e56f200b..80b78791 100644 --- a/common.c +++ b/common.c @@ -885,18 +885,27 @@ int COM_StringBeginsWith(const char *s, const char *match) return true; } -int COM_ReadAndTokenizeLine(const char **text, char **argv, int maxargc, char *tokenbuf, int tokenbufsize) +int COM_ReadAndTokenizeLine(const char **text, char **argv, int maxargc, char *tokenbuf, int tokenbufsize, const char *commentprefix) { - int argc; + int argc, commentprefixlength; char *tokenbufend; const char *l; argc = 0; tokenbufend = tokenbuf + tokenbufsize; l = *text; + commentprefixlength = 0; + if (commentprefix) + commentprefixlength = strlen(commentprefix); while (*l && *l != '\n') { if (*l > ' ') { + if (commentprefixlength && !strncmp(l, commentprefix, commentprefixlength)) + { + while (*l && *l != '\n') + l++; + break; + } if (argc >= maxargc) return -1; argv[argc++] = tokenbuf; diff --git a/common.h b/common.h index a10242a6..05dae49b 100644 --- a/common.h +++ b/common.h @@ -180,7 +180,7 @@ void COM_ToLowerString (const char *in, char *out, size_t size_out); void COM_ToUpperString (const char *in, char *out, size_t size_out); int COM_StringBeginsWith(const char *s, const char *match); -int COM_ReadAndTokenizeLine(const char **text, char **argv, int maxargc, char *tokenbuf, int tokenbufsize); +int COM_ReadAndTokenizeLine(const char **text, char **argv, int maxargc, char *tokenbuf, int tokenbufsize, const char *commentprefix); typedef struct stringlist_s { -- 2.39.2