dtcm: Resolve CID 87408
[oweals/cde.git] / cde / programs / dtcm / dtcm / process_msg
1 #!/bin/sh
2 # $TOG: process_msg /main/4 1999/09/20 10:33:13 mgreess $
3 # Script to determine which source files need to have new messages 
4 # substitued into them and accomplish those substitutions.  The 
5 # files on the command line will be run thru genmsg, and those 
6 # files that exhibit actual differences will then be checked out, 
7 # and really run thru genmsg, and then checked back in.
8 #
9 # To use the script, you must scccs get all of the source files you wish
10 # to process, as well as dtcm.msg and project.set.  When ready, one runs 
11 # "process_msg *.c".  It will look thru all the .c files, looking to 
12 # see which ones have unassigned message id's, and check those files out.  
13 # It will then run those files thru genmsg, and regenerate the dtcm.msg 
14 # file.  You must delta in the processed .c files as well as project.set 
15 # and dtcm.msg.  A bunch of old .msg files will remain in the directory.
16 # The old message file will be stored in dtcm.msg.orig.
17
18 rm -f *.new *.msg >/dev/null
19 filelist=""
20 null=""
21 for file in $* 
22 do
23         genmsg -l project.set $file >/dev/null
24         diff $file $file.new   >/dev/null
25         if [ $? != 0 ]  
26         then
27                 filelist="$filelist $file"
28         fi
29 done
30
31 echo $filelist
32
33 if [ "$filelist" = "$null" ] 
34 then
35         echo "No files need to be updated.  Exiting."
36         exit
37 fi
38
39 # Now that we have the list of files that actually need to 
40 # be changed, check to see if any of them are already checked 
41 # out.  If they are, then quit with an error, else run 
42 # genmsg to change them.
43
44 checkout=`sccs tell`
45
46 if [ "$checkout" ] 
47 then
48         for file in $filelist 
49         do
50                 for newfile in $checkout 
51                 do
52                         if [ "$file" = "$newfile" ] 
53                         then
54                                 echo "The file $file needs to be changed, but is already checked out.  Exiting"
55                                 exit
56                         fi
57                 done
58         done
59 fi
60
61
62 sccs edit $filelist project.set dtcm.msg
63
64
65 for file in $filelist 
66 do
67         genmsg -c NL_COMMENT -l project.set $file >/dev/null
68         mv $file.new $file
69         mv project.set.new project.set
70 done
71
72 # regenerate the message file for the application
73
74 mv -f dtcm.msg dtcm.msg.orig
75
76 genmsg -c NL_COMMENT -d dtcm.msg $* 
77
78 #sccs unedit $filelist project.set dtcm.msg
79 #rm *.new *.msg