pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:1:
/* -*- c -*- || 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.cmod,v 1.
252
2010/01/11
13
:
19
:
56
jonasw
Exp $
+
|| $Id: builtin.cmod,v 1.
253
2010/01/11
16
:
30
:
48
srb
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.cmod:779:
optflags OPT_TRY_OPTIMIZE; { size_t len = s->len, wlen; const void *src = s->str; unsigned shift = s->size_shift, replspace; const void *ws; void *wstemp = 0; struct string_builder sb; unsigned foundspace = 0;
+
wlen = replspace = 0; /* useless, but suppresses silly compiler warning */
+
{ unsigned bshift = shift, wshift; if(whitespace) if(!(wlen = whitespace->len)) REF_RETURN s; else { ws = whitespace->str; wshift = whitespace->size_shift; replspace = index_shared_string(whitespace, 0); if(replspace > 0xffff) bshift = 2;
pike.git/src/builtin.cmod:801:
if(wshift!=shift) { /* convert whitespace to shift of input */ PCHARP pcnws; wstemp = xalloc(wlen<<shift); pcnws = MKPCHARP(wstemp, shift); if(wshift>shift) { PCHARP pcows = MKPCHARP_STR(whitespace); size_t clen = wlen, i; i = wlen = 0; do { unsigned chr = INDEX_PCHARP(pcows, i++);
-
if (chr<=0xff || chr<=0xffff && shift)
/* shift is 0 or 1 */
+
if (chr<=0xff ||
(
chr<=0xffff && shift)
)
/* shift is 0 or 1 */
SET_INDEX_PCHARP(pcnws, wlen++, chr); } while(--clen); } else pike_string_cpy(pcnws, whitespace); ws = wstemp; } } else ws = 0;
pike.git/src/builtin.cmod:854:
found##TYPE: \ foundspace=0; \ *dst++ = *start; \ } \ sb.s->len = dst - (TYPE*)sb.s->str; \ } else { \ const TYPE*ps = (const TYPE*)ws+wlen; \ for (; start < end; start++) { \ size_t clen = wlen; \ do { \
-
if (ps[-clen] == *start)
\
+
if (ps[
0
-clen] == *start) \
goto lead##TYPE; \ } while(--clen); \ break; \ lead##TYPE:; \ } \ for (; start < end; start++) { \ TYPE chr = *start; \ size_t clen = wlen; \ do \
-
if (ps[-clen] == chr) {
\
+
if (ps[
0
-clen] == chr) { \
if (!foundspace) \ string_builder_putchar(&sb, replspace), foundspace=1; \ goto skip##TYPE; \ } \ while(--clen); \ if (foundspace && (chr=='\n' || chr=='\r')) { \ sb.s->len--; string_builder_putchar(&sb, chr); \ foundspace=0; \ goto lead##TYPE; \ } \