static void undo_do_something (GObject *object, EUndoDoType todo, void (* insert_func) (GObject *object, const gchar *text, gint position), void (* delete_func) (GObject *object, gint position_start, gint position_end)) { EUndoData *data; EUndoInfo *info = NULL; data = g_object_get_data (object, UNDO_DATA_KEY); if (!data) return; if (todo == E_UNDO_DO_UNDO && data->n_undos > 0) { info = data->undo_stack[REAL_INDEX (data->n_undos - 1)]; data->n_undos--; data->n_redos++; } else if (todo == E_UNDO_DO_REDO && data->n_redos > 0) { info = data->undo_stack[REAL_INDEX (data->n_undos)]; data->n_undos++; data->n_redos--; } if (!info) return; g_signal_handler_block (object, data->insert_handler_id); g_signal_handler_block (object, data->delete_handler_id); if (info->type == E_UNDO_INSERT) { if (todo == E_UNDO_DO_UNDO) { delete_func (object, info->position_start, info->position_start + g_utf8_strlen (info->text, -1)); widget_undo_place_cursor_at (object, info->position_start); } else { insert_func (object, info->text, info->position_start); widget_undo_place_cursor_at (object, info->position_start + g_utf8_strlen (info->text, -1)); } } else if (info->type == E_UNDO_DELETE) { if (todo == E_UNDO_DO_UNDO) { insert_func (object, info->text, info->position_start); widget_undo_place_cursor_at (object, info->position_start + g_utf8_strlen (info->text, -1)); } else { delete_func (object, info->position_start, info->position_end); widget_undo_place_cursor_at (object, info->position_start); } } data->current_info = NULL; g_signal_handler_unblock (object, data->delete_handler_id); g_signal_handler_unblock (object, data->insert_handler_id); }
static void register_silenced_functions(void) { struct token *token; char *func; char name[256]; silenced_funcs = create_function_hashtable(500); if (option_project == PROJ_NONE) return; snprintf(name, 256, "%s.silenced_functions", option_project_str); token = get_tokens_file(name); if (!token) return; if (token_type(token) != TOKEN_STREAMBEGIN) return; token = token->next; while (token_type(token) != TOKEN_STREAMEND) { if (token_type(token) != TOKEN_IDENT) return; func = alloc_string(show_ident(token->ident)); insert_func(silenced_funcs, func, INT_PTR(1)); token = token->next; } clear_token_alloc(); }
static void _cwt_textblock_insert_helper(CwtTextBlkPtr tb, void (*insert_func)(StringListPtr, StringListElemPtr, const CWT_CHAR*) , StringListElemPtr elem, const CWT_CHAR *text) { const CWT_CHAR *ptr, *ptr_begin, *ptr_end; int n; JQ_ASSERT(tb); n = strlen(text); ptr = text; ptr_begin = ptr; ptr_end = ptr + n + 1; while( ptr < ptr_end ) { if( *ptr == '\n' || *ptr == '\x0' ) { CWT_CHAR *tmp = jq_strndup(ptr_begin, (size_t)(ptr - ptr_begin)); insert_func(tb->lines, elem, tmp); if( insert_func == cwtStringListInsertAfter ) { if( !elem ) elem = tb->lines->strings.last; else elem = elem->next; } JQ_FREE(tmp); ptr_begin = ptr + 1; } ptr++; } /* tail */ if( ptr_begin < ptr ) { CWT_CHAR *tmp = jq_strndup(ptr_begin, (size_t)(ptr - ptr_begin)); insert_func(tb->lines, elem, tmp); JQ_FREE(tmp); } if( !tb->top_line ) tb->top_line = tb->lines->strings.first; }
int BuiltinFuncs::load_builtin_func(const std::string & name, float (*func_ptr)(float*), int num_args) { Func * func; int retval; /* Create new function */ func = new Func(name, func_ptr, num_args); if (func == 0) return PROJECTM_OUTOFMEM_ERROR; retval = insert_func( func ); return retval; }
void *thread_func(void *arg) { long long thread_num = (long long)arg; // insert elements int start_elem = thread_num * num_iterations; int end_elem = start_elem + num_iterations - 1; int i, hash; for (i = start_elem; i <= end_elem; i++) { hash = list_hash(list_elements[i]->key); insert_func(sorted_lists[hash], list_elements[i]); } //printf("printing list:\n"); //SortedList_print(sorted_list); // count lengths int total_length = 0; for (i = 0; i < num_lists; i++) { int list_size = length_func(sorted_lists[i]); if (list_size == -1) { fprintf(stderr, "length() detected corrupted list!\n"); exit(1); } total_length += list_size; } // lookup, deletes SortedListElement_t *found; for (i = start_elem; i <= end_elem; i++) { const char *key = list_elements[i]->key; hash = list_hash(key); found = lookup_func(sorted_lists[hash], key); if (found == NULL) { fprintf(stderr, "lookup() did not find key!\n"); exit(1); } if (delete_func(found)) { fprintf(stderr, "delete() detected corrupted list!\n"); exit(1); } } return (void*)arg; }
environment_list* insert_table(Node* node, environment_list* env, environment_list* previous, environment_list *outter_table){ Node *aux; Node *aux2; table_element *temp; table_element *nodeFunc; switch (node->type){ case VarDecl: ; aux=node; while(aux!=NULL){ aux2=aux->childs; Node *value=get_type(aux2); while(aux2->next!=NULL){ check_duplicates(aux2,env->locals); lower(aux2->value.s); env->locals=insert_line(env->locals,aux2->value.s,check_type(value,env),"",_NULL_); aux2=aux2->next; } aux=aux->next; } return env; case FuncDecl: case FuncDef2: case FuncDef: ; aux=node; while(aux!=NULL){ if(aux->type==FuncDef) nodeFunc=insert_func(1,aux->childs,env,outter_table); else if(aux->type==FuncDef2) nodeFunc=insert_funcdef2(aux->childs,env,outter_table); else if(aux->type==FuncDecl) nodeFunc=insert_func(0,aux->childs,env,outter_table); if(env->locals==NULL){ env->locals=nodeFunc; } else if(aux->type==FuncDef2){ if(nodeFunc!=NULL){ for(temp=env->locals;temp->next!=NULL;temp=temp->next){ if(strcmp(temp->name,nodeFunc->name)==0){ temp=nodeFunc; break; } } } } else{ for(temp=env->locals;temp->next!=NULL;temp=temp->next); temp->next=nodeFunc; } aux=aux->next; } return env; case Params: case VarParams: ; aux=node; while(aux!=NULL){ aux2=aux->childs; char *flag; if(aux->type==Params) flag="param"; else flag="varparam"; Node *value=get_type(aux2); while(aux2->next!=NULL){ check_duplicates(aux2,env->locals); lower(aux2->value.s); env->number_of_arguments++; env->locals=insert_line(env->locals,aux2->value.s,check_type(value,env),flag,_NULL_); aux2=aux2->next; } aux=aux->next; } return env; case IfElse: ; //check_statements(node->childs,"if",env); break; case While: ; //check_statements(node->childs,"while",env); break; case ValParam: ; //check_statements(node->childs,"val-paramstr",env); break; case Repeat: ; //check_statements(node->childs->next,"repeat-until",env); break; case Assign: ; //check_expressions(); break; case WriteLn: ; //check_writeln(node); break; case Call: ; check_number_of_arguments(node->childs,env); break; default: break; } if(node->childs){ env = insert_table(node->childs,env,previous,outter_table); } if(node->next) env = insert_table(node->next, env,previous,outter_table); return env; }