home *** CD-ROM | disk | FTP | other *** search
- /* Compile this program using lex and cc, name the object file 'chbar'
- * and install it somewhere that the system can get to it using the
- * 'changebar' shell script.
- */
- %{
- int stat=0;
- int bangstat=0;
- char txtbuf[256]=0;
- %}
- %%
- ^[^-\*\n\!].*$ {
- /* If already counting lines that have either a '- '
- * or a '! ' or a '*...' in the first columns, and encounter
- * a line that does NOT have that, put the closing
- * ^G.mc at the tail of the previous line and disable
- * the insertion of the .mc till the first line with
- * either of the two markers happens again.
- */
- if(stat == 1) {
- printf("%s\007.mc\n",txtbuf);
- stat = 0;
- }
- puts(yytext);
- }
-
- ^---\ .*$ { puts(yytext); /* If in a '---' block in a context diff,
- * then disable entry of .mc's in text lines.
- */
- bangstat = 0;
- }
-
- ^\*\*\*\ .*$ { puts(yytext); /* If in a '***' block in a context diff,
- * then enable entry of .mc's in text lines.
- */
- bangstat = 1;
- }
-
- ^\*\*\*.*$ { puts(yytext);
- }
-
- ^\-\ .*$ {
- /* If find a line that begins "- <anything>", and it
- * is the first line of its kind, then mark it.
- */
- if(stat == 0) {
- sprintf(txtbuf,"- .mc \\s+2\\(br\\s-2\007%s",&yytext[2]);
- stat = 1;
- }
- else {
- puts(txtbuf);
- sprintf(txtbuf,"%s",yytext);
- }
- }
-
-
-
-
-
-
-
-
- ^\!\ .*$ {
- /* If find a line that begins "! <anything>", and it
- * is the first line of its kind, then mark it.
- */
- if(bangstat==1)
- {
- if(stat == 0) {
- sprintf(txtbuf,"! .mc \\s+2\\(br\\s-2\007%s",
- &yytext[2]);
- stat = 1;
- }
- else {
- puts(txtbuf);
- sprintf(txtbuf,"%s",yytext);
- }
- }
- else {
- puts(yytext);
- }
- }
- \n {
- ;
- /* If there is nothing but a newline, do nothing, because
- * we are inserting our own newlines as needed.
- */
- }
- %%
- yywrap()
- {
- if (stat == 1)
- printf("%s\007.mc\n",txtbuf);
-
- return (1);
- }
- /*
- This LEX file adds change bars to the output of a 'diff -c'
- to indicate to the reader where sections have been added
- (no handling so far for lines that have been deleted).
-
- This allows the user to edit under SCCS to your heart's content,
- then SCCS-extract the old version and the new version...
- then:
-
- a. diff -c oldfile newfile > filediffs
- b. addchgbars < filediffs > filemods
- c. patch < filemods
-
- # oldfile is renamed to oldfile.orig
- # oldfile becomes newfile, but with change bars installed
-
- d. tr '\007' '\012' oldfile > file.to.print
-
- # change bars have ^G installed, has to be changed into a ^J;
- # makes patch program work unmodified.
-
- */
-