Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / 2004 / 12 / improving-fix-c.html
1 <!DOCTYPE html>
2 <html lang="en-us" itemscope itemtype="http://schema.org/Article">
3   <head>
4     <meta charset="utf-8">
5     <meta name="description" content=" Still unable to build 3.2.2/5.0.0 natively Worked on improving algorithm for copyright replacement...">
6     <meta name="generator" content="Movable Type 5.2.3">
7     <title>Improving fix_copyright.pl - Status</title>
8     <link rel="alternate" type="application/atom+xml" title="Recent Entries" href="http://defaria.com/blogs/Status/atom.xml">
9     <link rel="canonical" href="http://defaria.com/blogs/Status/2004/12/improving-fix-c.html">
10     <meta name="viewport" content="width=device-width,initial-scale=1">
11     <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles.css">
12     <!--[if lt IE 9]>
13     <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles_ie.css">
14     <script src="/mt/mt-static/support/theme_static/rainier/js/html5shiv.js"></script>
15     <![endif]-->
16     
17     <link rel="start" href="http://defaria.com/blogs/Status/">
18
19     <link rel="prev" href="http://defaria.com/blogs/Status/2004/12/los178-build500.html" title="LOS178 Build/5.0.0 native toolchain build">
20     <link rel="next" href="http://defaria.com/blogs/Status/2004/12/fixing-fix-copy.html" title="Fixing fix_copyright.pl">
21     <!-- Open Graph Protocol -->
22     <meta property="og:type" content="article">
23     <meta property="og:locale" content="en-us">
24     <meta property="og:title" content="Improving fix_copyright.pl">
25     <meta property="og:url" content="http://defaria.com/blogs/Status/2004/12/improving-fix-c.html">
26     <meta property="og:description" content=" Still unable to build 3.2.2/5.0.0 natively Worked on improving algorithm for copyright replacement...">
27     <meta property="og:site_name" content="Status">
28     <meta property="og:image" content="/mt/mt-static/support/theme_static/rainier/img/siteicon-sample.png">
29     <!-- Metadata -->
30     <meta itemprop="description" content=" Still unable to build 3.2.2/5.0.0 natively Worked on improving algorithm for copyright replacement...">
31     <link itemprop="url" href="http://defaria.com/blogs/Status/2004/12/improving-fix-c.html">
32     <link itemprop="image" href="/mt/mt-static/support/theme_static/rainier/img/siteicon-sample.png">
33     
34   </head>
35   <body>
36     <div id="container">
37       <div id="container-inner">
38         <header id="header" role="banner">
39           <div id="header-inner">
40             <div id="header-content">
41               <h1>
42                 <a href="http://defaria.com/blogs/Status/">
43
44                   Status
45
46                 </a>
47               </h1>
48               
49             </div>
50
51             <nav role="navigation">
52           <ul>
53             <li><a href="http://defaria.com/blogs/Status/">Home</a></li>
54
55
56           </ul>
57         </nav>
58
59           </div>
60         </header>
61         <div id="content">
62           <div id="content-inner">
63             <ul class="breadcrumb breadcrumb-list">
64               <li class="breadcrumb-list-item"><a href="http://defaria.com/blogs/Status/">Home</a></li>
65               <li class="breadcrumb-list-item">Improving fix_copyright.pl</li>
66             </ul>
67             <div id="individual-main" class="main" role="main">
68               <article id="entry-1535" class="entry entry-asset asset hentry">
69                 <div class="asset-header">
70                   <h2 itemprop="name" class="asset-name entry-title">Improving fix_copyright.pl</h2>
71                   <footer class="asset-meta">
72                     <ul class="asset-meta-list">
73                       <li class="asset-meta-list-item">Posted on <time datetime="2004-12-20T17:55:11-08:00" itemprop="datePublished">December 20, 2004</time></li>
74                       <li class="asset-meta-list-item">by <span class="author entry-author vcard"></span></li>
75
76   
77                       <li class="asset-meta-list-item">in <a itemprop="articleSection" rel="tag" href="http://defaria.com/blogs/Status/lynuxworks/">LynuxWorks</a></li>
78   
79
80                    </ul>
81                 </footer>
82                 </div>
83                 <div class="entry-content asset-content" itemprop="articleBody">
84                   <ul>
85
86 <li>Still unable to build 3.2.2/5.0.0 natively</li>
87
88 <li>Worked on improving algorithm for copyright replacement</li>
89
90 </ul>
91                   <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>
92
93 <p>My current algorithm attempts to do the following:</p>
94
95 <ul>
96   <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>
97
98   <li>Scan until the enclosing end comment (i.e. "*/"). Again this must appear at the end of a line ($).</li>
99
100   <li>Take those lines and examine them for the works "(C) Copyright" and "LynuxWorks" (additionally I found some files that had "LynuxWork,").</li>
101
102   <li>If found then the comment block it throw out (to be replaced by the new, more consistent copyright block.</li>
103
104 </ul>
105
106 <p>Currently the "official" copyright block is of the form:</p>
107
108 <div class="code">
109 <pre>
110     /* vi: ts=4 sw=4
111     *************************************************************
112     (C) Copyright $copy
113     LynuxWorks, Inc.
114     San Jose, CA
115     All rights reserved.
116
117     $Date: $Date$
118     $Revision: $Revision$
119     $Source: $Source$
120     ************************************************************/
121 </pre>
122 </div>
123
124 <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>
125
126 <div class="code">
127 <pre>
128     /* Start Copyright ******************************************
129     vi: ts=4 sw=4
130     (C) Copyright $copy LynuxWorks, Inc.
131     San Jose, CA
132     All rights reserved.
133
134     $Date: $Date$
135     $Revision: $Revision$
136     $Source: $Source$
137     * End Copyright *********************************************/
138 </pre>
139 </div>
140
141 <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>
142
143 <p>The problems that I'm having is that I'm seeing copyright blocks of the following forms:</p>
144
145 <div class="code">
146 <pre>  /************************************************************
147     (C) Copyright 1987-2000
148     Lynx Real-Time Systems, Inc.
149     San Jose, CA
150     All rights reserved.
151
152     $Date: 2003/11/14 22:44:44 $
153     $Revision: 1.1 $
154     ************************************************************/
155 </pre>
156 </div>
157
158 <p>(Does not contain LynuxWorks, rather Lynx Real-Time Systems)</p>
159
160 <div class="code">
161 <pre>
162     /*
163     .FP
164     ***********************************************************************
165      Revision History
166      See ClearCase
167      Version:
168     ***********************************************************************
169     *
170     * EXPORT NOTICE:
171     *
172     *   INFORMATION SUBJECT TO EXPORT CONTROL LAWS
173     *
174     * Subject to local country rules and laws when applicable, you
175     * must comply with the following:
176     *
177     * These commodities, technology, or software were exported from
178     * the United States in accordance with the Export Administration
179     * Regulations.  Diversion contrary to U. S. law and other relevant
180     * export controls is prohibited.   They may not be re-exported to
181     * any of the following destinations without authorization; Cuba,
182     * Iran, Iraq, Libya, North Korea, Sudan or any other country to
183     * which shipment is prohibited; nor to end-use(r)s involved in
184     * chemical, biological, nuclear, or missile weapons activity.
185     *
186     * COPYRIGHT NOTICE:
187     *   (C) Copyright 2001 Rockwell Collins, Inc.  All rights reserved.
188     *
189     * FILE NAME:
190     *   df.c
191     *
192     * PURPOSE:
193     *   utility to display disk usage
194     *
195     * NOTES:
196     *
197     * ABBREVIATIONS/ACRONYMS:
198     *
199     *****************************************************************
200     .FP END
201     */
202     /************************************************************
203     (C) Copyright 1987-1996
204     Lynx Real-Time Systems, Inc.
205     San Jose, CA
206     All rights reserved.
207
208     $Date: 2003/09/10 15:24:57 $
209     $Revision: 1.1.1.1 $
210     ************************************************************/
211 </pre>
212 </div>
213
214 <p>Contains multiple "(C) Copyright" strings, one being ours and the other being Rockwell's. Should both exist in the resultant file?</p>
215
216 <div class="code">
217 <pre>
218     /*
219     .FP
220      **********************************************************************
221      *
222      * FILE NAME:
223      *   hm_load_header.c
224      *
225      * PURPOSE:
226      *    Performs the integrity check of the program and data files
227      *    in the CPR read only file system.
228      *
229      * ABBREVIATIONS/ACRONYMS: (optional)
230      *
231      * NOTES: none
232      *
233      * COPYRIGHT NOTICE:
234      *   (C) Copyright 2001-2002 Rockwell Collins, Inc.  All rights reserved.
235      *       Proprietary and confidential material.  Distribution,
236      *       use, and disclosure restricted by Rockwell Collins, Inc.
237      *    Copyright (c) 2003-2004, LynuxWorks, Inc. All Rights Reserved.
238      *
239      ***********************************************************************
240     .FP END
241     */
242 </pre>
243 </div>
244
245 <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>
246                 </div>
247                 <nav class="page-navigation entry-navigation pagination content-nav">
248                   <ul class="page-navigation-list">
249
250                     <li class="page-navigation-list-item page-navigation-prev"><a rel="prev" href="http://defaria.com/blogs/Status/2004/12/los178-build500.html" title="LOS178 Build/5.0.0 native toolchain build">Previous entry</a></li>
251
252
253                     <li class="page-navigation-list-item page-navigation-next"><a rel="next" href="http://defaria.com/blogs/Status/2004/12/fixing-fix-copy.html" title="Fixing fix_copyright.pl">Next entry</a></li>
254
255                   </ul>
256                 </nav>
257                 <!--
258 <aside id="zenback" class="zenback feedback">
259   Please paste Zenback script code here.
260 </aside>
261 -->
262                 
263                 
264               </article>
265             </div>
266             <aside class="widgets related" role="complementary">
267               <nav class="widget-search widget">
268   <div class="widget-content">
269     <form method="get" id="search" action="http://defaria.com/mt/mt-search.cgi">
270       <div>
271         <input type="text" name="search" value="" placeholder="Search...">
272
273         <input type="hidden" name="IncludeBlogs" value="8">
274
275         <input type="hidden" name="limit" value="20">
276         <button type="submit" name="button">
277           <img alt="Search" src="/mt/mt-static/support/theme_static/rainier/img/search-icon.png">
278         </button>
279       </div>
280     </form>
281   </div>
282 </nav>
283 <nav class="widget-archive-category widget">
284   <h3 class="widget-header">Categories</h3>
285   <div class="widget-content">
286     
287       
288     <ul class="widget-list">
289       
290       
291       <li class="widget-list-item"><a href="http://defaria.com/blogs/Status/ameriquest/">Ameriquest (99)</a>
292       
293       
294       </li>
295       
296     
297       
298       
299       <li class="widget-list-item"><a href="http://defaria.com/blogs/Status/audience/">Audience (3)</a>
300       
301       
302       </li>
303       
304     
305       
306       
307       <li class="widget-list-item"><a href="http://defaria.com/blogs/Status/broadcom/">Broadcom (76)</a>
308       
309       
310       </li>
311       
312     
313       
314       
315       <li class="widget-list-item"><a href="http://defaria.com/blogs/Status/gpdb/">GPDB (35)</a>
316       
317       
318       </li>
319       
320     
321       
322       
323       <li class="widget-list-item"><a href="http://defaria.com/blogs/Status/general-dynamics/">General Dynamics (61)</a>
324       
325       
326       </li>
327       
328     
329       
330       
331       <li class="widget-list-item"><a href="http://defaria.com/blogs/Status/general-electric/">General Electric (13)</a>
332       
333       
334       </li>
335       
336     
337       
338       
339       <li class="widget-list-item"><a href="http://defaria.com/blogs/Status/hewlett-packard/">Hewlett Packard (13)</a>
340       
341       
342       </li>
343       
344     
345       
346       
347       <li class="widget-list-item"><a href="http://defaria.com/blogs/Status/lynuxworks/">LynuxWorks (162)</a>
348       
349       
350       </li>
351       
352     
353       
354       
355       <li class="widget-list-item"><a href="http://defaria.com/blogs/Status/pqa/">PQA (35)</a>
356       
357       
358       </li>
359       
360     
361       
362       
363       <li class="widget-list-item"><a href="http://defaria.com/blogs/Status/salira/">Salira (79)</a>
364       
365       
366       </li>
367       
368     
369       
370       
371       <li class="widget-list-item"><a href="http://defaria.com/blogs/Status/tellabs/">Tellabs (2)</a>
372       
373       
374       </li>
375       
376     
377       
378       
379       <li class="widget-list-item"><a href="http://defaria.com/blogs/Status/texas-instruments/">Texas Instruments (31)</a>
380       
381       
382       </li>
383       
384     </ul>
385       
386     
387   </div>
388 </nav>
389   
390
391 <nav class="widget-archive-dropdown widget">
392   <h3 class="widget-header">Archives</h3>
393   <div class="widget-content">
394     <select>
395       <option>Select a Month...</option>
396     
397       <option value="http://defaria.com/blogs/Status/2016/02/">February 2016</option>
398     
399   
400     
401       <option value="http://defaria.com/blogs/Status/2014/09/">September 2014</option>
402     
403   
404     
405       <option value="http://defaria.com/blogs/Status/2014/04/">April 2014</option>
406     
407   
408     
409       <option value="http://defaria.com/blogs/Status/2014/03/">March 2014</option>
410     
411   
412     
413       <option value="http://defaria.com/blogs/Status/2013/02/">February 2013</option>
414     
415   
416     
417       <option value="http://defaria.com/blogs/Status/2012/09/">September 2012</option>
418     
419   
420     
421       <option value="http://defaria.com/blogs/Status/2012/08/">August 2012</option>
422     
423   
424     
425       <option value="http://defaria.com/blogs/Status/2012/05/">May 2012</option>
426     
427   
428     
429       <option value="http://defaria.com/blogs/Status/2012/04/">April 2012</option>
430     
431   
432     
433       <option value="http://defaria.com/blogs/Status/2012/02/">February 2012</option>
434     
435   
436     
437       <option value="http://defaria.com/blogs/Status/2012/01/">January 2012</option>
438     
439   
440     
441       <option value="http://defaria.com/blogs/Status/2011/10/">October 2011</option>
442     
443   
444     
445       <option value="http://defaria.com/blogs/Status/2011/07/">July 2011</option>
446     
447   
448     
449       <option value="http://defaria.com/blogs/Status/2010/09/">September 2010</option>
450     
451   
452     
453       <option value="http://defaria.com/blogs/Status/2010/08/">August 2010</option>
454     
455   
456     
457       <option value="http://defaria.com/blogs/Status/2010/04/">April 2010</option>
458     
459   
460     
461       <option value="http://defaria.com/blogs/Status/2010/03/">March 2010</option>
462     
463   
464     
465       <option value="http://defaria.com/blogs/Status/2010/02/">February 2010</option>
466     
467   
468     
469       <option value="http://defaria.com/blogs/Status/2009/05/">May 2009</option>
470     
471   
472     
473       <option value="http://defaria.com/blogs/Status/2009/04/">April 2009</option>
474     
475   
476     
477       <option value="http://defaria.com/blogs/Status/2008/07/">July 2008</option>
478     
479   
480     
481       <option value="http://defaria.com/blogs/Status/2008/05/">May 2008</option>
482     
483   
484     
485       <option value="http://defaria.com/blogs/Status/2008/04/">April 2008</option>
486     
487   
488     
489       <option value="http://defaria.com/blogs/Status/2008/03/">March 2008</option>
490     
491   
492     
493       <option value="http://defaria.com/blogs/Status/2008/02/">February 2008</option>
494     
495   
496     
497       <option value="http://defaria.com/blogs/Status/2008/01/">January 2008</option>
498     
499   
500     
501       <option value="http://defaria.com/blogs/Status/2007/12/">December 2007</option>
502     
503   
504     
505       <option value="http://defaria.com/blogs/Status/2007/11/">November 2007</option>
506     
507   
508     
509       <option value="http://defaria.com/blogs/Status/2007/10/">October 2007</option>
510     
511   
512     
513       <option value="http://defaria.com/blogs/Status/2007/09/">September 2007</option>
514     
515   
516     
517       <option value="http://defaria.com/blogs/Status/2007/08/">August 2007</option>
518     
519   
520     
521       <option value="http://defaria.com/blogs/Status/2007/07/">July 2007</option>
522     
523   
524     
525       <option value="http://defaria.com/blogs/Status/2007/06/">June 2007</option>
526     
527   
528     
529       <option value="http://defaria.com/blogs/Status/2007/05/">May 2007</option>
530     
531   
532     
533       <option value="http://defaria.com/blogs/Status/2007/04/">April 2007</option>
534     
535   
536     
537       <option value="http://defaria.com/blogs/Status/2007/03/">March 2007</option>
538     
539   
540     
541       <option value="http://defaria.com/blogs/Status/2007/01/">January 2007</option>
542     
543   
544     
545       <option value="http://defaria.com/blogs/Status/2006/12/">December 2006</option>
546     
547   
548     
549       <option value="http://defaria.com/blogs/Status/2006/11/">November 2006</option>
550     
551   
552     
553       <option value="http://defaria.com/blogs/Status/2006/10/">October 2006</option>
554     
555   
556     
557       <option value="http://defaria.com/blogs/Status/2006/09/">September 2006</option>
558     
559   
560     
561       <option value="http://defaria.com/blogs/Status/2006/07/">July 2006</option>
562     
563   
564     
565       <option value="http://defaria.com/blogs/Status/2006/06/">June 2006</option>
566     
567   
568     
569       <option value="http://defaria.com/blogs/Status/2006/05/">May 2006</option>
570     
571   
572     
573       <option value="http://defaria.com/blogs/Status/2006/04/">April 2006</option>
574     
575   
576     
577       <option value="http://defaria.com/blogs/Status/2006/03/">March 2006</option>
578     
579   
580     
581       <option value="http://defaria.com/blogs/Status/2006/02/">February 2006</option>
582     
583   
584     
585       <option value="http://defaria.com/blogs/Status/2006/01/">January 2006</option>
586     
587   
588     
589       <option value="http://defaria.com/blogs/Status/2005/12/">December 2005</option>
590     
591   
592     
593       <option value="http://defaria.com/blogs/Status/2005/11/">November 2005</option>
594     
595   
596     
597       <option value="http://defaria.com/blogs/Status/2005/10/">October 2005</option>
598     
599   
600     
601       <option value="http://defaria.com/blogs/Status/2005/09/">September 2005</option>
602     
603   
604     
605       <option value="http://defaria.com/blogs/Status/2005/08/">August 2005</option>
606     
607   
608     
609       <option value="http://defaria.com/blogs/Status/2005/07/">July 2005</option>
610     
611   
612     
613       <option value="http://defaria.com/blogs/Status/2005/06/">June 2005</option>
614     
615   
616     
617       <option value="http://defaria.com/blogs/Status/2005/05/">May 2005</option>
618     
619   
620     
621       <option value="http://defaria.com/blogs/Status/2005/04/">April 2005</option>
622     
623   
624     
625       <option value="http://defaria.com/blogs/Status/2005/03/">March 2005</option>
626     
627   
628     
629       <option value="http://defaria.com/blogs/Status/2005/02/">February 2005</option>
630     
631   
632     
633       <option value="http://defaria.com/blogs/Status/2005/01/">January 2005</option>
634     
635   
636     
637       <option value="http://defaria.com/blogs/Status/2004/12/">December 2004</option>
638     
639   
640     
641       <option value="http://defaria.com/blogs/Status/2004/09/">September 2004</option>
642     
643   
644     
645       <option value="http://defaria.com/blogs/Status/2004/08/">August 2004</option>
646     
647   
648     
649       <option value="http://defaria.com/blogs/Status/2004/07/">July 2004</option>
650     
651   
652     
653       <option value="http://defaria.com/blogs/Status/2004/06/">June 2004</option>
654     
655   
656     
657       <option value="http://defaria.com/blogs/Status/2004/05/">May 2004</option>
658     
659   
660     
661       <option value="http://defaria.com/blogs/Status/2004/04/">April 2004</option>
662     
663   
664     
665       <option value="http://defaria.com/blogs/Status/2004/03/">March 2004</option>
666     
667   
668     
669       <option value="http://defaria.com/blogs/Status/2004/02/">February 2004</option>
670     
671   
672     
673       <option value="http://defaria.com/blogs/Status/2004/01/">January 2004</option>
674     
675   
676     
677       <option value="http://defaria.com/blogs/Status/2003/12/">December 2003</option>
678     
679   
680     
681       <option value="http://defaria.com/blogs/Status/2003/11/">November 2003</option>
682     
683     </select>
684   </div>
685 </nav>
686     
687   
688
689 <div class="widget-syndication widget section">
690   <div class="widget-content">
691     <p><img src="http://defaria.com/mt/mt-static/images/status_icons/feed.gif" alt="Subscribe to feed" width="9" height="9" /> <a href="http://defaria.com/blogs/Status/atom.xml">Subscribe to this blog's feed</a></p>
692
693   </div>
694 </div>
695
696             </aside>
697           </div>
698         </div>
699         <footer id="footer" role="contentinfo">
700           <div id="footer-inner">
701             <div id="footer-content">
702   <nav role="navigation">
703           <ul>
704             <li><a href="http://defaria.com/blogs/Status/">Home</a></li>
705
706
707           </ul>
708         </nav>
709
710   <p class="license">&copy; Copyright 2016.</p>
711   <p class="poweredby">Powered by <a href="http://www.movabletype.org/">Movable Type</a></p>
712 </div>
713           </div>
714         </footer>
715       </div>
716     </div>
717     <script src="http://defaria.com/mt/mt-static/jquery/jquery.min.js"></script>
718     <script src="http://defaria.com/blogs/Status/mt-theme-scale2.js"></script>
719   </body>
720 </html>