Esempio n. 1
0
/*
 * Read the rest of a line that starts `\c'. Including nothing at
 * all (tok_word with empty text).
 */
token get_codepar_token(input * in)
{
  int c;
  token ret;
  rdstring rs = { 0, 0, NULL };
  filepos cpos;

  ret.type = tok_word;
  c = get(in, &cpos);           /* expect (and discard) one space */
  ret.pos = cpos;
  if (c == ' ')
  {
    c = get(in, &cpos);
    ret.pos = cpos;
  }
  while (!isnl(c) && c != EOF)
  {
    int c2 = c;
    c = get(in, &cpos);
    /* Discard \r just before \n. */
    if (c2 != 13 || !isnl(c))
      rdadd(&rs, (wchar_t)c2);
  }
  unget(in, c, &cpos);
  ret.text = ustrdup(rs.text);
  sfree(rs.text);
  return ret;
}
Esempio n. 2
0
void CTableLimits::CalcBetsizesForEveryStreet()
{
	write_log(3, "CTableLimits::CalcBetsizesForEveryStreet()\n");
	// Use the best  known values here, not tablelimit_unreliable_input
	SetBet(k_betround_preflop, bblind());															
	SetBet(k_betround_flop,    bblind());															
	SetBet(k_betround_turn,    bigbet()>=0.01 ? bigbet() : (isnl() || ispl() ? bblind() : bblind()*2));	
	SetBet(k_betround_river,   bigbet()>=0.01 ? bigbet() : (isnl() || ispl() ? bblind() : bblind()*2));	
}
Esempio n. 3
0
/*
 * Read a token from the input file, in the normal way (`normal' in
 * the sense that code paragraphs work a different way).
 */
token get_token(input * in)
{
  int c;
  int nls;
  token ret;
  rdstring rs = { 0, 0, NULL };
  filepos cpos;

  ret.cmd = c__invalid;
  ret.aux = FALSE;
  ret.text = NULL;              /* default */
  c = get(in, &cpos);
  ret.pos = cpos;
  if (iswhite(c))
  {                             /* tok_white or tok_eop */
    nls = 0;
    do
    {
      if (isnl(c))
        nls++;
    }
    while ((c = get(in, &cpos)) != EOF && iswhite(c));
    if (c == EOF)
    {
      ret.type = tok_eof;
      return ret;
    }
    unget(in, c, &cpos);
    ret.type = (nls > 1 ? tok_eop : tok_white);
    return ret;
  } else if (c == EOF)
  {                             /* tok_eof */
    ret.type = tok_eof;
    return ret;
  } else if (c == '\\')
  {                             /* tok_cmd */
    c = get(in, &cpos);
    if (c == '-' || c == '\\' || c == '_' ||
        c == '#' || c == '{' || c == '}')
    {
      /* single-char command */
      rdadd(&rs, (wchar_t)c);
    } else if (c == 'u')
    {
      int len = 0;
      do
      {
        rdadd(&rs, (wchar_t)c);
        len++;
        c = get(in, &cpos);
      }
      while (ishex(c) && len < 5);
      unget(in, c, &cpos);
    } else if (iscmd(c))
    {
      do
      {
        rdadd(&rs, (wchar_t)c);
        c = get(in, &cpos);
      }
      while (iscmd(c));
      unget(in, c, &cpos);
    }
    /*
     * Now match the command against the list of available
     * ones.
     */
    ret.type = tok_cmd;
    ret.text = ustrdup(rs.text);
    match_kw(&ret);
    sfree(rs.text);
    return ret;
  } else if (c == '{')
  {                             /* tok_lbrace */
    ret.type = tok_lbrace;
    return ret;
  } else if (c == '}')
  {                             /* tok_rbrace */
    ret.type = tok_rbrace;
    return ret;
  } else
  {                             /* tok_word */
    /*
     * Read a word: the longest possible contiguous sequence of
     * things other than whitespace, backslash, braces and
     * hyphen. A hyphen terminates the word but is returned as
     * part of it; everything else is pushed back for the next
     * token. The `aux' field contains TRUE if the word ends in
     * a hyphen.
     */
    ret.aux = FALSE;            /* assumed for now */
    while (1)
    {
      if (iswhite(c) || c == '{' || c == '}' || c == '\\' || c == EOF)
      {
        /* Put back the character that caused termination */
        unget(in, c, &cpos);
        break;
      } else
      {
        rdadd(&rs, (wchar_t)c);
        if (c == '-')
        {
          ret.aux = TRUE;
          break;                /* hyphen terminates word */
        }
      }
      c = get(in, &cpos);
    }
    ret.type = tok_word;
    ret.text = ustrdup(rs.text);
    sfree(rs.text);
    return ret;
  }
}