1### Copyright (c) 2007, Tyzx Corporation. All rights reserved.
2
3function c = _g_istoken (str, token)
4### Check that first chararcters of str match that of token and that the first
5### non-matching char is ":"
6
7  if isempty (str),      c = 0;            return; endif
8  if isempty (token),    c = str(1)==":" ; return; endif
9
10  c = 1;
11  while 1
12    if str(c) != token(c)
13      if c > 1 && str(c) == ":", return; end
14      c = 0;
15      return;
16    endif
17    c++;
18    if c > length(str)
19      c--;
20      if str(c) == ":"; return; endif
21      c = 0; return;
22    endif
23    if c > length(token)
24      c--;
25      if token(c) == ":"; return; endif
26      c = 0;
27      return;
28    endif
29  endwhile
30endfunction
31