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.
242
2010/01/02 13:
17
:
10
srb Exp $
+
|| $Id: builtin.cmod,v 1.
243
2010/01/02 13:
24
:
19
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:783:
else ws = 0; init_string_builder_alloc (&sb, len, shift); sb.known_shift = shift; #define DO_IT_SPACECHECK(c) \ ((c)==' '||(c)=='\t'||(c)=='\r'||(c)=='\n'||(c)=='\v'||(c)=='\f') switch (shift) { #define DO_IT(TYPE) \ { TYPE *start = src, *end = start+len, *dst = (void*)sb.s->str; \
-
for (; start < end; start++) { \
-
unsigned chr = *start; \
+
if (!ws) { \
-
+
for (; start < end; start++) { \
+
unsigned chr = *start; \
if (!DO_IT_SPACECHECK(chr)) \ break; \
-
} else { \
-
char *p = ws; \
-
do { \
-
if (*p == chr) \
-
goto lead##TYPE; \
-
} while(*++p); \
-
break; \
+
} \
-
lead##TYPE:; \
-
} \
+
for (; start < end; start++) { \
-
unsigned chr = *start;
\
-
if (!ws) { \
+
unsigned chr = *start; \
if (DO_IT_SPACECHECK(chr)) \ if (foundspace) \ continue; \ else \ foundspace=1,chr=' '; \ else \ foundspace=0; \
-
} else { \
+
*dst++ = chr; \
+
}
\
+
}
else {
\
+
for (; start < end; start++) { \
+
unsigned chr = *start; \
char *p = ws; \ do { \ if (*p == chr) \
-
+
goto lead##TYPE; \
+
} while(*++p); \
+
break; \
+
lead##TYPE:; \
+
} \
+
for (; start < end; start++) { \
+
unsigned chr = *start; \
+
char *p = ws; \
+
do { \
+
if (*p == chr) \
if (foundspace) \ goto skip##TYPE; \ else { \ foundspace=1;chr=*ws; \ goto copy##TYPE; \ } \ } while(*++p); \ if (foundspace && (chr=='\n' || chr=='\r')) { \ dst[-1] = chr; foundspace=0; \ goto lead##TYPE; \ } \ foundspace=0; \
-
} \
+
copy##TYPE: \ *dst++ = chr; \ skip##TYPE:; \
-
+
} \
} \ len = dst - (TYPE*)sb.s->str; \ } case 0: DO_IT (p_wchar0); break; case 1: DO_IT (p_wchar1); break; case 2: DO_IT (p_wchar2); break; #undef DO_IT #undef DO_IT_SPACECHECK } if (foundspace)