File: ap_match.cc

package info (click to toggle)
acs 021-2.3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 2,196 kB
  • ctags: 2,629
  • sloc: cpp: 15,013; makefile: 166
file content (37 lines) | stat: -rw-r--r-- 1,249 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*$Id: ap_match.cc,v 11.38 96/03/24 17:59:04 al Exp $ -*- C++ -*-
 * string compare
 * compares characters until end of first string
 * any non-alpha character may be a terminator
 * Characters in reference string in UPPER case must match.
 * Always requires at least one character to match.
 */
#include "ap.h"
/*--------------------------------------------------------------------------*/
//	CS &	CS::pmatch(const char*);
/*--------------------------------------------------------------------------*/
static inline char to_lower(char c){return ((isupper(c))?tolower(c):c);}
/*--------------------------------------------------------------------------*/
CS & CS::pmatch(const char *str2)
{
  int start = cursor();
  skipbl();
  int tokenstart = cursor();
  while (*str2 && to_lower(peek()) == to_lower(*str2)){
    skip();
    ++str2;
  }
  if (strcmp(str2,"$$")==0){
    skipcom();
    ok = true;
  }else if (cursor() == tokenstart || is_alpha() 
	    || isupper(*str2) || isdigit(*str2)){
    reset(start);
    ok = false;    
  }else{
    skipcom();
    ok = true;
  }
  return *this;
}
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/