Changeset 1993 for trunk/base


Ignore:
Timestamp:
Feb 6, 2003, 11:28:48 AM (17 years ago)
Author:
eric
Message:

Stash the last few lines from SystemCmd output. It's not terribly space
efficient, and nothing is actually done with it yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/pextlib1.0/Pextlib.c

    r1500 r1993  
    5050
    5151#define BUFSIZ 1024
     52#define CBUFSIZ 30
    5253
    5354#if !defined(__APPLE__)
     
    123124{
    124125        char buf[BUFSIZ];
     126        char circbuf[CBUFSIZ][BUFSIZ];
     127        char errbuf[CBUFSIZ * BUFSIZ];
    125128        char *args[4];
    126129        char *cmdstring;
    127130        FILE *pdes;
    128131        int fdset[2], nullfd;
    129         int ret;
     132        int fline, pos, ret;
    130133        pid_t pid;
    131134        Tcl_Obj *tcl_result;
     
    173176
    174177        /* read from simulated popen() pipe */
     178        pos = 0;
     179        bzero(circbuf, sizeof(circbuf));
    175180        while (fgets(buf, BUFSIZ, pdes) != NULL) {
    176                 int ret = ui_info(interp, buf);
     181                memcpy(circbuf[pos++ % CBUFSIZ], buf, BUFSIZ);
     182                ret = ui_info(interp, buf);
    177183                if (ret != TCL_OK)
    178184                        return ret;
    179185        }
    180186        fclose(pdes);
     187
     188        bzero(errbuf, sizeof(errbuf));
     189        for (fline = pos; pos < fline + CBUFSIZ; pos++)
     190                strcat(errbuf, circbuf[pos % CBUFSIZ]);
    181191
    182192        if (wait(&ret) != pid)
Note: See TracChangeset for help on using the changeset viewer.