Changeset 7503


Ignore:
Timestamp:
06/27/18 16:14:00 (3 months ago)
Author:
paulf
Message:

yet another clean up of this code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/reporting/gmewhtmlemail/gmewhtmlemail.c

    r7487 r7503  
    3131 *****************************************************************************/ 
    3232 
    33 #define VERSION_STR "1.7.6 - 2018-06-25" 
     33#define VERSION_STR "1.7.7 - 2018-06-27" 
    3434 
    3535#define MAX_STRING_SIZE 1024    /* used for many static string place holders */ 
     
    471471int read_RAD_info( char *path ) { 
    472472    int i, j, k, max_region = 0, max_area = 0; 
    473     FILE *fp = fopen( path, "r" ); 
     473    FILE *fp; 
    474474    char buffer[300], word[20]; 
    475475    char *line, *brkt; 
     
    487487    } 
    488488    fp = fopen( path, "r" ); 
    489     if ( fp == NULL ) 
     489    if ( fp == NULL ) { 
     490        logit("et", "Error opening RAD file %s\n", path); 
    490491        return -1; 
     492    } 
     493    logit("et", "Reading RAD file from %s\n", path); 
    491494 
    492495    lineno++; 
    493496    line = fgets(buffer, 290, fp); 
    494     if ( strcmp( line, "#Regions\n" ) ) { 
     497    if ( strncmp( line, "#Region", 6 ) ) { 
    495498        logit("e","gmewhtmlemail: First line is not Regions header\n"); 
    496499        fclose(fp); 
     
    501504//     printf("Line(a) %d: %s", lineno, line); 
    502505    while ( line != NULL ) { 
    503         if ( strcmp( line, "#Area Offices\n" )==0 ) { 
     506        if ( strncmp( line, "#Area", 5 )==0 ) { 
    504507            stage += 1; 
    505508            lineno++; 
     
    532535    } 
    533536    while ( line != NULL ) { 
    534         if ( strcmp( line, "#Dams\n" )==0 ) { 
     537        if ( strncmp( line, "#Dams", 4 )==0 ) { 
    535538            stage += 1; 
    536539            lineno++; 
     
    584587        dam_tbl[dam_count].lon = atof( my_strtok_r(&brkt) ); 
    585588        strcpy( dam_tbl[dam_count].station, my_strtok_r( &brkt )); 
     589        // remove cariage return and newlines from station name string 
     590        i = strlen(dam_tbl[dam_count].station); 
     591        if (dam_tbl[dam_count].station[i-1]=='\n') dam_tbl[dam_count].station[i-1]='\0'; 
     592        i = strlen(dam_tbl[dam_count].station); 
     593        if (dam_tbl[dam_count].station[i-1]=='\r') dam_tbl[dam_count].station[i-1]='\0'; 
    586594        dam_tbl[dam_count].dam_id = dam_count; 
    587595        dam_order[dam_count] = dam_tbl+dam_count; 
     
    595603        logit("","Dams (%d):\n", dam_count); 
    596604        for ( i=0; i<dam_count; i++ ) 
    597             logit( "","   %2d %-3s %-3s (%10.4f,%10.4f) '%s'\n", i, 
     605            logit( "","   %2d %-3s %-3s (%10.4f,%10.4f) '%s' site=%s\n", i, 
    598606                   region_abbrs[dam_tbl[i].region_id], area_abbrs[dam_tbl[i].area_id], 
    599                    dam_tbl[i].lon, dam_tbl[i].lat, dam_tbl[i].name); 
     607                   dam_tbl[i].lon, dam_tbl[i].lat, dam_tbl[i].name, dam_tbl[i].station); 
    600608    } 
    601609    fclose( fp ); 
Note: See TracChangeset for help on using the changeset viewer.