[Trainsched-commit] trainsched timetable.c,1.2.2.2,1.2.2.3
Brought to you by:
philm
|
From: Steve M. <sma...@us...> - 2009-05-05 19:20:51
|
Update of /cvsroot/trainsched/trainsched In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23437 Modified Files: Tag: PDB_VER2 timetable.c Log Message: Fix: New abbreviations scheme to work with timetable PDB 1.0 ABBR file. Index: timetable.c =================================================================== RCS file: /cvsroot/trainsched/trainsched/timetable.c,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -C2 -d -r1.2.2.2 -r1.2.2.3 *** timetable.c 4 May 2009 17:21:43 -0000 1.2.2.2 --- timetable.c 5 May 2009 19:20:34 -0000 1.2.2.3 *************** *** 114,119 **** /* * Get the Abbreviations. This function sets the global variable Abbreviations. ! * For version 0.1 PDB files this is either from a defined database, or default ! * values if the database does not exist. For a 0.2 PDB file then it is from * within the PDB itself. */ --- 114,119 ---- /* * Get the Abbreviations. This function sets the global variable Abbreviations. ! * For version 1.0 PDB files this is either from a defined 'ABBR' PDB, or default ! * values if the database does not exist. For a 2.0 PDB file then it is from * within the PDB itself. */ *************** *** 141,172 **** { hAbbrevRec = DmQueryRecord(hAbbrevDb, 0); ! // StrCopy(szAbbreviations, MemHandleLock(hAbbrevRec)); ! MemHandleUnlock(hAbbrevRec); ! /* Convert '|' to '\n'. */ ! // strLen = StrLen(szAbbreviations); ! // for (i=0; i<strLen; i++) ! // if (szAbbreviations[i] == '|') szAbbreviations[i] = '\n'; ! nNumRecords = DmNumRecords(hAbbrevDb); /* Read in the abbreviations. */ ! for (i=1; i<=MAX_ABBREVIATIONS; i++) { /* Default to an empty string. */ ! StrCopy(Abbreviations[i], ""); ! /* Ensure index is in range because some releases will */ ! /* display fatal error message if DmQueryRecords() called */ ! /* an out-of-range record number. */ ! if (i <= nNumRecords) { hAbbrevRec = DmQueryRecord(hAbbrevDb, i); if (hAbbrevRec != NULL) { ! StrCopy(Abbreviations[i], MemHandleLock(hAbbrevRec)); MemHandleUnlock(hAbbrevRec); } } } ! numabbrev = i; } } --- 141,185 ---- { hAbbrevRec = DmQueryRecord(hAbbrevDb, 0); ! if (hAbbrevRec) { ! recordP = MemHandleLock(hAbbrevRec); ! if (recordP) { ! strPos = 0; ! recPos = 0; ! while (recordP[recPos] != '\0') { ! if(recordP[recPos] == '|') { ! AbbrevDeffs[numabbrev][strPos]='\0'; ! numabbrev++; ! strPos=0; ! } else { ! AbbrevDeffs[numabbrev][strPos]=recordP[recPos]; ! if (strPos < ABDEFLENGTH-1) strPos++; // Don't overrun. ! } ! recPos++; ! } ! AbbrevDeffs[numabbrev][strPos]='\0'; ! numabbrev++; ! // release lock on record. ! MemHandleUnlock(hAbbrevRec); ! } ! } ! nNumRecords = DmNumRecords(hAbbrevDb); /* Read in the abbreviations. */ ! for (i=1; i<nNumRecords; i++) { /* Default to an empty string. */ ! StrCopy(Abbreviations[i-1], ""); ! if (i-1 < MAX_ABBREVIATIONS) { hAbbrevRec = DmQueryRecord(hAbbrevDb, i); if (hAbbrevRec != NULL) { ! StrNCopy(Abbreviations[i-1], MemHandleLock(hAbbrevRec), ABBREVLENGTH-1); MemHandleUnlock(hAbbrevRec); } } } ! numabbrev = i-1; } } |