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

LCOV - code coverage report
Current view: top level - Zend - zend_indent.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 0 54 0.0 %
Date: 2014-10-24 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2014 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$ */
      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             : 
      34           0 : static void handle_whitespace(int *emit_whitespace)
      35             : {
      36             :         unsigned char c;
      37             :         int i;
      38             : 
      39           0 :         for (c=0; c<128; c++) {
      40           0 :                 if (emit_whitespace[c]>0) {
      41           0 :                         for (i=0; i<emit_whitespace[c]; i++) {
      42           0 :                                 zend_write((char *) &c, 1);
      43             :                         }
      44             :                 }
      45             :         }
      46           0 :         memset(emit_whitespace, 0, sizeof(int)*256);
      47           0 : }
      48             : 
      49             : 
      50           0 : ZEND_API void zend_indent()
      51             : {
      52             :         zval token;
      53             :         int token_type;
      54           0 :         int in_string=0;
      55           0 :         int nest_level=0;
      56             :         int emit_whitespace[256];
      57             :         int i;
      58             :         TSRMLS_FETCH();
      59             : 
      60           0 :         memset(emit_whitespace, 0, sizeof(int)*256);
      61             : 
      62             :         /* highlight stuff coming back from zendlex() */
      63           0 :         token.type = 0;
      64           0 :         while ((token_type=lex_scan(&token TSRMLS_CC))) {
      65           0 :                 switch (token_type) {
      66             :                         case T_INLINE_HTML:
      67           0 :                                 zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
      68           0 :                                 break;
      69             :                         case T_WHITESPACE: {
      70           0 :                                         token.type = 0;
      71             :                                         /* eat whitespace, emit newlines */
      72           0 :                                         for (i=0; i<LANG_SCNG(yy_leng); i++) {
      73           0 :                                                 emit_whitespace[(unsigned char) LANG_SCNG(yy_text)[i]]++;
      74             :                                         }
      75           0 :                                         continue;
      76             :                                 }
      77             :                                 break;
      78             :                         case '"':
      79           0 :                                 in_string = !in_string;
      80             :                                 /* break missing intentionally */
      81             :                         default:
      82           0 :                                 if (token.type==0) {
      83             :                                         /* keyword */
      84           0 :                                         switch (token_type) {
      85             :                                                 case ',':
      86           0 :                                                         ZEND_PUTS(", ");
      87           0 :                                                         goto dflt_printout;
      88             :                                                         break;
      89             :                                                 case '{':
      90           0 :                                                         nest_level++;
      91           0 :                                                         if (emit_whitespace['\n']>0) {
      92           0 :                                                                 ZEND_PUTS(" {\n");
      93           0 :                                                                 memset(emit_whitespace, 0, sizeof(int)*256);
      94             :                                                         } else {
      95           0 :                                                                 ZEND_PUTS("{");
      96             :                                                         }
      97           0 :                                                         break;
      98             :                                                 case '}':
      99           0 :                                                         nest_level--;
     100           0 :                                                         if (emit_whitespace['\n']==0) {
     101           0 :                                                                 ZEND_PUTS("\n");
     102             :                                                         }
     103           0 :                                                         for (i=0; i<nest_level; i++) {
     104           0 :                                                                 ZEND_PUTS("    ");
     105             :                                                         }
     106             :                                                         goto dflt_printout;
     107             :                                                         break;
     108             : dflt_printout:
     109             :                                                 default:
     110           0 :                                                         if (emit_whitespace['\n']>0) {
     111           0 :                                                                 for (i=0; i<emit_whitespace['\n']; i++) {
     112           0 :                                                                         ZEND_PUTS("\n");
     113             :                                                                 }
     114           0 :                                                                 memset(emit_whitespace, 0, sizeof(int)*256);
     115           0 :                                                                 for (i=0; i<nest_level; i++) {
     116           0 :                                                                         ZEND_PUTS("    ");
     117             :                                                                 }
     118             :                                                         } else {
     119           0 :                                                                 handle_whitespace(emit_whitespace);
     120             :                                                         }
     121           0 :                                                         zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
     122             :                                                         break;
     123             :                                         }
     124             :                                 } else {
     125           0 :                                         handle_whitespace(emit_whitespace);
     126           0 :                                         if (in_string) {
     127           0 :                                                 zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
     128             :                                                 /* a part of a string */
     129             :                                         } else {
     130           0 :                                                 zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
     131             :                                         }
     132             :                                 }
     133             :                                 break;
     134             :                 }
     135           0 :                 if (token.type == IS_STRING) {
     136           0 :                         switch (token_type) {
     137             :                         case T_OPEN_TAG:
     138             :                         case T_CLOSE_TAG:
     139             :                         case T_WHITESPACE:
     140           0 :                                 break;
     141             :                         default:
     142           0 :                                 efree(token.value.str.val);
     143             :                                 break;
     144             :                         }
     145             :                 }
     146           0 :                 token.type = 0;
     147             :         }
     148           0 : }
     149             : 
     150             : /*
     151             :  * Local variables:
     152             :  * tab-width: 4
     153             :  * c-basic-offset: 4
     154             :  * indent-tabs-mode: t
     155             :  * End:
     156             :  */

Generated by: LCOV version 1.10

Generated at Fri, 24 Oct 2014 05:21:44 +0000 (8 days ago)

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