* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
- * Version: $Id: embryo_cc_sc7.c 34246 2008-04-11 19:06:18Z doursse $
+ * Version: $Id: embryo_cc_sc7.c 51023 2010-08-11 20:35:26Z lucas $
*/
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
#ifdef HAVE_CONFIG_H
# include <config.h>
grow_stgbuffer(int requiredsize)
{
char *p;
- int clear = stgbuf == NULL; /* if previously none, empty buffer explicitly */
+ int clear = !stgbuf; /* if previously none, empty buffer explicitly */
assert(stgmax < requiredsize);
/* if the staging buffer (holding intermediate code for one line) grows
if (requiredsize > sSTG_MAX)
error(102, "staging buffer"); /* staging buffer overflow (fatal error) */
stgmax = requiredsize + sSTG_GROW;
- if (stgbuf != NULL)
+ if (stgbuf)
p = (char *)realloc(stgbuf, stgmax * sizeof(char));
else
p = (char *)malloc(stgmax * sizeof(char));
- if (p == NULL)
+ if (!p)
error(102, "staging buffer"); /* staging buffer overflow (fatal error) */
stgbuf = p;
if (clear)
void
stgbuffer_cleanup(void)
{
- if (stgbuf != NULL)
+ if (stgbuf)
{
free(stgbuf);
stgbuf = NULL;
start += 1; /* skip token */
/* allocate a argstack with sMAXARGS items */
stack = (argstack *) malloc(sMAXARGS * sizeof(argstack));
- if (stack == NULL)
+ if (!stack)
error(103); /* insufficient memory */
nest = 1; /* nesting counter */
argc = 0; /* argument counter */
char str[160];
/* count number of sequences */
- for (number = 0; sequences_cmp[number].find != NULL; number++)
+ for (number = 0; sequences_cmp[number].find; number++)
/* nothing */ ;
number++; /* include an item for the NULL terminator */
- if ((sequences = (SEQUENCE *) malloc(number * sizeof(SEQUENCE))) == NULL)
+ if (!(sequences = (SEQUENCE *)malloc(number * sizeof(SEQUENCE))))
return FALSE;
/* pre-initialize all to NULL (in case of failure) */
assert(len <= sizeof str);
assert(len == (int)strlen(str) + 1);
sequences[i].find = (char *)malloc(len);
- if (sequences[i].find != NULL)
+ if (sequences[i].find)
strcpy(sequences[i].find, str);
len =
strexpand(str, (unsigned char *)sequences_cmp[i].replace, sizeof str,
assert(len <= sizeof str);
assert(len == (int)strlen(str) + 1);
sequences[i].replace = (char *)malloc(len);
- if (sequences[i].replace != NULL)
+ if (sequences[i].replace)
strcpy(sequences[i].replace, str);
sequences[i].savesize = sequences_cmp[i].savesize;
- if (sequences[i].find == NULL || sequences[i].replace == NULL)
+ if (!sequences[i].find || !sequences[i].replace)
return phopt_cleanup();
} /* for */
{
int i;
- if (sequences != NULL)
+ if (sequences)
{
i = 0;
- while (sequences[i].find != NULL || sequences[i].replace != NULL)
+ while (sequences[i].find || sequences[i].replace)
{
- if (sequences[i].find != NULL)
+ if (sequences[i].find)
free(sequences[i].find);
- if (sequences[i].replace != NULL)
+ if (sequences[i].replace)
free(sequences[i].replace);
i++;
} /* while */
} /* while */
/* allocate a buffer to replace the sequence in */
- if ((buffer = malloc(*repl_length)) == NULL)
+ if (!(buffer = malloc(*repl_length)))
{
error(103);
return NULL;
else
{
seq = 0;
- while (sequences[seq].find != NULL)
+ while (sequences[seq].find)
{
assert(seq >= 0);
if (matchsequence