示例#1
0
void test_SpecialSymbols(void)
{
	int temp ;
	temp = is_special('a');
	TEST_ASSERT_FALSE(temp);
	temp = is_special('?');
	TEST_ASSERT_FALSE(temp);

}
示例#2
0
LPCSTR parse_mailboxdomain( LPCSTR s, LPCSTR nonspecial,
         LPSTR mailbox, size_t * mailboxlen, size_t mailboxmax,
         LPSTR comment, size_t * commentlen, size_t commentmax )
{
  const char *ps;

  while (*s)
  {
    SKIPWS (s);
    if (strchr (nonspecial, *s) == NULL && is_special (*s))
      return s;

    if (*s == '(')
    {
      if (*commentlen && *commentlen < commentmax)
        comment[(*commentlen)++] = ' ';
      ps = next_token (s, comment, commentlen, commentmax);
    }
    else
      ps = next_token (s, mailbox, mailboxlen, mailboxmax);
    if (!ps)
      return NULL;
    s = ps;
  }

  return s;
}
示例#3
0
/** Find the set of characters that are not present in the reachability of
 * graph \p g after a certain depth (currently 8). If a character in this set
 * is encountered, it means that the NFA is either dead or has not progressed
 * more than 8 characters from its start states. */
CharReach findStopAlphabet(const NGHolder &g, som_type som) {
    const depth max_depth(MAX_STOP_DEPTH);
    const InitDepths depths(g);
    const map<NFAVertex, BoundedRepeatSummary> no_vertices;

    CharReach stopcr;

    for (auto v : vertices_range(g)) {
        if (is_special(v, g)) {
            continue;
        }

        if (depths.maxDist(g, v) >= max_depth) {
            if (som == SOM_NONE) {
                stopcr |= reduced_cr(v, g, no_vertices);
            } else {
                stopcr |= g[v].char_reach;
            }
        }
    }

    // Turn alphabet into stops.
    stopcr.flip();

    return stopcr;
}
示例#4
0
bool firstMatchIsFirst(const NGHolder &p) {
    /* If the first match (by end offset) is not the first match (by start
     * offset) then we can't create a lock after it.
     *
     * Consider: 4009:/(foobar|ob).*bugger/s
     *
     * We don't care about races on the last byte as they can be resolved easily
     * at runtime /(foobar|obar).*hi/
     *
     * It should be obvious we don't care about one match being a prefix
     * of another as they share the same start offset.
     *
     * Therefore, the case were we cannot establish that the som does not
     * regress is when there exists s1 and s2 in the language of p and s2 is a
     * proper infix of s1.
     *
     * It is tempting to add the further restriction that there does not exist a
     * prefix of s1 that is in the language of p (as in which case we would
     * presume, the lock has already been set). However, we have no way of
     * knowing if the lock can be cleared by some characters, and if so, if it
     * is still set. TODO: if we knew the lock's escapes where we could verify
     * that the rest of s1 does not clear the lock. (1)
     */

    DEBUG_PRINTF("entry\n");

    /* If there are any big cycles throw up our hands in despair */
    if (hasBigCycles(p)) {
        DEBUG_PRINTF("fail, big cycles\n");
        return false;
    }

    set<NFAVertex> states;
    /* turn on all states (except starts - avoid suffix matches) */
    /* If we were doing (1) we would also except states leading to accepts -
       avoid prefix matches */
    for (auto v : vertices_range(p)) {
        assert(!is_virtual_start(v, p));
        if (!is_special(v, p)) {
            DEBUG_PRINTF("turning on %u\n", p[v].index);
            states.insert(v);
        }
    }

    /* run the prefix the main graph */
    execute_graph(p, p, &states);

    for (auto v : states) {
        /* need to check if this vertex may represent an infix match - ie
         * it does not have an edge to accept. */
        DEBUG_PRINTF("check %u\n", p[v].index);
        if (!edge(v, p.accept, p).second) {
            DEBUG_PRINTF("fail %u\n", p[v].index);
            return false;
        }
    }

    DEBUG_PRINTF("done first is first check\n");
    return true;
}
示例#5
0
static
bool pruneForwardUseless(NGHolder &h, const nfag_t &g, NFAVertex s,
                         vector<default_color_type> &vertexColor) {
    // Begin with all vertices set to white, as DFV only marks visited
    // vertices.
    fill(vertexColor.begin(), vertexColor.end(), boost::white_color);

    auto index_map = get(&NFAGraphVertexProps::index, g);

    depth_first_visit(g, s, make_dfs_visitor(boost::null_visitor()),
                      make_iterator_property_map(vertexColor.begin(),
                                                 index_map));

    vector<NFAVertex> dead;

    // All non-special vertices that are still white can be removed.
    for (auto v : vertices_range(g)) {
        u32 idx = g[v].index;
        if (!is_special(v, g) && vertexColor[idx] == boost::white_color) {
            DEBUG_PRINTF("vertex %u is unreachable from %u\n",
                         g[v].index, g[s].index);
            dead.push_back(v);
        }
    }

    if (dead.empty()) {
        return false;
    }

    DEBUG_PRINTF("removing %zu vertices\n", dead.size());
    remove_vertices(dead, h, false);
    return true;
}
示例#6
0
static
void getBackwardReach(const NGHolder &g, ReportID report, u32 lag,
                      map<s32, CharReach> &look) {
    ue2::flat_set<NFAVertex> curr, next;

    for (auto v : inv_adjacent_vertices_range(g.accept, g)) {
        if (contains(g[v].reports, report)) {
            curr.insert(v);
        }
    }

    for (u32 i = lag + 1; i <= MAX_BACK_LEN; i++) {
        if (curr.empty() || contains(curr, g.start) ||
            contains(curr, g.startDs)) {
            break;
        }

        next.clear();
        CharReach cr;

        for (auto v : curr) {
            assert(!is_special(v, g));
            cr |= g[v].char_reach;
            insert(&next, inv_adjacent_vertices(v, g));
        }

        assert(cr.any());
        look[0 - i] |= cr;
        curr.swap(next);
    }
}
示例#7
0
文件: rfc822.c 项目: 2ion/mutt-1.5.22
static const char *
parse_mailboxdomain (const char *s, const char *nonspecial,
		     char *mailbox, size_t *mailboxlen, size_t mailboxmax,
		     char *comment, size_t *commentlen, size_t commentmax)
{
  const char *ps;

  while (*s)
  {
    s = skip_email_wsp(s);
    if (strchr (nonspecial, *s) == NULL && is_special (*s))
      return s;

    if (*s == '(')
    {
      if (*commentlen && *commentlen < commentmax)
	comment[(*commentlen)++] = ' ';
      ps = next_token (s, comment, commentlen, commentmax);
    }
    else
      ps = next_token (s, mailbox, mailboxlen, mailboxmax);
    if (!ps)
      return NULL;
    s = ps;
  }

  return s;
}
示例#8
0
static
void getForwardReach(const NGHolder &g, u32 top, map<s32, CharReach> &look) {
    ue2::flat_set<NFAVertex> curr, next;

    // Consider only successors of start with the required top.
    for (const auto &e : out_edges_range(g.start, g)) {
        NFAVertex v = target(e, g);
        if (v == g.startDs) {
            continue;
        }
        if (g[e].top == top) {
            curr.insert(v);
        }
    }

    for (u32 i = 0; i < MAX_FWD_LEN; i++) {
        if (curr.empty() || contains(curr, g.accept) ||
            contains(curr, g.acceptEod)) {
            break;
        }

        next.clear();
        CharReach cr;

        for (auto v : curr) {
            assert(!is_special(v, g));
            cr |= g[v].char_reach;
            insert(&next, adjacent_vertices(v, g));
        }

        assert(cr.any());
        look[i] |= cr;
        curr.swap(next);
    }
}
示例#9
0
 inline
 int_adapter operator-(const int_adapter<rhs_type>& rhs)const
 {
   if(is_special() || rhs.is_special())
   {
     if (is_nan() || rhs.is_nan()) 
     {
       return int_adapter::not_a_number();
     }
     if((is_pos_inf(value_) && rhs.is_pos_inf(rhs.as_number())) ||
        (is_neg_inf(value_) && rhs.is_neg_inf(rhs.as_number())) )
     {
       return int_adapter::not_a_number();
     }
     if (is_infinity()) 
     {
       return *this;
     }
     if (rhs.is_pos_inf(rhs.as_number())) 
     {
       return int_adapter::neg_infinity();
     }
     if (rhs.is_neg_inf(rhs.as_number())) 
     {
       return int_adapter::pos_infinity();
     }
   }
   return int_adapter<int_type>(value_ - rhs.as_number());
 }
