Imported Upstream version 2.9.0
[debian/cc1111] / sim / ucsim / put(c)
1 #!/bin/sh
2
3 # Functions
4
5 debug()
6 {
7   if [ "$DEBUG" = "yes" ]; then
8     echo $*
9   fi
10 }
11
12
13 # Parsing options
14
15 DEBUG=no
16 STARTYEAR=`date +%Y`
17 YEAR=`date +%y`
18 FILES=""
19
20 while [ "$1" != "" ]; do
21 case $1 in
22   "-s")
23     shift
24     STARTYEAR=$1
25     ;;
26   "-V")
27     DEBUG=yes
28     ;;
29   *)
30     if [ "$FILES" = "" ]; then
31       FILES=$1
32     else
33       FILES="${FILES} ${1}"
34     fi
35     ;;
36 esac
37 shift
38 done
39
40 debug "STARTYEAR= ${STARTYEAR}"
41 debug "FILES= ${FILES}"
42
43
44
45 # Doing the job
46
47 putit()
48 {
49   sed -n '/^\/\*@1@\*\//,$p' $1 >${1}.tmp
50   if [ -f '(c).1' ]; then
51     (sed 's/@@F@@/'${1}'/g
52           s/@@S@@/'${STARTYEAR}'/g
53           s/@@Y@@/'${YEAR}'/g' '(c).1'
54      cat ${1}.tmp) >$1
55   else
56     (cat <<EOF
57 /*
58  * Simulator of MCS51 ${1}
59  *
60  * Copyright (c) Drotos Daniel, Talker Bt.  ${STARTYEAR},${YEAR}
61  *
62  */
63 EOF
64      cat ${1}.tmp) >$1
65   fi
66   rm -f ${1}.tmp
67 }
68
69 for FILE in ${FILES}; do
70   debug "Checking ${FILE}..."
71   if grep '^/\*@1@\*/' $FILE >/dev/null; then
72     # can do
73     debug "/*@1@*/ marker found in ${FILE}"
74     putit $FILE
75   else
76     # can not
77     debug "/*@1@*/ marker not found in ${FILE}"
78   fi
79 done
80
81
82 # End of putcopyright