home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / tools / ccc / ccc.doc next >
Text File  |  1986-09-19  |  7KB  |  228 lines

  1.  
  2.         CCC                          C Source Code PrettyPrinter  v1.0
  3.  
  4.  
  5.  
  6.                 CCC  -  A C Source Code Prettyprinter
  7.  
  8.                     Version 1.0  September, 1986
  9.  
  10.                        Copyright (C) 1986 by 
  11.  
  12.                             Raul Escobar
  13.                         26 Laurel Creek Lane
  14.                        Laguna Hills, CA 92653
  15.  
  16.  
  17.  
  18.         PURPOSE:
  19.  
  20.  
  21.         This program reads a C source file, and checks for mismatched
  22.         parentheses, comments and curly braces. It will print the file
  23.         to either the console (default), the printer (-p flag) or a
  24.         disk file with the same name as the source file, and ".CCC"
  25.         extention (-o flag). Curly braces are matched visually by 
  26.         drawing lines between opening and closing braces down the left
  27.         side of the page, allowing easy spotting of structures and errors.
  28.         These can either be drawn using IBM Graphic characters, or, 
  29.         in case your printer doesn't support them, standard ASCII
  30.         characters (-a flag). The program will optionally provide line 
  31.         numbers (-n flag) and page breaks with a header on each page
  32.         when you specify a page length (-l n flag). The program also
  33.         wraps lines at 80 characters unless a page width is specified
  34.         (-w n flag), and expands tabs to every fourth space unless
  35.         a tab width is specified (-T n flag). You may use any com-
  36.         bination of flags, except -o and -p together. Note that the
  37.         space between the flag and the number (n) is required.This
  38.         program preserves the users format, and does not impose its own
  39.         structure on the program.
  40.  
  41.  
  42.         FORMAT:
  43.  
  44.  
  45.         CCC filename [-A] [-L n] [N] [-O] [-P] [-T n] [-W n] 
  46.           where filename is the C source file.
  47.                 -A uses ASCII (defaults to IBM graphic characters).
  48.                 -L set page length (defaults to no page breaks).
  49.                 -N inserts line numbers.
  50.                 -O writes to the file filename.CCC.
  51.                 -P sends output to printer.
  52.                 -T sets tabs every n spaces (defaults to 4).
  53.                 -W sets page width to n columns (defaults to 80).
  54.  
  55.  
  56.         CCC                          C Source Code PrettyPrinter  v1.0
  57.  
  58.  
  59.  
  60.  
  61.         EXAMPLE:
  62.  
  63.  
  64.         Using the following program as input:
  65.  
  66.  
  67.         /*
  68.          * S I N G L E I T
  69.          *
  70.          */
  71.         #include "stdio.h"
  72.         
  73.         #define CR 13
  74.         #define LF 10
  75.         
  76.         main(argc,argv)
  77.         int argc;
  78.         char *argv[];
  79.         {
  80.            FILE *ifp,*ofp;
  81.            char c,c1,c2,c3,c4,buf[132];
  82.         
  83.            if ((ifp=fopen(argv[1],"r"))==NULL) usage();
  84.            if ((ofp=fopen(argv[2],"w"))==NULL) usage();
  85.         
  86.            while ((c=fgets(buf,132,ifp))!=NULL) {
  87.               if (buf[0]==CR||buf[0]==LF)
  88.                  ;
  89.               else 
  90.                  fputs(buf,ofp);
  91.            }
  92.            fcloseall();
  93.         }
  94.         
  95.         usage()
  96.         {
  97.            printf("\nUsage is: singleit <infile> <outfile>");
  98.            exit(0);
  99.         }
  100.            
  101.  
  102.  
  103.         CCC                          C Source Code PrettyPrinter  v1.0
  104.  
  105.  
  106.  
  107.  
  108.         issuing the command "CCC singleit.c -n -l 60 -w 60"
  109.         produces the console listing:
  110.  
  111.         
  112.         ┌─────────────────────────────────────────────────────────┐
  113.         │   File: singleit.c                           page   1   │
  114.         └─────────────────────────────────────────────────────────┘
  115.         
  116.             1:    /*
  117.             2:     * S I N G L E I T
  118.             3:     *
  119.             4:     */
  120.             5:    #include "stdio.h"
  121.             6:    
  122.             7:    #define CR 13
  123.             8:    #define LF 10
  124.             9:    
  125.            10:    main(argc,argv)
  126.            11:    int argc;
  127.            12:    char *argv[];
  128.            13:┌─  {
  129.            14:│      FILE *ifp,*ofp;
  130.            15:│      char c,c1,c2,c3,c4,buf[132];
  131.            16:│    
  132.            17:│      if ((ifp=fopen(argv[1],"r"))==NULL) usage();
  133.            18:│      if ((ofp=fopen(argv[2],"w"))==NULL) usage();
  134.            19:│    
  135.            20:│ ┌─   while ((c=fgets(buf,132,ifp))!=NULL) {
  136.            21:│ │       if (buf[0]==CR||buf[0]==LF)
  137.            22:│ │          ;
  138.            23:│ │       else 
  139.            24:│ │          fputs(buf,ofp);
  140.            25:│ └─   }
  141.            26:│      fcloseall();
  142.            27:└─  }
  143.            28:    
  144.            29:    usage()
  145.            30:┌─  {
  146.            31:│      printf("\nUsage is: singleit <infile> <outfil
  147.               │       e>");
  148.            32:│      exit(0);
  149.            33:└─  }
  150.            34:       
  151.         
  152.  
  153.         CCC                          C Source Code PrettyPrinter  v1.0
  154.  
  155.  
  156.  
  157.         and issuing the command "CCC singleit.c -a -o" 
  158.         produces a disk file called "SINGLEIT.CCC" containing:
  159.  
  160.             /*
  161.              * S I N G L E I T
  162.              *
  163.              */
  164.             #include "stdio.h"
  165.             
  166.             #define CR 13
  167.             #define LF 10
  168.             
  169.             main(argc,argv)
  170.             int argc;
  171.             char *argv[];
  172.         +-  {
  173.         |      FILE *ifp,*ofp;
  174.         |      char c,c1,c2,c3,c4,buf[132];
  175.         |    
  176.         |      if ((ifp=fopen(argv[1],"r"))==NULL) usage();
  177.         |      if ((ofp=fopen(argv[2],"w"))==NULL) usage();
  178.         |    
  179.         | +-   while ((c=fgets(buf,132,ifp))!=NULL) {
  180.         | |       if (buf[0]==CR||buf[0]==LF)
  181.         | |          ;
  182.         | |       else 
  183.         | |          fputs(buf,ofp);
  184.         | +-   }
  185.         |      fcloseall();
  186.         +-  }
  187.             
  188.             usage()
  189.         +-  {
  190.         |      printf("\nUsage is: singleit <infile> <outfile>");
  191.         |      exit(0);
  192.         +-  }
  193.         
  194.  
  195.         CCC                          C Source Code PrettyPrinter  v1.0
  196.  
  197.  
  198.  
  199.         
  200.         REMARKS:
  201.  
  202.  
  203.  
  204.         This is a public domain "freeware" program. You are encouraged
  205.         to use it, copy it and give it to your friends. You are also
  206.         encouraged to communicate any problems, bugs, questions, sug-
  207.         gestions, requests for enhancements, etc. Donations are also
  208.         accepted, and will enable you to receive future updates and
  209.         other programs written by the author. Please address all 
  210.         correspondence to:
  211.  
  212.  
  213.  
  214.                         Raul Escobar
  215.                         26 Laurel Creek Lane
  216.                         Laguna Hills, CA 92653
  217.  
  218.  
  219.  
  220.         Possible future enhancements include:
  221.  
  222.                 o  Outlining of keyword control structures
  223.                 o  Cross reference generation
  224.                 o  processing of #include files
  225.                 o  PASCAL version
  226.                 o  BASIC version
  227.  
  228.