Esempio n. 1
0
int			parse_exp_rredir(struct s_iterator *i,
					 struct s_btree *node)
{
  struct s_ast_node	*ast;
  struct s_ast_node_cmd	*cmd;
  struct s_token	*t;
  char			*copyfile;

  ast = btree_get(node);
  if (ast == NULL)
    return (-1);
  cmd = &(ast->value.cmd);
  if (cmd->rtype != RT_RUNKNOWN)
    return (fprintf(stderr, "error: multiple right redirections\n"), -1);
  (void) NEXT(i);
  if (!HAS_NEXT(i))
    return (fprintf(stderr,
		    "expected string token after redirection"
		    " but no token was found\n"), -1);
  t = NEXT(i);
  if (t->type != TT_STRING)
    return (fprintf(stderr, "expected string token after redirection\n"), -1);
  if ((copyfile = strdup(t->string._string)) == NULL)
    return (fprintf(stderr, "strdup failed\n"), -1);
  cmd->rtype = RT_RSIMPLE;
  cmd->rredir = copyfile;
  return (0);
}
Esempio n. 2
0
QModelIndex View::Invoicing::OperationTable::firstEditableIndex(View::Invoicing::DirectionEditing direction)
{
    QModelIndex index;
    int row = currentIndex().row();
    int col = currentIndex().column() + static_cast<int>(direction);

    do {
            index = INDEX(row, col);
    } while(!IS_EDITABLE(index) && HAS_NEXT(direction, col));

    if(!index.isValid()) {
        if(row == (model() -> rowCount() - 1))
            model() -> insertRows(row + 1, 1);
        index = INDEX(row + 1, ColumnOperationId);
    }

    return index;
}
Esempio n. 3
0
int			parse_exp_redir(struct s_iterator *i,
					struct s_btree *node)
{
  struct s_token	*t;

  if (HAS_NEXT(i))
    {
      t = PEEK(i);
      if (t->type == TT_RREDIR)
	return (parse_exp_rredir(i, node));
      else if (t->type == TT_DRREDIR)
	return (parse_exp_drredir(i, node));
      else if (t->type == TT_LREDIR)
	return (parse_exp_lredir(i, node));
      else if (t->type == TT_DLREDIR)
	return (parse_exp_dlredir(i, node));
      else if (t->type == TT_TLREDIR)
	return (parse_exp_tlredir(i, node));
      else
	return (fprintf(stderr, "error: unexpected token \"%s\"\n",
			t->string._string), -1);
    }
  return (0);
}
bool KisChunkAllocator::tryInsertChunk(KisChunkDataList &list,
                                       KisChunkDataListIterator &iterator,
                                       quint64 size)
{
    bool result = false;
    quint64 highBound = m_storeSize;
    quint64 lowBound = 0;
    quint64 shift = 0;

    if(HAS_NEXT(list, iterator))
        highBound = PEEK_NEXT(iterator).m_begin;

    if(HAS_PREVIOUS(list, iterator)) {
        lowBound = PEEK_PREVIOUS(iterator).m_end;
        shift = 1;
    }

    if(GAP_SIZE(lowBound, highBound) >= size) {
        list.insert(iterator, KisChunkData(lowBound + shift, size));
        result = true;
    }

    return result;
}