|
|
| version 1.115.2.12.2.10, 2003/03/24 08:27:45 | version 1.115.2.12.2.13, 2003/03/24 16:43:27 |
|---|---|
| Line 28 extern "C" { // author forgot to do that | Line 28 extern "C" { // author forgot to do that |
| #include "pa_sql_connection.h" | #include "pa_sql_connection.h" |
| #endif | #endif |
| // forwards | |
| void CORD_ec_flush_buf_optimize_whitespace(CORD_ec x); | |
| // defines | |
| #undef CORD_ec_append | |
| // redefining to intercept flushes and implement whitespace optimization | |
| // of all consequent white space chars leaving only first one | |
| #define CORD_ec_append(x, c) \ | |
| { \ | |
| bool skip=false; \ | |
| if(optimize) switch(c) { \ | |
| case ' ': case '\r': case '\n': case '\t': \ | |
| if(whitespace) \ | |
| skip=true; /*skipping subsequent*/ \ | |
| else \ | |
| whitespace=true; \ | |
| break; \ | |
| default: \ | |
| whitespace=false; \ | |
| break; \ | |
| } \ | |
| if(!skip) { \ | |
| if ((x)[0].ec_bufptr == (x)[0].ec_buf + CORD_BUFSZ) { \ | |
| CORD_ec_flush_buf(x); \ | |
| } \ | |
| *((x)[0].ec_bufptr)++ = (c); \ | |
| } \ | |
| } | |
| #define escape(action) \ | #define escape(action) \ |
| for(; fragment_length--; CORD_next(pos)) { \ | for(; fragment_length--; CORD_next(pos)) { \ |
| char c=CORD_pos_fetch(pos); \ | char c=CORD_pos_fetch(pos); \ |
| Line 217 inline bool mail_header_char_valid_withi | Line 250 inline bool mail_header_char_valid_withi |
| || c>='0' && c<='9' | || c>='0' && c<='9' |
| || strchr("!*+-/", c); | || strchr("!*+-/", c); |
| } | } |
| inline void ec_append(CORD_ec result, CORD_pos& pos, size_t size) { | inline void ec_append(CORD_ec& result, bool& optimize, bool& whitespace, CORD_pos& pos, size_t size) { |
| while(size--) { | while(size--) { |
| CORD_ec_append(result, CORD_pos_fetch(pos)); | CORD_ec_append(result, CORD_pos_fetch(pos)); |
| CORD_next(pos); | CORD_next(pos); |
| Line 237 StringBody String::cstr_to_string_body(L | Line 270 StringBody String::cstr_to_string_body(L |
| const Fragment& fragment=i.next(); | const Fragment& fragment=i.next(); |
| size_t fragment_length=fragment.length; | size_t fragment_length=fragment.length; |
| fragment_end=fragment_begin+fragment_length; | fragment_end=fragment_begin+fragment_length; |
| //fprintf(stderr, "%d, %d\n", fragment.lang, fragment.length); | |
| Language to_lang=lang==L_UNSPECIFIED?fragment.lang:lang; | Language to_lang=lang==L_UNSPECIFIED?fragment.lang:lang; |
| bool optimize=(to_lang & L_OPTIMIZE_BIT)!=0; | |
| if(!optimize) | |
| whitespace=false; | |
| switch(to_lang & ~L_OPTIMIZE_BIT) { | switch(to_lang & ~L_OPTIMIZE_BIT) { |
| case L_CLEAN: | case L_CLEAN: |
| Line 251 StringBody String::cstr_to_string_body(L | Line 288 StringBody String::cstr_to_string_body(L |
| // for ^process{body} evaluation | // for ^process{body} evaluation |
| // tainted, untaint language: as-is | // tainted, untaint language: as-is |
| ec_append(result, pos, fragment_length); | ec_append(result, optimize, whitespace, pos, fragment_length); |
| break; | break; |
| case L_FILE_SPEC: | case L_FILE_SPEC: |
| // tainted, untaint language: file [name] | // tainted, untaint language: file [name] |
| Line 402 StringBody String::cstr_to_string_body(L | Line 439 StringBody String::cstr_to_string_body(L |
| static_cast<int>(to_lang)); // should never | static_cast<int>(to_lang)); // should never |
| break; // never | break; // never |
| } | } |
| #ifdef LATER | |
| if(to_lang & L_OPTIMIZE_BIT) { | |
| // optimizing whitespace | |
| char *stop=dest; dest=start; | |
| for(char c=start; src<stop; src++) | |
| switch(c) { | |
| // of all consequent white space chars leaving only first one | |
| case ' ': case '\r': case '\n': case '\t': | |
| if(!whitespace) { | |
| *dest++=c; | |
| whitespace=true; | |
| } | |
| break; | |
| default: | |
| whitespace=false; | |
| *dest++=c; | |
| break; | |
| }; | |
| } else // piece without optimization | |
| whitespace=false; | |
| #endif | |
| } | } |
| return StringBody(CORD_ec_to_cord(result)); | return StringBody(CORD_ec_to_cord(result)); |