char buf[1024];
va_list ap;
va_start(ap, fmt);
- vsprintf(buf, fmt, ap);
+ vsnprintf(buf, 1024, fmt, ap);
va_end(ap);
errors->append(buf);
}
/*!
* \param[in,out] sel Root of the selection element tree to initialize.
- * \param[in] scanner Scanner data structure.
- * \returns 0 on success, an error code on error.
*
* Propagates the \ref SEL_DYNAMIC flag from the children of \p sel to \p sel
* (if any child of \p sel is dynamic, \p sel is also marked as such).
* operation does not descend beyond such elements.
*/
void
-_gmx_selelem_update_flags(const gmx::SelectionTreeElementPointer &sel,
- yyscan_t scanner)
+_gmx_selelem_update_flags(const gmx::SelectionTreeElementPointer &sel)
{
bool bUseChildType = false;
bool bOnlySingleChildren;
while (child)
{
/* Update the child */
- _gmx_selelem_update_flags(child, scanner);
- /* Propagate the dynamic flag */
- sel->flags |= (child->flags & SEL_DYNAMIC);
+ _gmx_selelem_update_flags(child);
+ /* Propagate the dynamic and unsorted flags */
+ sel->flags |= (child->flags & (SEL_DYNAMIC | SEL_UNSORTED));
/* Propagate the type flag if necessary and check for problems */
if (bUseChildType)
{
if ((sel->flags & SEL_VALTYPEMASK)
&& !(sel->flags & child->flags & SEL_VALTYPEMASK))
{
- _gmx_selparser_error(scanner, "invalid combination of selection expressions");
- // FIXME: Use an exception.
- return;
+ // TODO: Recollect when this is triggered, and whether the type
+ // is appropriate.
+ GMX_THROW(gmx::InvalidInputError("Invalid combination of selection expressions"));
}
sel->flags |= (child->flags & SEL_VALTYPEMASK);
}
const gmx::SelectionTreeElementPointer &sel,
yyscan_t scanner)
{
- gmx::MessageStringCollector *errors = _gmx_sel_lexer_error_reporter(scanner);
- char buf[1024];
- sprintf(buf, "In selection '%s'", _gmx_sel_lexer_pselstr(scanner));
- gmx::MessageStringContext context(errors, buf);
-
if (sel->v.type != POS_VALUE)
{
/* FIXME: Better handling of this error */
root->setName(name);
}
/* Update the flags */
- _gmx_selelem_update_flags(root, scanner);
+ _gmx_selelem_update_flags(root);
root->fillNameIfMissing(_gmx_sel_lexer_pselstr(scanner));
const char *pselstr = _gmx_sel_lexer_pselstr(scanner);
SelectionTreeElementPointer root;
- gmx::MessageStringCollector *errors = _gmx_sel_lexer_error_reporter(scanner);
- char buf[1024];
- sprintf(buf, "In selection '%s'", pselstr);
- gmx::MessageStringContext context(errors, buf);
-
- _gmx_selelem_update_flags(expr, scanner);
+ _gmx_selelem_update_flags(expr);
/* Check if this is a constant non-group value */
if (expr->type == SEL_CONST && expr->v.type != GROUP_VALUE)
{
_gmx_selelem_set_vtype(root->child, expr->v.type);
root->child->child = expr;
/* Update flags */
- _gmx_selelem_update_flags(root, scanner);
+ _gmx_selelem_update_flags(root);
/* Add the variable to the symbol table */
sc->symtab->addVariable(name, root->child);
finish: