From 22ffee20bbacbc3378e4ba0df5b7f0c3daaeffc0 Mon Sep 17 00:00:00 2001 From: horchi Date: Sun, 5 Mar 2017 16:47:41 +0100 Subject: git init --- scan.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 scan.c (limited to 'scan.c') diff --git a/scan.c b/scan.c new file mode 100644 index 0000000..3b00554 --- /dev/null +++ b/scan.c @@ -0,0 +1,90 @@ +/* + * scan.c: A plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * (c) 2007-2013 Jörg Wendel + * + * This code is distributed under the terms and conditions of the + * GNU GENERAL PUBLIC LICENSE. See the file COPYING for details. + * + */ + +//*************************************************************************** +// Includes +//*************************************************************************** + +#include + +//*************************************************************************** +// Scanner +//*************************************************************************** + +const char* Scan::delimiters = " ;,(){}[]\""; +const char* Scan::operators = " +-*:<>!="; +const char* Scan::whitespace = " ()"; +const char* Scan::logicalOps = "|&"; +const char* Scan::numprefix = "+-"; + +//*************************************************************************** +// Scanner +//*************************************************************************** + +int Scan::eat(int aANP) +{ + int i = 0; + int anp = aANP != na ? aANP : allowNumPrefix; + + _last[0] = 0; + isStr = no; + + skipWs(); + + while (p && *p && i < 1000) + { + if (*p == '"') + { + if (isStr) + { + p++; + break; + } + + isStr = yes; + p++; + + continue; + } + + if (!isStr && isDelimiter(*p)) + break; + + if (isStr && *p == '"') + break; + + if (i) + { + if (isOperator(*_last) && !isOperator(*p) && !isStr) + { + if (!isNum(*p)) + break; + if (!anp || !isNumPrefix(*_last)) + break; + } + + if (!isOperator(*_last) && isOperator(*p) && !isStr) + break; + + if (isNum(*_last) && !isNum(*p) && !isStr) + break; + } + + if (*p != '"') + _last[i++] = *p; + + p++; + } + + _last[i] = 0; + + return i == 0 ? fail : success; +} -- cgit v1.2.3