示例#10
0
static int length_of_normal_non_splitters( const char * buffer, const basic_parser_type * parser) {
  bool at_end  = false;
  int length   = 0;
  char current = buffer[0];

  while(current != '\0' && !at_end)   {
    length += 1;
    current = buffer[length];

    if( is_splitters( current, parser ) )  {
      at_end = true;
      continue;
    }
    if( is_special( current, parser ) )  {
      at_end = true;
      continue;
    }
    if( is_in_quoters( current, parser ) )  {
      at_end = true;
      continue;
    }
    if( length_of_comment(&buffer[length], parser) > 0)  {
      at_end = true;
      continue;
    }
  }

  return length;
}
示例#11
0
int
smart_font_rep::resolve (string c) {
  if (math_kind != 0) {
    if (is_greek (c))
      return sm->add_char (tuple ("italic-math"), c);
    if (is_special (c))
      return sm->add_char (tuple ("special"), c);
  }

  array<string> a= trimmed_tokenize (family, ",");
  for (int attempt= 1; attempt <= 20; attempt++) {
    if (attempt > 1 && substitute_math_letter (c, math_kind) != "") break;
    for (int i= 0; i < N(a); i++) {
      int nr= resolve (c, a[i], attempt);
      if (nr >= 0) return nr;
    }
  }

  string sf= substitute_math_letter (c, math_kind);
  if (sf != "") return sm->add_char (tuple (sf), c);

  string virt= find_in_virtual (c);
  if (math_kind != 0 && !unicode_provides (c) && virt == "")
    return sm->add_char (tuple ("other"), c);

  if (virt != "") {
    //cout << "Found " << c << " in " << virt << "\n";
    return sm->add_char (tuple ("virtual", virt), c);
  }

  return sm->add_char (tuple ("error"), c);
}
示例#12
0
/** Remove any vertices that can't be reached by traversing the graph in
 * reverse from acceptEod. */
