Changeset 9873
- Timestamp:
- Nov 6, 2006, 6:35:21 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/types/psMetadataConfig.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psMetadataConfig.c
r9872 r9873 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.1 09$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-11-07 04: 21:05$12 * @version $Revision: 1.110 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-11-07 04:35:21 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 1227 1227 { 1228 1228 // Check for NULL file name 1229 PS_ASSERT_PTR_NON_NULL(filename, NULL);1229 PS_ASSERT_PTR_NON_NULL(filename, NULL); 1230 1230 1231 1231 // Attempt to open specified file … … 1296 1296 bool overwrite) 1297 1297 { 1298 psArray* parseLevelInfoArray = NULL;1299 psS32 nestingLevel = 0; 1300 p_psParseLevelInfo* topLevelInfo = NULL;1298 bool allocedMD = false; 1299 1300 PS_ASSERT_PTR_NON_NULL(str, NULL); 1301 1301 1302 1302 // Initialise nFail, if provided … … 1307 1307 // Allocate metadata if necessary 1308 1308 if (md == NULL) { 1309 allocedMD = true; 1309 1310 md = psMetadataAlloc(); 1310 1311 } 1311 1312 1312 1313 // Allocate array to store parse level information 1313 p arseLevelInfoArray = psArrayAllocEmpty(INITIAL_LENGTH);1314 psArray *parseLevelInfoArray = psArrayAllocEmpty(INITIAL_LENGTH); 1314 1315 1315 1316 // Set parse level info for the top level 1316 topLevelInfo = p_psParseLevelInfoAlloc();1317 p_psParseLevelInfo *topLevelInfo = p_psParseLevelInfoAlloc(); 1317 1318 topLevelInfo->metadata = psMemIncrRefCounter(md); 1318 p arseLevelInfoArray = psArrayAdd(parseLevelInfoArray, 1, topLevelInfo);1319 psArrayAdd(parseLevelInfoArray, 0, topLevelInfo); 1319 1320 psFree(topLevelInfo); 1320 1321 1322 psList *doc = psStringSplit(str, "\n", false); 1323 if (!doc) { 1324 psError(PS_ERR_UNKNOWN, false, "failed to split string: %s", str); 1325 psFree(parseLevelInfoArray); 1326 if (allocedMD) { 1327 psFree(md); 1328 } 1329 return NULL; 1330 } 1331 if (psListLength(doc) == 0) { 1332 psError(PS_ERR_UNKNOWN, false, "string contained no lines"); 1333 psFree(doc); 1334 psFree(parseLevelInfoArray); 1335 if (allocedMD) { 1336 psFree(md); 1337 } 1338 return NULL; 1339 } 1340 1341 // clear the error stack so we can call psError(..., false, ...) and let 1342 // errors from the parse loop accumulate 1343 psErrorClear(); 1344 1321 1345 // While loop to parse the file 1322 psErrorClear(); // so we can call psError(..., false, ...)1323 1324 psList *doc = psStringSplit(str, "\n", false);1325 if (!doc || doc->n == 0) {1326 if (doc != NULL)1327 psFree(doc);1328 psFree(parseLevelInfoArray);1329 psFree(md);1330 return NULL;1331 }1332 1333 1346 long lineCount = 0; 1334 1347 char *line = NULL; 1348 psS32 nestingLevel = 0; 1335 1349 psListIterator *iter = psListIteratorAlloc(doc, 0, false); 1336 while ((line = psListGetAndIncrement(iter))) {1350 while ((line = psListGetAndIncrement(iter))) { 1337 1351 lineCount++; // indexed from 1 1338 1352 1339 if (!parseLine(&nestingLevel, parseLevelInfoArray, line, lineCount,1340 overwrite)) {1353 if (!parseLine(&nestingLevel, parseLevelInfoArray, line, lineCount, 1354 overwrite)) { 1341 1355 if (nFail != NULL) { 1342 1356 (*nFail)++;
Note:
See TracChangeset
for help on using the changeset viewer.
