Embryo:
[framework/uifw/embryo.git] / src / bin / embryo_cc_sc1.c
index 560ae81..1806796 100644 (file)
@@ -34,7 +34,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifndef _MSC_VER
+#ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
 
@@ -119,31 +119,7 @@ static char         binfname[PATH_MAX];    /* binary file name */
 int
 main(int argc, char *argv[], char *env[] __UNUSED__)
 {
-   char                argv0[PATH_MAX];
-   int                 i;
-
-   snprintf(argv0, sizeof(argv0), "%s", argv[0]);
-   /* Linux stores the name of the program in argv[0], but not the path.
-    * To adjust this, I store a string with the path in argv[0]. To do
-    * so, I try to get the current path with getcwd(), and if that fails
-    * I search for the PWD= setting in the environment.
-    */
-   if (NULL != getcwd(argv0, PATH_MAX))
-     {
-       i = strlen(argv0);
-       snprintf(argv0 + i, sizeof(argv0) - i, "/%s", argv[0]);
-     }
-   else
-     {
-       char               *pwd = getenv("PWD");
-
-       if (pwd != NULL)
-          snprintf(argv0, sizeof(argv0), "%s/%s", pwd, argv[0]);
-     }                         /* if */
-   argv[0] = argv0;            /* set location to new first parameter */
-
-   e_prefix_determine(argv0);
-
+   e_prefix_determine(argv[0]);
    return sc_compile(argc, argv);
 }
 
@@ -221,7 +197,7 @@ sc_openasm(int fd)
 void
 sc_closeasm(void *handle)
 {
-   if (handle != NULL)
+   if (handle)
       fclose((FILE *) handle);
 }
 
@@ -307,7 +283,7 @@ sc_compile(int argc, char *argv[])
    /* allocate memory for fixed tables */
    inpfname = (char *)malloc(PATH_MAX);
    litq = (cell *) malloc(litmax * sizeof(cell));
-   if (litq == NULL)
+   if (!litq)
       error(103);              /* insufficient memory */
    if (!phopt_init())
       error(103);              /* insufficient memory */
@@ -328,28 +304,26 @@ sc_compile(int argc, char *argv[])
    if (fd_out < 0)
      error(101, outfname);
 
-   unlink (outfname); /* kill this file as soon as it's (f)close'd */
-
    setconfig(argv[0]);         /* the path to the include files */
    lcl_ctrlchar = sc_ctrlchar;
    lcl_packstr = sc_packstr;
    lcl_needsemicolon = sc_needsemicolon;
    lcl_tabsize = sc_tabsize;
    inpf = inpf_org = (FILE *) sc_opensrc(inpfname);
-   if (inpf == NULL)
+   if (!inpf)
       error(100, inpfname);
    freading = TRUE;
    outf = (FILE *) sc_openasm(fd_out); /* first write to assembler
                                                 * file (may be temporary) */
-   if (outf == NULL)
+   if (!outf)
       error(101, outfname);
    /* immediately open the binary file, for other programs to check */
    binf = (FILE *) sc_openbin(binfname);
-   if (binf == NULL)
+   if (!binf)
      error(101, binfname);
    setconstants();             /* set predefined constants and tagnames */
    for (i = 0; i < skipinput; i++)     /* skip lines in the input file */
-      if (sc_readsrc(inpf, pline, sLINEMAX) != NULL)
+      if (sc_readsrc(inpf, pline, sLINEMAX))
         fline++;               /* keep line number up to date */
    skipinput = fline;
    sc_status = statFIRST;
@@ -422,7 +396,7 @@ sc_compile(int argc, char *argv[])
       error(13);               /* no entry point (no public functions) */
 
  cleanup:
-   if (inpf != NULL)           /* main source file is not closed, do it now */
+   if (inpf)           /* main source file is not closed, do it now */
       sc_closesrc(inpf);
    /* write the binary file (the file is already open) */
    if (errnum == 0 && jmpcode == 0)
@@ -431,14 +405,15 @@ sc_compile(int argc, char *argv[])
        sc_resetasm(outf);      /* flush and loop back, for reading */
        assemble(binf, outf);   /* assembler file is now input */
      }                         /* if */
-   if (outf != NULL)
+   if (outf)
       sc_closeasm(outf);
-   if (binf != NULL)
+   unlink (outfname);
+   if (binf)
       sc_closebin(binf, errnum != 0);
 
-   if (inpfname != NULL)
+   if (inpfname)
       free(inpfname);