void pruneUnreachable(NGHolder &g) {
    deque<NFAVertex> dead;

    if (!hasGreaterInDegree(1, g.acceptEod, g) &&
            !hasGreaterInDegree(0, g.accept, g) &&
            edge(g.accept, g.acceptEod, g).second) {
        // Trivial case: there are no in-edges to our accepts (other than
        // accept->acceptEod), so all non-specials are unreachable.
        for (auto v : vertices_range(g)) {
            if (!is_special(v, g)) {
                dead.push_back(v);
            }
        }
    } else {
        // Walk a reverse graph from acceptEod with Boost's depth_first_visit
        // call.
        typedef reverse_graph<NFAGraph, NFAGraph&> RevNFAGraph;
        RevNFAGraph revg(g.g);

        map<NFAVertex, default_color_type> colours;

        depth_first_visit(revg, g.acceptEod,
                          make_dfs_visitor(boost::null_visitor()),
                          make_assoc_property_map(colours));

        DEBUG_PRINTF("color map has %zu entries after DFV\n", colours.size());

        // All non-special vertices that aren't in the colour map (because they
        // weren't reached) can be removed.
        for (auto v : vertices_range(revg)) {
            if (is_special(v, revg)) {
                continue;
            }
            if (!contains(colours, v)) {
                dead.push_back(v);
            }
        }
    }

    if (dead.empty()) {
        DEBUG_PRINTF("no unreachable vertices\n");
        return;
    }

    remove_vertices(dead, g, false);
    DEBUG_PRINTF("removed %zu unreachable vertices\n", dead.size());
}
示例#13
0
static
void buildPred(NFAStateSet &pred, const NGHolder &g, NFAVertex v) {
    for (auto u : inv_adjacent_vertices_range(v, g)) {
        if (!is_special(u, g)) {
            pred.set(g[u].index);
        }
    }
}
示例#14
0
 /*! Provided for cases when automatic conversion from 
  * 'int' to 'int_adapter' causes incorrect results. */
 int_adapter operator%(const int rhs) const
 {
   if(is_special() && rhs != 0)
   {
     return mult_div_specials(rhs);
   }
   return int_adapter<int_type>(value_ % rhs);
 }
