Ignore:
Timestamp:
Jul 12, 2013 11:57:45 AM (11 years ago)
Author:
gah
Message:

fix multiple barchart results, fix PDB reader, dynamically create tabs for vtkviewer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/src/RpPdbToVtk.c

    r3665 r3782  
    3232
    3333static INLINE char *
    34 GetLine(char **stringPtr, const char *endPtr)
     34GetLine(char **stringPtr, const char *endPtr, int *lengthPtr)
    3535{
    3636    char *line, *p;
     
    4040        if (*p == '\n') {
    4141            *stringPtr = p + 1;
     42            *lengthPtr = p - line;
    4243            return line;
    4344        }
     
    298299
    299300    symbolIndex = elemIndex = -1;
    300 
     301    elemName = SkipSpaces(elemName);
    301302    for (p = symbolNames; *p != NULL; p++) {
    302303        if (strcasecmp(elemName, *p) == 0) {
     
    305306        }
    306307    }
     308    symbolName = SkipSpaces(symbolName);
    307309    for (p = symbolNames; *p != NULL; p++) {
    308310        if (strcasecmp(symbolName, *p) == 0) {
     
    360362    objPtr = NULL;
    361363    for (p = string, pend = p + length; p < pend; /*empty*/) {
    362         char *line;
     364        char *line, *q;
    363365        char c;
    364 
    365         line = GetLine(&p, pend);
     366        int lineLength;
     367
     368        line = GetLine(&p, pend, &lineLength);
    366369        if (line >= pend) {
    367370            break;                      /* EOF */
     
    381384            int atom;
    382385
     386            if (lineLength < 47) {
     387                Tcl_AppendResult(interp, "short ATOM line \"", line, "\"",
     388                        (char *)NULL);
     389                goto error;
     390            }           
    383391            strncpy(buf, line + 6, 5);
    384392            buf[5] = '\0';
     
    427435            }
    428436            Tcl_ListObjAppendElement(interp, pointsObjPtr, Tcl_NewDoubleObj(z));
    429             strncpy(symbolName, line + 77, 2);
    430             symbolName[2] = '\0';
    431 
     437            symbolName[0] = '\0';
     438            if (lineLength >= 78) {
     439                symbolName[0] = line[76];
     440                symbolName[1] = line[77];
     441                symbolName[2] = '\0';
     442            }
    432443            atom = VerifyElement(SkipSpaces(atomName), SkipSpaces(symbolName));
    433444            if (atom < 0) {
    434                 Tcl_AppendResult(interp, "bad atom/element \"", atomName,
    435                                  "\" \"", symbolName, "\"", (char *)NULL);
     445                Tcl_AppendResult(interp, "bad atom \"", atomName,
     446                        "\" or element \"", symbolName, "\"", (char *)NULL);
    436447                goto error;
    437448            }
Note: See TracChangeset for help on using the changeset viewer.