diff -r 1bdbfcca2fc6 -r 4a5b86aed1d6 parser.cxx --- a/parser.cxx Sat Jul 14 16:12:59 2012 +0300 +++ b/parser.cxx Sat Jul 14 16:24:57 2012 +0300 @@ -124,11 +124,14 @@ if (comm) { w->Write (DH_COMMAND); w->Write (comm->number); - w->Write (comm->numargs); + w->Write (comm->maxargs); MustNext ("("); int curarg = 0; while (1) { - if (curarg >= comm->numargs) { + if (curarg >= comm->maxargs) { + if (!PeekNext().compare (",")) + ParserError ("got `,` while expecting command-terminating `)`, are you passing too many parameters? (max %d)", + comm->maxargs); MustNext (")"); break; } @@ -148,8 +151,16 @@ int i = atoi (token.chars ()); w->Write (i); - if (curarg != comm->numargs - 1) + if (curarg < comm->numargs - 1) { MustNext (","); + } else if (curarg < comm->maxargs - 1) { + // Can continue, but can terminate as well. + if (!PeekNext ().compare (")")) { + MustNext (")"); + break; + } else + MustNext (","); + } curarg++; }