source: issm/oecreview/Archive/12261-12280/ISSM-12261-12262.diff

Last change on this file was 12325, checked in by Eric.Larour, 13 years ago

11990 to 12321 oec compliance

File size: 3.0 KB
  • proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/EnumDefinitions/Synchronize.sh

     
    11#!/bin/bash
    22#Synchronize EnumToStringx.cpp and StringToEnumx.cpp and matlab Enums
    33
    4 #Get all lines of EnumDefinitions2.h which hold Enum | remove all comas | add line number in the first column > 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" | awk '{ printf "%s %s\n", NR, $0 }' > temp
     4#Get all lines of EnumDefinitions2.h which hold Enum | remove all comas > put everything in file temp
     5cat EnumDefinitions.h | grep -e "[0-9]Enum," -e "[a-zA-Z]Enum," | grep -v include | sed -e "s/,//g" > temp
    66
    77#Removed existing files
    88rm $ISSM_DIR/src/m/enum/*.m
     
    1212#Get number of enums
    1313NUMENUMS=$(wc -l temp | awk '{printf("%s",$1);}');
    1414
    15 #Build EnumToStringx.cpp {{{1
     15#Build EnumToStringx.cpp {{{
    1616#Header
    1717cat <<END >  $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
    1818/*
     
    3434
    3535END
    3636#core
    37 cat temp |  awk '{print "\t\t" "case " $2" : return \"" substr($2,1,length($2)-4) "\";"}' >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
     37cat temp |  awk '{print "\t\t" "case " $1" : return \"" substr($1,1,length($1)-4) "\";"}' >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
    3838#Footer
    3939cat <<END >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
    4040                default : return "unknown";
     
    8282for (( i=1 ; i<=100 ; i++ )); do
    8383        echo "   if(stage==$i){" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp
    8484        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.cpp
     85        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
    8686        echo "         else stage=$(($i+1));" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp
    8787        echo "   }" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp
    8888       
     
    103103for (( i=1 ; i<=$NUMENUMS ; i++ )); do
    104104
    105105        #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);}');
    107107        NAME=$(echo $NAMEENUM | sed -e "s/Enum//g")
    108108        ENUM=$i;
    109109        #offset Enum by one (Enum begins with 0 and not 1!)
     
    155155%      macro=MaximumNumberOfEnums()
    156156
    157157macro=$(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 }' \
    159159                | grep "MaximumNumberOfEnums" | awk '{print $1}');
    160160END
    161161#}}}
Note: See TracBrowser for help on using the repository browser.