pike.git / src / post_modules / Unicode / unicode_module.cmod

version» Context lines:

pike.git/src/post_modules/Unicode/unicode_module.cmod:37:    SET_SVAL(r->item[i], PIKE_T_STRING, 0, string,    make_shared_binary_string2( d+w->words[i].start,    w->words[i].size ));    }    r->type_field = BIT_STRING;    push_array( r );    uc_buffer_free( data );    uc_words_free( w );   }    - static void push_words0( struct pike_string *ds, struct words *w ) - { -  /* push_object( clone_object( words_program, 0 ) ); */ -  struct array *r = allocate_array( w->size ); -  const p_wchar0 *d = STR0(ds); -  unsigned int i; -  for( i=0; i<w->size; i++ ) -  { -  SET_SVAL(r->item[i], PIKE_T_STRING, 0, string, -  make_shared_binary_string( (const char *)d+w->words[i].start, -  w->words[i].size )); -  } -  r->type_field = BIT_STRING; -  pop_stack(); -  push_array( r ); -  uc_words_free( w ); - } -  -  +    /*! @decl array(string) split_words(string input)    *! Splits the input string into an array of words, on the boundaries between    *! the different kinds of word characters as defined by @[is_wordchar]. The    *! result is an array of words, with the non-word characters between them    *! thrown away.    */   PIKEFUN array(string) split_words( string input )    optflags OPT_TRY_OPTIMIZE;   {    struct words *res;
pike.git/src/post_modules/Unicode/unicode_module.cmod:82:      /*! @decl array(string) split_words_and_normalize(string input)    *!    *! A less wasteful equivalent of    *! @expr{@[split_words](@[normalize](@[input], "NFKD"))@}.    */   PIKEFUN array(string) split_words_and_normalize( string input )    optflags OPT_TRY_OPTIMIZE;   {    struct words *res; - #if 0 -  /* Invalid optimization. See testsuite. */ -  if( !input->size_shift && (res = unicode_split_words_pikestr0( input )) ) +     { -  push_words0( input, res ); -  return; -  } - #endif -  -  { +     struct buffer *data;    data = uc_buffer_from_pikestring(input);    pop_n_elems( args );    data = unicode_decompose_buffer( data, COMPAT_BIT );    res = unicode_split_words_buffer( data );    push_words( data, res );    }   }      /*! @decl string normalize( string data, string method );
pike.git/src/post_modules/Unicode/unicode_module.cmod:195:    */   PIKEFUN int is_wordchar( int c )    optflags OPT_TRY_OPTIMIZE;   {    RETURN unicode_is_wordchar( c );   }      static int is_rtl_char( int c )   {    unsigned int rtl=0, i; -  for(i=0; i<sizeof(_rtl); i++) +  for(i=0; i<NELEM(_rtl); i++)    {    if(c<_rtl[i]) return rtl;    rtl ^= 1;    }    return 0;   }      /*! @decl int is_rtlchar( int c )    *! Returns @expr{1@} if the character is a RTL character or    *! indicator, otherwise @expr{0@}.
pike.git/src/post_modules/Unicode/unicode_module.cmod:231:    char *str;    shift = s->size_shift;    if( shift==0 ) RETURN 0;    len = s->len;    str = s->str;    while( --len )    if( is_rtl_char(INDEX_CHARP(str,len,shift)) ) RETURN 1;    RETURN 0;   }    + /*! @decl int(0..1) is_whitespace( int c ) +  *! Returns @expr{1@} if the character is a white space character, +  *! otherwise @expr{0@}. +  */ + PIKEFUN int(0..1) is_whitespace( int c ) +  optflags OPT_TRY_OPTIMIZE; + { +  RETURN wide_isspace(c); + } +    /*! @decl constant version    *! Contains the version of the current Unicode database as a string,    *! e.g. @expr{"5.0.0"@}.    */      /*! @endmodule    */      PIKE_MODULE_INIT   {    INIT    unicode_normalize_init();    add_string_constant("version", UVERSION, 0);   }      PIKE_MODULE_EXIT   {    EXIT   }