Changeset 35 for trunk/src


Ignore:
Timestamp:
Mar 18, 2003, 4:58:49 AM (22 years ago)
Author:
bird
Message:

emx is kind of working again...

Location:
trunk/src/kmk
Files:
4 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/Makefile.emx.mak

    r33 r35  
    33
    44CC = gcc
    5 CFLAGS = -I. -I./include -I../kLib/Generic/include \
     5CFLAGS = -g -I. -I./include -I../kLib/Generic/include \
    66#         -DUSE_KLIB \
    7          -DOS2 -D__i386__ -D__32BIT__ -DMACHINE=\"ibmos2\" -DMACHINE_ARCH=\"x86\" -DMACHINE_CPU=\"386\" \
     7         -DOS2 -D__i386__ -D__32BIT__ -DNMAKE -DMACHINE=\"ibmos2\" -DMACHINE_ARCH=\"x86\" -DMACHINE_CPU=\"386\" \
    88
    99OBJDIR=obj.emx
     
    5454$(OBJDIR)\var.o\
    5555$(OBJDIR)\util.o\
     56$(OBJDIR)\helpers.o\
    5657
    5758INCOBJS=\
     
    6263
    6364kmk.exe: $(BASEOBJS) $(LSTOBJS) $(INCOBJS)
    64     $(CC) $(CFLAGS) $** -o $@ -lregexp
     65    $(CC) $(CFLAGS) -Zmap $** -o $@ -lregex
    6566
    6667$(LSTOBJS): lst.lib\$(@B).c list.h lst.h
  • trunk/src/kmk/Makefile.icc.mak

    r34 r35  
    33
    44CC = icc
    5 CFLAGS = /Q     /Ti+ /Ss+ /Ge+ /I. /I./include /I../kLib/Generic/include \
    6          -DUSE_KLIB -DOS2 -D__i386__ -D__32BIT__ -DMACHINE=\"ibmos2\" -DMACHINE_ARCH=\"x86\" -DMACHINE_CPU=\"386\" \
     5CFLAGS = /Q /Ti+ /Ss+ /Ge+ /I. /I./include /I../kLib/Generic/include \
     6         -DUSE_KLIB -DOS2 -D__i386__ -D__32BIT__ -DNMAKE=1 -DMACHINE=\"ibmos2\" -DMACHINE_ARCH=\"x86\" -DMACHINE_CPU=\"386\" \
    77
    88OBJDIR=obj.icc
     
    3939$(OBJDIR)\arch.obj\
    4040$(OBJDIR)\buf.obj\
    41 #$(OBJDIR)\compat.obj\
     41$(OBJDIR)\compat.obj\
    4242$(OBJDIR)\cond.obj\
    4343$(OBJDIR)\dir.obj\
    4444$(OBJDIR)\for.obj\
    4545$(OBJDIR)\hash.obj\
    46 #$(OBJDIR)\job.obj\
     46$(OBJDIR)\job.obj\
    4747$(OBJDIR)\main.obj\
    4848$(OBJDIR)\make.obj\
     
    5353$(OBJDIR)\var.obj\
    5454$(OBJDIR)\util.obj\
     55$(OBJDIR)\helpers.obj\
    5556
    5657INCOBJS=\
     
    6162
    6263kmk.exe: $(BASEOBJS) $(LSTOBJS) $(INCOBJS)
    63     $(CC) $(CFLAGS) $** /Fm$(@F).map /Fe$@
     64    $(CC) @<<
     65$(CFLAGS) $** /Fm$(@F).map /Fe$@ ..\klib\lib\debug\klib.lib
     66<<
    6467
    6568$(LSTOBJS): lst.lib\$(@B).c list.h lst.h
  • trunk/src/kmk/arch.c

    r27 r35  
    162162         entry != NULL;
    163163         entry = Hash_EnumNext(&search))
    164         free((Address) Hash_GetValue (entry));
    165 
    166     free(a->name);
     164        efree((Address) Hash_GetValue (entry));
     165
     166    efree(a->name);
    167167    efree(a->fnametab);
    168168    Hash_DeleteTable(&a->members);
    169     free((Address) a);
     169    efree((Address) a);
    170170}
    171171
     
    226226
    227227            if (freeIt) {
    228                 free(result);
     228                efree(result);
    229229            }
    230230            cp += length-1;
     
    268268
    269269                if (freeIt) {
    270                     free(result);
     270                    efree(result);
    271271                }
    272272                cp += length;
     
    334334
    335335                if (gn == NILGNODE) {
    336                     free(buf);
     336                    efree(buf);
    337337                    return(FAILURE);
    338338                } else {
     
    342342            } else if (Arch_ParseArchive(&sacrifice, nodeLst, ctxt)!=SUCCESS) {
    343343                /*
    344                  * Error in nested call -- free buffer and return FAILURE
     344                 * Error in nested call -- efree buffer and return FAILURE
    345345                 * ourselves.
    346346                 */
    347                 free(buf);
     347                efree(buf);
    348348                return(FAILURE);
    349349            }
     
    351351             * Free buffer and continue with our work.
    352352             */
    353             free(buf);
     353            efree(buf);
    354354        } else if (Dir_HasWildcards(memName)) {
    355355            Lst   members = Lst_Init(FALSE);
     
    367367
    368368                snprintf(nameBuf, sz, "%s(%s)", libName, member);
    369                 free(member);
     369                efree(member);
    370370                gn = Targ_FindNode (nameBuf, TARG_CREATE);
    371371                if (gn == NILGNODE) {
    372                     free(nameBuf);
     372                    efree(nameBuf);
    373373                    return (FAILURE);
    374374                } else {
     
    385385            }
    386386            Lst_Destroy(members, NOFREE);
    387             free(nameBuf);
     387            efree(nameBuf);
    388388        } else {
    389389            size_t sz = strlen(libName) + strlen(memName) + 3;
     
    391391            snprintf(nameBuf, sz, "%s(%s)", libName, memName);
    392392            gn = Targ_FindNode (nameBuf, TARG_CREATE);
    393             free(nameBuf);
     393            efree(nameBuf);
    394394            if (gn == NILGNODE) {
    395395                return (FAILURE);
     
    407407        }
    408408        if (doSubst) {
    409             free(memName);
     409            efree(memName);
    410410        }
    411411
     
    414414
    415415    /*
    416      * If substituted libName, free it now, since we need it no longer.
     416     * If substituted libName, efree it now, since we need it no longer.
    417417     */
    418418    if (subLibName) {
    419         free(libName);
     419        efree(libName);
    420420    }
    421421
     
    668668    Hash_DeleteTable (&ar->members);
    669669    efree(ar->fnametab);
    670     free ((Address)ar);
     670    efree ((Address)ar);
    671671    return (NULL);
    672672}
     
    11291129    gn->path = Dir_FindFile (libName, path);
    11301130
    1131     free (libName);
     1131    efree (libName);
    11321132
    11331133#ifdef LIBRARIES
  • trunk/src/kmk/buf.c

    r25 r35  
    188188        bp->outPtr = newBuf + BUF_UNGET_INC;
    189189        bp->inPtr = bp->outPtr + numBytes;
    190         free ((char *)bp->buffer);
     190        efree ((char *)bp->buffer);
    191191        bp->buffer = newBuf;
    192192        bp->size += BUF_UNGET_INC;
     
    232232        bp->outPtr = newBuf + newBytes;
    233233        bp->inPtr = bp->outPtr + curNumBytes;
    234         free ((char *)bp->buffer);
     234        efree ((char *)bp->buffer);
    235235        bp->buffer = newBuf;
    236236        bp->size += newBytes;
     
    446446
    447447    if (freeData) {
    448         free ((char *)buf->buffer);
    449     }
    450     free ((char *)buf);
     448        efree ((char *)buf->buffer);
     449    }
     450    efree ((char *)buf);
    451451}
    452452
  • trunk/src/kmk/compat.c

    r27 r35  
    6666#include    <sys/wait.h>
    6767#endif
     68#if defined(__EMX__)
     69#include <sys/process.h>
     70#endif
     71#if defined(OS2) && defined(__IBMC__)
     72#include <process.h>
     73#endif
    6874#include    <ctype.h>
    6975#include    <errno.h>
     
    134140
    135141    }
     142    #if !(defined(OS2) && defined(__IBMC__))
    136143    if (signo == SIGQUIT)
    137144        exit(signo);
     145    #endif
    138146    (void) signal(signo, SIG_DFL);
    139147    (void) kill(getpid(), signo);
     
    228236
    229237    if (*cmdStart == '\0') {
    230         free(cmdStart);
     238        efree(cmdStart);
    231239        Error("%s expands to empty string", cmd);
    232240        return(0);
     
    329337     * Fork and execute the single command. If the fork fails, we abort.
    330338     */
     339#ifdef OS2 //@todo use klib later!
     340    cpid = _spawnvp(P_NOWAIT, av[0], av);
     341#else
    331342    cpid = vfork();
    332343    if (cpid < 0) {
     
    345356        exit(1);
    346357    }
     358#endif
    347359
    348360    /*
    349361     * we need to print out the command associated with this Gnode in
    350362     * Targ_PrintCmd from Targ_PrintGraph when debugging at level g2,
    351      * in main(), Fatal() and DieHorribly(), therefore do not free it
     363     * in main(), Fatal() and DieHorribly(), therefore do not efree it
    352364     * when debugging.
    353365     */
    354366    if (!DEBUG(GRAPH2)) {
    355         free(cmdStart);
     367        efree(cmdStart);
    356368        Lst_Replace (cmdNode, cmdp);
    357369    }
     
    664676        signal(SIGTERM, CompatInterrupt);
    665677    }
     678    #if !(defined(OS2) && defined(__IBMC__))
    666679    if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
    667680        signal(SIGHUP, CompatInterrupt);
    668681    }
     682    #endif
     683    #if !(defined(OS2) && defined(__IBMC__))
    669684    if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) {
    670685        signal(SIGQUIT, CompatInterrupt);
    671686    }
     687    #endif
    672688
    673689    for (cp = "#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) {
  • trunk/src/kmk/cond.c

    r25 r35  
    236236            Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
    237237            if (doFree) {
    238                 free(cp2);
     238                efree(cp2);
    239239            }
    240240            cp += len;
     
    383383    if (path != (char *)NULL) {
    384384        result = TRUE;
    385         free(path);
     385        efree(path);
    386386    } else {
    387387        result = FALSE;
     
    529529                t = EndOfFile;
    530530                break;
     531
     532            #ifdef NMAKE
     533            case '[':
     534                //@todo execute this command!!!
     535                t = False;
     536                condExpr += strlen(condExpr);
     537                break;
     538            #endif
     539
     540
     541            #ifdef NMAKE
     542            case '"':
     543            #endif
    531544            case '$': {
    532545                char    *lhs;
     
    535548                int     varSpecLen;
    536549                Boolean doFree;
     550                #ifdef NMAKE
     551                Boolean fQuoted = (*condExpr == '"');
     552                if (fQuoted)
     553                    condExpr++;
     554                #endif
    537555
    538556                /*
     
    542560                t = Err;
    543561                lhs = Var_Parse(condExpr, VAR_CMD, doEval,&varSpecLen,&doFree);
     562                #ifdef NMAKE
     563                if (lhs == var_Error)
     564                {
     565                    //@todo check if actually parsed correctly.
     566                    doFree = 0;
     567                }
     568                #else
    544569                if (lhs == var_Error) {
    545570                    /*
     
    549574                    return(Err);
    550575                }
     576                #endif
    551577                condExpr += varSpecLen;
    552578
     579                #ifdef NMAKE
     580                if (    (fQuoted && *condExpr != '"')
     581                    ||  (!fQuoted && !isspace((unsigned char) *condExpr) && strchr("!=><", *condExpr) == NULL)
     582                    )
     583                #else
    553584                if (!isspace((unsigned char) *condExpr) &&
    554                     strchr("!=><", *condExpr) == NULL) {
     585                    strchr("!=><", *condExpr) == NULL)
     586                #endif
     587                {
    555588                    Buffer buf;
    556589                    char *cp;
     
    562595
    563596                    if (doFree)
    564                         free(lhs);
    565 
    566                     for (;*condExpr && !isspace((unsigned char) *condExpr);
    567                          condExpr++)
     597                        efree(lhs);
     598
     599                    #ifdef NMAKE
     600                    for (;*condExpr && (fQuoted ? *condExpr != '"' : !isspace((unsigned char) *condExpr)); condExpr++)
     601                    #else
     602                    for (;*condExpr && !isspace((unsigned char) *condExpr); condExpr++)
     603                    #endif
    568604                        Buf_AddByte(buf, (Byte)*condExpr);
    569605
     
    578614                 * Skip whitespace to get to the operator
    579615                 */
     616                #ifdef NMAKE
     617                if (fQuoted && *condExpr == '"')
     618                    condExpr++;
     619                #endif
    580620                while (isspace((unsigned char) *condExpr))
    581621                    condExpr++;
     
    653693                                Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
    654694                                if (freeIt) {
    655                                     free(cp2);
     695                                    efree(cp2);
    656696                                }
    657697                                cp += len - 1;
     
    682722                        t = strcmp(lhs, string) ? True : False;
    683723                    }
    684                     free(string);
     724                    efree(string);
    685725                    if (rhs == condExpr) {
    686726                        if (!qt && *cp == ')')
     
    709749                            if (*CondCvtArg(string, &right) != '\0') {
    710750                                if (freeIt)
    711                                     free(string);
     751                                    efree(string);
    712752                                goto do_string_compare;
    713753                            }
    714754                            if (freeIt)
    715                                 free(string);
     755                                efree(string);
    716756                            if (rhs == condExpr)
    717757                                condExpr += len;
     
    771811error:
    772812                if (doFree)
    773                     free(lhs);
     813                    efree(lhs);
    774814                break;
    775815            }
     
    851891                        }
    852892                        if (doFree) {
    853                             free(val);
     893                            efree(val);
    854894                        }
    855895                        /*
     
    898938                     (invert ? False : True) :
    899939                     (invert ? True : False));
    900                 free(arg);
     940                efree(arg);
    901941                break;
    902942            }
  • trunk/src/kmk/dir.c

    r25 r35  
    469469        } else {
    470470        next:
    471             free(file);
     471            efree(file);
    472472        }
    473473        start = cp+1;
     
    653653 * Results:
    654654 *      The path to the file or NULL. This path is guaranteed to be in a
    655  *      different part of memory than name and so may be safely free'd.
     655 *      different part of memory than name and so may be safely efree'd.
    656656 *
    657657 * Side Effects:
     
    678678    struct stat   stb;      /* Buffer for stat, if necessary */
    679679    Hash_Entry    *entry;   /* Entry for mtimes table */
     680
     681#ifdef NMAKE
     682    cp = name;
     683    while ((cp = strchr(cp, '\\')) != 0)
     684        *cp = '/';
     685#endif
    680686
    681687    /*
     
    863869                return (file);
    864870            } else {
    865                 free (file);
     871                efree (file);
    866872            }
    867873        }
     
    10001006        if (gn->type & OP_MEMBER) {
    10011007            if (fullName != gn->path)
    1002                 free(fullName);
     1008                efree(fullName);
    10031009            return Arch_MemMTime (gn);
    10041010        } else {
     
    11871193
    11881194        Hash_DeleteTable (&p->files);
    1189         free((Address)p->name);
    1190         free((Address)p);
     1195        efree((Address)p->name);
     1196        efree((Address)p);
    11911197    }
    11921198}
  • trunk/src/kmk/for.c

    r25 r35  
    201201        else
    202202            Buf_Destroy(buf, TRUE);
    203         free((Address) sub);
     203        efree((Address) sub);
    204204
    205205        forBuf = Buf_Init(0);
     
    301301    Lst_ForEach(arg.lst, ForExec, (ClientData) &arg);
    302302
    303     free((Address)arg.var);
    304     Lst_Destroy(arg.lst, (void (*) __P((ClientData))) free);
     303    efree((Address)arg.var);
     304    Lst_Destroy(arg.lst, (void (*) __P((ClientData))) efree);
    305305    Buf_Destroy(arg.buf, TRUE);
    306306}
  • trunk/src/kmk/hash.c

    r25 r35  
    144144                for (h = *hp++; h != NULL; h = nexth) {
    145145                        nexth = h->next;
    146                         free((char *)h);
     146                        efree((char *)h);
    147147                }
    148148        }
    149         free((char *)t->bucketPtr);
     149        efree((char *)t->bucketPtr);
    150150
    151151        /*
     
    266266 * Hash_DeleteEntry --
    267267 *
    268  *      Delete the given hash table entry and free memory associated with
     268 *      Delete the given hash table entry and efree memory associated with
    269269 *      it.
    270270 *
     
    291291                if (p == e) {
    292292                        *hp = p->next;
    293                         free((char *)p);
     293                        efree((char *)p);
    294294                        t->numEntries--;
    295295                        return;
     
    420420                }
    421421        }
    422         free((char *)oldhp);
    423 }
     422        efree((char *)oldhp);
     423}
  • trunk/src/kmk/job.c

    r34 r35  
    990990        job->node->made = MADE;
    991991        Make_Update(job->node);
    992         free((Address)job);
     992        efree((Address)job);
    993993    } else if (*status != 0) {
    994994        errors += 1;
    995         free((Address)job);
     995        efree((Address)job);
    996996    }
    997997
     
    12401240#endif /* RMT_NO_EXEC */
    12411241
     1242#ifdef __EMX__
     1243    if ((cpid = fork()) == -1) {
     1244#else
    12421245    if ((cpid = vfork()) == -1) {
     1246#endif
    12431247        Punt("Cannot fork");
    12441248    } else if (cpid == 0) {
     
    18791883                Make_Update(job->node);
    18801884            }
    1881             free((Address)job);
     1885            efree((Address)job);
    18821886            return(JOB_FINISHED);
    18831887        } else {
    1884             free((Address)job);
     1888            efree((Address)job);
    18851889            return(JOB_ERROR);
    18861890        }
     
    21482152                 * There's still more in that thar buffer. This time, though,
    21492153                 * we know there's no newline at the end, so we add one of
    2150                  * our own free will.
     2154                 * our own efree will.
    21512155                 */
    21522156                if (*cp != '\0') {
     
    22112215                 * There's still more in that thar buffer. This time, though,
    22122216                 * we know there's no newline at the end, so we add one of
    2213                  * our own free will.
     2217                 * our own efree will.
    22142218                 */
    22152219                (void) fprintf(stdout, "%s", cp);
     
    27832787
    27842788    /*
    2785      * Do not free up the words themselves, since they might be in use by the
     2789     * Do not efree up the words themselves, since they might be in use by the
    27862790     * shell specification...
    27872791     */
    2788     free(words);
     2792    efree(words);
    27892793    return SUCCESS;
    27902794}
  • trunk/src/kmk/lst.lib/lstConcat.c

    r25 r35  
    4545 *      Function to concatentate two lists.
    4646 */
    47 
    4847#include    "lstInt.h"
    4948
     
    119118            list1->lastPtr->nextPtr = list1->firstPtr;
    120119        }
    121         free ((Address)l2);
     120        efree ((Address)l2);
    122121    } else if (list2->firstPtr != NilListNode) {
    123122        /*
  • trunk/src/kmk/lst.lib/lstDestroy.c

    r25 r35  
    4545 *      Nuke a list and all its resources
    4646 */
    47 
    4847#include        "lstInt.h"
    4948
     
    8483        list->lastPtr->nextPtr = NilListNode;
    8584    else {
    86         free ((Address)l);
     85        efree ((Address)l);
    8786        return;
    8887    }
     
    9291             tln = ln->nextPtr;
    9392             (*freeProc) (ln->datum);
    94              free ((Address)ln);
     93             efree ((Address)ln);
    9594        }
    9695    } else {
    9796        for (ln = list->firstPtr; ln != NilListNode; ln = tln) {
    9897             tln = ln->nextPtr;
    99              free ((Address)ln);
     98             efree ((Address)ln);
    10099        }
    101100    }
    102101
    103     free ((Address)l);
     102    efree ((Address)l);
    104103}
  • trunk/src/kmk/lst.lib/lstForEachFrom.c

    r25 r35  
    106106
    107107        if (tln->flags & LN_DELETED) {
    108             free((char *)tln);
     108            efree((char *)tln);
    109109        }
    110110        tln = next;
  • trunk/src/kmk/main.c

    r34 r35  
    322322                }
    323323                case 'E':
    324                         p = malloc(strlen(optarg) + 1);
    325                         if (!p)
    326                                 Punt("make: cannot allocate memory.");
     324                        p = emalloc(strlen(optarg) + 1);
    327325                        (void)strcpy(p, optarg);
    328326                        (void)Lst_AtEnd(envFirstVars, (ClientData)p);
     
    845843#ifdef POSIX
    846844                #ifdef USE_KLIB
    847                 kEnvSet("MAKEFLAGS", p);
     845                kEnvSet("MAKEFLAGS", p, TRUE);
    848846                #else
    849847                setenv("MAKEFLAGS", p, 1);
     
    851849#else
    852850                #ifdef USE_KLIB
    853                 kEnvSet("MAKE", p);
     851                kEnvSet("MAKE", p, TRUE);
    854852                #else
    855853                setenv("MAKE", p, 1);
     
    887885                        path = cp + 1;
    888886                } while (savec == ':');
    889                 (void)free((Address)vpath);
     887                (void)efree((Address)vpath);
    890888        }
    891889
     
    908906                        char *value;
    909907                        if (expandVars) {
    910                                 p1 = malloc(strlen((char *)Lst_Datum(ln)) + 1 + 3);
    911                                 if (!p1)
    912                                         Punt("make: cannot allocate memory.");
     908                                p1 = emalloc(strlen((char *)Lst_Datum(ln)) + 1 + 3);
    913909                                /* This sprintf is safe, because of the malloc above */
    914910                                (void)sprintf(p1, "${%s}", (char *)Lst_Datum(ln));
     
    920916                        printf("%s\n", value ? value : "");
    921917                        if (p1)
    922                                 free(p1);
     918                                efree(p1);
    923919                }
    924920        }
     
    961957        Lst_Destroy(variables, NOFREE);
    962958        Lst_Destroy(makefiles, NOFREE);
    963         Lst_Destroy(create, (void (*) __P((ClientData))) free);
     959        Lst_Destroy(create, (void (*) __P((ClientData))) efree);
    964960
    965961        /* print the graph now it's been processed if the user requested it */
     
    10931089     * Fork
    10941090     */
     1091#ifdef __EMX__
     1092    switch (cpid = fork()) {
     1093#else
    10951094    switch (cpid = vfork()) {
     1095#endif
    10961096    case 0:
    10971097        /*
     
    11081108        (void) close(fds[1]);
    11091109
     1110        #ifdef OS2
     1111        {
     1112            const char *psz = getenv("COMSPEC");
     1113            if (!psz)
     1114                psz = getenv("OS2_SHELL");
     1115            if (!psz)
     1116                psz = "c:\\os2\\cmd.exe";
     1117            (void) execv(psz, args);
     1118        }
     1119        #else
    11101120        (void) execv("/bin/sh", args);
     1121        #endif
    11111122        _exit(1);
    11121123        /*NOTREACHED*/
     
    13781389
    13791390/*
     1391 * efree --
     1392 *      efree, no change.
     1393 */
     1394void
     1395efree(ptr)
     1396      void *ptr;
     1397{
     1398    if (ptr)
     1399        free(ptr);
     1400}
     1401
     1402/*
    13801403 * enomem --
    13811404 *      die when out of memory.
     
    13971420        struct stat st;
    13981421
     1422#ifdef __EMX__
     1423        if (stat(file, &st) == -1)
     1424#else
    13991425        if (lstat(file, &st) == -1)
     1426#endif
    14001427                return -1;
    14011428
  • trunk/src/kmk/nonints.h

    r25 r35  
    7474char *estrdup __P((const char *));
    7575void *emalloc __P((size_t));
    76 /* efree(x) works when x==NULL. STDC behavior, may need some different
    77  * definition for cross-builds on deficient systems */
    78 #define efree   free
     76void efree __P((void *));
    7977void *erealloc __P((void *, size_t));
    8078void enomem __P((void));
  • trunk/src/kmk/parse.c

    r30 r35  
    252252static void ParseUnreadc __P((int));
    253253static void ParseHasCommands __P((ClientData));
    254 static void ParseDoInclude __P((char *));
     254static void ParseDoInclude __P((char *, char));
    255255static void ParseDoError __P((char *));
    256256#ifdef SYSVINCLUDE
     
    540540         * If we have noted the existence of a .MAIN, it means we need
    541541         * to add the sources of said target to the list of things
    542          * to create. The string 'src' is likely to be free, so we
     542         * to create. The string 'src' is likely to be efree, so we
    543543         * must make a new copy of it. Note that this will only be
    544544         * invoked if the user didn't specify a target on the command
     
    765765
    766766                if (freeIt) {
    767                     free(result);
     767                    efree(result);
    768768                }
    769769                cp += length-1;
     
    14541454
    14551455        Var_Set(line, cp, ctxt);
    1456         free(cp);
     1456        efree(cp);
    14571457    } else if (type == VAR_SHELL) {
    14581458        Boolean freeCmd = FALSE; /* TRUE if the command needs to be freed, i.e.
     
    14721472        res = Cmd_Exec(cp, &err);
    14731473        Var_Set(line, res, ctxt);
    1474         free(res);
     1474        efree(res);
    14751475
    14761476        if (err)
     
    14781478
    14791479        if (freeCmd)
    1480             free(cp);
     1480            efree(cp);
    14811481    } else {
    14821482        /*
     
    16051605 */
    16061606static void
    1607 ParseDoInclude (file)
     1607ParseDoInclude (file, chPre)
    16081608    char          *file;        /* file specification */
     1609    char           chPre;       /* Preprocessor char */
    16091610{
    16101611    char          *fullname;    /* full pathname of file */
     
    16211622    }
    16221623
     1624    #ifndef NMAKE
    16231625    if ((*file != '"') && (*file != '<')) {
    16241626        Parse_Error (PARSE_FATAL,
    1625             ".include filename must be delimited by '\"' or '<'");
     1627            "%cinclude filename must be delimited by '\"' or '<'", chPre);
    16261628        return;
    16271629    }
     1630    #endif
    16281631
    16291632    /*
     
    16371640    } else {
    16381641        isSystem = FALSE;
     1642        #ifdef NMAKE
     1643        if (*file == '"')
     1644            endc = '"';
     1645        else
     1646        {
     1647            endc = '\0';
     1648            file--;
     1649        }
     1650        #else
    16391651        endc = '"';
     1652        #endif
    16401653    }
    16411654
     
    16471660    }
    16481661
     1662    #ifdef NMAKE
     1663    if (endc && *cp != endc) {
     1664    #else
    16491665    if (*cp != endc) {
     1666    #endif
    16501667        Parse_Error (PARSE_FATAL,
    16511668                     "Unclosed %cinclude filename. '%c' expected",
    1652                      '.', endc);
     1669                     chPre, endc);
    16531670        return;
    16541671    }
     
    16921709                fullname = Dir_FindFile(newName, dirSearchPath);
    16931710            }
    1694             free (newName);
     1711            efree (newName);
    16951712            *prefEnd = '/';
    16961713        } else {
    16971714            fullname = (char *)NULL;
    16981715        }
    1699         free (Fname);
     1716        efree (Fname);
    17001717    } else {
    17011718        fullname = (char *)NULL;
     
    17251742    if (fullname == (char *) NULL) {
    17261743        *cp = endc;
    1727         Parse_Error (PARSE_FATAL, "Could not find %s", file);
     1744        Parse_Error (PARSE_FATAL, "Could not find '%s'", file);
    17281745        return;
    17291746    }
    17301747
    1731     free(file);
     1748    efree(file);
    17321749
    17331750    /*
     
    18821899            fullname = Dir_FindFile(newName, dirSearchPath);
    18831900        }
    1884         free (newName);
     1901        efree (newName);
    18851902        *prefEnd = '/';
    18861903    } else {
     
    19771994
    19781995    ifile = (IFile *) Lst_DeQueue (includes);
    1979     free ((Address) fname);
     1996    efree ((Address) fname);
    19801997    fname = ifile->fname;
    19811998    lineno = ifile->lineno;
     
    19832000        (void) fclose (curFILE);
    19842001    if (curPTR) {
    1985         free((Address) curPTR->str);
    1986         free((Address) curPTR);
     2002        efree((Address) curPTR->str);
     2003        efree((Address) curPTR);
    19872004    }
    19882005    curFILE = ifile->F;
    19892006    curPTR = ifile->p;
    1990     free ((Address)ifile);
     2007    efree ((Address)ifile);
    19912008    return (CONTINUE);
    19922009}
     
    20832100        Buf_AddByte(buf, (Byte)'\0');
    20842101        line = (char *)Buf_GetAll(buf, &lineLength);
     2102    #ifdef NMAKE
     2103    } while (skip == 1 && line[0] != '.' && line[0] != '!');
     2104    #else
    20852105    } while (skip == 1 && line[0] != '.');
     2106    #endif
    20862107
    20872108    Buf_Destroy(buf, FALSE);
     
    23282349                 */
    23292350                do {
    2330                     free (line);
     2351                    efree (line);
    23312352                    line = ParseSkipLine(1);
    23322353                } while (line && Cond_Eval(line) != COND_PARSE);
     
    23352356                /*FALLTHRU*/
    23362357            case COND_PARSE:
    2337                 free ((Address) line);
     2358                efree ((Address) line);
    23382359                line = ParseReadLine();
    23392360                break;
     
    23412362                if (For_Eval(line)) {
    23422363                    int ok;
    2343                     free(line);
     2364                    efree(line);
    23442365                    do {
    23452366                        /*
     
    23532374                        }
    23542375                        ok = For_Eval(line);
    2355                         free(line);
     2376                        efree(line);
    23562377                    }
    23572378                    while (ok);
     
    24302451        while ((line = ParseReadLine ()) != NULL) {
    24312452//debugkso: fprintf(stderr, "%s(%d): inLine=%d line=%s\n", fname, lineno, inLine, line);
     2453            #ifdef NMAKE
     2454            if (*line == '.' || *line == '!') {
     2455            #else
    24322456            if (*line == '.') {
     2457            #endif
    24332458                /*
    24342459                 * Lines that begin with the special character are either
     
    24392464                }
    24402465                if (strncmp (cp, "include", 7) == 0) {
    2441                     ParseDoInclude (cp + 7);
     2466                    ParseDoInclude (cp + 7, *line);
    24422467                    goto nextLine;
    24432468                } else if (strncmp (cp, "error", 5) == 0) {
     
    25532578
    25542579                    cp = Var_Subst (NULL, line, VAR_CMD, TRUE);
    2555                     free (line);
     2580                    efree (line);
    25562581                    line = cp;
    25572582
     
    25732598            nextLine:
    25742599
    2575             free (line);
     2600            efree (line);
    25762601        }
    25772602        /*
     
    26142639Parse_End()
    26152640{
    2616     Lst_Destroy(targCmds, (void (*) __P((ClientData))) free);
     2641    Lst_Destroy(targCmds, (void (*) __P((ClientData))) efree);
    26172642    if (targets)
    26182643        Lst_Destroy(targets, NOFREE);
  • trunk/src/kmk/str.c

    r25 r35  
    7575    if (argv) {
    7676        if (argv[0])
    77             free(argv[0]);
    78         free((Address) argv);
     77            efree(argv[0]);
     78        efree((Address) argv);
    7979    }
    8080    if (buffer)
    81         free(buffer);
     81        efree(buffer);
    8282}
    8383
     
    120120        memcpy(result + len1, s2, len2 + 1);
    121121
    122         /* free original strings */
     122        /* efree original strings */
    123123        if (flags & STR_DOFREE) {
    124                 (void)free(s1);
    125                 (void)free(s2);
     124                (void)efree(s1);
     125                (void)efree(s2);
    126126        }
    127127        return(result);
     
    155155        if ((len = strlen(str) + 1) > curlen) {
    156156                if (buffer)
    157                     free(buffer);
     157                    efree(buffer);
    158158                buffer = emalloc(curlen = len);
    159159        }
  • trunk/src/kmk/suff.c

    r25 r35  
    137137    struct _Src     *parent;    /* The Src for which this is a source */
    138138    GNode           *node;      /* The node describing the file */
    139     int             children;   /* Count of existing children (so we don't free
     139    int             children;   /* Count of existing children (so we don't efree
    140140                                 * this thing too early or never nuke it) */
    141141#ifdef DEBUG_SRC
     
    359359    Lst_Destroy (s->searchPath, Dir_Destroy);
    360360
    361     free ((Address)s->name);
    362     free ((Address)s);
     361    efree ((Address)s->name);
     362    efree ((Address)s);
    363363}
    364364
     
    614614         * New specification for transformation rule. Just nuke the old list
    615615         * of commands so they can be filled in again... We don't actually
    616          * free the commands themselves, because a given command can be
     616         * efree the commands themselves, because a given command can be
    617617         * attached to several different transformations.
    618618         */
     
    905905
    906906    Var_Set(".INCLUDES", ptr = Dir_MakeFlags("-I", inIncludes), VAR_GLOBAL);
    907     free(ptr);
     907    efree(ptr);
    908908    Var_Set(".LIBS", ptr = Dir_MakeFlags("-L", inLibs), VAR_GLOBAL);
    909     free(ptr);
     909    efree(ptr);
    910910
    911911    Lst_Destroy(inIncludes, Dir_Destroy);
     
    10811081 *
    10821082 * Side Effects:
    1083  *      The memory is free'd.
     1083 *      The memory is efree'd.
    10841084 *----------------------------------------------------------------------
    10851085 */
     
    11051105        s = (Src *) Lst_Datum (ln);
    11061106        if (s->children == 0) {
    1107             free ((Address)s->file);
     1107            efree ((Address)s->file);
    11081108            if (!s->parent)
    1109                 free((Address)s->pref);
     1109                efree((Address)s->pref);
    11101110            else {
    11111111#ifdef DEBUG_SRC
     
    11171117            }
    11181118#ifdef DEBUG_SRC
    1119             printf("free: [l=%x] p=%x %d\n", l, s, s->children);
     1119            printf("efree: [l=%x] p=%x %d\n", l, s, s->children);
    11201120            Lst_Destroy(s->cp, NOFREE);
    11211121#endif
    11221122            Lst_Remove(l, ln);
    1123             free ((Address)s);
     1123            efree ((Address)s);
    11241124            t |= 1;
    11251125            Lst_Close(l);
     
    11871187            printf("remove %x from %x\n", s, srcs);
    11881188#endif
    1189             free(ptr);
     1189            efree(ptr);
    11901190            break;
    11911191        }
     
    12681268                     * Hot Damn! Create a new Src structure to describe
    12691269                     * this transformation (making sure to duplicate the
    1270                      * source node's name so Suff_FindDeps can free it
     1270                     * source node's name so Suff_FindDeps can efree it
    12711271                     * again (ick)), and return the new structure.
    12721272                     */
     
    14011401
    14021402                        if (doFree) {
    1403                             free(junk);
     1403                            efree(junk);
    14041404                        }
    14051405                    } else if (*cp == '\\' && *cp != '\0') {
     
    14441444             * Free the result
    14451445             */
    1446             free((char *)cp);
     1446            efree((char *)cp);
    14471447        }
    14481448        /*
     
    16031603    tname = str_concat(s->name, t->name, 0);
    16041604    ln = Lst_Find(transforms, (ClientData)tname, SuffGNHasNameP);
    1605     free(tname);
     1605    efree(tname);
    16061606
    16071607    if (ln == NILLNODE) {
     
    23542354 *
    23552355 * Side Effects:
    2356  *      The memory is free'd.
     2356 *      The memory is efree'd.
    23572357 *----------------------------------------------------------------------
    23582358 */
  • trunk/src/kmk/targ.c

    r25 r35  
    213213
    214214
    215     free(gn->name);
     215    efree(gn->name);
    216216    efree(gn->path);
    217217
     
    224224    Lst_Destroy(gn->context, NOFREE);
    225225    Lst_Destroy(gn->commands, NOFREE);
    226     free((Address)gn);
     226    efree((Address)gn);
    227227}
    228228
  • trunk/src/kmk/util.c

    r25 r35  
    5252        return NULL;
    5353    len = strlen(str) + 1;
    54     if ((p = malloc(len)) == NULL)
     54    if ((p = emalloc(len)) == NULL)
    5555        return NULL;
    5656
     
    6060#endif
    6161
    62 #if defined(sun) || defined(__hpux) || defined(__sgi)
     62#if defined(sun) || defined(__hpux) || defined(__sgi) || defined(__EMX__) || (defined(OS2) && defined(__IBMC__))
    6363
    6464int
     
    7070    register char *p;
    7171    int len = strlen(name) + strlen(value) + 2; /* = \0 */
    72     char *ptr = (char*) malloc(len);
     72    char *ptr = (char*) emalloc(len);
    7373
    7474    (void) dum;
     
    9090
    9191    len = putenv(ptr);
    92 /*    free(ptr); */
     92    efree(ptr);
    9393    return len;
    9494}
  • trunk/src/kmk/var.c

    r30 r35  
    412412{
    413413    Var *v = (Var *) vp;
    414     free(v->name);
     414    efree(v->name);
    415415    Buf_Destroy(v->val, TRUE);
    416     free((Address) v);
     416    efree((Address) v);
    417417}
    418418
     
    505505    if (ctxt == VAR_CMD) {
    506506        #ifdef USE_KLIB
    507         kEnvSet(name, val);
     507        kEnvSet(name, val, TRUE);
    508508        #else
    509509        setenv(name, val, 1);
     
    593593        return(FALSE);
    594594    } else if (v->flags & VAR_FROM_ENV) {
    595         free(v->name);
     595        efree(v->name);
    596596        Buf_Destroy(v->val, TRUE);
    597         free((char *)v);
     597        efree((char *)v);
    598598    }
    599599    return(TRUE);
     
    626626        if (v->flags & VAR_FROM_ENV) {
    627627            Buf_Destroy(v->val, FALSE);
    628             free((Address) v);
     628            efree((Address) v);
    629629            *frp = p;
    630630        }
     
    11681168    regerror(err, pat, errbuf, errlen);
    11691169    Error("%s: %s", str, errbuf);
    1170     free(errbuf);
     1170    efree(errbuf);
    11711171}
    11721172
     
    14221422                    Buf_AddBytes(buf, strlen(cp2), (Byte *) cp2);
    14231423                    if (freeIt)
    1424                         free(cp2);
     1424                        efree(cp2);
    14251425                    cp += len - 1;
    14261426                } else {
     
    15351535    Boolean         err;        /* TRUE if undefined variables are an error */
    15361536    int             *lengthPtr; /* OUT: The length of the specification */
    1537     Boolean         *freePtr;   /* OUT: TRUE if caller should free result */
     1537    Boolean         *freePtr;   /* OUT: TRUE if caller should efree result */
    15381538{
    15391539    register char   *tstr;      /* Pointer into str */
     
    16301630                                Buf_AddBytes(buf, strlen(rval), (Byte *) rval);
    16311631                                if (rfree)
    1632                                         free(rval);
     1632                                        efree(rval);
    16331633                        }
    16341634                        tstr += rlen - 1;
     
    17081708                        /*
    17091709                         * Resulting string is dynamically allocated, so
    1710                          * tell caller to free it.
     1710                         * tell caller to efree it.
    17111711                         */
    17121712                        *freePtr = TRUE;
     
    19361936                    }
    19371937                    if (copy) {
    1938                         free(pattern);
     1938                        efree(pattern);
    19391939                    }
    19401940                    break;
     
    19901990                                Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
    19911991                                if (freeIt) {
    1992                                     free(cp2);
     1992                                    efree(cp2);
    19931993                                }
    19941994                                cp += len - 1;
     
    20142014                        *lengthPtr = cp - start + 1;
    20152015                        if (*freePtr) {
    2016                             free(str);
     2016                            efree(str);
    20172017                        }
    20182018                        Buf_Destroy(buf, TRUE);
     
    20612061                            cp += len - 1;
    20622062                            if (freeIt) {
    2063                                 free(cp2);
     2063                                efree(cp2);
    20642064                            }
    20652065                        } else if (*cp == '&') {
     
    20792079                        *lengthPtr = cp - start + 1;
    20802080                        if (*freePtr) {
    2081                             free(str);
     2081                            efree(str);
    20822082                        }
    20832083                        Buf_Destroy(buf, TRUE);
     
    21082108                     * Free the two strings.
    21092109                     */
    2110                     free(pattern.lhs);
    2111                     free(pattern.rhs);
     2110                    efree(pattern.lhs);
     2111                    efree(pattern.rhs);
    21122112                    break;
    21132113                }
     
    21292129                        *lengthPtr = cp - start + 1;
    21302130                        if (*freePtr)
    2131                             free(str);
     2131                            efree(str);
    21322132                        if (delim != '\0')
    21332133                            Error("Unclosed substitution for %s (%c missing)",
     
    21382138                    if ((pattern.replace = VarGetPattern(ctxt, err, &cp,
    21392139                        delim, NULL, NULL, NULL)) == NULL){
    2140                         free(re);
     2140                        efree(re);
    21412141
    21422142                        /* was: goto cleanup */
    21432143                        *lengthPtr = cp - start + 1;
    21442144                        if (*freePtr)
    2145                             free(str);
     2145                            efree(str);
    21462146                        if (delim != '\0')
    21472147                            Error("Unclosed substitution for %s (%c missing)",
     
    21652165
    21662166                    error = regcomp(&pattern.re, re, REG_EXTENDED);
    2167                     free(re);
     2167                    efree(re);
    21682168                    if (error)  {
    21692169                        *lengthPtr = cp - start + 1;
    21702170                        VarREError(error, &pattern.re, "RE substitution error");
    2171                         free(pattern.replace);
     2171                        efree(pattern.replace);
    21722172                        return (var_Error);
    21732173                    }
     
    21832183                                       (ClientData) &pattern);
    21842184                    regfree(&pattern.re);
    2185                     free(pattern.replace);
    2186                     free(pattern.matches);
     2185                    efree(pattern.replace);
     2186                    efree(pattern.matches);
    21872187                    break;
    21882188                }
     
    23272327
    23282328            if (*freePtr) {
    2329                 free (str);
     2329                efree (str);
    23302330            }
    23312331            str = newStr;
     
    23572357        } else {
    23582358            /*
    2359              * Returning the value unmodified, so tell the caller to free
     2359             * Returning the value unmodified, so tell the caller to efree
    23602360             * the thing.
    23612361             */
     
    23632363        }
    23642364        Buf_Destroy(v->val, destroy);
    2365         free((Address)v);
     2365        efree((Address)v);
    23662366    } else if (v->flags & VAR_JUNK) {
    23672367        /*
    2368          * Perform any free'ing needed and set *freePtr to FALSE so the caller
    2369          * doesn't try to free a static pointer.
     2368         * Perform any efree'ing needed and set *freePtr to FALSE so the caller
     2369         * doesn't try to efree a static pointer.
    23702370         */
    23712371        if (*freePtr) {
    2372             free(str);
     2372            efree(str);
    23732373        }
    23742374        *freePtr = FALSE;
    23752375        Buf_Destroy(v->val, TRUE);
    2376         free((Address)v);
     2376        efree((Address)v);
    23772377        if (dynamic) {
    23782378            str = emalloc(*lengthPtr + 1);
     
    25412541                Buf_AddBytes (buf, strlen (val), (Byte *)val);
    25422542                if (doFree) {
    2543                     free ((Address)val);
     2543                    efree ((Address)val);
    25442544                }
    25452545            }
Note: See TracChangeset for help on using the changeset viewer.