~ubuntu-branches/ubuntu/raring/perl-tk/raring

« back to all changes in this revision

Viewing changes to pTk/mTk/tixGeneric/tixImgXpm.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Tuckley
  • Date: 2008-02-15 13:56:59 UTC
  • mfrom: (1.1.3 upstream) (4.1.1 hardy)
  • Revision ID: james.westby@ubuntu.com-20080215135659-ru2oqlykuju20fav
Tags: 1:804.028-1
* New Upstream Release (Closes: #463080).
* Update to Debhelper v5.
* Build with XFT=1 (Closes: #411129).

Show diffs side-by-side

added added

removed removed

Lines of Context:
514
514
    char * fileName;
515
515
    int * numLines_return;
516
516
{
517
 
    int fileId, size;
 
517
    Tcl_Channel chan;
 
518
    int size;
518
519
    char ** data;
519
520
    struct stat statBuf;
520
521
    char *cmdBuffer = NULL;
525
526
        goto error;
526
527
    }
527
528
 
528
 
    fileId = open(fileName, O_RDONLY, 0);
529
 
    if (fileId < 0) {
530
 
        Tcl_AppendResult(interp, "couldn't read file \"", fileName,
531
 
                "\": ", Tcl_PosixError(interp), (char *) NULL);
532
 
        goto error;
533
 
    }
534
 
    if (fstat(fileId, &statBuf) == -1) {
535
 
        Tcl_AppendResult(interp, "couldn't stat file \"", fileName,
536
 
                "\": ", Tcl_PosixError(interp), (char *) NULL);
537
 
        close(fileId);
538
 
        goto error;
539
 
    }
540
 
    cmdBuffer = (char *) ckalloc((unsigned) statBuf.st_size+1);
541
 
    size = read(fileId, cmdBuffer, (size_t) statBuf.st_size);
 
529
    chan = Tcl_OpenFileChannel(interp, fileName, "r", 0);
 
530
    if (chan == NULL) {
 
531
        goto error;
 
532
    }
 
533
 
 
534
    size = Tcl_Seek(chan, 0, SEEK_END);
 
535
    if (size == -1) {
 
536
        Tcl_AppendResult(interp, "couldn't seek to end of file \"", fileName,
 
537
                "\": ", Tcl_PosixError(interp), (char *) NULL);
 
538
        Tcl_Close(interp, chan);
 
539
        goto error;
 
540
    }
 
541
 
 
542
    /* seek back to beginning */
 
543
    if (Tcl_Seek(chan, 0, SEEK_SET) == -1) {
 
544
        goto error;
 
545
    }
 
546
 
 
547
    cmdBuffer = (char *) ckalloc((unsigned) size+1);
 
548
    size = Tcl_Read(chan, cmdBuffer, size);
542
549
    if (size < 0) {
543
550
        Tcl_AppendResult(interp, "error in reading file \"", fileName,
544
 
                "\": ", Tcl_PosixError(interp), (char *) NULL);
545
 
        close(fileId);
 
551
                         "\": ", Tcl_PosixError(interp), (char *) NULL);
 
552
        Tcl_Close(interp,chan);
546
553
        goto error;
547
554
    }
548
 
    if (close(fileId) != 0) {
 
555
 
 
556
    if (Tcl_Close(interp,chan) != TCL_OK) {
549
557
        Tcl_AppendResult(interp, "error closing file \"", fileName,
550
 
                "\": ", Tcl_PosixError(interp), (char *) NULL);
 
558
                         "\": ", Tcl_PosixError(interp), (char *) NULL);
551
559
        goto error;
552
560
    }
553
561
    cmdBuffer[size] = 0;