Subversion Repositories HelenOS

Rev

Rev 1199 | Rev 1272 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright (C) 2001-2004 Jakub Jermar
  3.  * Copyright (C) 2006 Josef Cejka
  4.  * All rights reserved.
  5.  *
  6.  * Redistribution and use in source and binary forms, with or without
  7.  * modification, are permitted provided that the following conditions
  8.  * are met:
  9.  *
  10.  * - Redistributions of source code must retain the above copyright
  11.  *   notice, this list of conditions and the following disclaimer.
  12.  * - Redistributions in binary form must reproduce the above copyright
  13.  *   notice, this list of conditions and the following disclaimer in the
  14.  *   documentation and/or other materials provided with the distribution.
  15.  * - The name of the author may not be used to endorse or promote products
  16.  *   derived from this software without specific prior written permission.
  17.  *
  18.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  19.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  20.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  22.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  23.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  27.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28.  */
  29.  
  30. #include <unistd.h>
  31. #include <stdio.h>
  32. #include <io/printf_core.h>
  33. #include <ctype.h>
  34. #include <string.h>
  35.  
  36. #define __PRINTF_FLAG_PREFIX        0x00000001  /* show prefixes 0x or 0*/
  37. #define __PRINTF_FLAG_SIGNED        0x00000002  /* signed / unsigned number */
  38. #define __PRINTF_FLAG_ZEROPADDED    0x00000004  /* print leading zeroes */
  39. #define __PRINTF_FLAG_LEFTALIGNED   0x00000010  /* align to left */
  40. #define __PRINTF_FLAG_SHOWPLUS      0x00000020  /* always show + sign */
  41. #define __PRINTF_FLAG_SPACESIGN     0x00000040  /* print space instead of plus */
  42. #define __PRINTF_FLAG_BIGCHARS      0x00000080  /* show big characters */
  43. #define __PRINTF_FLAG_NEGATIVE      0x00000100  /* number has - sign */
  44.  
  45. #define PRINT_NUMBER_BUFFER_SIZE    (64+5)      /* Buffer big enought for 64 bit number
  46.                              * printed in base 2, sign, prefix and
  47.                              * 0 to terminate string.. (last one is only for better testing
  48.                              * end of buffer by zero-filling subroutine)
  49.                              */
  50. typedef enum {
  51.     PrintfQualifierByte = 0,
  52.     PrintfQualifierShort,
  53.     PrintfQualifierInt,
  54.     PrintfQualifierLong,
  55.     PrintfQualifierLongLong,
  56.     PrintfQualifierSizeT,
  57.     PrintfQualifierPointer
  58. } qualifier_t;
  59.  
  60. static char digits_small[] = "0123456789abcdef";    /* Small hexadecimal characters */
  61. static char digits_big[] = "0123456789ABCDEF";  /* Big hexadecimal characters */
  62.  
  63. /** Print count chars from buffer without adding newline
  64.  * @param buf Buffer with size at least count bytes - NULL pointer NOT allowed!
  65.  * @param count
  66.  * @param ps output method and its data
  67.  * @return 0 on success, EOF on fail
  68.  */
  69. static int printf_putnchars(const char * buf, size_t count, struct printf_spec *ps)
  70. {
  71.     if (ps->write((void *)buf, count, ps->data) == count) {
  72.         return 0;
  73.     }
  74.    
  75.     return EOF;
  76. }
  77.  
  78. /** Print string without added newline
  79.  * @param str string to print
  80.  * @param ps write function specification and support data
  81.  * @return 0 on success or EOF on fail
  82.  */
  83. static int printf_putstr(const char * str, struct printf_spec *ps)
  84. {
  85.     size_t count;
  86.    
  87.     if (str == NULL) {
  88.         return printf_putnchars("(NULL)", 6, ps);
  89.     }
  90.  
  91.     for (count = 0; str[count] != 0; count++);
  92.  
  93.     if (ps->write((void *) str, count, ps->data) == count) {
  94.         return 0;
  95.     }
  96.    
  97.     return EOF;
  98. }
  99.  
  100. /** Print one character to output
  101.  * @param c one character
  102.  * @param ps output method
  103.  * @return printed character or EOF
  104.  */
  105. static int printf_putchar(int c, struct printf_spec *ps)
  106. {
  107.     unsigned char ch = c;
  108.    
  109.     if (ps->write((void *) &ch, 1, ps->data) == 1) {
  110.         return c;
  111.     }
  112.    
  113.     return EOF;
  114. }
  115.  
  116. /** Print one formatted character
  117.  * @param c character to print
  118.  * @param width
  119.  * @param flags
  120.  * @return number of printed characters or EOF
  121.  */
  122. static int print_char(char c, int width, uint64_t flags, struct printf_spec *ps)
  123. {
  124.     int counter = 0;
  125.    
  126.     if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
  127.         while (--width > 0) {   /* one space is consumed by character itself hence predecrement */
  128.             /* FIXME: painful slow */
  129.             printf_putchar(' ', ps);   
  130.             ++counter;
  131.         }
  132.     }
  133.    
  134.     if (printf_putchar(c, ps) == EOF) {
  135.         return EOF;
  136.     }
  137.  
  138.     while (--width > 0) { /* one space is consumed by character itself hence predecrement */
  139.         printf_putchar(' ', ps);
  140.         ++counter;
  141.     }
  142.    
  143.     return ++counter;
  144. }
  145.  
  146. /** Print one string
  147.  * @param s string
  148.  * @param width
  149.  * @param precision
  150.  * @param flags
  151.  * @return number of printed characters or EOF
  152.  */
  153.                        
  154. static int print_string(char *s, int width, int precision, uint64_t flags, struct printf_spec *ps)
  155. {
  156.     int counter = 0;
  157.     size_t size;
  158.  
  159.     if (s == NULL) {
  160.         return printf_putstr("(NULL)", ps);
  161.     }
  162.    
  163.     size = strlen(s);
  164.  
  165.     /* print leading spaces */
  166.  
  167.     if (precision == 0)
  168.         precision = size;
  169.  
  170.     width -= precision;
  171.    
  172.     if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
  173.         while (width-- > 0) {  
  174.             printf_putchar(' ', ps);   
  175.             counter++;
  176.         }
  177.     }
  178.  
  179.     while (precision > size) {
  180.         precision--;
  181.         printf_putchar(' ', ps);   
  182.         ++counter;
  183.     }
  184.    
  185.     if (printf_putnchars(s, precision, ps) == EOF) {
  186.         return EOF;
  187.     }
  188.  
  189.     counter += precision;
  190.  
  191.     while (width-- > 0) {
  192.         printf_putchar(' ', ps);   
  193.         ++counter;
  194.     }
  195.    
  196.     return ++counter;
  197. }
  198.  
  199.  
  200. /** Print number in given base
  201.  *
  202.  * Print significant digits of a number in given
  203.  * base.
  204.  *
  205.  * @param num  Number to print.
  206.  * @param width
  207.  * @param precision
  208.  * @param base Base to print the number in (should
  209.  *             be in range 2 .. 16).
  210.  * @param flags output modifiers
  211.  * @return number of written characters or EOF
  212.  *
  213.  */
  214. static int print_number(uint64_t num, int width, int precision, int base , uint64_t flags, struct printf_spec *ps)
  215. {
  216.     char *digits = digits_small;
  217.     char d[PRINT_NUMBER_BUFFER_SIZE];   /* this is good enough even for base == 2, prefix and sign */
  218.     char *ptr = &d[PRINT_NUMBER_BUFFER_SIZE - 1];
  219.     int size = 0; /* size of number with all prefixes and signs */
  220.     int number_size; /* size of plain number */
  221.     int written = 0;
  222.     char sgn;
  223.    
  224.     if (flags & __PRINTF_FLAG_BIGCHARS)
  225.         digits = digits_big;   
  226.    
  227.     *ptr-- = 0; /* Put zero at end of string */
  228.  
  229.     if (num == 0) {
  230.         *ptr-- = '0';
  231.         size++;
  232.     } else {
  233.         do {
  234.             *ptr-- = digits[num % base];
  235.             size++;
  236.         } while (num /= base);
  237.     }
  238.    
  239.     number_size = size;
  240.  
  241.     /* Collect sum of all prefixes/signs/... to calculate padding and leading zeroes */
  242.     if (flags & __PRINTF_FLAG_PREFIX) {
  243.         switch(base) {
  244.             case 2: /* Binary formating is not standard, but usefull */
  245.                 size += 2;
  246.                 break;
  247.             case 8:
  248.                 size++;
  249.                 break;
  250.             case 16:
  251.                 size += 2;
  252.                 break;
  253.         }
  254.     }
  255.  
  256.     sgn = 0;
  257.     if (flags & __PRINTF_FLAG_SIGNED) {
  258.         if (flags & __PRINTF_FLAG_NEGATIVE) {
  259.             sgn = '-';
  260.             size++;
  261.         } else if (flags & __PRINTF_FLAG_SHOWPLUS) {
  262.                 sgn = '+';
  263.                 size++;
  264.             } else if (flags & __PRINTF_FLAG_SPACESIGN) {
  265.                     sgn = ' ';
  266.                     size++;
  267.                 }
  268.     }
  269.  
  270.     if (flags & __PRINTF_FLAG_LEFTALIGNED) {
  271.         flags &= ~__PRINTF_FLAG_ZEROPADDED;
  272.     }
  273.  
  274.     /* if number is leftaligned or precision is specified then zeropadding is ignored */
  275.     if (flags & __PRINTF_FLAG_ZEROPADDED) {
  276.         if ((precision == 0) && (width > size)) {
  277.             precision = width - size + number_size;
  278.         }
  279.     }
  280.  
  281.     /* print leading spaces */
  282.     if (number_size > precision) /* We must print whole number not only a part */
  283.         precision = number_size;
  284.  
  285.     width -= precision + size - number_size;
  286.    
  287.     if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
  288.         while (width-- > 0) {  
  289.             printf_putchar(' ', ps);   
  290.             written++;
  291.         }
  292.     }
  293.    
  294.     /* print sign */
  295.     if (sgn) {
  296.         printf_putchar(sgn, ps);
  297.         written++;
  298.     }
  299.    
  300.     /* print prefix */
  301.    
  302.     if (flags & __PRINTF_FLAG_PREFIX) {
  303.         switch(base) {
  304.             case 2: /* Binary formating is not standard, but usefull */
  305.                 printf_putchar('0', ps);
  306.                 if (flags & __PRINTF_FLAG_BIGCHARS) {
  307.                     printf_putchar('B', ps);
  308.                 } else {
  309.                     printf_putchar('b', ps);
  310.                 }
  311.                 written += 2;
  312.                 break;
  313.             case 8:
  314.                 printf_putchar('o', ps);
  315.                 written++;
  316.                 break;
  317.             case 16:
  318.                 printf_putchar('0', ps);
  319.                 if (flags & __PRINTF_FLAG_BIGCHARS) {
  320.                     printf_putchar('X', ps);
  321.                 } else {
  322.                     printf_putchar('x', ps);
  323.                 }
  324.                 written += 2;
  325.                 break;
  326.         }
  327.     }
  328.  
  329.     /* print leading zeroes */
  330.     precision -= number_size;
  331.     while (precision-- > 0) {  
  332.         printf_putchar('0', ps);   
  333.         written++;
  334.     }
  335.  
  336.    
  337.     /* print number itself */
  338.  
  339.     written += printf_putstr(++ptr, ps);
  340.    
  341.     /* print ending spaces */
  342.    
  343.     while (width-- > 0) {  
  344.         printf_putchar(' ', ps);   
  345.         written++;
  346.     }
  347.  
  348.     return written;
  349. }
  350.  
  351.  
  352. /** General formatted text print
  353.  *
  354.  * Print string formatted according the fmt parameter
  355.  * and variant arguments. Each formatting directive
  356.  * must have the following form:
  357.  * % [ flags ] [ width ] [ .precision ] [ type ] conversion
  358.  *
  359.  * FLAGS:
  360.  * #    Force to print prefix. For conversion %o is prefix 0, for %x and %X are prefixes 0x and 0X and for conversion %b is prefix 0b.
  361.  * -    Align to left.
  362.  * +    Print positive sign just as negative.
  363.  *   (space)    If printed number is positive and '+' flag is not set, print space in place of sign.
  364.  * 0    Print 0 as padding instead of spaces. Zeroes are placed between sign and the rest of number. This flag is ignored if '-' flag is specified.
  365.  *
  366.  * WIDTH:
  367.  * Specify minimal width of printed argument. If it is bigger, width is ignored.
  368.  * If width is specified with a '*' character instead of number, width is taken from parameter list.
  369.  * Int parameter expected before parameter for processed conversion specification.
  370.  * If this value is negative it is taken its absolute value and the '-' flag is set.
  371.  *
  372.  * PRECISION:
  373.  * Value precision. For numbers it specifies minimum valid numbers.
  374.  * Smaller numbers are printed with leading zeroes. Bigger numbers are not affected.
  375.  * Strings with more than precision characters are cutted of.
  376.  * Just as width could be '*' used instead a number.
  377.  * A int value is then expected in parameters. When both width and precision are specified using '*',
  378.  * first parameter is used for width and second one for precision.
  379.  *
  380.  * TYPE:
  381.  * hh   signed or unsigned char
  382.  * h    signed or usigned short
  383.  *  signed or usigned int (default value)
  384.  * l    signed or usigned long int
  385.  * ll   signed or usigned long long int
  386.  * z    size_t type
  387.  *
  388.  *
  389.  * CONVERSIONS:
  390.  *
  391.  * %    Print percentage character.
  392.  *
  393.  * c    Print single character.
  394.  *
  395.  * s    Print zero terminated string. If a NULL value is passed as value, "(NULL)" is printed instead.
  396.  *
  397.  * P, p Print value of a pointer. Void * value is expected and it is printed in hexadecimal notation with prefix
  398.  * ( as with %#X or %#x for 32bit or %#X / %#x for 64bit long pointers)
  399.  *
  400.  * b    Print value as unsigned binary number.  Prefix is not printed by default. (Nonstandard extension.)
  401.  *
  402.  * o    Print value as unsigned octal number. Prefix is not printed by default.
  403.  *
  404.  * d,i  Print signed decimal number. There is no difference between d and i conversion.
  405.  *
  406.  * u    Print unsigned decimal number.
  407.  *
  408.  * X, x Print hexadecimal number with upper- or lower-case. Prefix is not printed by default.
  409.  *
  410.  * All other characters from fmt except the formatting directives
  411.  * are printed in verbatim.
  412.  *
  413.  * @param fmt Formatting NULL terminated string.
  414.  * @return count of printed characters or negative value on fail.
  415.  */
  416. int printf_core(const char *fmt, struct printf_spec *ps, va_list ap)
  417. {
  418.     int i = 0, j = 0; /* i is index of currently processed char from fmt, j is index to the first not printed nonformating character */
  419.     int end;
  420.     int counter; /* counter of printed characters */
  421.     int retval; /* used to store return values from called functions */
  422.     char c;
  423.     qualifier_t qualifier;  /* type of argument */
  424.     int base;   /* base in which will be parameter (numbers only) printed */
  425.     uint64_t number; /* argument value */
  426.     size_t  size; /* byte size of integer parameter */
  427.     int width, precision;
  428.     uint64_t flags;
  429.    
  430.     counter = 0;
  431.    
  432.     while ((c = fmt[i])) {
  433.         /* control character */
  434.         if (c == '%' ) {
  435.             /* print common characters if any processed */ 
  436.             if (i > j) {
  437.                 if ((retval = printf_putnchars(&fmt[j], (size_t)(i - j), ps)) == EOF) { /* error */
  438.                     return -counter;
  439.                 }
  440.                 counter += retval;
  441.             }
  442.        
  443.             j = i;
  444.             /* parse modifiers */
  445.             flags = 0;
  446.             end = 0;
  447.            
  448.             do {
  449.                 ++i;
  450.                 switch (c = fmt[i]) {
  451.                     case '#': flags |= __PRINTF_FLAG_PREFIX; break;
  452.                     case '-': flags |= __PRINTF_FLAG_LEFTALIGNED; break;
  453.                     case '+': flags |= __PRINTF_FLAG_SHOWPLUS; break;
  454.                     case ' ': flags |= __PRINTF_FLAG_SPACESIGN; break;
  455.                     case '0': flags |= __PRINTF_FLAG_ZEROPADDED; break;
  456.                     default: end = 1;
  457.                 }; 
  458.                
  459.             } while (end == 0);
  460.            
  461.             /* width & '*' operator */
  462.             width = 0;
  463.             if (isdigit(fmt[i])) {
  464.                 while (isdigit(fmt[i])) {
  465.                     width *= 10;
  466.                     width += fmt[i++] - '0';
  467.                 }
  468.             } else if (fmt[i] == '*') {
  469.                 /* get width value from argument list*/
  470.                 i++;
  471.                 width = (int)va_arg(ap, int);
  472.                 if (width < 0) {
  473.                     /* negative width means to set '-' flag */
  474.                     width *= -1;
  475.                     flags |= __PRINTF_FLAG_LEFTALIGNED;
  476.                 }
  477.             }
  478.            
  479.             /* precision and '*' operator */   
  480.             precision = 0;
  481.             if (fmt[i] == '.') {
  482.                 ++i;
  483.                 if (isdigit(fmt[i])) {
  484.                     while (isdigit(fmt[i])) {
  485.                         precision *= 10;
  486.                         precision += fmt[i++] - '0';
  487.                     }
  488.                 } else if (fmt[i] == '*') {
  489.                     /* get precision value from argument list*/
  490.                     i++;
  491.                     precision = (int)va_arg(ap, int);
  492.                     if (precision < 0) {
  493.                         /* negative precision means to ignore it */
  494.                         precision = 0;
  495.                     }
  496.                 }
  497.             }
  498.  
  499.             switch (fmt[i++]) {
  500.                 /** TODO: unimplemented qualifiers:
  501.                  * t ptrdiff_t - ISO C 99
  502.                  */
  503.                 case 'h':   /* char or short */
  504.                     qualifier = PrintfQualifierShort;
  505.                     if (fmt[i] == 'h') {
  506.                         i++;
  507.                         qualifier = PrintfQualifierByte;
  508.                     }
  509.                     break;
  510.                 case 'l':   /* long or long long*/
  511.                     qualifier = PrintfQualifierLong;
  512.                     if (fmt[i] == 'l') {
  513.                         i++;
  514.                         qualifier = PrintfQualifierLongLong;
  515.                     }
  516.                     break;
  517.                 case 'z':   /* size_t */
  518.                     qualifier = PrintfQualifierSizeT;
  519.                     break;
  520.                 default:
  521.                     qualifier = PrintfQualifierInt; /* default type */
  522.                     --i;
  523.             }  
  524.            
  525.             base = 10;
  526.  
  527.             switch (c = fmt[i]) {
  528.  
  529.                 /*
  530.                 * String and character conversions.
  531.                 */
  532.                 case 's':
  533.                     if ((retval = print_string(va_arg(ap, char*), width, precision, flags, ps)) == EOF) {
  534.                         return -counter;
  535.                     };
  536.                    
  537.                     counter += retval;
  538.                     j = i + 1;
  539.                     goto next_char;
  540.                 case 'c':
  541.                     c = va_arg(ap, unsigned int);
  542.                     if ((retval = print_char(c, width, flags, ps)) == EOF) {
  543.                         return -counter;
  544.                     };
  545.                    
  546.                     counter += retval;
  547.                     j = i + 1;
  548.                     goto next_char;
  549.  
  550.                 /*
  551.                  * Integer values
  552.                 */
  553.                 case 'P': /* pointer */
  554.                         flags |= __PRINTF_FLAG_BIGCHARS;
  555.                 case 'p':
  556.                     flags |= __PRINTF_FLAG_PREFIX;
  557.                     base = 16;
  558.                     qualifier = PrintfQualifierPointer;
  559.                     break; 
  560.                 case 'b':
  561.                     base = 2;
  562.                     break;
  563.                 case 'o':
  564.                     base = 8;
  565.                     break;
  566.                 case 'd':
  567.                 case 'i':
  568.                     flags |= __PRINTF_FLAG_SIGNED;  
  569.                 case 'u':
  570.                     break;
  571.                 case 'X':
  572.                     flags |= __PRINTF_FLAG_BIGCHARS;
  573.                 case 'x':
  574.                     base = 16;
  575.                     break;
  576.                 /* percentile itself */
  577.                 case '%':
  578.                     j = i;
  579.                     goto next_char;
  580.                 /*
  581.                 * Bad formatting.
  582.                 */
  583.                 default:
  584.                     /* Unknown format
  585.                      *  now, the j is index of '%' so we will
  586.                      * print whole bad format sequence
  587.                      */
  588.                     goto next_char;    
  589.             }
  590.        
  591.        
  592.         /* Print integers */
  593.             /* print number */
  594.             switch (qualifier) {
  595.                 case PrintfQualifierByte:
  596.                     size = sizeof(unsigned char);
  597.                     number = (uint64_t)va_arg(ap, unsigned int);
  598.                     break;
  599.                 case PrintfQualifierShort:
  600.                     size = sizeof(unsigned short);
  601.                     number = (uint64_t)va_arg(ap, unsigned int);
  602.                     break;
  603.                 case PrintfQualifierInt:
  604.                     size = sizeof(unsigned int);
  605.                     number = (uint64_t)va_arg(ap, unsigned int);
  606.                     break;
  607.                 case PrintfQualifierLong:
  608.                     size = sizeof(unsigned long);
  609.                     number = (uint64_t)va_arg(ap, unsigned long);
  610.                     break;
  611.                 case PrintfQualifierLongLong:
  612.                     size = sizeof(unsigned long long);
  613.                     number = (uint64_t)va_arg(ap, unsigned long long);
  614.                     break;
  615.                 case PrintfQualifierPointer:
  616.                     size = sizeof(void *);
  617.                     number = (uint64_t)(unsigned long)va_arg(ap, void *);
  618.                     break;
  619.                 case PrintfQualifierSizeT:
  620.                     size = sizeof(size_t);
  621.                     number = (uint64_t)va_arg(ap, size_t);
  622.                     break;
  623.                 default: /* Unknown qualifier */
  624.                     return -counter;
  625.                    
  626.             }
  627.            
  628.             if (flags & __PRINTF_FLAG_SIGNED) {
  629.                 if (number & (0x1 << (size*8 - 1))) {
  630.                     flags |= __PRINTF_FLAG_NEGATIVE;
  631.                
  632.                     if (size == sizeof(uint64_t)) {
  633.                         number = -((int64_t)number);
  634.                     } else {
  635.                         number = ~number;
  636.                         number &= (~((0xFFFFFFFFFFFFFFFFll) <<  (size * 8)));
  637.                         number++;
  638.                     }
  639.                 }
  640.             }
  641.  
  642.             if ((retval = print_number(number, width, precision, base, flags, ps)) == EOF ) {
  643.                 return -counter;
  644.             };
  645.  
  646.             counter += retval;
  647.             j = i + 1;
  648.         }  
  649. next_char:
  650.            
  651.         ++i;
  652.     }
  653.    
  654.     if (i > j) {
  655.         if ((retval = printf_putnchars(&fmt[j], (size_t)(i - j), ps)) == EOF) { /* error */
  656.             return -counter;
  657.         }
  658.         counter += retval;
  659.     }
  660.    
  661.     return counter;
  662. }
  663.  
  664.