-   if (litq != NULL)
+   if (litq)
       free(litq);
    phopt_cleanup();
    stgbuffer_cleanup();
@@ -489,7 +464,7 @@ sc_addtag(char *name)
    constvalue         *ptr;
    int                 last, tag;
 
-   if (name == NULL)
+   if (!name)
      {
        /* no tagname was given, check for one */
        if (lex(&val, &name) != tLABEL)
@@ -501,7 +476,7 @@ sc_addtag(char *name)
 
    last = 0;
    ptr = tagname_tab.next;
-   while (ptr != NULL)
+   while (ptr)
      {
        tag = (int)(ptr->value & TAGMASK);
        if (strcmp(name, ptr->name) == 0)
@@ -679,15 +654,15 @@ setconfig(char *root)
    int                 len;
 
    /* add the default "include" directory */
-   if (root != NULL)
+   if (root)
      {
        /* path + filename (hopefully) */
        strncpy(path, root, sizeof(path) - 1);
        path[sizeof(path) - 1] = 0;
      }
 /* terminate just behind last \ or : */
-   if ((ptr = strrchr(path, DIRSEP_CHAR)) != NULL
-       || (ptr = strchr(path, ':')) != NULL)
+   if ((ptr = strrchr(path, DIRSEP_CHAR))
+       || (ptr = strchr(path, ':')))
      {
        /* If there was no terminating "\" or ":",
         * the filename probably does not
@@ -828,7 +803,7 @@ parse(void)
          case tSTATIC:
             /* This can be a static function or a static global variable;
              * we know which of the two as soon as we have parsed up to the
-             * point where an opening paranthesis of a function would be
+             * point where an opening parenthesis of a function would be
              * expected. To back out after deciding it was a declaration of
              * a static variable after all, we have to store the symbol name
              * and tag.
@@ -1042,7 +1017,7 @@ declglb(char *firstname, int firsttag, int fpublic, int fstatic,
        size = 1;               /* single size (no array) */
        numdim = 0;             /* no dimensions */
        ident = iVARIABLE;
-       if (firstname != NULL)
+       if (firstname)
          {
             assert(strlen(firstname) <= sNAMEMAX);
             strcpy(name, firstname);   /* save symbol name */
@@ -1058,9 +1033,9 @@ declglb(char *firstname, int firsttag, int fpublic, int fstatic,
             strcpy(name, str); /* save symbol name */
          }                     /* if */
        sym = findglb(name);
-       if (sym == NULL)
+       if (!sym)
           sym = findconst(name);
-       if (sym != NULL && (sym->usage & uDEFINE) != 0)
+       if (sym && (sym->usage & uDEFINE) != 0)
           error(21, name);     /* symbol already defined */
        ispublic = fpublic;
        if (name[0] == PUBLIC_CHAR)
@@ -1094,7 +1069,7 @@ declglb(char *firstname, int firsttag, int fpublic, int fstatic,
         * for public variables
         */
        cidx = 0;               /* only to avoid a compiler warning */
-       if (sc_status == statWRITE && sym != NULL
+       if (sc_status == statWRITE && sym
            && (sym->usage & (uREAD | uWRITTEN | uPUBLIC)) == 0)
          {
             sc_status = statSKIP;
@@ -1121,7 +1096,7 @@ declglb(char *firstname, int firsttag, int fpublic, int fstatic,
        dumplits();             /* dump the literal queue */
        dumpzero((int)size - litidx);
        litidx = 0;
-       if (sym == NULL)
+       if (!sym)
          {                     /* define only if not yet defined */
             sym =
                addvariable(name, sizeof(cell) * glb_declared, ident, sGLOBAL,
@@ -1201,14 +1176,14 @@ declloc(int fstatic)
         * the "nesting level" of local variables to verify the
         * multi-definition of symbols.
         */
-       if ((sym = findloc(name)) != NULL && sym->compound == nestlevel)
+       if ((sym = findloc(name)) && sym->compound == nestlevel)
           error(21, name);     /* symbol already defined */
        /* Although valid, a local variable whose name is equal to that
         * of a global variable or to that of a local variable at a lower
         * level might indicate a bug.
         */
-       if (((sym = findloc(name)) != NULL && sym->compound != nestlevel)
-           || findglb(name) != NULL)
+       if (((sym = findloc(name)) && sym->compound != nestlevel)
+           || findglb(name))
           error(219, name);    /* variable shadows another symbol */
        while (matchtoken('['))
          {
@@ -1710,7 +1685,7 @@ fetchfunc(char *name, int tag)
         * symbol instruction.
         */
      }                         /* if */
-   if ((sym = findglb(name)) != 0)
+   if ((sym = findglb(name)))
      {                         /* already in symbol table? */
        if (sym->ident != iFUNCTN)
          {
@@ -1758,7 +1733,7 @@ define_args(void)
     * local symbols are function arguments.
     */
    sym = loctab.next;
-   while (sym != NULL)
+   while (sym)
      {
        assert(sym->ident != iLABEL);
        assert(sym->vclass == sLOCAL);
@@ -1767,7 +1742,7 @@ define_args(void)
          {
             symbol             *sub = sym;
 
-            while (sub != NULL)
+            while (sub)
               {
                  symbolrange(sub->dim.array.level, sub->dim.array.length);
                  sub = finddepend(sub);
@@ -1904,7 +1879,7 @@ operatoradjust(int opertok, symbol * sym, char *opername, int resulttag)
    /* change the operator name */
    assert(opername[0] != '\0');
    operator_symname(tmpname, opername, tags[0], tags[1], count, resulttag);
-   if ((oldsym = findglb(tmpname)) != NULL)
+   if ((oldsym = findglb(tmpname)))
      {
        int                 i;
 
@@ -1918,7 +1893,7 @@ operatoradjust(int opertok, symbol * sym, char *opername, int resulttag)
        sym->usage |= oldsym->usage;    /* copy flags from the previous
                                         * definition */
        for (i = 0; i < oldsym->numrefers; i++)
-          if (oldsym->refer[i] != NULL)
+          if (oldsym->refer[i])
              refer_symbol(sym, oldsym->refer[i]);
        delete_symbol(&glbtab, oldsym);
      }                         /* if */
@@ -2110,7 +2085,7 @@ funcstub(int native)
 
    sym = fetchfunc(symbolname, tag);   /* get a pointer to the
                                         * function entry */
-   if (sym == NULL)
+   if (!sym)
       return;
    if (native)
      {
@@ -2199,7 +2174,7 @@ newfunc(char *firstname, int firsttag, int fpublic, int fstatic, int stock)
    glbdecl = 0;
    filenum = fcurrent;         /* save file number at start of declaration */
 
-   if (firstname != NULL)
+   if (firstname)
      {
        assert(strlen(firstname) <= sNAMEMAX);
        strcpy(symbolname, firstname);  /* save symbol name */
@@ -2243,7 +2218,7 @@ newfunc(char *firstname, int firsttag, int fpublic, int fstatic, int stock)
      }                         /* if */
    sym = fetchfunc(symbolname, tag);   /* get a pointer to the
                                         * function entry */
-   if (sym == NULL)
+   if (!sym)
       return TRUE;
    if (fpublic)
       sym->usage |= uPUBLIC;
@@ -2517,7 +2492,7 @@ declargs(symbol * sym)
                       sym->dim.arglist =
                          (arginfo *) realloc(sym->dim.arglist,
                                              (argcnt + 2) * sizeof(arginfo));
-                      if (sym->dim.arglist == 0)
+                      if (!sym->dim.arglist)
                          error(103);   /* insufficient memory */
                       sym->dim.arglist[argcnt] = arg;
                       sym->dim.arglist[argcnt + 1].ident = 0;  /* keep the list
@@ -2554,7 +2529,7 @@ declargs(symbol * sym)
                       sym->dim.arglist =
                          (arginfo *) realloc(sym->dim.arglist,
                                              (argcnt + 2) * sizeof(arginfo));
-                      if (sym->dim.arglist == 0)
+                      if (!sym->dim.arglist)
                          error(103);   /* insufficient memory */
                       sym->dim.arglist[argcnt + 1].ident = 0;  /* keep the list
                                                                 * terminated */
@@ -2565,7 +2540,7 @@ declargs(symbol * sym)
                       sym->dim.arglist[argcnt].numtags = numtags;
                       sym->dim.arglist[argcnt].tags =
                          (int *)malloc(numtags * sizeof tags[0]);
-                      if (sym->dim.arglist[argcnt].tags == NULL)
+                      if (!sym->dim.arglist[argcnt].tags)
                          error(103);   /* insufficient memory */
                       memcpy(sym->dim.arglist[argcnt].tags, tags,
                              numtags * sizeof tags[0]);
@@ -2697,7 +2672,7 @@ doarg(char *name, int ident, int offset, int tags[], int numtags,
             assert(size >= litidx);
             /* allocate memory to hold the initial values */
             arg->defvalue.array.data = (cell *) malloc(litidx * sizeof(cell));
-            if (arg->defvalue.array.data != NULL)
+            if (arg->defvalue.array.data)
               {
                  int                 i;
 
@@ -2705,7 +2680,7 @@ doarg(char *name, int ident, int offset, int tags[], int numtags,
                  arg->hasdefault = TRUE;       /* argument has default value */
                  arg->defvalue.array.size = litidx;
                  arg->defvalue.array.addr = -1;
-                 /* calulate size to reserve on the heap */
+                 /* calculate size to reserve on the heap */
                  arg->defvalue.array.arraysize = 1;
                  for (i = 0; i < arg->numdim; i++)
                     arg->defvalue.array.arraysize *= arg->dim[i];
@@ -2744,8 +2719,7 @@ doarg(char *name, int ident, int offset, int tags[], int numtags,
                       cell                val;
 
                       tokeninfo(&val, &name);
-                      if ((arg->defvalue.size.symname =
-                           strdup(name)) == NULL)
+                      if (!(arg->defvalue.size.symname = strdup(name)))
                          error(103);   /* insufficient memory */
                       arg->defvalue.size.level = 0;
                       if (size_tag_token == uSIZEOF)
@@ -2776,17 +2750,17 @@ doarg(char *name, int ident, int offset, int tags[], int numtags,
    arg->usage = (char)(fconst ? uCONST : 0);
    arg->numtags = numtags;
    arg->tags = (int *)malloc(numtags * sizeof tags[0]);
-   if (arg->tags == NULL)
+   if (!arg->tags)
       error(103);              /* insufficient memory */
    memcpy(arg->tags, tags, numtags * sizeof tags[0]);
    argsym = findloc(name);
-   if (argsym != NULL)
+   if (argsym)
      {
        error(21, name);        /* symbol already defined */
      }
    else
      {
-       if ((argsym = findglb(name)) != NULL && argsym->ident != iFUNCTN)
+       if ((argsym = findglb(name)) && argsym->ident != iFUNCTN)
           error(219, name);    /* variable shadows another symbol */
        /* add details of type and address */
        assert(numtags > 0);
@@ -2810,7 +2784,7 @@ count_referrers(symbol * entry)
 
    count = 0;
    for (i = 0; i < entry->numrefers; i++)
-      if (entry->refer[i] != NULL)
+      if (entry->refer[i])
         count++;
    return count;
 }
@@ -2829,9 +2803,9 @@ reduce_referrers(symbol * root)
    do
      {
        restart = 0;
-       for (sym = root->next; sym != NULL; sym = sym->next)
+       for (sym = root->next; sym; sym = sym->next)
          {
-            if (sym->parent != NULL)
+            if (sym->parent)
                continue;       /* hierarchical data type */
             if (sym->ident == iFUNCTN
                 && (sym->usage & uNATIVE) == 0
@@ -2842,9 +2816,9 @@ reduce_referrers(symbol * root)
                  sym->usage &= ~(uREAD | uWRITTEN);    /* erase usage bits if
                                                         * there is no referrer */
                  /* find all symbols that are referred by this symbol */
-                 for (ref = root->next; ref != NULL; ref = ref->next)
+                 for (ref = root->next; ref; ref = ref->next)
                    {
-                      if (ref->parent != NULL)
+                      if (ref->parent)
                          continue;     /* hierarchical data type */
                       assert(ref->refer != NULL);
                       for (i = 0; i < ref->numrefers && ref->refer[i] != sym;
@@ -2860,7 +2834,7 @@ reduce_referrers(symbol * root)
               }
             else if ((sym->ident == iVARIABLE || sym->ident == iARRAY)
                      && (sym->usage & uPUBLIC) == 0
-                     && sym->parent == NULL && count_referrers(sym) == 0)
+                     && !sym->parent && count_referrers(sym) == 0)
               {
                  sym->usage &= ~(uREAD | uWRITTEN);    /* erase usage bits if
                                                         * there is no referrer */
@@ -2892,7 +2866,7 @@ testsymbols(symbol * root, int level, int testlabs, int testconst)
 
    symbol             *sym = root->next;
 
-   while (sym != NULL && sym->compound >= level)
+   while (sym && sym->compound >= level)
      {
        switch (sym->ident)
          {
@@ -2923,7 +2897,7 @@ testsymbols(symbol * root, int level, int testlabs, int testconst)
             break;
          default:
             /* a variable */
-            if (sym->parent != NULL)
+            if (sym->parent)
                break;          /* hierarchical data type */
             if ((sym->usage & (uWRITTEN | uREAD | uSTOCK | uPUBLIC)) == 0)
                error(203, sym->name);  /* symbol isn't used (and not stock
@@ -2956,7 +2930,7 @@ calc_array_datasize(symbol * sym, cell * offset)
      {
        cell                sublength =
           calc_array_datasize(finddepend(sym), offset);
-       if (offset != NULL)
+       if (offset)
           *offset = length * (*offset + sizeof(cell));
        if (sublength > 0)
           length *= length * sublength;
@@ -2965,7 +2939,7 @@ calc_array_datasize(symbol * sym, cell * offset)
      }
    else
      {
-       if (offset != NULL)
+       if (offset)
           *offset = 0;
      }                         /* if */
    return length;
@@ -2978,7 +2952,7 @@ destructsymbols(symbol * root, int level)
    int                 savepri = FALSE;
    symbol             *sym = root->next;
 
-   while (sym != NULL && sym->compound >= level)
+   while (sym && sym->compound >= level)
      {
        if (sym->ident == iVARIABLE || sym->ident == iARRAY)
          {
@@ -2988,9 +2962,9 @@ destructsymbols(symbol * root, int level)
 
             /* check that the '~' operator is defined for this tag */
             operator_symname(symbolname, "~", sym->tag, 0, 1, 0);
-            if ((opsym = findglb(symbolname)) != NULL)
+            if ((opsym = findglb(symbolname)))
               {
-                 /* save PRI, in case of a return statment */
+                 /* save PRI, in case of a return statement */
                  if (!savepri)
                    {
                       push1(); /* right-hand operand is in PRI */
@@ -3022,7 +2996,7 @@ destructsymbols(symbol * root, int level)
                  if (sc_status != statSKIP)
                     markusage(opsym, uREAD);   /* do not mark as "used" when this
                                                 * call itself is skipped */
-                 if (opsym->x.lib != NULL)
+                 if (opsym->x.lib)
                     opsym->x.lib->value += 1;  /* increment "usage count"
                                                 * of the library */
               }                /* if */
@@ -3040,7 +3014,7 @@ insert_constval(constvalue * prev, constvalue * next, char *name,
 {
    constvalue         *cur;
 
-   if ((cur = (constvalue *) malloc(sizeof(constvalue))) == NULL)
+   if (!(cur = (constvalue *)malloc(sizeof(constvalue))))
       error(103);              /* insufficient memory (fatal error) */
    memset(cur, 0, sizeof(constvalue));
    strcpy(cur->name, name);
@@ -3057,7 +3031,7 @@ append_constval(constvalue * table, char *name, cell val, short index)
    constvalue         *cur, *prev;
 
    /* find the end of the constant table */
-   for (prev = table, cur = table->next; cur != NULL;
+   for (prev = table, cur = table->next; cur;
        prev = cur, cur = cur->next)
       /* nothing */ ;
    return insert_constval(prev, NULL, name, val, index);
@@ -3068,7 +3042,7 @@ find_constval(constvalue * table, char *name, short index)
 {
    constvalue         *ptr = table->next;
 
-   while (ptr != NULL)
+   while (ptr)
      {
        if (strcmp(name, ptr->name) == 0 && ptr->index == index)
           return ptr;
@@ -3082,7 +3056,7 @@ find_constval_byval(constvalue * table, cell val)
 {
    constvalue         *ptr = table->next;
 
-   while (ptr != NULL)
+   while (ptr)
      {
        if (ptr->value == val)
           return ptr;
@@ -3118,7 +3092,7 @@ delete_consttable(constvalue * table)
 {
    constvalue         *cur = table->next, *next;
 
-   while (cur != NULL)
+   while (cur)
      {
        next = cur->next;
        free(cur);
@@ -3187,7 +3161,7 @@ statement(int *lastindent, int allow_decl)
    if (tok != '{')
       setline(fline, fcurrent);
    /* lex() has set stmtindent */
-   if (lastindent != NULL && tok != tLABEL)
+   if (lastindent && tok != tLABEL)
      {
 #if 0
        if (*lastindent >= 0 && *lastindent != stmtindent &&
@@ -3457,7 +3431,7 @@ test(int label, int parens, int invert)
    if (lval.ident == iARRAY || lval.ident == iREFARRAY)
      {
        char               *ptr =
-          (lval.sym->name != NULL) ? lval.sym->name : "-unknown-";
+          (lval.sym->name) ? lval.sym->name : "-unknown-";
        error(33, ptr);         /* array must be indexed */
      }                         /* if */
    if (lval.ident == iCONSTEXPR)
@@ -3730,10 +3704,10 @@ doswitch(void)
                   * case values at the same time.
                   */
                  for (csp = &caselist, cse = caselist.next;
-                      cse != NULL && cse->value < val;
+                      cse && cse->value < val;
                       csp = cse, cse = cse->next)
                     /* nothing */ ;
-                 if (cse != NULL && cse->value == val)
+                 if (cse && cse->value == val)
                     error(40, val);    /* duplicate "case" label */
                  /* Since the label is stored as a string in the
                   * "constvalue", the size of an identifier must
@@ -3756,10 +3730,10 @@ doswitch(void)
                            casecount++;
                            /* find the new insertion point */
                            for (csp = &caselist, cse = caselist.next;
-                                cse != NULL && cse->value < val;
+                                cse && cse->value < val;
                                 csp = cse, cse = cse->next)
                               /* nothing */ ;
-                           if (cse != NULL && cse->value == val)
+                           if (cse && cse->value == val)
                               error(40, val);  /* duplicate "case" label */
                            insert_constval(csp, cse, itoh(lbl_case), val, 0);
                         }      /* if */
@@ -3798,10 +3772,10 @@ doswitch(void)
    while (tok != '}');
 
 #if !defined NDEBUG
-   /* verify that the case table is sorted (unfortunatly, duplicates can
+   /* verify that the case table is sorted (unfortunately, duplicates can
     * occur; there really shouldn't be duplicate cases, but the compiler
     * may not crash or drop into an assertion for a user error). */
-   for (cse = caselist.next; cse != NULL && cse->next != NULL; cse = cse->next)
+   for (cse = caselist.next; cse && cse->next; cse = cse->next)
      ; /* empty. no idea whether this is correct, but we MUST NOT do
         * the setlabel(lbl_table) call in the loop body. doing so breaks
         * switch statements that only have one case statement following.
@@ -3823,7 +3797,7 @@ doswitch(void)
      }                         /* if */
    ffcase(casecount, labelname, TRUE);
    /* generate the rest of the table */
-   for (cse = caselist.next; cse != NULL; cse = cse->next)
+   for (cse = caselist.next; cse; cse = cse->next)
       ffcase(cse->value, cse->name, FALSE);
 
    setlabel(lbl_exit);
@@ -3896,7 +3870,7 @@ dolabel(void)
    symbol             *sym;
 
    tokeninfo(&val, &st);       /* retrieve label name again */
-   if (find_constval(&tagname_tab, st, 0) != NULL)
+   if (find_constval(&tagname_tab, st, 0))
       error(221, st);          /* label name shadows tagname */
    sym = fetchlab(st);
    setlabel((int)sym->addr);
@@ -3983,7 +3957,7 @@ dobreak(void)
 
    ptr = readwhile();          /* readwhile() gives an error if not in loop */
    needtoken(tTERM);
-   if (ptr == NULL)
+   if (!ptr)
       return;
    destructsymbols(&loctab, nestlevel);
    modstk(((int)declared - ptr[wqBRK]) * sizeof(cell));
@@ -3997,7 +3971,7 @@ docont(void)
 
    ptr = readwhile();          /* readwhile() gives an error if not in loop */
    needtoken(tTERM);
-   if (ptr == NULL)
+   if (!ptr)
       return;
    destructsymbols(&loctab, nestlevel);
    modstk(((int)declared - ptr[wqCONT]) * sizeof(cell));
@@ -4016,9 +3990,9 @@ exporttag(int tag)
 
        assert((tag & PUBLICTAG) == 0);
        for (ptr = tagname_tab.next;
-            ptr != NULL && tag != (int)(ptr->value & TAGMASK); ptr = ptr->next)
+            ptr && tag != (int)(ptr->value & TAGMASK); ptr = ptr->next)
           /* nothing */ ;
-       if (ptr != NULL)
+       if (ptr)
           ptr->value |= PUBLICTAG;
      }                         /* if */
 }