home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume2 / duonly / duonly.c next >
Encoding:
C/C++ Source or Header  |  1991-08-07  |  18.1 KB  |  683 lines

  1. /*
  2.  * duonly.c
  3.  * dennis bednar Feb 17, 1988
  4.  *
  5.  * Reads stdin of du output, and outputs sizes based ONLY on the
  6.  * space used within a directory only.  The size will be the
  7.  * number of blocks used by the directory itself, plus any
  8.  * files contained within that directory.
  9.  *
  10.  * NOTE:
  11.  * Much of the source code in dugraph.c (contributed to comp.unix.misc)
  12.  * I borrowed "as is".  What functions I added are at the end.
  13.  * I also added the "father" link.  All of the brothers of the
  14.  * first son, including the first son, have the same father node.
  15.  * That is, if we have /a/b, and /a/c, then "b" and "c" are brothers,
  16.  * and "b"'s and "c"'s father are both "a".  I also added a new
  17.  * variable "me_size" which is the size of the directory, not including
  18.  * the sizes of the sons immediately below it.
  19.  *
  20.  * NOTE: If you do "du /dir1/dir2/dir3| duonly", then the size of
  21.  * /dir1, and /dir2 will be 0, since they were NOT included in
  22.  * the original output of du!!!
  23.  *
  24.  * NOTE: if you do "du /dir1/dir2/dir3| duonly", then the root
  25.  * placeholder points to a cell for "", and NOT to "dir1" as
  26.  * you might expect.  This is because of how read_input() parses
  27.  * its input.  It is not a problem per se, except that the node
  28.  * containing a blank name should not be printed in this case.
  29.  * So, the solution is to add an extra check and avoid the print
  30.  * when the name is "".  By the way the root for "" only occurs
  31.  * because the pathnames are absolute (begin with a /).
  32.  *
  33.  * NOTE: although output of directory names are sorted there is
  34.  * one minor anomoly that occurs when you have input as follows
  35.  * (sizes ommited, since irrelevant):
  36.  * ../dir
  37.  * ...dir/RCS
  38.  * ...dir.ext
  39.  * The important point is that we have both a "/" and a "." after the
  40.  * same name "dir".
  41.  * A sort would place the "." before the "/" (ie line 3 before line 2),
  42.  * but the sort performed by du is only within each directory level, so
  43.  * that duonly would output line 2 before line 3 (since ../dir and
  44.  * ../dir.ext are sorted brothers, and ../dir/RCS is a sorted son of
  45.  * ../dir) !!
  46.  *
  47.  */
  48. #if 0
  49. Path: rlgvax!sundc!seismo!uunet!husc6!think!ames!necntc!ncoast!allbery
  50. From: drw@culdev1.UUCP (Dale Worley)
  51. Newsgroups: comp.sources.misc
  52. Subject: Prettyprint a du listing
  53. Message-ID: <6803@ncoast.UUCP>
  54. Date: 17 Dec 87 02:33:54 GMT
  55. Sender: allbery@ncoast.UUCP
  56. Organization: Cullinet Software, Westwood, MA, USA
  57. Lines: 447
  58. Approved: allbery@ncoast.UUCP
  59. X-Archive: comp.sources.misc/8712/8
  60.  
  61. I've always wanted to get a du listing that shows how the space is
  62. being used graphically.  I finally wrote a program to digest a du
  63. listing and print out a tree, where each directory occupies lines
  64. proportionally to how much space the files in it consume.
  65.  
  66. To run it, type "du | dugraph" or some such.  The listing for each
  67. directory starts with a blank space showing space occupied by files
  68. directly in that directory, then the subtrees for each subdirectory
  69. (in descending order of size).  If the subdirectories at the bottom
  70. get so small that they occupy less than 1 line each, they are all
  71. merged into an entry "(etc.)".
  72.  
  73. The entire listing always occupies 60 lines (the value of 'length').
  74. This program has tab-width = 5.
  75. --------------------------dugraph.c---------------------------------
  76. #endif
  77. /* program to make a pretty graph out of a du report */
  78.  
  79. #include <stdio.h>
  80. #include <string.h>
  81.  
  82. /* number of lines the listing should occupy */
  83. int    length = 60;
  84. /* message for suppressed directories */
  85. #define    SUPPRESSED    "(etc.)"
  86.  
  87. /* format of a tree node */
  88. struct node {
  89.             struct node    *lson;    /* left son */
  90.             struct node    *rbrother;/* right brother */
  91.             struct node    *father; /* parent node, up ptr */
  92.             unsigned long    size;    /* size of directory in kbytes */
  93.             unsigned long    me_size;    /* size of directory only */
  94.             int            loc;        /* location we will print it at */
  95.             int            print_col;/* column to print name in */
  96.             int            print_limit;
  97.                                 /* location we can't print on or
  98.                                  * after */
  99.             int            last;    /* are we last son of our father? */
  100.             char            name[1];    /* name */
  101.           };
  102.  
  103. /* root of the tree */
  104. struct node    *root = NULL;
  105. /* total size of things listed */
  106. unsigned long    total_size;
  107. /* current line number we are on (0-origin) */
  108. int            current_line = 0;
  109. /* list of where to put bars */
  110. int            bar_list[50];
  111. /* number of bars in the list */
  112. int            bar_count = 0;
  113.  
  114. /* declare functions */
  115. void            read_input();
  116. struct node    *insert_in_tree();
  117. void            dfs();
  118. void            dfs1();
  119. void            missing_sizes();
  120. void            sort_size();    /* sort tree by size */
  121. void            sort_name();    /* sort tree alphabetically */
  122. void            calc_loc();
  123. void            blank();
  124. void            mark_last();
  125. void            calc_pc();
  126. void            output();
  127. void            position();
  128. void            show_node();
  129. void            my_space();
  130.  
  131. main()
  132.     {
  133.     struct node    *t;    /* scratch */
  134.  
  135.     /* read the input and form a tree */
  136.     read_input();
  137.     root->size = 0;
  138.     /* put sizes on entries that have none */
  139.     dfs(NULL, missing_sizes);
  140.     /* sort each directory */
  141.     dfs(sort_name, NULL);
  142.  
  143.     /* for each directory, subtract the space used up by
  144.      * all children one level below me, so that we
  145.      * can tell how much space is occupied by this
  146.      * directory only.
  147.      * IMPORTANT: We need to compute in pre-order, or we
  148.      * won't get the right results.
  149.      */
  150.     dfs(my_space, NULL);
  151.  
  152.     /* print the tree */
  153.     dfs(show_node, NULL);
  154.     exit(0);
  155.  
  156.     /* unused left-over code I might need later. */
  157.  
  158.     /* calculate the total size */
  159.     total_size = 0;
  160.     for (t = root->lson; t != NULL; t = t->rbrother)
  161.         total_size += t->size;
  162.     /* calculate the location of each directory */
  163.     /* blank out subdirectories that get scrunched together at the bottom */
  164.     root->print_limit = length;
  165.     dfs(calc_loc, blank);
  166.     /* print out the tree */
  167.     for (t = root->lson; t != NULL; t = t->rbrother)
  168.         {
  169.         /* mark the last son of each directory */
  170.         /* figure out the print columns */
  171.         t->print_col = 0;
  172.         dfs1(calc_pc, mark_last, t);
  173.         dfs1(output, NULL, t);
  174.         }
  175.     /* put blank space at end */
  176.     position(length);
  177.     }
  178.  
  179. /* read input and form a tree */
  180. void read_input()
  181.     {
  182.     unsigned long    size;        /* size read from input */
  183.     char            name[100];    /* directory name read from input */
  184.  
  185.     /* make the dummy node at the top of the tree */
  186.     root = (struct node *)malloc(sizeof (struct node));
  187.     root->name[0] = '\0';
  188.     root->lson = NULL;
  189.     root->father = NULL;    /* if walking up the ladder, don't fall off ! */
  190.     /* read the next line of input */
  191.     while (fscanf(stdin, "%lu %s\n", &size, name) != EOF)
  192.         {
  193.         /* insert (or find) the directory in the tree and save its size */
  194.         insert_in_tree(name)->size = size;
  195.         }
  196.     }
  197.  
  198. /* insert (or find) a directory in the tree */
  199. struct node *insert_in_tree(name)
  200.     char    *name;        /* name of the directory */
  201.     {
  202.     struct node    *t;    /* pointer for searching down through tree */
  203.     char            *np;    /* points to next part of directory name to be
  204.                      * examined */
  205.     struct node    *t1;    /* scratch pointer */
  206.     char            *np1;/* scratch pointer */
  207.  
  208.     /* read through the name, one directory-part at a time, and hunt
  209.      * down the tree, constructing nodes as needed */
  210.     for (t = root, np = name; np != NULL; np = np1)
  211.         {
  212.         /* extract the next directory-part */
  213.         if ((np1 = strchr(np, '/')) != NULL)
  214.             {
  215.             /* we found a slash, replace it with a null, and position
  216.              * np1 to point to the remainder of the name */
  217.             /* can store node.name=="" when name begins with / */
  218.             *np1++ = '\0';
  219.             }
  220.         /* else */
  221.             /* we found no shash, so we are at the end of the name
  222.              * np1 has been set to NULL for us by strchr */
  223.         /* search the sons of this node for a node with the proper name */
  224.         for (t1 = t->lson; t1 != NULL && strcmp(t1->name, np) != 0;
  225.                 t1 = t1->rbrother)
  226.             ;
  227.         /* did we find one? */
  228.         if (t1 != NULL)
  229.             /* yes, go to it */
  230.             t = t1;
  231.         else
  232.             {
  233.             /* no, make one */
  234.             t1 = (struct node *)malloc(sizeof(struct node) + strlen(np));
  235.             strcpy(t1->name, np);
  236.             t1->lson = NULL;
  237.             t1->rbrother = NULL;
  238.             t1->father = t;
  239.             t1->size = 0;
  240.             /* insert it in tree */
  241.             t1->rbrother = t->lson;
  242.             t->lson = t1;
  243.             t = t1;
  244.             }
  245.         }
  246.     return t;
  247.     }
  248.  
  249. /* depth-first-search routine */
  250. void dfs(pre_routine, post_routine)
  251.     void    (*pre_routine)();    /* routine to execute before scanning
  252.                          * descendants */
  253.     void    (*post_routine)();    /* routine to execute after scanning
  254.                          * descendants */
  255.     {
  256.     dfs1(pre_routine, post_routine, root);
  257.     }
  258.  
  259. /* depth-first-search service routine */
  260. void dfs1(pre_routine, post_routine, t)
  261.     void    (*pre_routine)();    /* routine to execute before scanning
  262.                          * descendants */
  263.     void    (*post_routine)();    /* routine to execute after scanning
  264.                          * descendants */
  265.     struct node *t;        /* node to operate on */
  266.     {
  267.     struct node *t1;        /* scratch pointer */
  268.  
  269.     /* if it exists, execute the pre-routine */
  270.     if (pre_routine != NULL)
  271.         pre_routine(t);
  272.     /* call self on sons of this node */
  273.     for (t1 = t->lson; t1 != NULL; t1 = t1->rbrother)
  274.         dfs1(pre_routine, post_routine, t1);
  275.     /* if it exists, execute the post-routine */
  276.     if (post_routine != NULL)
  277.         post_routine(t);
  278.     }
  279.  
  280. /* add missing sizes */
  281. void missing_sizes(t)
  282.     struct node    *t;
  283.     {
  284.     struct node    *t1;        /* scratch pointer */
  285.     unsigned long    s;        /* scratch */
  286.  
  287.     if (t->size == 0)
  288.         {
  289.         /* size is missing, we have to calcuate it */
  290.         s = 0;
  291.         for (t1 = t->lson; t1 != NULL; t1 = t1->rbrother)
  292.             s += t1->size;
  293.         t->size = s;
  294.         }
  295.     }
  296.  
  297. /* sort the directories under a directory by size */
  298. void sort_size(t)
  299.     struct node    *t;
  300.     {
  301.     struct node    *p1, *p2, *p3, *pp;        /* scratch pointers */
  302.     int            nodes, n;                /* scratch */
  303.  
  304.     /* count the number of nodes */
  305.     nodes = 0;
  306.     for (p1 = t->lson; p1 != NULL; p1 = p1->rbrother)
  307.         nodes++;
  308.     /* just a simple and inefficient bubble sort */
  309.     for (n = 1; n < nodes; n++)
  310.         for (p1 = NULL, p2 = t->lson, p3 = p2->rbrother; p3 != NULL;
  311.                 p1 = p2, p2 = p3, p3 = p3->rbrother)
  312.             {
  313.             if (p2->size < p3->size)
  314.                 {
  315.                 /* exchange the nodes p2 and p3 */
  316.                 pp = p3->rbrother;
  317.                 p3->rbrother = p2;
  318.                 p2->rbrother = pp;
  319.                 if (p1 != NULL)
  320.                     p1->rbrother = p3;
  321.                 else
  322.                     t->lson = p3;
  323.                 /* exchange the values of p2 and p3 */
  324.                 pp = p2;
  325.                 p2 = p3;
  326.                 p3 = pp;
  327.                 }
  328.             }
  329.     }
  330.  
  331. /* calculate the print location */
  332. void calc_loc(t)
  333.     struct node    *t;
  334.     {
  335.     unsigned long    cs;        /* scratch */
  336.     struct node    *t1, *t2;    /* scratch pointers */
  337.     int            print_limit;
  338.                         /* location next directory after t will
  339.                          * be printed */
  340.  
  341.     if (t == root)
  342.         cs = 0;
  343.     else
  344.         {
  345.         /* figure out how much is in the directory itself */
  346.         for (t1 = t->lson, cs = 0; t1 != NULL; t1 = t1->rbrother)
  347.             {
  348.             cs += t1->size;
  349.             }
  350.         /* cs is the size accounted for by subdirectories */
  351.         cs = t->size - cs;
  352.         }
  353.     /* cs is the size of the files in the directory itself */
  354.     /* convert cs to lines */
  355.     cs = cs*length/total_size + t->loc;
  356.     /* calculate where next directory after t will be */
  357.     print_limit = t->print_limit;
  358.     /* assign locations */
  359.     for (t1 = t->lson, t2 = NULL; t1 != NULL; t2 = t1, t1 = t1->rbrother)
  360.         {
  361.         /* make sure we don't run into next directory */
  362.         if (cs >= print_limit)
  363.             {
  364.             cs = print_limit-1;
  365.             }
  366.         t1->loc = cs;
  367.         if (t2 != NULL)
  368.             t2->print_limit = cs;
  369.         cs += t1->size*length/total_size;
  370.         }
  371.     if (t2 != NULL)
  372.         t2->print_limit = print_limit;
  373.     }
  374.  
  375. /* figure out which directories to blank out */
  376. void blank(t)
  377.     struct node    *t;
  378.     {
  379.     struct node    *t1, *t2, *t3;        /* loop pointers */
  380.  
  381.     /* return if there aren't at least two sons */
  382.     if (t->lson == NULL || t->lson->rbrother == NULL)
  383.         return;
  384.     for (t1 = NULL, t2 = t->lson, t3 = t2->rbrother; t3 != NULL;
  385.             t1 = t2, t2 = t3, t3 = t3->rbrother)
  386.         if (t2->loc == t3->loc)
  387.             {
  388.             /* replace t1 and succeeding nodes with "(etc.)" */
  389.             t3 = (struct node *)malloc(sizeof (struct node) +
  390.                 sizeof (SUPPRESSED) - 1);
  391.             strcpy(t3->name, SUPPRESSED);
  392.             t3->lson = t3->rbrother = NULL;
  393.             t3->loc = t2->loc;
  394.             if (t1 == NULL)
  395.                 t->lson = t3;
  396.             else
  397.                 t1->rbrother = t3;
  398.             }
  399.     }
  400.  
  401. /* mark the last son of each directory */
  402. void mark_last(t)
  403.     struct node    *t;
  404.     {
  405.     struct node    *t1, *t2;    /* scratch pointers */
  406.     t->last = 0;
  407.     for (t1 = t->lson, t2 = NULL; t1 != NULL; t2 = t1, t1 = t1->rbrother)
  408.         ;
  409.     if (t2 != NULL)
  410.         t2->last = 1;
  411.     }
  412.  
  413. /* calculate the print columns */
  414. void calc_pc(t)
  415.     struct node    *t;
  416.     {
  417.     struct node    *t1;        /* scratch pointer */
  418.     int            c;        /* column suns will be printed in */
  419.  
  420.     c = t->print_col + strlen(t->name) + 5;
  421.     for (t1 = t->lson; t1 != NULL; t1 = t1->rbrother)    
  422.         t1->print_col = c;
  423.     }
  424.  
  425. /* write the output */
  426. void output(t)
  427.     struct node    *t;
  428.     {
  429.     position(t->loc);
  430.     printf("--%s%s", t->name, (t->lson != NULL ? "--+" : ""));
  431.     /* remove the bar for our father if we are the last son */
  432.     if (t->last)
  433.         bar_count--;
  434.     /* add the location of the bar to the bar list if we have a son */
  435.     if (t->lson != NULL)
  436.         {
  437.         bar_list[bar_count] = t->print_col + strlen(t->name) + 5 - 1;
  438.         bar_count++;
  439.         }
  440.     }
  441.  
  442. /* position to a specific line */
  443. void position(line)
  444.     int    line;        /* line number */
  445.     {
  446.     int    i;            /* counts through the bar list */
  447.     int    j;            /* current column number */
  448.  
  449.     /* for every line we need to go down */
  450.     for (; current_line < line; current_line++)
  451.         {
  452.         putchar('\n');
  453.         /* print the bars for this line */
  454.         j = 0;
  455.         for (i = 0; i < bar_count; i++)
  456.             {
  457.             for (; j < bar_list[i]; j++)
  458.                 putchar(' ');
  459.             if (current_line == line-1 && i == bar_count-1)
  460.                 putchar('+');
  461.             else
  462.                 putchar('|');
  463.             j++;
  464.             }
  465.         }
  466.     }
  467. #if 0
  468. -----------------------------------example-----------------------------------
  469. --.--+
  470.      |
  471.      |
  472.      |
  473.      |
  474.      |
  475.      |
  476.      |
  477.      +--scpp--+--ftps--+
  478.      |        |        +--scpp--+--temp
  479.      |        +--error
  480.      |        |
  481.      |        +--shar--+
  482.      |                 |
  483.      |                 +--temp
  484.      +--uemacs--+--uemacs3.9
  485.      |
  486.      |
  487.      |
  488.      |
  489.      |
  490.      |
  491.      +--patch--+--dist
  492.      |         |
  493.      |         |
  494.      |         +--build
  495.      |
  496.      |
  497.      |
  498.      +--sccs--+--all
  499.      |        |
  500.      |        |
  501.      |        |
  502.      |        +--(etc.)
  503.      +--yacctest
  504.      |
  505.      |
  506.      |
  507.      +--yacc
  508.      |
  509.      |
  510.      |
  511.      +--rnsend--+--dist1
  512.      |          +--dist3
  513.      |          +--dist2
  514.      +--bin--+
  515.      |       +--source
  516.      +--sources
  517.      |
  518.      +--kwfrob
  519.      +--rsts.tape
  520.      +--rnews
  521.      +--ftp-server
  522.      +--(etc.)
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529. ------------------------------end of example------------------------------
  530. -- 
  531. Dale Worley    Cullinet Software      ARPA: culdev1!drw@eddie.mit.edu
  532. UUCP: ...!seismo!harvard!mit-eddie!culdev1!drw
  533. Nothing shocks me -- I'm a scientist.
  534. #endif
  535.  
  536.  
  537. /* begin of new code added by dennis bednar */
  538. /*
  539.  * Print the full name associated with the path to this component.
  540.  * Since each node contains only one component of the full path name,
  541.  * in order to print out the entire name, we have to print the
  542.  * "father part of the component", followed by the component.
  543.  * This is why I invented the "father" up pointer.
  544.  * This is done recursively, I might add.
  545.  *
  546.  * the root is a dummy holder, it contains no real name.
  547.  * The top node which contains the first real name will have
  548.  * a father pointer to root.
  549.  * Rather, root -> lson contains the first real root of the tree.
  550.  * This is why root->rbrother is NULL.
  551.  *
  552.  * So do NOT print the root node's name.
  553.  * Also, when printing root->lson's father, it will be "".
  554.  */
  555. void
  556. show_node( p )
  557.     struct    node    *p;
  558. {
  559.     if (p == root)    /* just a placeholder, its lson is the real root */
  560.         return;    /* don't print jibberish */
  561.  
  562.     /* avoid printing root's lson node whose name is "".
  563.      * This occurs when first line of stdin contains a
  564.      * directory name beginning with a leading /.
  565.      * PS, since root node's name is also "", I probably could remove
  566.      * the "if" check above, and let this if stmt do the work of
  567.      * both, but I didn't feel like it.
  568.      */
  569.     if (p -> name[0] == '\0')
  570.         return;
  571.  
  572.     /* avoid printing /a and /b whose size is zero, just
  573.      * because we did a "du /a/b/c | duonly".
  574.      */
  575.     if (p -> me_size == 0L)
  576.         return;
  577.  
  578. /*    printf("'%s' and my father is <%s>\n", p -> name, p -> father -> name); */
  579.     printf("%ld\t", p -> me_size);
  580.     path_print(p);
  581.     putchar( '\n' );    /* terminate line */
  582. }
  583.  
  584. /*
  585.  * recursively print the full path by printing the "part before me",
  586.  * then printing my component name.
  587.  */
  588. path_print( p )
  589.     struct    node    *p;
  590. {
  591.     /* this should not ever happen, because of how path_print() is written */
  592.     if (p == NULL)
  593.         return;        /* paranenoid */
  594.  
  595.     /* this code is structured so that a leading slash will NOT
  596.      * be printed before the first component, but rather ONLY
  597.      * between all components, and NOT after the last component.
  598.      */
  599.     if (p -> father == root)
  600.         {
  601.         printf("%s", p ->name );
  602.         return;
  603.         }
  604.     else
  605.         {
  606.         /* recursion */
  607.         path_print( p -> father );    /* print components before me */
  608.         printf( "/%s", p -> name );    /* print my component */
  609.         }
  610. }
  611.  
  612. /*
  613.  * compute size of this directory only, ie don't include
  614.  * size of children directories.  This leaves space only
  615.  * occupied by this directory remaining in the "me_size".
  616.  */
  617. void
  618. my_space( p )
  619.     struct    node    *p;
  620. {
  621.     long    total = 0;
  622.     struct    node    *s;    /* each son of the parent p */
  623.  
  624.     total = p -> size;    /* blocks used by this directory */
  625.  
  626.     /* subtract blocks used by immediate children directories.
  627.      * WILL NOT WORK CORRECTLY if a child is a file !!!!!
  628.      * this will leave total containing only the number of blocks
  629.      * in this directory.
  630.      */
  631.     for ( s = p -> lson; s; s = s -> rbrother)
  632.         total -= s -> size;
  633.  
  634.     /* store my size only for this parent */
  635.     p -> me_size = total;
  636. }
  637.  
  638. /*
  639.  * sort the directories under a directory by name.
  640.  *
  641.  * this is just the old "sort()" routine [sort() renamed to
  642.  * sort_size() for clarity] with a minor change, where
  643.  * we now compare names, not size.  That is, we sort
  644.  * the brothers or peers at each level.
  645.  * SEE ALSO the anomoly concerning "." and "/" with regards
  646.  * to sorting, described at the top of this file.
  647.  */
  648. void sort_name(t)
  649.     struct node    *t;
  650.     {
  651.     struct node    *p1, *p2, *p3, *pp;        /* scratch pointers */
  652.     int            nodes, n;                /* scratch */
  653.     int    cmp;
  654.  
  655.     /* count the number of nodes */
  656.     nodes = 0;
  657.     for (p1 = t->lson; p1 != NULL; p1 = p1->rbrother)
  658.         nodes++;
  659.     /* just a simple and inefficient bubble sort */
  660.     for (n = 1; n < nodes; n++)
  661.         for (p1 = NULL, p2 = t->lson, p3 = p2->rbrother; p3 != NULL;
  662.                 p1 = p2, p2 = p3, p3 = p3->rbrother)
  663.             {
  664.             cmp = strcmp( p2 -> name, p3 -> name );
  665.             if (cmp > 0)    /* not alphabetized, p3 1st, p2 2nd */
  666.                 {
  667.                 /* exchange the nodes p2 and p3 */
  668.                 pp = p3->rbrother;
  669.                 p3->rbrother = p2;
  670.                 p2->rbrother = pp;
  671.                 if (p1 != NULL)
  672.                     p1->rbrother = p3;
  673.                 else
  674.                     t->lson = p3;
  675.                 /* exchange the values of p2 and p3 */
  676.                 pp = p2;
  677.                 p2 = p3;
  678.                 p3 = pp;
  679.                 }
  680.             }
  681.     }
  682.  
  683.