Patent Abstract:
A software conversion tool that facilitates automated conversion of a software program from one operating environment to another. More particularly, a computer program is compiled using a compiler for a software environment other than a software environment assumed by the computer program. As a result, the compiler produces an error message, and, in response to the error message, source code within the computer program is automatically modified in order to remove a condition causing the error. The software conversion tool acts in concert with the compiler, which may be a standard compiler, to form in effect an error-correcting compiler, i.e., a compiler that instead of only detecting errors and presenting them to the user, is able to actually correct errors such that they do not occur during recompilation.

Full Description:
BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     The present invention relates to software development tools, in particular to software conversion tools. 
     2. State of the Art 
     Software development is a time-consuming and laborious process. Maintaining and reworking previously-written software is at least equally laborious. Many times a need will arise to convert programs written to run in one software environment (i.e., written to interface to one system) to a form that will run in another different software environment. Such a conversion requires finding all language elements in the programs which refer to the old system and replacing them with language elements that refer to the new system. If the programs are large, including several hundreds of thousands or even a million or more lines of code, performing such a conversion manually is an enormous task. Clearly, it is desirable to devise a machine-assisted method of performing such a conversion. 
     Unfortunately, a simple &#34;search and replace&#34; strategy, in which every occurrence of a specified text string is replaced with a different specified text string, is too simple to provide useful results. In computer languages as in natural languages, the meaning of a particular language element is heavily context-dependent. Sometimes, for example, a local version of a name may appear. Replacing the local version of a name with a global new name results in a program that will not run or will not run correctly. 
     Therefore, there exists a need for a software tool that automates, to the greatest extent possible, software conversions of the type described. 
     SUMMARY OF THE INVENTION 
     The present invention, generally speaking, provides a software conversion tool that facilitates automated conversion of a software program from one operating environment to another. In accordance with one embodiment of the invention, a computer program is compiled using a compiler for a software environment other than a software environment assumed by the computer program. As a result, the compiler produces an error message. In response to the error message, source code within the computer program is automatically modified in order to remove a condition causing the error. The software conversion tool acts in concert with the compiler, which may be a standard compiler, to form in effect an error-correcting compiler, i.e., a compiler that instead of only detecting errors and presenting them to the user, is able to actually correct errors such that they do not occur during recompilation. 
    
    
     BRIEF DESCRIPTION OF THE DRAWING 
     The present invention may be further understood from the following description in conjunction with the appended drawing. In the drawing: 
     FIG. 1 is a perspective view of a conventional computer workstation with which the present invention may be used; 
     FIG. 2 is a block diagram of a portion of the computer workstation of FIG. 1; 
     FIG. 3 is block diagram of the error correcting compiler of the present invention; and 
     FIG. 4 is a flow diagram illustrating operation of the error correcting compiler of FIG. 3. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     A computer system with which the error correcting compiler may be used will first be described, followed more particularly by a description of the error correcting compiler itself. 
     Referring first to FIG. 1, the error correcting compiler may be used on a computer workstation of the type shown, having a monitor 110, a keyboard 120 and a mouse 130. A mouse cursor 140 appears on the monitor screen and moves as the mouse is moved. 
     The internal hardware of the computer workstation of FIG. 1 may be represented in simplified block diagram form as shown in FIG. 2. The computer system has a central processor 202, a system memory 204, a display 206, a printer 208, a keyboard 210, a pointing device 212, a disk storage subsystem 214, an I/O controller 216, and interconnecting means 218 such as a system bus. 
     Having described the hardware environment of the invention, the software components of the error correcting compiler and their interrelation will now be more particularly described with reference to FIG. 3. 
     The error correcting compiler is in actuality a standard compiler operating in concert with a software conversion program. In one embodiment, the software conversion program is used to convert Objective C programs compatible with one application interface (e.g., NextStep™) to Objective C programs compatible with another application interface (e.g., OpenStep™) and is named &#34;cvtcc&#34;, referring to the function performed by the program of converting code from one version of Objective C to another. 
     Referring to FIG. 3, the conversion program 310 has four principal components, a simple parser 311, a database 313, a substitution program 315 and a control program 317. The conversion program 310 operates in concert with a standard compiler 320 to convert an old program 330 that assumes an old software environment into a new program 340 that assumes a new software environment. 
     The parser 311 and the substitution program 315 together function as an access program. The data base 313 and the access program map old language elements into new. In particular, the parser 311 receives error messages from the compiler 320 and extracts from the error messages old resource names and the file names and line numbers where the old resource names appear. The old names are used to look up corresponding new names in the database 313. The new names, file names and line numbers are then supplied to the substitution program 315, which performs the actual substitution of the new names for the old names. The database is constructed manually by a skilled programmer familiar with both the old software environment and the new software environment. 
     To convert an old program to a new program, the conversion program 310 is run repeatedly by a control program 317. First, the user calls the compiler, designed or configured to compile to the new system environment instead of the old, to compile the old program. As a result, errors are generated on uses of the old system language elements. Under control of the control program, the error correcting compiler (i.e., the conversion program 310 in cooperation with the compiler 320) iteratively replaces one or more old system elements with corresponding new elements found in the conversion database and recompiles. Thus, the error correcting compiler will continue to call the actual compiler, which will fix the resulting errors until no more errors can be fixed. 
     Referring more particularly to FIG. 4, when the error correcting compiler begins to run, a flag fixedSome is set to false (Step 401). A regular compiler is then called to compile the program to be converted, and the error listing from the compiler is captured (Step 403). The first error message is then parsed (Step 405). If the error is not of a recognized type (Step 407), then if there is a next error message (Step 409), it is parsed, and so forth. 
     If the error is of a recognized type, i.e., a type that the error correcting compiler may be able to fix, such as an &#34;identifier not found&#34; message (Step 407), then the name of the old programmatic element is extracted from the error message (Step 411), together with the location (file, line number) of the reference to the old name. The old name is then looked up in the database (Step 413). If the old name is not found in the database (Step 415), then the next error message (if there is one) is processed. If the old name is found in the database (Step 415), then the old name is replaced with the new name found in the database (Step 417), after which the flag fixedSome is set to true (step 419). 
     The foregoing sequence of operation is performed for all of the error messages until there is no next error message (Step 409). Then, if fixedSome is true (Step 421), the process repeats from the beginning, by resetting fixedSome to false (Step 401) and recompiling the modified program (Step 403). 
     Operation proceeds in this fashion until the error correcting compiler is unable to fix any more errors, i.e., until fixedSome remains false in Step 421. The error correcting compiler then stops. Errors that the error correcting compiler was not able to fix may then be fixed manually. 
     The error correcting compiler may be further appreciated from the following Appendices. Appendix A is a listing of a sample database. Appendix B is a screen printout generated during use of the error correcting compiler. 
     Referring to Appendix A, the database, in the illustrated embodiment, is of a very simple organization. Entries beginning in the first text column are old names to be replaced. If a replacement entry is found in the database, it is entered on the line immediately following, beginning in the second text column. Not all old names have corresponding new names, and vice versa. The symbols &#34;#&#34;, &#34;@&#34;, &#34;+&#34;, &#34;-&#34; have recognized meanings in Objective C. 
     Referring to Appendix B, to provide a concrete example of operation of the error correcting compiler, a version of the error correcting compiler running on a SparcStation™ computer and running under the SunOS operating system was called on the example program of lines 1-7. Beginning on line 8, the compiler is run, resulting in the four error messages listed on lines 11-14. Beginning on line 16, the conversion program is run using the error message file generated by the compiler. The conversion program first tries to fix include file errors. Hence in lines 21-24, the conversion program reports that it changed the name of the include files as specified in the database. the compiler is then called again to recompile the modified program (line 26). The errors reported in further error messages are then fixed. In line 44, the error correcting compiler reports that it has fixed all the errors it can. The resulting modified program is listed in lines 48-54. Note that &#34;Menu&#34; in the original program has been changed to &#34;NSMenu&#34;, and &#34;initTitle&#34; has been changed to &#34;initWithTitle&#34;. 
     It will be appreciated by those of ordinary skill in the art that the invention can be embodied in other specific forms without departing from the spirit or essential character thereof. The foregoing description is therefore considered in all respects to be illustrative and not restrictive. The scope of the invention is indicated by the appended claims, and all changes which come within the meaning and range of equivalents thereof are intended to be embraced therein. 
     
                                           APPENDIX A__________________________________________________________________________appkit/Menu.h AppKit/NSMenu.h@interface Menu : Panel @interface NSMenu : NSPanel+ setMenuZone: (NXZone *)aZone; + (void)setMenuZone: (NSZone *)aZone;+ (NXZone *)menuZone; + (NSZone *)menuZone;#- init;initTitle: (const char *)aTitle;(id)initWithTitle: (NSString *)aTitle; // if aTitle is NULL, change it to @&#34;&#34;(id) insertItemWithTitle: (NSString *)aString action: (SEL)aSelectorkeyEquivaient (NSStringaddItem: (const char *)aString action: (SEL)aSelector keyEquivalent:(unsigned short)charCode(id)addItemWithTitle: (NSString *)aString action: (SEL)aSelectorkeyEquivalent (NSString *)setSubmenu:aMenu forItem:aCell;(NSMenuCell *) setSubmenu: (NSMenu *) aMenu forItem: (NSMenuCell *)aCell;(NSMenu *)supermenu;(NSMenu *)attachedMenu;(BOOL) isAttached;(BOOL) isTornOff;itemList;(NSMatrix *)itemMatrix;setItemList: aMatrix;(void) setItemMatrix:(NSMatrix *)aMatrix;display;sizeToFit;(void)sizeToFit;windowMoved: (NXEvent *)theEvent;close;update;setAutoupdate: (BOOL)flag;(void) setAutoenablesItems: (BOOL) flag;(BOOL)autoenablesItems;findCellWithTag: (int)aTag;(id)cellWithTag: (int)aTag;getLocation: (NXPoint *)theLocation forSubmenu:aSubmenu;(NSPoint) locationForSubmenu: (NSMenu *) aSubmenu;mouseDown: (NXEvent *)theEvent;rightMouseDown:(NXEvent *)theEvent;#+ new;+ newTitle: (const char *)aTitle; @end@end@interface Menu (SubmenuDummyAction) @interface NSMenu (NSSubmenuDummyAction)submenuAction:sender;(void)submenuAction: (id)sender;@end @end @interface NSObject (NSMenuActionResponder)(BOOL)validateCell: (id)aCell;@end__________________________________________________________________________ 
    
     
                                           APPENDIX B__________________________________________________________________________  &gt;&gt;:271 more ˜/all.m2 #import &lt;appkit/appkit.h&gt;34 void gus( ) {5  Menu *fred;6   fred initTitle: &#34;abc&#34;!;7 }8 &gt;&gt;:272 CC ˜/all.m -C -I/net/doe/export/o6p/dev8/jjh/nsrt/src/inclu  de \9     -I/usr/openwin/include/X11 -I:/usr/openwin/include10  &#34;/home/jjh/all.m&#34;, line 2: Error: Could not open include file  &lt;appkit/appkit.h&gt;.11  &#34;/home/jjh/all.m&#34;, line 5: Error: Menu is not defined.12  &#34;/home/jjh/all.m&#34;, line 5: Error: fred is not defined.13  &#34;/home/jjh/all.m&#34;, line 6: Error: fred is not defined.14  4 Error(s) detected.15  &gt;&gt;:273 bin/cvtCC ˜/all.m -c -I/net/doe/export/o6p/dev8/jjh/nsrt/sr  c/include \16 -I/usr/openwin/include/X11 -I/usr/openwin/include17  Using default fileName: /home/jjh/myaux/src/ConversionTools/appkitdb18  *** Compiling ***19  *** Attempting to fix errors ***20  *** Fixed these msgs ***21  &#34;/home/jjh/all.m&#34;, line 2: Error: Could not open include file  &lt;appkit/appkit.h&gt;.22   -- from&gt; source= `appkit/appkit.h`23   -- to&gt; source= `AppKit/AppKit.h`24  *** Fixed some missing include file errors; recompiling ***25  *** Attempting to fix errors ***26  *** Fixed these msgs ***27  *** Fixed these msgs ***28  &#34;/home/jjh/all.m&#34;, line 5: Error: Menu is not defined.29   -- from&gt; file=appkit/Menu.h, source= `@interface Menu : Panel`30   --  to&gt; file=AppKit/NSMenu.h, source= `@interface NSMenu :NSPanel`3132  *** Fixed some errors, recompiling ***33  *** Attempting to fix errors ***34  *** Fixed these msgs ***35  &#34;/home/jjh/all.m&#34;, line 6: Warning: Cannot find instance method  initTitle: \36  for class NSMenu:NSPanel:NSWindow:NSResponse:NSObject.37initTitle:(const char *)aTitle;`source= `38(id)initWithTitle:(NSString *)aTitle;`e= `39 // if aTitle is NULL, change it to @&#34;&#34;4041  *** Fixed some errors, recompiling ***42  *** Attempting to fix errors ***4344  *** Fixed all we can in this file ***454647  &gt;&gt;:274 more ˜/all.m4849  #import &lt;AppKit/AppKit.h&gt;5051  void gus( ) {52   NSMenu *fred;53    fred initWithTitle: &#34;abc&#34;!;54  }__________________________________________________________________________

Technology Classification (CPC): 6