pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: builtin_functions.c,v 1.596 2005/04/02 15:06:02 mast Exp $ + || $Id: builtin_functions.c,v 1.597 2005/05/05 20:42:02 nilsson Exp $   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"
pike.git/src/builtin_functions.c:1917:    *! @seealso    *! @[Locale.Charset.encoder()], @[string_to_unicode()], @[string_to_utf8()],    *! @[unicode_to_string()]    */   PMOD_EXPORT void f_utf8_to_string(INT32 args)   {    struct pike_string *in;    struct pike_string *out;    ptrdiff_t len = 0;    int shift = 0; -  ptrdiff_t i,j; +  ptrdiff_t i,j=0;    INT_TYPE extended = 0;       get_all_args("utf8_to_string", args, "%S.%i", &in, &extended);       for(i=0; i < in->len; i++) {    unsigned int c = STR0(in)[i];    len++;    if (c & 0x80) {    int cont = 0;   
pike.git/src/builtin_functions.c:2100:    /* 7bit in == 7bit out */    pop_n_elems(args-1);    return;    }       out = begin_wide_shared_string(len, shift);       switch (shift) {    case 0: {    p_wchar0 *out_str = STR0 (out); -  for(j=i=0; i < in->len;) { +  for(i=0; i < in->len;) {    unsigned int c = STR0(in)[i++];    /* NOTE: No tests here since we've already tested the string above. */    if (c & 0x80) {    /* 11bit */    unsigned int c2 = STR0(in)[i++] & 0x3f;    c &= 0x1f;    c = (c << 6) | c2;    }    out_str[j++] = c;    }    break;    }       case 1: {    p_wchar1 *out_str = STR1 (out); -  for(j=i=0; i < in->len;) { +  for(i=0; i < in->len;) {    unsigned int c = STR0(in)[i++];    /* NOTE: No tests here since we've already tested the string above. */    if (c & 0x80) {    if ((c & 0xe0) == 0xc0) {    /* 11bit */    unsigned int c2 = STR0(in)[i++] & 0x3f;    c &= 0x1f;    c = (c << 6) | c2;    } else {    /* 16bit */
pike.git/src/builtin_functions.c:2140:    c = (c << 12) | (c2 << 6) | c3;    }    }    out_str[j++] = c;    }    break;    }       case 2: {    p_wchar2 *out_str = STR2 (out); -  for(j=i=0; i < in->len;) { +  for(i=0; i < in->len;) {    unsigned int c = STR0(in)[i++];    /* NOTE: No tests here since we've already tested the string above. */    if (c & 0x80) {    int cont = 0;    if ((c & 0xe0) == 0xc0) {    /* 11bit */    cont = 1;    c &= 0x1f;    } else if ((c & 0xf0) == 0xe0) {    /* 16bit */