Differ: File Diften:nClfH.2 TonI for C Source Code i\ ..

advertisement
Differ: i\. File Diften:nClfH.2 TonI for C Source Code
L
An Honors ThesIs (HONRS ,199)
Jalllt.:s
PullarJ
Dolores Z:lgc. Advisor
TJ "I
Dal
Statc
L.
T'·
"
UnlVt.:fSH\
Muncie. Indiana
::.} ....
Parpn<.:,' or I hl~si"
TIl..: purpo;,,~ v1 thl:> proJect vvas td d.::\is..: and impkm..:nt ;In algorithm to shO\\
diikrenccs h:il.\'CCn 1\\;;) 1.'>:rsi(!Tls,f tiL ';;.;.11':: C ,.,,)j1J",-,.' ":.)(L ;In,.:um.::nt. \!;m\" t(IO\S ('XiS1
currently fell ;lc.'::dmplishin~ thi; Iuikti,m in plJin k\:t docui11<2nts. using assumptions about
the differem;es that ilrc found HI thosl.: samt: ~'pc of dOl.:uments. The problem is that these
assumptions arc not yalid in ~'~ry application. and tend to i)\r..:r-n::porl Ch~Hl;~:S Ih:!! do not
truly dfl:ct a file' s structure. Compukr plOgrammep· arc frequently faced \vi rh the lask of
tr,l(;ing chang(~ made 10 .. pwj ;..:1 in on 1.::1' 1<' disJ". c! an impiank,d f1;1\\. hut rhetooh that
trl.."at all dOOllTl,;nls as plain 11:.\1 do not ad.:qui.ltd\" !k... crib~ 10 lhe prorrammer the changes
in "(luree code Thi" progr,lm will h()p(;full~' pruyidr.. a pradi~al ~olution to the i~sucs ·..of
0\.'-':1'110'" \vith ~;.\(rJno;;ous infol mali(l}1 and miST I;.pr-,:sl.'lltation of l-hatlg\;s .
-
.
Input Format
The input format to Differ will be a list of files to compare separated by a "_s" option, or option flags
may be used to tell Differ that one or more index files are to be read for the directory of a fileset.
Example command lines look like:
•
•
•
•
"Differ newfile 1 newfile2 ... newfilen -s oldfile 1 0ldfile2 ... oldfilem"
"Differ -0 oldindexfile newfilel ... newfilen"
"Differ -n newindexfile oldfilel ... oldfilem"
"Differ -0 oldindexfile -n newindexfile".
·tak into au.oun! <;('v('rall~'\ ;;~1, tl! pr,):,;r:nn
s[ructur..:, . \,1 each of these kvd-;, J differe1l! ".:1 uf faLIO! s musl he Llken mID ,[cenum,
\yhen it is h.;:i112 dC~\,T1llj:,:d\'.h~!1 in Ll. t \\ a" <.: har:~('d bdw('ctl th:: 1',,,(' '.-".:r"jp:1': cf tJ':: file,
r uil~ umkl :'l;Uh~i.ng [h,.: IMLUl\.; (' i 111-: eh.in":!;'; i:-, Ihe gOd, of UiLL b':Uli'i(, with !lui
unckr<;ti1ndin~ m':<.:sJg('" can he: ~m:".;:nh:d tn the 11<:,:1' in J ck.:1r Jnd conci"c \Y;lY, Cutting
rile diff.:r::Hcing 01 (' sourc.: ,,;oe1:.:
du\\ n un th .. u\l.'rh,,'ad .:nabk"
tnU,,(
til": progrdlllnkT j u SI.',- \\- ilh
pT"llC'~S'
hi"
C1\\
n c! ...~" i1l-. ;. hang!.:
and 1J;;~ !hal knowkdg-: to llnd the (;;'11"(>1' that \\ J" it"rodl!c\~d I he: mJin k\(;;'l" pi
tt> d '-(lUlL,; u'lk fi1...: .11': th,' i;"';,'.:l lh,. d,. «'1111<:lh!liOil \\ilhin 1>_' \. \,
fundifln as a unl\. dlld the imli,j·l!ullln<:;'- tjnt 1i!'!~'.'> U!) cll. i. hHi\,("'P "),·nk 111'.'" ill ih.:
sirudlU<..:
••• '-
,.., -.." l
-
,-
<~ •
!! \ i
i ~,
•
~ ~
Documentation
Cosmetic Changes
• Most Changes to Documentation
Real Changes
• Uncommenting
Overview: Changing documentation is a cosmetic change that does not affect program function.
Rearrangement of lines and changing of the text should not be flagged as an error, but a message may
appear alerting the user to a documentation difference. Uncommenting of lines is a real change in
program function, but this change will be caught as an addition of source code lines.
Functions
Cosmetic Changes
• Reordering
Real Changes
•
•
•
•
Renaming
Adding
Deleting
Change in scope
Examples
Overview: Rearrangement of the functions in a C source file does not affect the compilation of the file
(assuming prototypes are available), and therefore should not trigger an alert to the user. Feedback
indicating to the user the movement of functions might be appropriate, but the current Diff s line by line
listing of added and deleted statements is unnecessary. Keying on functions in this program for
comparison will be based on function names, and therefore renamed functions will be flagged as new
functions. Because the act of renaming a function effects all of the calling modules in the same source
file as well as any files that use the function externally, renaming of a function is reasonably sized
source code alteration. Although a renamed function (if done properly) will not affect program
operation, an error or warning flag is a reasonable tradeoff for allowing an effective function tracking
mechanism. Scope change of a function is a definite change in source code and program operation, and
therefore will need to be flagged with error messages. Addition and deletion of functions will cause the
function location to be listed, but the entire code of the function does not need to be listed.
--
#Include File List
Cosmetic Changes
• Reordering
Real Changes
• Deletion
• Addition
Examples
Overview: The #Include File List at the top of a C source code file can be reordered in most cases
without changing the operation of a program. With "ifdef" statements inserted correctly in the header
files, multiple initialization of variables and other compiler-unfriendly actions are prevented while first
passes are still allowed through all of the headers. This protects the compiler against repetition of
include statements that arise with nested calls. In the case of #include reordering, a simple warning
message would probably be a lot more helpful than a line by line listing of statements that have been
changed. At the very least, a line that has been moved should not appear as both added and deleted from
the same header. As in the current Diff, actual additions and deletions in the list of #include statements
should trigger an alarm to the user, because program function and/or compilation has been altered.
Source Lines
Cosmetic Changes
• None
Real Changes
• Rearrangement
• Addition
• Deletion
Examples
,-
Overview: Changes to lines of source code within a function body should account for the majority of
error messages in the output of any differencing of project versions. There are only two ways to improve
upon the operation of the current Diff program in this area. The first change is the limiting of version
comparison to the boundaries of separate functions. This will reduce needless warning messages that
arise with function movement. The second improvement that can be made on the current Diff error
messaging is cross-checking of addition and deletion lists for line rearrangement. Movement of lines in
source code is a legitimate change in program structure, but listing a line as added and deleted creates
extra error messages. Reducing clutter in the output of a differencing run is one of the primary goals of
Differ, and this is one of the more effective ways of accomplishing this goal.
Multiple Files
Example
Overview: As a project grows in size, it often becomes necessary to break a large source file into
smaller pieces holding related functions. Because of compiler requirements, all of the pieces must
contain similar header material for definition of global variables and include statements. Using Diff on
concatenated files in this manner would not give satisfactory output, because function reordering and
header changes would be flagged as real changes to the file and the screen would quickly fill up with
needless warnings.
Functions will be addressed and tracked according to their name and functions that have identical
names will be thrown into a pool for comparison. Since there can only be one external function of a
particular name per project external functions in the comparison pool will be matched. Overlapping
externals will produce an error, because the file set is not a single project. For static functions in the
pool, functions in files with similar names will be matched together as versions of each other. The
remaining functions (if any) are not possible to automatically match, and will therefore require operator
input to make the connections. Prompting the operator will allow matches to be made or the tool can
abort operation.
-
\\ Hllolll .Ii< '-.ll,-h..lIL ..:lkL-l;\.; "~.lr~h 11l,,:,jlU~llb ... jJlU,lJdtri \,DllJd ~ii.lg \u d ll.dl'h It!1lUlUlh
QF\', ;'1 ';1 7
,•
.1nd rh(
~.T DLll,-j ~(juj\,., . Il
r;li11~I'.'·
(J\..h ;'un..:lioll
~ii('11"; ilLT..\J<'
dhHilh.aU\
hy' til!'".
r':c1'i'.'n. tlh.'
Jlgorithm chosen
Jnd unh trJvds forwJrd tlu'ough tk'
s1Jt~nl\.:nt
ii"t l11l" also helps tlK' prGgram to be streJmlincd. not taking tnn ITmd' of J hitc (1m of
il\ail.lhk 11'lI.;mor:,. amllully using lh..: .,pa..:..: thai It ('0":"; h<l\.. th..: 11.)1;,\,,\ Ell:' iLclhlr,niolb
shO\\ Differs ad'on
(In
Of'
two t:'\tn'n1";;'I;. <;nnpL.: "ds (,I ((,de
",ueh "nu1i:.\.1rllpL·:"'I.
il h":\..Oli'-:~' \..],,;di
1,0\\ Lllgc
:-.(:h
H~'
ulI<iI:.T..:t;mdim!
\If "lA..:nl..:nh
1,0\\
it \\:or'h.s
Cdn he plOc..:ss.~'d.
Tn th.: illustr;ttinns, the arnHV at each Y~rsjon of th~ program r.:presents the ;';1I!1'.;nt
L\,xpt [('If short 1.Joks alicacl. rlh' ~irn'\\ ira\cb -;ill(l\·l111y f~jn\anJ. pro\>.:;,~ing th..:
funcriotl one lin..:; at a rime Th.; liqs at th..: bottom of the diagram are bun;';r~ holdlng
«tjlm" of cock thJt a1": susp..:cl.::d to 11a\ .. b..:-:n dd..:k,11i( -m or ackkd 10 th~ c~tiginal tit..:
tu creak the fe\·jsc;d \.;;;1'51011. Sorn;;; olrh-.;se lines do in IJct tum OUI to be added or ddekd
from the cod..::. but lHJny i..ll c;o '1r..~ dd.:nnll1('d to haye he en mo\'ed from on..: an:a of th:
program ill anothcr. Because mO\'ement is an actual chang~' to program tunctim1. it must
he flag.ged as <;uch. and a big SJ,ings is made in mcssJging 0\,;:1' tr:lditiona! Dift progJ'am"
that \\(mid have nOh';'d rl1'.:: lines as haying b"::d1 dckr.:d hom. \.:<11 added to th~, clocurn~nt.
\i\..y\
-
,-
,-
-
,-
-
,-
-
-
-
-
-
-
,-
-
-
-
-
-
-
-
-
-
.-
-
-
-
,-
-
c-
-
-
-
-
--
.-
-
-
-
-
-,
-
-
-
-
-
-
-
.-
-
-
T11-: follcming u~t j" :1 ,Jurt Jc(lj, at sOtn..: of th\.' ,-'OI]\\.'ntioT1S thaI \\ ..:r~' fDlhm·,:d
\\h(;11 t(mtlulaling th..: program hmdion. ScY(;1al of thl.:m \\ ll1 s.:..:m Unimp(ll1.111L but 11 is
n(':C:SSJry to knmy th;: a~sumptic·n<;: J<1'::.1c I-~, an algorithm t" fully unckr!'tmd it-; functi()Tl
Folhmln:; 111~il li"I lS a p.1g( thal \\ J~ dliginally \.;\:sign..:d a" an ii.l-:a' c.\Jmpk d'11o\-.
tlL Oll1:)Ui of th\.~ pr"gJatn should lonk t'1 tht;.' U"('l'. TIK rrl("~Jgjng in dl': 111ode! Ins heen
clu.'-.dy malch..::d n ,he .1ctual \\t}lki.ll~ ptugram, anJ .,i) llUl'.iully [h..: m~·s"ag.'cs gi\..:n to the
1.'''('1
-
-
will
b~
;l')
ckat a" th<-'"
\v~rt' mknd~d to h~.
Conventions
1. If a match is not found for a statement in the remaining statement list for the function body, the
deleted/added list should be searched upwards, because when lines are moved they are assumed to
have moved the least possible distance.
2. When comparing header info, only compare if filename matches.
3. When comparing file names, do not include directory in comparison.
4. No spaces between words and operators or punctuation marks ( '" ,. { }[]O+=-M/I&% k> ) in the
table file returned from the utility
5. Comments will be removed from function body
6. # statements will have # placed at end of statement
7. Lines are more likely to have been added than subtracted, so equal distances should defer to item
having been added to old file to make new file
8. There can only be one extern function of the same name per project file list
9. Multiple static functions of the same name are matched first on filename, and then on user input
10. Processing is done on list of functions in old files
11. Input table file will have a static/extern character thrown in even for entries that are headers for
files.
12. Headers for files will not have names in the function field, and will only be matched based on
filenames being exact
-
Differ Operation Examples
Function Call Changes
Original
example.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int x(int a, int b)
{
return(a + b) ;
}
int y(int a, int b)
{
return(a * b) ;
int z(int a, int b)
{
return(a / b) ;
static int v(int a, int b)
{
return (a
-
-
b) ;
int u(int a, int b)
{
return(a '" b) ;
file2. c
int x(int a, int b)
{
printf("this is the original x in file2.c\n");
return(l) ;
Revision
example.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int x(int a, int b)
{
return(a + b) ;
int w(int a, int b)
{
return(a / b) ;
int v(int a, int b)
-
{
return(a
-
b) ;
static int u(int a, int b)
-
return (a
A
b);
}
file2b.c
int x(int a, int b)
{
printf("this is the original x from file2.c\n");
return(l);
}
int y(int a, int b)
{
printf("this is the original y from example.c\n");
return (a * b);
Output
-
>example.c-example.c+example.c-example.c+example.c++example.c--example.c>example.c-file2b.c
+example.c-y
>file2.c-file2b.c
-file2.c-x
+file2.c-x
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int z(int a, int b) { ... }
int w(int a, int b) { ... }
static int v(int a, int b) { ... }
int u(int a, int b) { ... }
inty(inta, intb) { ... }
printf("this is the original y from example.c\n");
int x(int a, int b) { ... }
printf("this is the original x in file2.c\n");
printf("this is the original x from file2.c\n");
This says that:
#include <stdio.h> was moved in the example.e file
#include <unistd.h> was deleted in the example.e file
#include <string.h> was added in the example.e file
function z was deleted in example.e
function w was added in example.e
function v has gained external scope in example.e
function u has lost external scope in example.e
function int y(int a, int b) {... } was moved from example.e to file2b.e
printf("this is the original y from example.e\n"); was added to function y in example.e
function int x(int a, int b) {... } was moved from file2.e to file2b.e
printf("this is the original x in example.e\n"); was deleted from function x in file2.e
printf("this is the original x from example.e\n"); was added to function x in file2.e
The functions named x are traced only because one pair is found in files of the same name, example.c.
Therefore the two that are left are assumed to correspond. If this were not the case, the user would be
prompted to provide the correlation of the functions.
-
The function table output from the tool would look like this:
Original
Revision
1
1
Internal
1 Location
1 Name
1
Location
1 Change?
-----------1----------------1-------------1-----------------1-----------1 example.c 1
1
example.c
1 *
1 example.c 1 x
1
example.c
1
x
1 example.c 1 y
1
file2b.c
1 *
y
1
1
1 example.c 1
z
Name
v
I
u
I
example.c
example.c
I
I
x
I
file2.c
file2.c
I
v
u
I
w
I
I
I
I
I
I
I
x
I
example.c
example.c
example.c
file2b.c
file2b.c
I
I
I
I
I
*
This table says that:
file example.c was not renamed but has internal changes (globals or defines)
function x from example.c was not moved or changed internally
function y from example.c was moved to file2b.c and changed internally
function z from example.c was not found in the revised file set
function v from example.c was not moved or changed internally
function u from example.c was not moved or changed internally
function w in the revised example.c was not in the original file set
file file2.c was renamed to file2b.c but has no internal changes (globals or defines)
function x from file2.c was moved to file2b.c and changed internally
-
l'hc follmYing ';ections inc1Hck J sd "ff1.tn,:1iot1s us\.'d le: i;;.'st th.:' r~ ()gram fUllction.
and the output g,:naJt...:J in DiHer. rh..:. uUlpul ... ~m k: ,,~(:n to match dosch' th..: modd
seen prc""\i0u<;1y 11 alnl()s! all cas .. s. The m(;~'";;:lges generated in a little more than a page of
output gi\e the same messages that the L>T'\ tooi Dift' givcs in the nearly rwo Jnd a half
page set of output followLl1g. Sot only is t1h.' output nearly half a<; long. but it should 11<.:
casier to tollmv lor a progranun,-T anal.vzing his project.
-
-
/***********************************************************************
*
Old File Set
James Pollard
April 20, 1997
These functions were used as the original file set for
testing.
These were not necessarily developed by
me, but were found freely available.
Reformatted for printing
* File
...... Developer
Date
* Description
*
*
* Note
*
***********************************************************************/
int x(int argc,char**argv)
{
extern int optind;
extern int opterr;
int aflg=O;
int iflg=l;
int nread;
int flags;
int *fd;
int badfiles=O;
int n;
int index;
char buffer [BUFSIZ] ;
opterr=O;
while ( (c=getopt (argc+1, argv, "ai" ) ) ! =EOF)
switch(c)
-
{
case , a' :
aflg++i
breaki
case , i' :
iflg++i
case '?':
(void)fprintf(stderr,
"usage: cmd [-al-i]
exit(2) i
file1
}
if(aflg==l)
flags=O_APPENDlo_CREATlo_WRONLYi
else
flags=O_TRUNC IO_CREAT IO_WRONLYi
if(iflg==l)
signal(SIGINT,SIG IGN);
fd[O]=li
fd=(int*)malloc( (argc-optind+1)*sizeof(int)) i
for (n=lioptind<argcioptind++)
if((fd[n]=open(argv[optind] ,flags,0666))<0)
{
fprintf(stderr,"%s :",*argv);
perror (argv [optind] ) i
}
badfiles++i
else
--
n++i
while((nread=read(O,buffer,BUFSIZ))>O)
for (index=Oiindex<niindex++)
if (write (fd[index] ,buffer,nread) !=nread)
{
fprintf(stderr,"%s :",*argv)
i
[ ... ] \n")i
-
perror(": Could not write to file\n")j
exit (badfiles+1) j
free (fd) j
}
free (fd) j
return badfilesj
}
void main(argc,argv)
int argcjchar *argv[]
register int ij
char buf[MAXLAME]
if (argc>l)
j
j
{
if(*argv[l]=='-')
{
usage()
exit () j
j
}
for(i=lji<argcji++)
{
sprintf(buf,"%s ",argv[i])
lamerize(buf) j
-
j
}
printf ("\n")
exit () j
j
}
lame()
exit ()
j
j
lame ()
{
char ch,ch_buf[MAXLAME]
register int ij
ch buf[O]=NULLj
whIle (1)
j
{
ch=fgetc(stdin) j
if (ch==EOF)
return (-1) j
strncat(ch buf,&ch,l)
if (ch=='\n')
j
{
lamerize(ch buf) j
for(i=Oji<strlen(ch buf) ji++)
-
{
-
ch_buf[i]=NULLj
}
}
}
Jo-..nerize(buf}
char buf[] i
{
register int j,count=Oi
char out [MAXLAME] i
#ifdef LAME SRAND#
time t t i
srand((unsigned) time(&t))
#else#
srand((unsigned)getpid()) j
#endif#
for(j=Ojj<strlen(buf) jj++)
j
{
if(buf[j]=='y'&&buf[j+1]=='o'&&buf[j+2]=='u')
{
out [count++]='U' i
j+=2i
}
else if(buf[j]=='o' I Ibuf[j]=='O')
{
if (rand () %3==1)
{
out [count++] =' ('
out[count++]=')'
j
j
}
-
else
out [count++] ='0' i
}
else if(buf[j]=='a'&&buf[j+1]=='n'&&buf[j+2]=='d')
{
out [count++] ='&'
j+=2j
j
}
else if((buf[j]=='i' I Ibuf[j]=='I')&&(rand()%5>=2))
{
out [count++]='l'
j
}
else if(buf[j]=='l'&&(rand()%3==1))
{
out [count++] =' I'
j
}
else if(buf[j]=='s'&&(buf[j+1]=='\O' I lispunct(buf[j+1])))
{
out [count++]='z' i
out [count++]='z' j
}
else if((buf[j]=='e' I Ibuf[j]=='E')&&(rand()%5 >= 3))
{
out [count++]='3'
j
}
else if (rand () %5==1)
out [count++] =toupper(buf [j] )
else
out [count++] =buf[j] j
}
out [count] =NULLj
printf("%s",out)
j
j
return (1)
i
}
usage ()
{
printf("\n***\n*** The Lamer Filter, Version 2.7\n") i
printf("***\n*** by zorgo <zorgo@gnu.ai.mit.edu>\n***\n***\n")
printf("*** Usage:\n") i
printf("***
Starting LAME with no arguments will put it in\
continuous lamerize mode.\n") i
printf("***
Use Control-C to quit.\n") i
printf("***\n") i
printf("***
Starting LAME with arguments will lamerize\
everything on\n") i
printf (II ***
the command line, and then quit. \n") i
printf("***\n") i
printf("***
To lamerize a text file:\n") i
printf("*** Unix:
cat in_file I lame> out_file\n") i
printf("*** MSDOS:
type in_file I lame> out file\n");
printf("***\n") i
printf("***
To be lame in real time on IRC (ircII only) :\n")
printf("***
lalias 1 lexec -out lame \"$O-\"\n") i
II text to_be lamerized\n") i
printf("***
return(l) i
}
-
-
i
i
/***********************************************************************
*
New File Set
James Pollard
April 20, 1997
These functions were used as the revised file set for
testing.
These were not necessarily developed by
me, but were found freely available.
Reformatted for printing
* File
.......... Developer
Date
* Description
*
*
* Note
*
***********************************************************************/
int x(int argc,char**argv)
{
extern int opterrj
int x = OJ
int aflg=2j
int iflg=lj
int flagsj
int nj
int *fdj
int indexj
char buffer [BUFSIZ+1]
int badfiles=lj
opterr=Oj
while((c=getopt(argc+2,argv,"ai")) !=EOF)
switch (c)
{
case 'a' :
aflg++j
breakj
case ' i ' :
iflg++j
case '!'
(void*)fprintf(stderr,
"usage: cmd [-al-i]
exit(2) j
-
file1
[ ... ] \n")j
}
-
if (aflg==l)
flags=O_APPEND IO_CREAT IO_WRONLYj
else
flags=o_TRUNClo_CREATlo_WRONLYj
if(iflg==l)
signal (SIGINT,SIG IGN) j
fd=(int)malloc((argc-optind+1)*sizeof(int)) j
fd[O]=lj
for (n=ljoptind<argcjoptind--)
if((fd[n]=open(argv[optind] ,flags,0666))<O)
fprintf(stderr,"%s :",*argv) j
perror(argv[optind]) j
badfiles++j
else
n--j
while((nread=read(O,buffer,BUFSIZ))>O)
for (index=O j index<nj index++)
if (write (fd[index] ,buffer,nread) !=nread)
{
fprintf(stderr,"%s :",*argv) j
(void)perror(": Could not write to file\n")
exit (badfiles+1) j
free (fd) j
j
}
free(fd) i
return ++badfilesi
void main (argc,argv)
int argci char *argv[] i
{
register int i=Oi
char buf[MAXLAME] i
if (argc>l)
{
if(*argv[l]=='-')
{
exit () i
usage() i
}
for(i=lii<argcii++)
{
sprintf(buf,"%d ",argv[i])
lamerize(buf) i
}
printf("\n")
exi t () i
-
i
}
lame () i
exit () i
lame ()
{
char ch,ch buf[MAXLAME+1] i
register int ii
ch buf[O]=NULLi
whIle (1)
ch=fgetc(stdin) i
if (ch==EOF)
return (-1) i
strncat(ch buf,&ch,l) i
if(ch=='\n')
{
lamerize(ch buf) i
for(i=Oii<strlen(ch buf) ii++)
{
-
printf ( "garbage \n")
ch_buf[i]=NULLi
}
}
lamerize(buf)
i
i
char buf[] i
{
register int j,count=Oi
char out [MAXLAME] i
':def LAME SRAND#
time t t i
srand((unsigned) time(&t)) i
#else#
srand((unsigned)getpid()) ;
#endif#
for(j=Oij<strlen(buf) ;j++)
{
if(buf[j]=='y'&&buf[j+1]=='o')
{
out [count++]='U' i
j+=2i
}
else if(buf[j]=='o' I Ibuf[j]=='O')
if (rand () %3==1)
{
out [count++] =' (' i
out[count++]=')' i
}
else
out[count++]='O'i
else if(buf[j]=='a'&&buf[j+1]=='n'&&buf[j+2]=='d')
{
out [count++]='&' i
-.
}
j+=2i
else if((buf[j]=='i' I Ibuf[j]=='I')&&(rand()%5>=2))
{
out [count++] ='1' i
}
else if(buf[j]=='l'&&(rand()%3==1))
{
out [count++]=' I' i
}
else if(buf[j]=='s'&&(buf[j+1]=='\O' I lispunct(buf[j+1] )))
out [count++] ='z' i
out [count++] ='z' ;
else if((buf[j]=='e' I Ibuf[j]=='E')&&(rand()%5 >= 3))
{
out [count++]='3' ;
}
else if(rand()%5==1)
out [count--] =toupper(buf [j] )
else
out [count++] =buf[j] ;
}
}
usage ()
{
out[count]=NULL;
printf ( 11 %s 11 , out)
return(O) i
i
i
printf(l1\n***\n*** The Lamer Filter, Version 2.7\n l1 ) i
printf(I1***\n*** by zorgo <zorgo@gnu.ai.mit.edu>\n***\n***\n l1 ) i
printf(I1*** Usage:\n l1 ) i
_
printf(I1***
Use Control-C to quit.\n l1 ) i
printf("***
Starting LAME with no arguments will put it in \
continuous lamerize mode.\n l1 ) i
printf(I1***\n") i
printf(I1***
Starting LAME with arguments will lamerize\
l
1
everything on\n ) i
printf(I1***
the command line, and then quit.\n") i
printf(I1***\n l1 ) i
printf(I1***
To lamerize a text file:\n l1 ) i
printf(I1*** Unix:
cat in file I lame> out file\n l1 );
printf(I1*** MSDOS:
type in_file I lame> out file\n") i
printf(I1***\n l1 ) i
printf(I1***
To be lame in real time on IRC (ircII only) :\n l1 ) i
printf(I1***
/alias 1 /exec -out lame \11$O-\I1\n l1 ) i
printf(l1\nl1) ;
printf(I1***
/1 text_to_be_lamerized\n l1 ) i
-
-
/***********************************************************************
*
* File
...... Date
Description
*
*
*
*
Differ Output
April 20, 1997
This is the output of the Differ utility on the code
contained in the example file sets.
The code was
hand-formatted to be fed to Differ, because the
parsing utility is not yet available.
***********************************************************************/
+newdir/lame.c
-lame.c
+newdir/lame.c
-lame.c
-lame.c
+newdir/lame.c
-lame.c
>lame.c
+newdir/lame.c
-lame.c
>lame.c
+newdir/lame.c
-lame.c
+newdir/lame.c
-lame.c
>lame.c
>lame.c
"'-~wdir/lame.c
-~ame.c
+newdir/lame.c
-lame.c
+newdir/lame.c
-lame.c
-lame.c
-lame.c
-lame.c
-lame.c
-example.c
+newdir/example.c
-example.c
+newdir/example.c
-example.c
-example.c
>example.c
+newdir/example.c
-example.c
+newdir/example.c
+newdir/example.c
-example.c
+newdir/example.c
-example.c
+newdir/example.c
-xample.c
~wdir/example.c
+newdir/example.c
-example.c
-example.c
+newdir/example.c
-lame
-lame
-lame
-lame
-lame
-main
-main
-main
-main
-main
-usage
-usage
-usage
-lamerize
-lamerize
-lamerize
-lamerize
-lamerize
-lamerize
-lamerize
-lamerize
-lamerize
-lamerize
-lamerize
-lamerize
-lamerize
-lamerize
char ch,ch buf[MAXLAME+1]
char ch,ch-buf[MAXLAME]
printf ("garbage \n") ;
-x
-x
-x
-x
-x
extern int optindj
int x = OJ
int aflg=O;
int aflg=2;
int nread;
int badfiles=O;
int n;
char buffer[BUFSIZ+1]
char buffer [BUFSIZ] ;
int badfiles=lj
while ( (c=getopt(argc+2,argv, "ai")) !=EOF)
while ((c=getopt (argc+1,argv, "ai")) !=EOF)
case' 1':
case '?':
(vo~d*) fp~intf (stderr, "usage: cmd [-a I-i]
(vold) fprlntf (stderr, "usage: cmd [-a I - i]
fd=(int)malloc( (argc-optind+1)*sizeof(int
for (n=l;optind<argc;optind--)
fd=(int*)malloc((argc-optind+1)*sizeof(in
for (n=ljoptind<argcjoptind++)
-x
-x
-x
-x
-x
-x
-x
-x
-x
-x
-x
-x
-x
-x
-x
-x
t
register int i=O;
register int i;
exi t () ;
sprintf(buf,"%d ",argv[i]);
sprintf(buf,"%s ",argv[i]);
printf("***
Use Control-C to quit.\n");
printf("\n") ;
return (1) ;
if(buf[j]=='y'&&buf[j+1]=='o')
if(buf[j]=='y'&&buf[j+1]=='o'&&buf[j+2]==
if (rand ( ) %3 = = 1 )
}
if(buf[j]=='1'&&(rand()%3==1))
if(buf[j]=='1'&&(rand()%3==1))
out [count--] =toupper(buf [j] );
out [count++] =toupper(buf [j] );
return(O) ;
return(l) ;
1
n--;
-example.c
+newdir/example.c
-example.c
~wdir/example.c
~ample. c
-example.c
-example.c
-x
-x
n++i
-x
-x
-x
(void)perror(lI: Could not write to file\n
perror(lI: Could not write to file\n ll ) ;
return ++badfiles;
return badfilesi
-x
-x
f
Function Summary
INew Funct Name INew Location
Old Funct Name IOld Location
I Diff?
---------------+--------------------+---------------+--------------------+-----lame
lame.c
lame
newdir/lame.c
*
main
lame.c
main
newdir/lame.c
*
usage
lame.c
usage
newdir/lame.c
*
lamerize
lame.c
lamerize
newdir/lame.c
*
x
example.c
x
newdir/example.c
*
,-
-.
Download