Mercurial > hg > CbC > old > device
changeset 623:4e08fbf6754b
macro stringrise, switch unsginged mungle
author | kono |
---|---|
date | Sun, 10 Sep 2006 22:11:41 +0900 |
parents | 682c8ec38d45 |
children | 4d28634e46e4 |
files | Changes mc-macro.c mc-switch.c test/i3.c test/macro.c |
diffstat | 5 files changed, 88 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Thu Sep 07 11:50:17 2006 +0900 +++ b/Changes Sun Sep 10 22:11:41 2006 +0900 @@ -8829,3 +8829,17 @@ 確定しないとまずい? もう少し考えてみないと実現できるかどうかわからない。 + +Sun Sep 10 11:46:30 JST 2006 + +return がないとかのwaringを出した方が良いね。 +それほど難しくないはず。 + + +Sun Sep 10 22:05:38 JST 2006 + +test/i3.c がひどい... + + + +
--- a/mc-macro.c Thu Sep 07 11:50:17 2006 +0900 +++ b/mc-macro.c Sun Sep 10 22:11:41 2006 +0900 @@ -850,6 +850,7 @@ int c,len; int in_quote = 0; int in_wquote = 0; + int string_flag = 0; char *macro; char *body = body0; char **expand; @@ -879,14 +880,26 @@ mconcat = 1; // name concatenation. flag only. remove and re-evaluate // in the top level. (and skip space) + } else if (!mconcat && c=='#' && alpha(*body)) { + // turn into string next macro literal + string_flag = 1; + *cheap->ptr = '"'; + cheap = increment_cheap(cheap,expand); + goto names; } else if (alpha(c)) { // find a name body--; // ungetc +names: nptrm = get_name(body,&len,NONDEF); if (!nptrm) { while((*cheap->ptr = *body++) && len--) cheap = increment_cheap(cheap,expand); body--; + if (string_flag) { + string_flag = 0; + *cheap->ptr = '"'; + cheap = increment_cheap(cheap,expand); + } continue; } body += len; @@ -894,6 +907,7 @@ nptrm = name_space_search(nptrm,MACRO); macro = (char *)car(nptrm->dsp); // if (check_recurse(macro,history)) goto skip; +// string_falg = 0; switch(nptrm->sc) { case FMACRO: if (c==' '||c=='\t') { @@ -911,7 +925,14 @@ break; case MACRO: if (neqname(nptrm->nm,macro)) { - if (macro[0]==0) continue; + if (macro[0]==0) { + if (string_flag) { + string_flag = 0; + *cheap->ptr = '"'; + cheap = increment_cheap(cheap,expand); + } + continue; + } *cheap->ptr = 0; cheap = increment_cheap(cheap,expand); macrop=macro_eval(macrop,macro,list2((int)macro,history)); @@ -926,6 +947,11 @@ while((*cheap->ptr = *macro++)/* && len-- */) cheap = increment_cheap(cheap,expand); } + if (string_flag) { + string_flag = 0; + *cheap->ptr = '"'; + cheap = increment_cheap(cheap,expand); + } continue; } *cheap->ptr = c;
--- a/mc-switch.c Thu Sep 07 11:50:17 2006 +0900 +++ b/mc-switch.c Sun Sep 10 22:11:41 2006 +0900 @@ -120,6 +120,7 @@ { int range = max-min; int g; + int c = 128*CASE_MERGE_RATE/100; // compute possible merge delta g = gcd(*delta,delta1); g = gcd(g,range); @@ -136,7 +137,7 @@ } #endif // count/((max-min)/delta) > 0.8 - return count1*128>(range*128*CASE_MERGE_RATE/100); + return count1*128>(range*c); } static void
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/i3.c Sun Sep 10 22:11:41 2006 +0900 @@ -0,0 +1,25 @@ + +extern int printf(const char *,...); + +// #define CASE_MERGE_RATE 50 +unsigned int CASE_MERGE_RATE=50; +unsigned int a=100; + +int +main() +{ + int max = 524288; + int min = 131072; + int range = 393216; + int count1 = 3; + int g = 1; + +// range 393216 min 131072, max 524288, count 3, delta 1, rate 0.000762939 t=0 + + printf("## range %d min %d, max %d, count %d, delta %d, rate %g t=%d\n", + range, min,max,count1,g, + ((double)count1)*100.0/range, + count1*128>(range*128*CASE_MERGE_RATE/a) + ); + return 0; +}
--- a/test/macro.c Thu Sep 07 11:50:17 2006 +0900 +++ b/test/macro.c Sun Sep 10 22:11:41 2006 +0900 @@ -79,6 +79,26 @@ return 0; } +/* For GCC 2.7 and later, we can use specific type-size attributes. */ +# define __intN_t(N, MODE) \ + typedef int int##N##_t __attribute__ ((__mode__ (MODE))) +# define __u_intN_t(N, MODE) \ + typedef unsigned int u_int##N##_t __attribute__ ((__mode__ (MODE))) + +# ifndef __int8_t_defined +# define __int8_t_defined +__intN_t (8, __QI__); +__intN_t (16, __HI__); +__intN_t (32, __SI__); +__intN_t (64, __DI__); +# endif + +__u_intN_t (8, __QI__); +__u_intN_t (16, __HI__); +__u_intN_t (32, __SI__); +__u_intN_t (64, __DI__); + + int tmp() #if 0 {