Changeset 1813 for palm


Ignore:
Timestamp:
Apr 6, 2016 9:38:56 AM (9 years ago)
Author:
maronga
Message:

extented document_changes for updating the copyright statement in the file headers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/document_changes

    r1811 r1813  
    1515# PALM. If not, see <http://www.gnu.org/licenses/>.
    1616#
    17 # Copyright 1997-2014 Leibniz Universitaet Hannover
     17# Copyright 1997-2016 Leibniz Universitaet Hannover
    1818#------------------------------------------------------------------------------#
    1919#
    2020# Current revisions:
    2121# -----------------
    22 #
     22# Added update of the copyright statements in the file headers.
    2323#
    2424# Former revisions:
    2525# -----------------
    2626# $Id$
    27 #
     27# 
    2828# 1810 2016-04-05 20:25:29Z maronga
    2929# document_changes now checks all subdirectories. Modified printing to screen.
     
    5858    comment_char=="!"   #: comment character
    5959    count_changes=0     #: count the number of files with CR text
     60    count_updates=0     #: count the number of files with copyright update
    6061    count_files=0       #: count the number of files
    6162    fn=""               #: current file name to be scanned
     
    7374    list_delete=""      #: contains the line no. that must be deleted from CR
    7475    timestamp=""        #: the svn timestamp of the file
     76    current_year=$(date +"%Y")
    7577
    7678#
     
    9294    printf "\n  *** Checking files in $input_dir and all recursive subdirectories...\n"
    9395
     96   
     97#
     98#-- scan all (sub-)directories for files.
    9499    IFS=$'\n';
    95     for fn in $(find $input_dir -not -name '*.pdf' -and -not -name '*.x' -and -not -name '*.eps' -and -not -name '*.png' -and -not -name '*.svn*'); do
    96 
    97 #
    98 #--    exclude backup and invisible files
     100    for fn in $(find $input_dir -not -name '*.pdf'  -and -not -name '*.x'      \
     101                           -and -not -name '*.eps'  -and -not -name '*.png'    \
     102                           -and -not -name '*.svn*' -and -not -name '*~'       \
     103                           -and -not -name '*.tar'); do
     104
     105#
     106#--    exclude invisible files
    99107       file_firstchar=${fn:0:1}
    100108       file_lastchar=`echo -n $fn| tail -c -1`
    101109       file_extension=${fn##*.}
    102        if [[ "$file_firstchar" == "." || "$file_extension" == "x" || "$file_lastchar" == "~" || "$file_extension" == "tar" ]]
     110       if [[ "$file_firstchar" == "." ]]
    103111       then
    104112          continue
     
    115123
    116124#
    117 #--    read one line at a time
     125#--    read one line at a time and move revision comments
    118126       while read line
    119127       do
     
    176184       done <"$fn"
    177185
     186       
     187       
     188#
     189#--    check for updates of the copyright statement
     190       found_update_year=false
     191
     192       while read line
     193       do
     194
     195          line_tmp=""
     196          line_tmp2=""     
     197          line_tmp=${line:22:29}
     198          line_tmp2=${line:2:15}
     199         
     200#           echo "$line_tmp $line_tmp2"
     201         
     202          if  [[ "$line_tmp" == "Leibniz Universitaet Hannover" && "$line_tmp2" == "Copyright 1997-" ]]
     203          then
     204         
     205             year_in_file=${line:17:4}
     206             if  [[ "$year_in_file" != "$current_year" ]]
     207             then
     208     
     209                printf "\r%$(tput cols)s" " "   
     210                printf "\r  \e[1;33m*** Copyright update required in $fn\e[0m\n"
     211
     212                comment_char=${line:0:1}
     213                found_update_year=true             
     214                cp $fn $fn~
     215               
     216             fi
     217          fi
     218       
     219       done <"$fn"
     220         
    178221       printf "\r%$(tput cols)s" " "   
    179        printf "\r\e[1m  *** Searched files: $count_files. Comments found: $count_changes\e[0m."
     222       printf "\r\e[1m  *** Searched files: $count_files. Comments found: $count_changes. Copyright updates found: $count_updates\e[0m"
    180223       
    181224#
     
    200243       fi
    201244
     245#
     246#--    move comments from current revisions to former revisions
     247       if [[ "$found_update_year" == true ]]
     248       then
     249
     250          (( count_updates = count_updates + 1 )) 
     251         
     252           sed -i "s/$comment_char Copyright 1997-.*Leibniz Universitaet Hannover/$comment_char Copyright 1997-$current_year Leibniz Universitaet Hannover/" $fn
     253     
     254       fi
     255       
    202256    done
    203257
     
    205259#-- inform the user about the changes
    206260    printf "\r%$(tput cols)s" " "
    207     printf "\r\e[1m  *** Searched files: $count_files. Comments found: $count_changes\e[0m. - \e[1;32mfinished.\e[0m\n\n"
     261    printf "\r\e[1m  *** Searched files: $count_files. Comments found: $count_changes. Copyright updates found: $count_updates\e[0m. - \e[1;32mfinished.\e[0m\n\n"
    208262
    209263    if  [[ $count_changes -gt 0 ]]
Note: See TracChangeset for help on using the changeset viewer.