Index: /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/EnumDefinitions/Synchronize.sh =================================================================== --- /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/EnumDefinitions/Synchronize.sh (revision 12261) +++ /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/EnumDefinitions/Synchronize.sh (revision 12262) @@ -1,8 +1,8 @@ #!/bin/bash #Synchronize EnumToStringx.cpp and StringToEnumx.cpp and matlab Enums -#Get all lines of EnumDefinitions2.h which hold Enum | remove all comas | add line number in the first column > put everything in file temp -cat EnumDefinitions.h | grep -e "[0-9]Enum," -e "[a-zA-Z]Enum," | grep -v include | sed -e "s/,//g" | awk '{ printf "%s %s\n", NR, $0 }' > temp +#Get all lines of EnumDefinitions2.h which hold Enum | remove all comas > put everything in file temp +cat EnumDefinitions.h | grep -e "[0-9]Enum," -e "[a-zA-Z]Enum," | grep -v include | sed -e "s/,//g" > temp #Removed existing files rm $ISSM_DIR/src/m/enum/*.m @@ -12,7 +12,7 @@ #Get number of enums NUMENUMS=$(wc -l temp | awk '{printf("%s",$1);}'); -#Build EnumToStringx.cpp {{{1 +#Build EnumToStringx.cpp {{{ #Header cat < $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp /* @@ -34,7 +34,7 @@ END #core -cat temp | awk '{print "\t\t" "case " $2" : return \"" substr($2,1,length($2)-4) "\";"}' >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp +cat temp | awk '{print "\t\t" "case " $1" : return \"" substr($1,1,length($1)-4) "\";"}' >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp #Footer cat <> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp default : return "unknown"; @@ -82,7 +82,7 @@ for (( i=1 ; i<=100 ; i++ )); do echo " if(stage==$i){" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp awk -v i1=$i1 -v i2=$i2 '{if(NR>=i1 && NR<=i2) print $0 }' temp | - awk '{print "\t" ((NR==1)?" if":" else if") " (strcmp(name,\"" substr($2,1,length($2)-4) "\")==0) return " $2 ";"}' >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp + awk '{print "\t" ((NR==1)?" if":" else if") " (strcmp(name,\"" substr($1,1,length($1)-4) "\")==0) return " $1 ";"}' >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp echo " else stage=$(($i+1));" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp echo " }" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp @@ -103,7 +103,7 @@ for (( i=1 ; i<=$NUMENUMS ; i++ )); do #Get name and enum of the line i - NAMEENUM=$(cat temp | grep "^[ ]*$i " | awk '{printf("%s",$2);}'); + NAMEENUM=$(cat temp | grep "^[ ]*$i " | awk '{printf("%s",$1);}'); NAME=$(echo $NAMEENUM | sed -e "s/Enum//g") ENUM=$i; #offset Enum by one (Enum begins with 0 and not 1!) @@ -155,7 +155,7 @@ % macro=MaximumNumberOfEnums() macro=$(cat EnumDefinitions.h | grep -e "[0-9]Enum" -e "[a-zA-Z]Enum" | grep -v include \ - | awk '{ printf "%s %s\n", NR, $0 }' \ + | awk '{ printf "%s %s\n", NR-1, $0 }' \ | grep "MaximumNumberOfEnums" | awk '{print $1}'); END #}}}