1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/scripts/unify-sources.sh Sun Jul 13 16:46:56 2008 +0100
1.3 @@ -0,0 +1,134 @@
1.4 +#!/bin/bash
1.5 +
1.6 +YEAR=`date +2003-%Y`
1.7 +HGROOT=`hg root`
1.8 +
1.9 +function update_header() {
1.10 + TMP_FILE=`mktemp`
1.11 + FILE_NAME=$1
1.12 +
1.13 + (echo "/* -*- mode: C++; indent-tabs-mode: nil; -*-
1.14 + *
1.15 + * This file is a part of LEMON, a generic C++ optimization library.
1.16 + *
1.17 + * Copyright (C) "$YEAR"
1.18 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.19 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.20 + *
1.21 + * Permission to use, modify and distribute this software is granted
1.22 + * provided that this copyright notice appears in all copies. For
1.23 + * precise terms see the accompanying LICENSE file.
1.24 + *
1.25 + * This software is provided \"AS IS\" with no warranty of any kind,
1.26 + * express or implied, and with no claim as to its suitability for any
1.27 + * purpose.
1.28 + *
1.29 + */
1.30 +"
1.31 + awk 'BEGIN { pm=0; }
1.32 + pm==3 { print }
1.33 + /\/\* / && pm==0 { pm=1;}
1.34 + /[^:blank:]/ && (pm==0 || pm==2) { pm=3; print;}
1.35 + /\*\// && pm==1 { pm=2;}
1.36 + ' $1
1.37 + ) >$TMP_FILE
1.38 +
1.39 + HEADER_CH=`diff -q $TMP_FILE $FILE_NAME >/dev/null&&echo NO||echo YES`
1.40 +
1.41 + rm $FILE_NAME
1.42 + mv $TMP_FILE $FILE_NAME
1.43 +}
1.44 +
1.45 +function update_tabs() {
1.46 + TMP_FILE=`mktemp`
1.47 + FILE_NAME=$1
1.48 +
1.49 + cat $1 |
1.50 + sed -e 's/\t/ /g' >$TMP_FILE
1.51 +
1.52 + TABS_CH=`diff -q $TMP_FILE $FILE_NAME >/dev/null&&echo NO||echo YES`
1.53 +
1.54 + rm $FILE_NAME
1.55 + mv $TMP_FILE $FILE_NAME
1.56 +}
1.57 +
1.58 +function remove_trailing_space() {
1.59 + TMP_FILE=`mktemp`
1.60 + FILE_NAME=$1
1.61 +
1.62 + cat $1 |
1.63 + sed -e 's/ \+$//g' >$TMP_FILE
1.64 +
1.65 + SPACES_CH=`diff -q $TMP_FILE $FILE_NAME >/dev/null&&echo NO||echo YES`
1.66 +
1.67 + rm $FILE_NAME
1.68 + mv $TMP_FILE $FILE_NAME
1.69 +}
1.70 +
1.71 +function long_line_test() {
1.72 + cat $1 |grep -q -E '.{81,}'
1.73 +}
1.74 +
1.75 +function update_file() {
1.76 + echo -n ' update' $i ...
1.77 +
1.78 + update_header $1
1.79 + update_tabs $1
1.80 + remove_trailing_space $1
1.81 +
1.82 + CHANGED=NO;
1.83 + if [[ $HEADER_CH = YES ]];
1.84 + then
1.85 + echo -n ' [header updated]'
1.86 + CHANGED=YES;
1.87 + fi
1.88 + if [[ $TABS_CH = YES ]];
1.89 + then
1.90 + echo -n ' [tabs removed]'
1.91 + CHANGED=YES;
1.92 + fi
1.93 + if [[ $SPACES_CH = YES ]];
1.94 + then
1.95 + echo -n ' [trailing spaces removed]'
1.96 + CHANGED=YES;
1.97 + fi
1.98 + if long_line_test $1 ;
1.99 + then
1.100 + echo -n ' [LONG LINES]'
1.101 + ((LONG_LINE_FILES++))
1.102 + fi
1.103 + echo
1.104 + if [[ $CHANGED = YES ]];
1.105 + then
1.106 + ((CHANGED_FILES++))
1.107 + fi
1.108 +}
1.109 +
1.110 +CHANGED_FILES=0
1.111 +TOTAL_FILES=0
1.112 +LONG_LINE_FILES=0
1.113 +if [ $# == 0 ]; then
1.114 + echo Update all source files...
1.115 + for i in `hg manifest|grep -E '\.(cc|h|dox)$'`
1.116 + do
1.117 + update_file $HGROOT/$i
1.118 + ((TOTAL_FILES++))
1.119 + done
1.120 + echo ' done.'
1.121 +else
1.122 + for i in $*
1.123 + do
1.124 + update_file $i
1.125 + ((TOTAL_FILES++))
1.126 + done
1.127 +fi
1.128 +echo $CHANGED_FILES out of $TOTAL_FILES files has been changed.
1.129 +if [[ $LONG_LINE_FILES -gt 1 ]]; then
1.130 + echo
1.131 + echo WARNING: $LONG_LINE_FILES files contains long lines!
1.132 + echo
1.133 +elif [[ $LONG_LINE_FILES -gt 0 ]]; then
1.134 + echo
1.135 + echo WARNING: a file contains long lines!
1.136 + echo
1.137 +fi
2.1 --- a/scripts/update-copyright-header.sh Sun Jul 13 16:35:05 2008 +0100
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,52 +0,0 @@
2.4 -#!/bin/bash
2.5 -
2.6 -YEAR=`date +2003-%Y`
2.7 -HGROOT=`hg root`
2.8 -
2.9 -function update_file() {
2.10 - TMP_FILE=`mktemp`
2.11 - FILE_NAME=$1
2.12 -
2.13 - (echo "/* -*- C++ -*-
2.14 - *
2.15 - * This file is a part of LEMON, a generic C++ optimization library
2.16 - *
2.17 - * Copyright (C) "$YEAR"
2.18 - * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
2.19 - * (Egervary Research Group on Combinatorial Optimization, EGRES).
2.20 - *
2.21 - * Permission to use, modify and distribute this software is granted
2.22 - * provided that this copyright notice appears in all copies. For
2.23 - * precise terms see the accompanying LICENSE file.
2.24 - *
2.25 - * This software is provided \"AS IS\" with no warranty of any kind,
2.26 - * express or implied, and with no claim as to its suitability for any
2.27 - * purpose.
2.28 - *
2.29 - */
2.30 -"
2.31 - awk 'BEGIN { pm=0; }
2.32 - pm==3 { print }
2.33 - /\/\* / && pm==0 { pm=1;}
2.34 - /[^:blank:]/ && (pm==0 || pm==2) { pm=3; print;}
2.35 - /\*\// && pm==1 { pm=2;}
2.36 - ' $1
2.37 - ) >$TMP_FILE
2.38 - rm $FILE_NAME
2.39 - mv $TMP_FILE $FILE_NAME
2.40 -}
2.41 -
2.42 -
2.43 -if [ $# == 0 ]; then
2.44 - echo -n Update all source files...
2.45 - for i in `hg manifest|grep -E '\.(cc|h|dox)$'`
2.46 - do
2.47 - update_file $HGROOT/$i
2.48 - done
2.49 - echo ' done.'
2.50 -else
2.51 - for i in $*
2.52 - do
2.53 - update_file $i
2.54 - done
2.55 -fi