Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / 000261.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4 <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <meta name="generator" content="Movable Type 5.2.3" />
7
8    <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
9    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://defaria.com/blogs/Status/atom.xml" />
10    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://defaria.com/blogs/Status/index.xml" />
11
12    <title>Status for Andrew DeFaria: Improving fix_copyright.pl</title>
13
14    <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
15    <link rel="prev" href="http://defaria.com/blogs/Status/archives/000260.html" title="LOS178 Build/5.0.0 native toolchain build" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/000262.html" title="Fixing fix_copyright.pl" />
17
18    
19
20    
21
22    <script type="text/javascript" src="http://defaria.com/blogs/Status/mt-site.js"></script>
23 </head>
24 <body class="layout-one-column" onload="individualArchivesOnLoad(commenter_name)">
25    <div id="container">
26       <div id="container-inner" class="pkg">
27
28          <div id="banner">
29             <div id="banner-inner" class="pkg">
30                <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
31                <h2 id="banner-description">Searchable status reports and work log</h2>
32             </div>
33          </div>
34
35          <div id="pagebody">
36             <div id="pagebody-inner" class="pkg">
37                <div id="alpha">
38                   <div id="alpha-inner" class="pkg">
39
40                      <p class="content-nav">
41                         <a href="http://defaria.com/blogs/Status/archives/000260.html">&laquo; LOS178 Build/5.0.0 native toolchain build</a> |
42                         <a href="http://defaria.com/blogs/Status/">Main</a>
43                         | <a href="http://defaria.com/blogs/Status/archives/000262.html">Fixing fix_copyright.pl &raquo;</a>
44                      </p>
45
46                      <a id="a000261"></a>
47                      <div class="entry" id="entry-261">
48                         <h3 class="entry-header">Improving fix_copyright.pl</h3>
49                         <div class="entry-content">
50                            <div class="entry-body">
51                               <ul>
52
53 <li>Still unable to build 3.2.2/5.0.0 natively</li>
54
55 <li>Worked on improving algorithm for copyright replacement</li>
56
57 </ul>
58                            </div>
59                            <div id="more" class="entry-more">
60                               <p>I'm finding it very difficult to develop a hueristic algorithm to find what I call "LynuxWorks copyright blocks" in existing source files. The problem is that the input data is not necessarily consistant. Sure we can go for the 80% fix and hand fix the rest (in fact, that's what I did before) however those 20% often cause compiler errors during the build. What's potential worse is that it is possible that some files will be altered in such a way as to not produce a compiler error but rather to change behavior of the resulting code.</p>
61
62 <p>My current algorithm attempts to do the following:</p>
63
64 <ul>
65   <li>Locate the start of a C comment (i.e. "/*"). This comment must be at the beginning of the line (for now I am not considering inline comments as the chances of these containing a bona fide copyright statement is unlikely).</il>
66
67   <li>Scan until the enclosing end comment (i.e. "*/"). Again this must appear at the end of a line ($).</li>
68
69   <li>Take those lines and examine them for the works "(C) Copyright" and "LynuxWorks" (additionally I found some files that had "LynuxWork,").</li>
70
71   <li>If found then the comment block it throw out (to be replaced by the new, more consistent copyright block.</li>
72
73 </ul>
74
75 <p>Currently the "official" copyright block is of the form:</p>
76
77 <div class="code">
78 <pre>
79     /* vi: ts=4 sw=4
80     *************************************************************
81     (C) Copyright $copy
82     LynuxWorks, Inc.
83     San Jose, CA
84     All rights reserved.
85
86     $Date: $Date$
87     $Revision: $Revision$
88     $Source: $Source$
89     ************************************************************/
90 </pre>
91 </div>
92
93 <p>The "$copy" is replaced by the copyright date found in the file. Dates of the form <year> are changed to <year>-<current year> (unless <year> == <current year>. Dates of the form <year1>, <year2>, <year3> are changed to <year1>-<curernt year>. In order to make finding such copyright information eaiser in the future I would suggest changing the above format to:</p>
94
95 <div class="code">
96 <pre>
97     /* Start Copyright ******************************************
98     vi: ts=4 sw=4
99     (C) Copyright $copy LynuxWorks, Inc.
100     San Jose, CA
101     All rights reserved.
102
103     $Date: $Date$
104     $Revision: $Revision$
105     $Source: $Source$
106     * End Copyright *********************************************/
107 </pre>
108 </div>
109
110 <p>This would 1) retain the "vi: ts=4 sw=4" annotation that I assume is for vi users, 2) group both the copyright string ("(C) Copyright") along with the company name of LynuxWorks on the same line. This makes it easier to grep for in the future considering some files have Rockwell copyrights. 3) Clearly delineates the start and stop of the copyright block.</p>
111
112 <p>The problems that I'm having is that I'm seeing copyright blocks of the following forms:</p>
113
114 <div class="code">
115 <pre>  /************************************************************
116     (C) Copyright 1987-2000
117     Lynx Real-Time Systems, Inc.
118     San Jose, CA
119     All rights reserved.
120
121     $Date: 2003/11/14 22:44:44 $
122     $Revision: 1.1 $
123     ************************************************************/
124 </pre>
125 </div>
126
127 <p>(Does not contain LynuxWorks, rather Lynx Real-Time Systems)</p>
128
129 <div class="code">
130 <pre>
131     /*
132     .FP
133     ***********************************************************************
134      Revision History
135      See ClearCase
136      Version:
137     ***********************************************************************
138     *
139     * EXPORT NOTICE:
140     *
141     *   INFORMATION SUBJECT TO EXPORT CONTROL LAWS
142     *
143     * Subject to local country rules and laws when applicable, you
144     * must comply with the following:
145     *
146     * These commodities, technology, or software were exported from
147     * the United States in accordance with the Export Administration
148     * Regulations.  Diversion contrary to U. S. law and other relevant
149     * export controls is prohibited.   They may not be re-exported to
150     * any of the following destinations without authorization; Cuba,
151     * Iran, Iraq, Libya, North Korea, Sudan or any other country to
152     * which shipment is prohibited; nor to end-use(r)s involved in
153     * chemical, biological, nuclear, or missile weapons activity.
154     *
155     * COPYRIGHT NOTICE:
156     *   (C) Copyright 2001 Rockwell Collins, Inc.  All rights reserved.
157     *
158     * FILE NAME:
159     *   df.c
160     *
161     * PURPOSE:
162     *   utility to display disk usage
163     *
164     * NOTES:
165     *
166     * ABBREVIATIONS/ACRONYMS:
167     *
168     *****************************************************************
169     .FP END
170     */
171     /************************************************************
172     (C) Copyright 1987-1996
173     Lynx Real-Time Systems, Inc.
174     San Jose, CA
175     All rights reserved.
176
177     $Date: 2003/09/10 15:24:57 $
178     $Revision: 1.1.1.1 $
179     ************************************************************/
180 </pre>
181 </div>
182
183 <p>Contains multiple "(C) Copyright" strings, one being ours and the other being Rockwell's. Should both exist in the resultant file?</p>
184
185 <div class="code">
186 <pre>
187     /*
188     .FP
189      **********************************************************************
190      *
191      * FILE NAME:
192      *   hm_load_header.c
193      *
194      * PURPOSE:
195      *    Performs the integrity check of the program and data files
196      *    in the CPR read only file system.
197      *
198      * ABBREVIATIONS/ACRONYMS: (optional)
199      *
200      * NOTES: none
201      *
202      * COPYRIGHT NOTICE:
203      *   (C) Copyright 2001-2002 Rockwell Collins, Inc.  All rights reserved.
204      *       Proprietary and confidential material.  Distribution,
205      *       use, and disclosure restricted by Rockwell Collins, Inc.
206      *    Copyright (c) 2003-2004, LynuxWorks, Inc. All Rights Reserved.
207      *
208      ***********************************************************************
209     .FP END
210     */
211 </pre>
212 </div>
213
214 <p>Contains multiple "(C) Copyright" strings, one being ours and the other being Rockwells, in the same comment block! Also notice the inconsistant form of one bying "(C) Copyright" while the other being "Copyright (C)". How should this case be handled?</p>
215                            </div>
216                         </div>
217                         <p class="entry-footer">
218                            <span class="post-footers">Posted by  on December 20, 2004  5:55 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000261.html">Permalink</a>
219                         </p>
220                      </div>
221
222                      
223
224                      
225                   </div>
226                </div>
227             </div>
228          </div>
229       </div>
230    </div>
231 </body>
232 </html>