Changeset 11407


Ignore:
Timestamp:
02/13/12 11:38:48 (13 years ago)
Author:
Mathieu Morlighem
Message:

minor changes to Synchronize.sh so that it errors out when string not found

Location:
issm/trunk-jpl/src/c
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/EnumDefinitions/Synchronize.sh

    r11404 r11407  
    99rm $ISSM_TIER/src/c/modules/EnumToStringx/EnumToStringx.cpp
    1010rm $ISSM_TIER/src/c/modules/StringToEnumx/StringToEnumx.cpp
     11
     12#Get number of enums
     13NUMENUMS=$(wc -l temp | awk '{printf("%s",$1);}');
    1114
    1215#Take care of EnumToModelField.m first (easy)
     
    100103
    101104#core
    102 #number of enums:
    103 numenums=`wc -l temp | awk '{printf("%s\n",$1);}'`
    104105i1=1;
    105106i2=120;
    106107for (( i=1 ; i<=100 ; i++ )); do
    107108        echo "   if(stage==$i){" >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
    108         awk -vi1=$i1 -vi2=$i2 '{if(NR>=i1 && NR<=i2) print $0 }' temp > "temp_batch$i"
    109 
    110         cat "temp_batch$i" |  awk '{print "\t" ((NR==1)?"      if":"      else if") " (strcmp(name,\"" substr($2,1,length($2)-4) "\")==0) return " $2 ";"}' >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
     109        awk -v i1=$i1 -v i2=$i2 '{if(NR>=i1 && NR<=i2) print $0 }' temp |
     110        awk '{print "\t" ((NR==1)?"      if":"      else if") " (strcmp(name,\"" substr($2,1,length($2)-4) "\")==0) return " $2 ";"}' >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
    111111        echo "         else stage=$(($i+1));" >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
    112112        echo "   }" >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp
    113113       
    114        
    115         if [ $i2 -ge $numenums ]; then break; fi
    116         i1=$(($i1+120));
    117         i2=$(($i2+120));
     114        if [ $i2 -ge $NUMENUMS ]; then break; fi
     115        let i1=$i1+120
     116        let i2=$i2+120
    118117done
    119118
     119#footer
    120120cat <<END >> $ISSM_TIER/src/c/modules/StringToEnumx/StringToEnumx.cpp
    121    else _error_("Enum %s not found",name);
     121        /*If we reach this point, the string provided has not been found*/
     122   _error_("Enum %s not found",name);
    122123}
    123124END
    124125#}}}
    125126
    126 #get number of lines in temp
    127 NUMBEROFLINES=$(wc -l temp | awk '{printf("%s",$1);}');
    128 
    129127# go through the lines of temp
    130 for (( i=1 ; i<=$NUMBEROFLINES ; i++ )); do
     128for (( i=1 ; i<=$NUMENUMS ; i++ )); do
    131129
    132130        #Get name and enum of the line i
     
    141139        then
    142140                printf "\r                                                                      "
    143                 printf "\r  $i/$NUMBEROFLINES Adding "$NAME"..."
     141                printf "\r  $i/$NUMENUMS Adding "$NAME"..."
    144142        else
    145143                if [ $i -lt 100 ]
    146144                then
    147145                        printf "\r                                                                      "
    148                         printf "\r $i/$NUMBEROFLINES Adding "$NAME"..."
     146                        printf "\r $i/$NUMENUMS Adding "$NAME"..."
    149147                else
    150148                        printf "\r                                                                      "
    151                         printf "\r$i/$NUMBEROFLINES Adding "$NAME"..."
     149                        printf "\r$i/$NUMENUMS Adding "$NAME"..."
    152150                fi
    153151        fi
     
    171169done
    172170
    173 
    174171#clean up{{{
    175 rm temp temp_batch*
     172rm temp
    176173#}}}
    177174#print info {{{
  • issm/trunk-jpl/src/c/modules/StringToEnumx/StringToEnumx.cpp

    r11405 r11407  
    456456         else stage=5;
    457457   }
    458    else _error_("Enum %s not found",name);
     458        /*If we reach this point, the string provided has not been found*/
     459   _error_("Enum %s not found",name);
    459460}
Note: See TracChangeset for help on using the changeset viewer.