Function: core_init_state Initialize the input data for the state machine. Populate the input with several predetermined strings, interspersed. Actual patterns chosen depend on the seed parameter. Note: The seed parameter MUST be supplied from a source that cannot be determined at compile time */
| 114 | The seed parameter MUST be supplied from a source that cannot be determined at compile time |
| 115 | */ |
| 116 | void core_init_state(ee_u32 size, ee_s16 seed, ee_u8 *p) { |
| 117 | ee_u32 total=0,next=0,i; |
| 118 | ee_u8 *buf=0; |
| 119 | #if CORE_DEBUG |
| 120 | ee_u8 *start=p; |
| 121 | ee_printf("State: %d,%d\n",size,seed); |
| 122 | #endif |
| 123 | size--; |
| 124 | next=0; |
| 125 | while ((total+next+1)<size) { |
| 126 | if (next>0) { |
| 127 | for(i=0;i<next;i++) |
| 128 | *(p+total+i)=buf[i]; |
| 129 | *(p+total+i)=','; |
| 130 | total+=next+1; |
| 131 | } |
| 132 | seed++; |
| 133 | switch (seed & 0x7) { |
| 134 | case 0: /* int */ |
| 135 | case 1: /* int */ |
| 136 | case 2: /* int */ |
| 137 | buf=intpat[(seed>>3) & 0x3]; |
| 138 | next=4; |
| 139 | break; |
| 140 | case 3: /* float */ |
| 141 | case 4: /* float */ |
| 142 | buf=floatpat[(seed>>3) & 0x3]; |
| 143 | next=8; |
| 144 | break; |
| 145 | case 5: /* scientific */ |
| 146 | case 6: /* scientific */ |
| 147 | buf=scipat[(seed>>3) & 0x3]; |
| 148 | next=8; |
| 149 | break; |
| 150 | case 7: /* invalid */ |
| 151 | buf=errpat[(seed>>3) & 0x3]; |
| 152 | next=8; |
| 153 | break; |
| 154 | default: /* Never happen, just to make some compilers happy */ |
| 155 | break; |
| 156 | } |
| 157 | } |
| 158 | size++; |
| 159 | while (total<size) { /* fill the rest with 0 */ |
| 160 | *(p+total)=0; |
| 161 | total++; |
| 162 | } |
| 163 | #if CORE_DEBUG |
| 164 | ee_printf("State Input: %s\n",start); |
| 165 | #endif |
| 166 | } |
| 167 | |
| 168 | static ee_u8 ee_isdigit(ee_u8 c) { |
| 169 | ee_u8 retval; |