From: lum Date: Thu, 6 May 2021 07:16:24 +0000 (+0000) Subject: Give parse error if character found between blocks. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=818faf029652de24b1519eed264a17a221477a73;p=openbsd Give parse error if character found between blocks. --- diff --git a/usr.bin/mg/interpreter.c b/usr.bin/mg/interpreter.c index c8bc1b74b47..c0d2ea342ab 100644 --- a/usr.bin/mg/interpreter.c +++ b/usr.bin/mg/interpreter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interpreter.c,v 1.25 2021/05/05 06:12:23 lum Exp $ */ +/* $OpenBSD: interpreter.c,v 1.26 2021/05/06 07:16:24 lum Exp $ */ /* * This file is in the public domain. * @@ -156,6 +156,11 @@ foundparen(char *funstr, int llen) p = funstr; for (i = 0; i < llen; ++i, p++) { + if (pctr == 0 && *p != ' ' && *p != '\t' && *p != '(') { + if (*p == ')') + return(dobeep_msg("Extra ')' found")); + return(dobeep_msg("parse error")); + } if (*p == '\\') { esc = 1; } else if (*p == '(') { @@ -212,14 +217,14 @@ foundparen(char *funstr, int llen) if (*p == '"') { if (inquote == 0 && esc == 0) { if (*prechr != ' ' && *prechr != '\t') - return(dobeep_msg("char err")); + return(dobeep_msg("parse err")); inquote++; } else if (inquote > 0 && esc == 1) esc = 0; else inquote--; } else if (*prechr == '"' && inquote == 0) { - return(dobeep_msg("char err")); + return(dobeep_msg("parse err")); } endp = NULL; } else if (endp == NULL && (*p == ' ' || *p == '\t')) {