//==========================================================================
//
// Returns the index of the given line special
//
//==========================================================================
int FindLineSpecial(const char * string)
{
	const ACSspecials *spec;

	spec = is_special(string, (unsigned int)strlen(string));
	if (spec) return spec->Special;
	return 0;
}
示例#16
0
 /*! Provided for cases when automatic conversion from 
  * 'int' to 'int_adapter' causes incorrect results. */
 int_adapter operator*(const int rhs) const
 {
   if(is_special())
   {
     return mult_div_specials(rhs);
   }
   return int_adapter<int_type>(value_ * rhs);
 }
示例#17
0
static
void buildSucc(NFAStateSet &succ, const NGHolder &g, NFAVertex v) {
    for (auto w : adjacent_vertices_range(v, g)) {
        if (!is_special(w, g)) {
            succ.set(g[w].index);
        }
    }
}
示例#18
0
std::string RemoveSpecialChar(const std::string& str)
{
    std::string r = str;
    r.erase(std::remove_if(r.begin(), r.end(),
                           [](char x) { return is_special(x); }),
            r.end());

    return r;
}
void anon_print_uri(FILE *f, struct matches *matches, char *text) {
  unsigned int i;

  fprintf_nbytes(f, text, matches->start[0]);   /* nonmatching */
  for (i=0; i < matches->count; i++) {

    if ((matches->start[i] == 0 || is_special(text + matches->start[i] - 1)) && is_special(text + matches->stop[i] + 1)) {
      fprintf_anon_nbytes(f, text + matches->start[i], matches->stop[i] - matches->start[i] + 1);   /* matching and special */
    } else {
      fprintf_nbytes(f, text + matches->start[i], matches->stop[i] - matches->start[i] + 1);   /* matching, not special */
    }
    if (i < matches->count-1) {
      fprintf_nbytes(f, text + matches->stop[i] + 1, matches->start[i+1] - matches->stop[i] - 1); /* nonmatching */
    } else {
      fprintf(f, text + matches->stop[i] + 1);  /* nonmatching */
    }
  }
}
示例#20
0
static int extract_filename(const str* pattern)
{
  if (!is_special(pattern)) return 0;
  if (pattern->s[2] == '@')
    str_copyb(&filename, pattern->s+3, pattern->len-5);
  else
    str_copyb(&filename, pattern->s+2, pattern->len-4);
  return 1;
}
示例#21
0
static
bool inIsIrreducible(NFAVertex &v, const NGHolder &g) {
    unsigned nonSpecialVertices = 0;
    for (auto u : inv_adjacent_vertices_range(v, g)) {
        if (!is_special(u, g) && u != v) {
            nonSpecialVertices++;
        }
    }
    return nonSpecialVertices == 1;
}
示例#22
0
bool is_illegal(char c)
{
  /* This function makes sure that the shell contains tokens that fall
    within the allowable subset. This doesn't apply to comments*/
    
  if((isalnum((unsigned char)c) == 0) && (!is_special(c)) && (c != ';')
    && (!is_token(c)) && (isspace((unsigned char)c) == 0))
    return true;
  return false;
}
示例#23
0
static
CharReach getReachability(const NGHolder &h) {
    CharReach cr;
    for (const auto &v : vertices_range(h)) {
        if (!is_special(v, h)) {
            cr |= h[v].char_reach;
        }
    }
    return cr;
}
void
st_rewind (st_parameter_filepos *fpp)
{
  gfc_unit *u;

  library_start (&fpp->common);

  u = find_unit (fpp->common.unit);
  if (u != NULL)
    {
      if (u->flags.access == ACCESS_DIRECT)
	generate_error (&fpp->common, LIBERROR_BAD_OPTION,
			"Cannot REWIND a file opened for DIRECT access");
      else
	{
	  /* If there are previously written bytes from a write with ADVANCE="no",
	     add a record marker before performing the ENDFILE.  */

	  if (u->previous_nonadvancing_write)
	    finish_last_advance_record (u);

	  u->previous_nonadvancing_write = 0;

	  fbuf_reset (u);

	  u->last_record = 0;

	  if (sseek (u->s, 0, SEEK_SET) < 0)
	    generate_error (&fpp->common, LIBERROR_OS, NULL);

	  /* Handle special files like /dev/null differently.  */
	  if (!is_special (u->s))
	    {
	      /* We are rewinding so we are not at the end.  */
	      u->endfile = NO_ENDFILE;
	    }
	  else
	    {
	      /* Set this for compatibilty with g77 for /dev/null.  */
	      if (file_length (u->s) == 0  && stell (u->s) == 0)
		u->endfile = AT_ENDFILE;
	      /* Future refinements on special files can go here.  */
	    }

	  u->current_record = 0;
	  u->strm_pos = 1;
	  u->read_bad = 0;
	}
      /* Update position for INQUIRE.  */
      u->flags.position = POSITION_REWIND;
      unlock_unit (u);
    }

  library_end ();
}
示例#25
0
文件: parser.cpp 项目: nooga/recom
Node* RJParser::conexp() {
  //  printf("con\n");
	Node *a, *b;
	a = quantexp();
        if(!is_special(cur)) {
            b = conexp();
            return node(CON, a,b);
        } else {
            return a;
        }
}
示例#26
0
    void runTest() {
        auto a = m_A;
        auto b = m_B;

        for (std::size_t i = 0; i < 1000; ++i) {
            checkPass(a.is_well_formed() == b.wellFormed());
            checkPass(a.is_special() == b.isSpecial());

            auto c = a;
            auto d = b;
            c.to_special();
            d.toSpecial();

            checkPass(c.is_well_formed() == d.wellFormed());
            checkPass(c.is_special() == d.isSpecial());

            a = a + U::one();
            b = b + T::one();
        }
    }
