env: remove asserts

The assertions didn’t help catch the most recent bug which
was in their area, and kind of get in the way.
* src/env.c: Do not include <assert.h>, and remove all assertions.
These seem to have been put in to pacify gcov, but surely there’s
a better way.
(escape_char): Pacify GCC with 'assume' instead.
This commit is contained in:
Paul Eggert committed 2021-03-26 15:17:28 -07:00
1 parent 6c4efdc0f5
commit 52f11d8b7c
1 file changed
+1 -10
+1 -10
View File
@@ -23,7 +23,6 @@
#include <c-ctype.h>
#include <signal.h>
#include <assert.h>
#include "system.h"
#include "die.h"
#include "error.h"
@@ -210,7 +209,7 @@ escape_char (const char c)
case 'r': return '\r';
case 't': return '\t';
case 'v': return '\v';
default: assert (0); /* LCOV_EXCL_LINE */
default: assume (false);
}
}
@@ -221,7 +220,6 @@ escape_char (const char c)
static const char* _GL_ATTRIBUTE_PURE
scan_varname (const char* str)
{
assert (str && *str == '$'); /* LCOV_EXCL_LINE */
if ( *(str+1) == '{' && (c_isalpha (*(str+2)) || *(str+2) == '_'))
{
const char* end = str+3;
@@ -280,8 +278,6 @@ validate_split_str (const char* str, size_t* /*out*/ bufsize,
size_t buflen;
int cnt = 1;
assert (str && str[0] && !c_isspace (str[0])); /* LCOV_EXCL_LINE */
dq = sq = sp = false;
buflen = strlen (str)+1;
@@ -303,12 +299,10 @@ validate_split_str (const char* str, size_t* /*out*/ bufsize,
switch (*str)
{
case '\'':
assert (!(sq && dq)); /* LCOV_EXCL_LINE */
sq = !sq && !dq;
break;
case '"':
assert (!(sq && dq)); /* LCOV_EXCL_LINE */
dq = !sq && !dq;
break;
@@ -395,8 +389,6 @@ build_argv (const char* str, int extra_argc)
} \
} while (0)
assert (str && str[0] && !c_isspace (str[0])); /* LCOV_EXCL_LINE */
validate_split_str (str, &buflen, &newargc);
/* allocate buffer. +6 for the "DUMMY\0" executable name, +1 for NUL. */
@@ -486,7 +478,6 @@ build_argv (const char* str, int extra_argc)
/* Store the ${VARNAME} value. */
{
char *n = extract_varname (str);
assert (n); /* ${VARNAME} already validated. */
char *v = getenv (n);
if (v)
{