[12325] | 1 | Index: /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/EnumDefinitions/Synchronize.sh
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/EnumDefinitions/Synchronize.sh (revision 12261)
|
---|
| 4 | +++ /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/EnumDefinitions/Synchronize.sh (revision 12262)
|
---|
| 5 | @@ -1,8 +1,8 @@
|
---|
| 6 | #!/bin/bash
|
---|
| 7 | #Synchronize EnumToStringx.cpp and StringToEnumx.cpp and matlab Enums
|
---|
| 8 |
|
---|
| 9 | -#Get all lines of EnumDefinitions2.h which hold Enum | remove all comas | add line number in the first column > put everything in file temp
|
---|
| 10 | -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
|
---|
| 11 | +#Get all lines of EnumDefinitions2.h which hold Enum | remove all comas > put everything in file temp
|
---|
| 12 | +cat EnumDefinitions.h | grep -e "[0-9]Enum," -e "[a-zA-Z]Enum," | grep -v include | sed -e "s/,//g" > temp
|
---|
| 13 |
|
---|
| 14 | #Removed existing files
|
---|
| 15 | rm $ISSM_DIR/src/m/enum/*.m
|
---|
| 16 | @@ -12,7 +12,7 @@
|
---|
| 17 | #Get number of enums
|
---|
| 18 | NUMENUMS=$(wc -l temp | awk '{printf("%s",$1);}');
|
---|
| 19 |
|
---|
| 20 | -#Build EnumToStringx.cpp {{{1
|
---|
| 21 | +#Build EnumToStringx.cpp {{{
|
---|
| 22 | #Header
|
---|
| 23 | cat <<END > $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
|
---|
| 24 | /*
|
---|
| 25 | @@ -34,7 +34,7 @@
|
---|
| 26 |
|
---|
| 27 | END
|
---|
| 28 | #core
|
---|
| 29 | -cat temp | awk '{print "\t\t" "case " $2" : return \"" substr($2,1,length($2)-4) "\";"}' >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
|
---|
| 30 | +cat temp | awk '{print "\t\t" "case " $1" : return \"" substr($1,1,length($1)-4) "\";"}' >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
|
---|
| 31 | #Footer
|
---|
| 32 | cat <<END >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
|
---|
| 33 | default : return "unknown";
|
---|
| 34 | @@ -82,7 +82,7 @@
|
---|
| 35 | for (( i=1 ; i<=100 ; i++ )); do
|
---|
| 36 | echo " if(stage==$i){" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp
|
---|
| 37 | awk -v i1=$i1 -v i2=$i2 '{if(NR>=i1 && NR<=i2) print $0 }' temp |
|
---|
| 38 | - 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
|
---|
| 39 | + 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
|
---|
| 40 | echo " else stage=$(($i+1));" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp
|
---|
| 41 | echo " }" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp
|
---|
| 42 |
|
---|
| 43 | @@ -103,7 +103,7 @@
|
---|
| 44 | for (( i=1 ; i<=$NUMENUMS ; i++ )); do
|
---|
| 45 |
|
---|
| 46 | #Get name and enum of the line i
|
---|
| 47 | - NAMEENUM=$(cat temp | grep "^[ ]*$i " | awk '{printf("%s",$2);}');
|
---|
| 48 | + NAMEENUM=$(cat temp | grep "^[ ]*$i " | awk '{printf("%s",$1);}');
|
---|
| 49 | NAME=$(echo $NAMEENUM | sed -e "s/Enum//g")
|
---|
| 50 | ENUM=$i;
|
---|
| 51 | #offset Enum by one (Enum begins with 0 and not 1!)
|
---|
| 52 | @@ -155,7 +155,7 @@
|
---|
| 53 | % macro=MaximumNumberOfEnums()
|
---|
| 54 |
|
---|
| 55 | macro=$(cat EnumDefinitions.h | grep -e "[0-9]Enum" -e "[a-zA-Z]Enum" | grep -v include \
|
---|
| 56 | - | awk '{ printf "%s %s\n", NR, $0 }' \
|
---|
| 57 | + | awk '{ printf "%s %s\n", NR-1, $0 }' \
|
---|
| 58 | | grep "MaximumNumberOfEnums" | awk '{print $1}');
|
---|
| 59 | END
|
---|
| 60 | #}}}
|
---|