source:
issm/oecreview/Archive/12261-12280/ISSM-12261-12262.diff
Last change on this file was 12325, checked in by , 13 years ago | |
---|---|
File size: 3.0 KB |
-
proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/EnumDefinitions/Synchronize.sh
1 1 #!/bin/bash 2 2 #Synchronize EnumToStringx.cpp and StringToEnumx.cpp and matlab Enums 3 3 4 #Get all lines of EnumDefinitions2.h which hold Enum | remove all comas | add line number in the first column> put everything in file temp5 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 }'> temp4 #Get all lines of EnumDefinitions2.h which hold Enum | remove all comas > put everything in file temp 5 cat EnumDefinitions.h | grep -e "[0-9]Enum," -e "[a-zA-Z]Enum," | grep -v include | sed -e "s/,//g" > temp 6 6 7 7 #Removed existing files 8 8 rm $ISSM_DIR/src/m/enum/*.m … … 12 12 #Get number of enums 13 13 NUMENUMS=$(wc -l temp | awk '{printf("%s",$1);}'); 14 14 15 #Build EnumToStringx.cpp {{{ 115 #Build EnumToStringx.cpp {{{ 16 16 #Header 17 17 cat <<END > $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp 18 18 /* … … 34 34 35 35 END 36 36 #core 37 cat temp | awk '{print "\t\t" "case " $ 2" : return \"" substr($2,1,length($2)-4) "\";"}' >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp37 cat temp | awk '{print "\t\t" "case " $1" : return \"" substr($1,1,length($1)-4) "\";"}' >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp 38 38 #Footer 39 39 cat <<END >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp 40 40 default : return "unknown"; … … 82 82 for (( i=1 ; i<=100 ; i++ )); do 83 83 echo " if(stage==$i){" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp 84 84 awk -v i1=$i1 -v i2=$i2 '{if(NR>=i1 && NR<=i2) print $0 }' temp | 85 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.cpp85 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 86 86 echo " else stage=$(($i+1));" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp 87 87 echo " }" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp 88 88 … … 103 103 for (( i=1 ; i<=$NUMENUMS ; i++ )); do 104 104 105 105 #Get name and enum of the line i 106 NAMEENUM=$(cat temp | grep "^[ ]*$i " | awk '{printf("%s",$ 2);}');106 NAMEENUM=$(cat temp | grep "^[ ]*$i " | awk '{printf("%s",$1);}'); 107 107 NAME=$(echo $NAMEENUM | sed -e "s/Enum//g") 108 108 ENUM=$i; 109 109 #offset Enum by one (Enum begins with 0 and not 1!) … … 155 155 % macro=MaximumNumberOfEnums() 156 156 157 157 macro=$(cat EnumDefinitions.h | grep -e "[0-9]Enum" -e "[a-zA-Z]Enum" | grep -v include \ 158 | awk '{ printf "%s %s\n", NR , $0 }' \158 | awk '{ printf "%s %s\n", NR-1, $0 }' \ 159 159 | grep "MaximumNumberOfEnums" | awk '{print $1}'); 160 160 END 161 161 #}}}
Note:
See TracBrowser
for help on using the repository browser.