示例#27
0
文件: chio.c 项目: weiyeh/OpenBSD-src
static int
parse_special(char *cp)
{
    int val;

    val = is_special(cp);
    if (val)
        return (val);

    errx(1, "invalid modifier `%s'", cp);
}
示例#28
0
static
bool getTransientPrefixReach(const NGHolder &g, u32 lag,
                             map<s32, CharReach> &look) {
    if (in_degree(g.accept, g) != 1) {
        DEBUG_PRINTF("more than one accept\n");
        return false;
    }

    // Must be a floating chain wired to startDs.
    if (!hasSingleFloatingStart(g)) {
        DEBUG_PRINTF("not a single floating start\n");
        return false;
    }

    NFAVertex v = *(inv_adjacent_vertices(g.accept, g).first);
    u32 i = lag + 1;
    while (v != g.startDs) {
        DEBUG_PRINTF("i=%u, v=%u\n", i, g[v].index);
        if (is_special(v, g)) {
            DEBUG_PRINTF("special\n");
            return false;
        }

        look[0 - i] = g[v].char_reach;

        NFAVertex next = NGHolder::null_vertex();
        for (auto u : inv_adjacent_vertices_range(v, g)) {
            if (u == g.start) {
                continue; // Benign, checked by hasSingleFloatingStart
            }
            if (next == NGHolder::null_vertex()) {
                next = u;
                continue;
            }
            DEBUG_PRINTF("branch\n");
            return false;
        }

        if (next == NGHolder::null_vertex() || next == v) {
            DEBUG_PRINTF("no predecessor or only self-loop\n");
            // This graph is malformed -- all vertices in a graph that makes it
            // to this analysis should have predecessors.
            assert(0);
            return false;
        }

        v = next;
        i++;
    }

    DEBUG_PRINTF("done\n");
    return true;
}
示例#29
0
文件: rfc822.c 项目: tejux/mutt-hacks
static const char *
next_token (const char *s, char *token, size_t *tokenlen, size_t tokenmax)
{
        if (*s == '(')
                return (parse_comment (s + 1, token, tokenlen, tokenmax));
        if (*s == '"')
                return (parse_quote (s + 1, token, tokenlen, tokenmax));
        if (is_special (*s)) {
                if (*tokenlen < tokenmax)
                        token[(*tokenlen)++] = *s;
                return (s + 1);
        }
        while (*s) {
                if (is_email_wsp(*s) || is_special (*s))
                        break;
                if (*tokenlen < tokenmax)
                        token[(*tokenlen)++] = *s;
                s++;
        }
        return s;
}
示例#30
0
文件: chio.c 项目: bsh-git/netbsd-src
static int
parse_special(const char *cp)
{
	int val;

	val = is_special(cp);
	if (val)
		return (val);

	errx(EXIT_FAILURE, "invalid modifier `%s'", cp);
	/* NOTREACHED */
}