int check_tetri(char *s) { size_t j; int d; size_t p[3]; d = 0; p[0] = 0; p[1] = 0; p[2] = 0; j = 0; while (s[j]) { if (s[j] == '.') p[0]++; if (s[j] == '#') p[1]++; if (s[j] == '\n') p[2]++; d += check_if(s, j); j++; } if (p[0] != 12 || p[1] != 4 || p[2] != 3 || d < 6) return (0); return (1); }
void up_and_down( unsigned num ) { while( --num ) { check_if( num ); if( (num & 0xff) == 0x00 ) printf( "\r ]][[ \r" ); if( (num & 0xff) == 0x80 ) printf( "\r [[]] \r" ); } printf( "\r ;;;; \r" ); }
int check(int num,int product){ int r; int num2 = num; //printf("\nChecking %d and %d",num,product); while(num){ r = num % 10; if(check_if(r,product)); //count++; else return 0; num = num / 10; } //printf("\n%d = %d",num2,product); return 1; }
cc_int32 check_once_cc_ccache_iterator_next(cc_ccache_iterator_t iterator, cc_uint32 expected_count, cc_int32 expected_err, const char *description) { cc_int32 err = ccNoError; // BEGIN_CHECK_ONCE(description); cc_int32 possible_return_values[6] = { ccNoError, ccIteratorEnd, ccErrBadParam, ccErrNoMem, ccErrInvalidCCacheIterator, ccErrCCacheNotFound, }; #define possible_ret_val_count sizeof(possible_return_values)/sizeof(possible_return_values[0]) cc_ccache_t ccache = NULL; cc_uint32 actual_count = 0; while (!err) { err = cc_ccache_iterator_next(iterator, &ccache); if (ccache) { actual_count++; cc_ccache_release(ccache); ccache = NULL; } } if (err == ccIteratorEnd) { err = ccNoError; } // check returned error check_err(err, expected_err, possible_return_values); check_if(actual_count != expected_count, "iterator didn't iterate over all ccaches"); // END_CHECK_ONCE; return err; }
int check_stmt(is_stmt* node) { int errors = 0; /* ; empty statement */ if (!node) return 0; switch (node->type) { case t_stmt_stmt_list: node->data.stmt_list.scope = scope_new(NULL, false); scope_push(node->data.stmt_list.scope); errors += check_stmt_list(node->data.stmt_list.list); scope_pop(); if (errors == 0) node->terminates = node->data.stmt_list.list->terminated; break; case t_stmt_var_stmt: errors += check_var_stmt(node->data.var, false); break; case t_stmt_assign: errors += check_assign_op(node->data.assign); break; case t_stmt_incr: errors += check_incr_op(node->data.incr); break; case t_stmt_if: errors += check_if(node->data.if_stmt); if (errors == 0) node->terminates = node->data.if_stmt->terminates; break; case t_stmt_loop: errors += check_loop_stmt(node->data.loop); if (errors == 0) node->terminates = node->data.loop->terminates; break; case t_stmt_func_call: errors += check_func_call(node->data.func_call); break; case t_stmt_switch: errors += check_switch(node->data.switch_stmt); if (errors == 0) node->terminates = node->data.switch_stmt->terminates; break; case t_stmt_break: errors += check_break(node->data.break_stmt); node->terminates = true; break; case t_stmt_continue: errors += check_continue(node->data.continue_stmt); node->terminates = true; break; case t_stmt_return: errors += check_return(node->data.return_stmt); node->terminates = true; break; } return errors; }
/* readbuffer * Reads in the input file and stores all strings in the * section between "#ifdef SCPACK" and "#else" in a buffer. * Only text that is between double quotes is added to the * buffer; the \" escape code is handled. Multiple strings * on one line are handled. */ unsigned readbuffer(FILE *input, unsigned char *buffer) { char str[256]; unsigned buffersize; int i,linenr; linenr=0; buffersize=0; rewind(input); while (!feof(input)) { while (fgets(str,sizeof str,input)!=NULL) { linenr++; check_tablename(str); check_separator(str); if (strmatch(str,START_TOKEN,NULL)) break; } /* while */ if (!strmatch(str,START_TOKEN,NULL)) return buffersize; /* no (more) section found, quit */ while (fgets(str,sizeof str,input)!=NULL) { linenr++; check_if(str,linenr); if (check_tablename(str)) printf("Error: table name definition should not be in SCPACK section (line %d)\n", linenr); check_separator(str); if (strmatch(str,"#else",NULL)) break; /* done */ /* add to the buffer only what is between double quotes */ i=0; do { while (str[i]!='\0' && str[i]!='"') i++; if (str[i]=='"') { /* we are in a string */ i++; while (str[i]!='\0' && str[i]!='"') { /* handle escape sequences */ if (str[i]=='\\') { i++; switch (str[i]) { case 'a': /* alarm */ buffer[buffersize++]='\a'; i++; break; case 'b': /* backspace */ buffer[buffersize++]='\b'; i++; break; case 'f': /* form feed */ buffer[buffersize++]='\f'; i++; break; case 'n': /* newline */ buffer[buffersize++]='\n'; i++; break; case 'r': /* carriage return */ buffer[buffersize++]='\n'; i++; break; case 't': /* tab */ buffer[buffersize++]='\t'; i++; break; case '\'': buffer[buffersize++]='\''; i++; break; case '"': buffer[buffersize++]='"'; i++; break; default: // ??? octal character code escapes and hexadecimal escapes // not supported printf("Unknown escape sequence '\\%c' on line %d\n", str[i], linenr); } /* switch */ } else { buffer[buffersize++]=str[i++]; } /* if */ } /* while */ if (str[i]=='"') { buffer[buffersize++]='\0'; /* terminate each string */ i++; } else { printf("Error: unterminated string on line %d\n",linenr); } /* if */ } /* if */ } while (str[i]!='\0'); } /* while - in SCPACK section */ /* put in another '\0' to terminate the section */ buffer[buffersize++]='\0'; } /* while - !feof(input) */ return buffersize; }