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 - json - utf8_to_utf16.c
Test: PHP Code Coverage
Date: 2009-11-19 Instrumented lines: 15
Code covered: 100.0 % Executed lines: 15
Legend: not executed executed

       1                 : /* utf8_to_utf16.c */
       2                 : 
       3                 : /* 2005-12-25 */
       4                 : 
       5                 : /*
       6                 : Copyright (c) 2005 JSON.org
       7                 : 
       8                 : Permission is hereby granted, free of charge, to any person obtaining a copy
       9                 : of this software and associated documentation files (the "Software"), to deal
      10                 : in the Software without restriction, including without limitation the rights
      11                 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      12                 : copies of the Software, and to permit persons to whom the Software is
      13                 : furnished to do so, subject to the following conditions:
      14                 : 
      15                 : The above copyright notice and this permission notice shall be included in all
      16                 : copies or substantial portions of the Software.
      17                 : 
      18                 : The Software shall be used for Good, not Evil.
      19                 : 
      20                 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      21                 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      22                 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      23                 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      24                 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      25                 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      26                 : SOFTWARE.
      27                 : */
      28                 : 
      29                 : #include "utf8_to_utf16.h"
      30                 : #include "utf8_decode.h"
      31                 : 
      32                 : int 
      33                 : utf8_to_utf16(unsigned short w[], char p[], int length) 
      34             434 : {
      35                 :     int c;
      36             434 :     int the_index = 0;
      37                 :     json_utf8_decode utf8;
      38                 :     
      39             434 :     utf8_decode_init(&utf8, p, length);
      40                 :     for (;;) {
      41           18533 :         c = utf8_decode_next(&utf8);
      42           18533 :         if (c < 0) {
      43             434 :             return (c == UTF8_END) ? the_index : UTF8_ERROR;
      44                 :         }
      45           18099 :         if (c < 0x10000) {
      46           18082 :             w[the_index] = (unsigned short)c;
      47           18082 :             the_index += 1;
      48                 :         } else {
      49              17 :             c -= 0x10000;
      50              17 :             w[the_index] = (unsigned short)(0xD800 | (c >> 10));
      51              17 :             the_index += 1;
      52              17 :             w[the_index] = (unsigned short)(0xDC00 | (c & 0x3FF));
      53              17 :             the_index += 1;
      54                 :         }
      55           18099 :     }
      56                 : }

Generated by: LTP GCOV extension version 1.5

Generated at Thu, 19 Nov 2009 08:20:09 +0000 (5 days ago)

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