Module Name: src Committed By: kre Date: Sun May 7 10:37:00 UTC 2017
Modified Files: src/bin/sh: eval.c Log Message: POSIX says that the arg to break or continue is to be a positive integer (by which they mean > 0). We were checking for negative numbers, but not for 0. More by chance of the implementation than any specific design (I suspect) "break 0" was being treated the same as "break" or "break 1". Since 3 ways to achieve the same thing is overkill, let's do what posix wants and forbid "break 0" and "continue 0". To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/bin/sh/eval.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.134 src/bin/sh/eval.c:1.135 --- src/bin/sh/eval.c:1.134 Thu May 4 04:37:51 2017 +++ src/bin/sh/eval.c Sun May 7 10:37:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.134 2017/05/04 04:37:51 kre Exp $ */ +/* $NetBSD: eval.c,v 1.135 2017/05/07 10:37:00 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.134 2017/05/04 04:37:51 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.135 2017/05/07 10:37:00 kre Exp $"); #endif #endif /* not lint */ @@ -1231,6 +1231,8 @@ breakcmd(int argc, char **argv) { int n = argc > 1 ? number(argv[1]) : 1; + if (n <= 0) + error("invalid count: %d", n); if (n > loopnest) n = loopnest; if (n > 0) {