mcdonald@AEDC-VAX.AF.MIL (05/16/91)
The following is a short c-prog for converting FORMS 1.2 programs to FORMS 1.3 programs. There are three files with this: convert.c - The conversion program CONVERT.lower - listing of lowercase strings to replace CONVERT.upper - listing of UPPERCASE strings to replace The CONVERT.lower & CONVERT.upper can be replaced with the listing from Mark Overmars that was posted to this list, but this will slow the prog down a little because I am searching/replacing strings of the form set_ get_. This conversion program works considerably faster than the one I posted yesterday that made use of perl. Any comments/suggestions should be returned directly to me at mcdonald@aedc-vax.af.mil. All you need to do is unarchive this by saving the contents below in a file, and then sh filename. To run it type convert formsfile.c. ------------------------------ < CUT HERE > ----------------------------------- #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: ./CONVERT.lower ./CONVERT.upper ./convert.c # Wrapped by c60244@ccfiris.aedc on Thu May 16 09:08:14 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f './CONVERT.lower' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'./CONVERT.lower'\" else echo shar: Extracting \"'./CONVERT.lower'\" \(333 characters\) sed "s/^X//" >'./CONVERT.lower' <<'END_OF_FILE' Xactivate_ Xadd_ Xaddto_ Xbgn_ Xblkqread Xcheck_ Xclear_ Xcreate_ Xcurrent_ Xdeactivate_ Xdelete_ Xdeselect_ Xdisplay_ Xdo_ Xdraw_ Xdrw_ Xend_ Xfind_ Xfreeze_ Xget_ Xgetmcolor Xhandle_ Xhide_ Xinsert_ Xisqueued Xisselected_ Xload_ Xmake_ Xmapcolor Xnew_ Xqdevice Xqenter Xqread Xqreset Xqtest Xredraw_ Xremove_ Xreplace_ Xselect_ Xset_ Xshow_ Xtie Xunfreeze_ Xunqdevice Xunset_ END_OF_FILE if test 333 -ne `wc -c <'./CONVERT.lower'`; then echo shar: \"'./CONVERT.lower'\" unpacked with wrong size! fi # end of './CONVERT.lower' fi if test -f './CONVERT.upper' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'./CONVERT.upper'\" else echo shar: Extracting \"'./CONVERT.upper'\" \(537 characters\) sed "s/^X//" >'./CONVERT.upper' <<'END_OF_FILE' XALIGN_ XALL_FREE XALWAYS_ XBEGIN_ XBITMAP_ XBOLD_ XBORDER_ XBOT_ XBOUND_ XBOX_ XBROWSER_ XBUTTON_ XCALLBACKPTR XCHOICE_ XCLOCK_ XCONTINUOUS_ XCOUNTER_ XDIAL_ XDOWN_ XDRAWPTR XEND_ XENGRAVED_ XEVENTCALLBACKPTR XFIND_ XFIXED_ XFLAT_ XFONT_ XFORM XFRAME_ XHANDLEPTR XHIDDEN_ XHOLD_ XHOR_ XINOUT_ XINPUT_ XITALIC_ XKEYBOARD XLABEL_ XLARGE_ XLEAVE XLEFT_ XLIGHTBUTTON_ XLINE_DIAL XMENU_ XMOVE XMULTI_ XNORMAL_ XNO_ XOBJECT XPLACE_ XPOSITIONER_ XPUSH_ XRADIO_ XRELEASE XRETURN_ XRIGHT_ XROUNDBUTTON_ XROUND_ XSELECT_ XSHADOW_ XSLEEPING_ XSLIDER_ XSMALL_ XSQUARE_ XSTEP XTEXT_ XTOP_ XTOUCH_ XUP_ XVALSLIDER XVERT_ END_OF_FILE if test 537 -ne `wc -c <'./CONVERT.upper'`; then echo shar: \"'./CONVERT.upper'\" unpacked with wrong size! fi # end of './CONVERT.upper' fi if test -f './convert.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'./convert.c'\" else echo shar: Extracting \"'./convert.c'\" \(1776 characters\) sed "s/^X//" >'./convert.c' <<'END_OF_FILE' X#include <stdio.h> XFILE *ifp, *ofp; Xchar filebuff[80000],tmpfilebuff[80000]; Xint len; X Xint rplstr(char *str, char *rpstr) X{ X int slen,pos,tpos,i,match=0; X char cmpbuf[25],*fpr, ans[5]; X X fpr=filebuff; X slen = strlen(str); X pos=0; X len = strlen(fpr); X tpos=0; X while (*fpr) { X memcpy(cmpbuf,fpr,slen); X if (memcmp(cmpbuf,str,slen)==0) { X strcat(tmpfilebuff,rpstr); X strcat(tmpfilebuff,str); X pos+=slen; tpos+=slen+3; fpr+=slen; X tmpfilebuff[tpos]='\0'; X match++; X } X else { X tmpfilebuff[tpos]=filebuff[pos]; X pos++; tpos++; fpr++; X tmpfilebuff[tpos]='\0'; X } X } X return(match); X} X Xmain(int argc, char *argv[]) X{ X FILE *fp; X char str[20], rpstr[20], tmpfile[20], cmd[50]; X X if (argc!=2) { X fprintf (stderr,"usage: %s file\n",argv[0]); X exit(1); X } X sprintf (cmd,"ls %s > /dev/null 2> /dev/null",argv[1]); X if (system(cmd) != 0) { X fprintf (stderr,"error: %s: %s not found\n",argv[0],argv[1]); X exit(1); X } X sprintf(tmpfile,"%s.orig",argv[1]); X sprintf(cmd,"mv %s %s",argv[1],tmpfile); X system(cmd); X ofp = fopen(argv[1],"w"); X ifp = fopen(tmpfile,"r"); X while (fgets(str,256,ifp)!=NULL) { X strcat(filebuff,str); X } X fclose(ifp); X fp = fopen ("CONVERT.upper","r"); X while (fgets(str,25,fp)!=NULL) { X str[strlen(str)-1]='\0'; X sprintf(rpstr,"FL_%s",str); X if (rplstr(str,rpstr)) X strcpy(filebuff,tmpfilebuff); X } X fclose(fp); X fp = fopen ("CONVERT.lower","r"); X while (fgets(str,25,fp)!=NULL) { X str[strlen(str)-1]='\0'; X sprintf(rpstr,"fl_%s",str); X if (rplstr(str,rpstr)) X strcpy(filebuff,tmpfilebuff); X } X fclose(fp); X fputs(filebuff,ofp); X} END_OF_FILE if test 1776 -ne `wc -c <'./convert.c'`; then echo shar: \"'./convert.c'\" unpacked with wrong size! fi # end of './convert.c' fi echo shar: End of shell archive. exit 0 ------------------------------ < CUT HERE > ----------------------------------- vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv | Kenneth M. McDonald * OAO Corp * Arnold Engineering Development Center | | MS 120 * Arnold AFS, TN 37389-9998 * (615) 454-3413 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNET: mcdonald@aedc-vax.af.mil LOCAL: c60244@ccfiris