IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 12, 2008, 3:42:23 PM (18 years ago)
Author:
Paul Price
Message:

Change aborts to errors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfig.c

    r16341 r16414  
    12271227    PS_ASSERT_PTR_NON_NULL(argv, NULL);
    12281228
    1229     int Narg;
     1229    int Narg;                           // Argument number
    12301230
    12311231    // we load all input files onto a psArray, to be parsed later
     
    12641264
    12651265    // load the list from the supplied text file
    1266     if (list && strlen(list) > 0 && (Narg = psArgumentGet (*argc, argv, list))) {
    1267         int nItems;
    1268         char line[1024]; // XXX limits the list lines to 1024 chars
    1269         char word[1024];
    1270         char *filename;
    1271 
     1266    if (list && strlen(list) > 0 && (Narg = psArgumentGet(*argc, argv, list))) {
    12721267        psArgumentRemove (Narg, argc, argv);
    12731268        FILE *f = fopen (argv[Narg], "r");
    1274         if (f == NULL) {
    1275             psAbort("unable to open specified list file");
    1276         }
    1277         while (fgets (line, 1024, f) != NULL) {
    1278             nItems = sscanf (line, "%s", word);
     1269        if (!f) {
     1270            psError(PS_ERR_IO, true, "Unable to open specified list file");
     1271            psFree(input);
     1272            return NULL;
     1273        }
     1274
     1275        // XXX Reading the list should be reimplemented using psSlurp
     1276
     1277        char line[1024]; // XXX limits the list lines to 1024 chars
     1278        while (fgets(line, 1024, f) != NULL) {
     1279            char word[1024];
     1280            int nItems = sscanf(line, "%s", word);
    12791281            switch (nItems) {
    1280             case 0:
     1282              case 0:
    12811283                break;
    1282             case 1:
    1283                 filename = psStringCopy (word);
    1284                 psArrayAdd (input, 16, filename);
    1285                 psFree (filename);
    1286                 break;
    1287             default:
     1284              case 1: {
     1285                  psString filename = psStringCopy(word);
     1286                  psArrayAdd(input, 16, filename);
     1287                  psFree(filename);
     1288                  fclose(f);
     1289                  break;
     1290              }
     1291              default:
    12881292                // rigid format, no comments allowed?
    1289                 psAbort("error parsing input list file");
    1290                 break;
    1291             }
    1292         }
    1293         psArgumentRemove (Narg, argc, argv);
     1293                psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to parse file list: spaces detected.");
     1294                psFree(input);
     1295                fclose(f);
     1296                return NULL;
     1297            }
     1298        }
     1299        psArgumentRemove(Narg, argc, argv);
     1300        fclose(f);
    12941301    }
    12951302
Note: See TracChangeset for help on using the changeset viewer.