PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - var/php_gcov/PHP_HEAD/Zend - zend_indent.c
Test: PHP Code Coverage
Date: 2009-11-23 Instrumented lines: 55
Code covered: 0.0 % Executed lines: 0
Legend: not executed executed

       1                 : /*
       2                 :    +----------------------------------------------------------------------+
       3                 :    | Zend Engine                                                          |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
       6                 :    +----------------------------------------------------------------------+
       7                 :    | This source file is subject to version 2.00 of the Zend license,     |
       8                 :    | that is bundled with this package in the file LICENSE, and is        |
       9                 :    | available through the world-wide-web at the following url:           |
      10                 :    | http://www.zend.com/license/2_00.txt.                                |
      11                 :    | If you did not receive a copy of the Zend license and are unable to  |
      12                 :    | obtain it through the world-wide-web, please send a note to          |
      13                 :    | license@zend.com so we can mail you a copy immediately.              |
      14                 :    +----------------------------------------------------------------------+
      15                 :    | Authors: Andi Gutmans <andi@zend.com>                                |
      16                 :    |          Zeev Suraski <zeev@zend.com>                                |
      17                 :    +----------------------------------------------------------------------+
      18                 : */
      19                 : 
      20                 : /* $Id: zend_indent.c 282162 2009-06-15 14:06:30Z pajoye $ */
      21                 : 
      22                 : /* This indenter doesn't really work, it's here for no particular reason. */
      23                 : 
      24                 : 
      25                 : #include "zend.h"
      26                 : #include <zend_language_parser.h>
      27                 : #include "zend_compile.h"
      28                 : #include "zend_indent.h"
      29                 : 
      30                 : #define zendtext LANG_SCNG(yy_text)
      31                 : #define zendleng LANG_SCNG(yy_leng)
      32                 : 
      33                 : static void handle_whitespace(unsigned int *emit_whitespace) /* {{{ */
      34               0 : {
      35                 :         unsigned char c;
      36                 :         unsigned int i;
      37                 : 
      38               0 :         for (c=0; c<128; c++) {
      39               0 :                 if (emit_whitespace[c]>0) {
      40               0 :                         for (i=0; i<emit_whitespace[c]; i++) {
      41               0 :                                 zend_write((char *) &c, 1);
      42                 :                         }
      43                 :                 }
      44                 :         }
      45               0 :         memset(emit_whitespace, 0, sizeof(int)*256);
      46               0 : }
      47                 : /* }}} */
      48                 : 
      49                 : ZEND_API void zend_indent(void) /* {{{ */
      50               0 : {
      51                 :         zval token;
      52                 :         int token_type;
      53               0 :         int in_string=0;
      54               0 :         unsigned int nest_level=0;
      55                 :         unsigned int emit_whitespace[256];
      56                 :         unsigned int i;
      57                 :         TSRMLS_FETCH();
      58                 : 
      59               0 :         memset(emit_whitespace, 0, sizeof(int)*256);
      60                 : 
      61                 :         /* highlight stuff coming back from zendlex() */
      62               0 :         Z_TYPE(token) = 0;
      63               0 :         while ((token_type=lex_scan(&token TSRMLS_CC))) {
      64               0 :                 switch (token_type) {
      65                 :                         case T_INLINE_HTML:
      66               0 :                                 zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
      67               0 :                                 break;
      68                 :                         case T_WHITESPACE: {
      69               0 :                                         Z_TYPE(token) = 0;
      70                 :                                         /* eat whitespace, emit newlines */
      71               0 :                                         for (i=0; i<LANG_SCNG(yy_leng); i++) {
      72               0 :                                                 emit_whitespace[(unsigned char) LANG_SCNG(yy_text)[i]]++;
      73                 :                                         }
      74               0 :                                         continue;
      75                 :                                 }
      76                 :                                 break;
      77                 :                         case '"':
      78               0 :                                 in_string = !in_string;
      79                 :                                 /* break missing intentionally */
      80                 :                         default:
      81               0 :                                 if (Z_TYPE(token)==0) {
      82                 :                                         /* keyword */
      83               0 :                                         switch (token_type) {
      84                 :                                                 case ',':
      85               0 :                                                         ZEND_PUTS(", ");
      86               0 :                                                         goto dflt_printout;
      87                 :                                                         break;
      88                 :                                                 case '{':
      89               0 :                                                         nest_level++;
      90               0 :                                                         if (emit_whitespace['\n']>0) {
      91               0 :                                                                 ZEND_PUTS(" {\n");
      92               0 :                                                                 memset(emit_whitespace, 0, sizeof(int)*256);
      93                 :                                                         } else {
      94               0 :                                                                 ZEND_PUTS("{");
      95                 :                                                         }
      96               0 :                                                         break;
      97                 :                                                 case '}':
      98               0 :                                                         nest_level--;
      99               0 :                                                         if (emit_whitespace['\n']==0) {
     100               0 :                                                                 ZEND_PUTS("\n");
     101                 :                                                         }
     102               0 :                                                         for (i=0; i<nest_level; i++) {
     103               0 :                                                                 ZEND_PUTS("    ");
     104                 :                                                         }
     105                 :                                                         goto dflt_printout;
     106                 :                                                         break;
     107               0 : dflt_printout:
     108                 :                                                 default:
     109               0 :                                                         if (emit_whitespace['\n']>0) {
     110               0 :                                                                 for (i=0; i<emit_whitespace['\n']; i++) {
     111               0 :                                                                         ZEND_PUTS("\n");
     112                 :                                                                 }
     113               0 :                                                                 memset(emit_whitespace, 0, sizeof(int)*256);
     114               0 :                                                                 for (i=0; i<nest_level; i++) {
     115               0 :                                                                         ZEND_PUTS("    ");
     116                 :                                                                 }
     117                 :                                                         } else {
     118               0 :                                                                 handle_whitespace(emit_whitespace);
     119                 :                                                         }
     120               0 :                                                         zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
     121                 :                                                         break;
     122                 :                                         }
     123                 :                                 } else {
     124               0 :                                         handle_whitespace(emit_whitespace);
     125               0 :                                         if (in_string) {
     126               0 :                                                 zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
     127                 :                                                 /* a part of a string */
     128                 :                                         } else {
     129               0 :                                                 zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
     130                 :                                         }
     131                 :                                 }
     132                 :                                 break;
     133                 :                 }
     134               0 :                 if (Z_TYPE(token) == IS_STRING) {
     135               0 :                         switch (token_type) {
     136                 :                         case T_OPEN_TAG:
     137                 :                         case T_CLOSE_TAG:
     138                 :                         case T_WHITESPACE:
     139               0 :                                 break;
     140                 :                         default:
     141               0 :                                 efree(Z_STRVAL(token));
     142                 :                                 break;
     143                 :                         }
     144                 :                 }
     145               0 :                 Z_TYPE(token) = 0;
     146                 :         }
     147               0 : }
     148                 : /* }}} */
     149                 : 
     150                 : /*
     151                 :  * Local variables:
     152                 :  * tab-width: 4
     153                 :  * c-basic-offset: 4
     154                 :  * indent-tabs-mode: t
     155                 :  * End:
     156                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Mon, 23 Nov 2009 17:39:26 +0000 (34 hours ago)

Copyright © 2005-2009 The PHP Group
All rights reserved.