/* * Union of two nfa's: this & n */ void nfa::union_nfa (nfa &n) { int states_add = n.transitions.size (); cout <<"my transitions " << endl; print_transitions () ; cout << "n's trans " ; n.print_transitions (); for (int i=0; i<states_add; i++) { for (int j=0; j<n.transitions[i].size (); j++) { set<int>::iterator it; set<int> n_set; for (it=n.transitions[i][j].begin (); it != n.transitions[i][j].end (); it++) { cout << "*it+num_states " << *it+num_states <<" i j " << i <<" " << j << endl; n_set.insert (*it + num_states); } // n.transitions[i][j] = n_set; } transitions.push_back (n.transitions[i]); } vector< set<int> > start_new (MAX_ALPHABET); vector< set<int> > final_new (MAX_ALPHABET); start_new[EPSILON].insert (num_states-2); // start state of this start_new[EPSILON].insert (num_states + n.num_states-2); // start state of n transitions[num_states-1][EPSILON].insert (num_states + n.num_states+1); // final state for new from final this transitions[num_states + n.num_states-1][EPSILON].insert (num_states + n.num_states+1); // from final of n alphabet.insert (n.alphabet.begin (), n.alphabet.end ()); num_states += n.num_states + 2; transitions.push_back (start_new); transitions.push_back (final_new); }
ident = PyThread_start_new_thread(t_bootstrap, (void*) boot); if (ident == -1) { PyErr_SetString(ThreadError, "can't start new thread"); Py_DECREF(func); Py_DECREF(args); Py_XDECREF(keyw); PyThreadState_Clear(boot->tstate); PyMem_DEL(boot); return NULL; } return PyLong_FromLong(ident); } PyDoc_STRVAR(start_new_doc, "start_new_thread(function, args[, kwargs])\n\ (start_new() is an obsolete synonym)\n\ \n\ Start a new thread and return its identifier. The thread will call the\n\ function with positional arguments from the tuple args and keyword arguments\n\ taken from the optional dictionary kwargs. The thread exits when the\n\ function returns; the return value is ignored. The thread will also exit\n\ when the function raises an unhandled exception; a stack trace will be\n\ printed unless the exception is SystemExit.\n"); static PyObject * thread_PyThread_exit_thread(PyObject *self) { PyErr_SetNone(PyExc_SystemExit); return NULL; }
// Read an environment BOOL environment_open(Cfg_Environment *env,char *name,BOOL first,APTR prog) { struct OpenEnvironmentData *opendata; BOOL success; short progress=1; // Free volatile memory ClearMemHandle(env->volatile_memory); // Initialise open structure if (!(opendata=AllocMemH(env->volatile_memory,sizeof(struct OpenEnvironmentData)))) return 0; opendata->memory=env->desktop_memory; opendata->volatile_memory=env->volatile_memory; opendata->flags=OEDF_ALL; // Initialise progress SetProgressWindowTags(prog,PW_FileCount,14,PW_FileNum,1,TAG_END); // Read environment if ((success=OpenEnvironment((name)?name:env->path,opendata))) { // Check stack setting and increase if too low if (opendata->env.default_stack < STACK_DEFAULT) opendata->env.default_stack = STACK_DEFAULT; // Copy things back to the environment CopyMem((char *)&opendata->env,(char *)env->env,sizeof(CFG_ENVR)); strcpy(env->toolbar_path,opendata->toolbar_path); strcpy(env->menu_path,opendata->menu_path); strcpy(env->user_menu_path,opendata->user_menu_path); strcpy(env->scripts_path,opendata->scripts_path); strcpy(env->hotkeys_path,opendata->hotkeys_path); // Get maximum filename length // we have to do this before the listers are opened GUI->def_filename_length=environment->env->settings.max_filename; if (GUI->def_filename_length<FILENAME_LEN) GUI->def_filename_length=FILENAME_LEN; else if (GUI->def_filename_length>107) GUI->def_filename_length=107; } // Successful? if (success || first) { ButtonBankNode *button; OpenListerNode *lister; // Bump progress main_bump_progress(prog,progress++,0); // Store new environment path if (name) strcpy(env->path,name); // Bump progress main_bump_progress(prog,progress++,0); // Get new toolbar FreeToolBar(GUI->toolbar); GUI->toolbar=OpenToolBar(0,env->toolbar_path); // Bump progress main_bump_progress(prog,progress++,0); // Free lister menu, get new one CloseButtonBank(GUI->lister_menu); if ((GUI->lister_menu=OpenButtonBank(env->menu_path))) { // Check if it needs conversion if (!(GUI->lister_menu->window.flags&BTNWF_FIX_MENU)) { // Convert it to new format ConvertStartMenu(GUI->lister_menu); GUI->lister_menu->window.flags|=BTNWF_FIX_MENU; } } // Bump progress main_bump_progress(prog,progress++,0); // Free user menu, get new one CloseButtonBank(GUI->user_menu); GUI->user_menu=OpenButtonBank(env->user_menu_path); // Bump progress main_bump_progress(prog,progress++,0); // Free scripts, get new set CloseButtonBank(GUI->scripts); GUI->scripts=OpenButtonBank(env->scripts_path); // Bump progress main_bump_progress(prog,progress++,0); // Free hotkeys, get new ones send_main_reset_cmd(CONFIG_CHANGE_HOTKEYS,0,0); // Go through buttons to open for (button=(ButtonBankNode *)opendata->buttons.mlh_Head; button->node.ln_Succ;) { ButtonBankNode *next=(ButtonBankNode *)button->node.ln_Succ; Buttons *but; // Create button bank from this node if ((but=buttons_new(button->node.ln_Name,0,&button->pos,0,button->flags|BUTTONF_FAIL))) { // Set icon position but->icon_pos_x=button->icon_pos_x; but->icon_pos_y=button->icon_pos_y; } // Free this node, get next Remove((struct Node *)button); FreeMemH(button->node.ln_Name); FreeMemH(button); button=next; } // Bump progress main_bump_progress(prog,progress++,0); // Go through StartMenus to open for (button=(ButtonBankNode *)opendata->startmenus.mlh_Head; button->node.ln_Succ;) { ButtonBankNode *next=(ButtonBankNode *)button->node.ln_Succ; // Create new start menu start_new(button->node.ln_Name,0,0,button->pos.Left,button->pos.Top); // Free this node, get next Remove((struct Node *)button); FreeMemH(button->node.ln_Name); FreeMemH(button); button=next; } // Bump progress main_bump_progress(prog,progress++,0); // Go through listers to open for (lister=(OpenListerNode *)opendata->listers.mlh_Head; lister->node.ln_Succ;) { OpenListerNode *next=(OpenListerNode *)lister->node.ln_Succ; // Create lister from this node if (lister->lister) lister_new((Cfg_Lister *)lister->lister); // Free this node, get next Remove((struct Node *)lister); FreeMemH(lister); lister=next; } // Bump progress main_bump_progress(prog,progress++,0); // Free existing desktop list env_free_desktop(&env->desktop); // Copy new desktop into list if (!(IsListEmpty((struct List *)&opendata->desktop))) { env->desktop=opendata->desktop; env->desktop.mlh_TailPred->mln_Succ=(struct MinNode *)&env->desktop.mlh_Tail; env->desktop.mlh_Head->mln_Pred=(struct MinNode *)&env->desktop.mlh_Head; } // Free existing path list env_free_desktop(&env->path_list); // Copy new pathlist into list if (!(IsListEmpty((struct List *)&opendata->pathlist))) { env->path_list=opendata->pathlist; env->path_list.mlh_TailPred->mln_Succ=(struct MinNode *)&env->path_list.mlh_Tail; env->path_list.mlh_Head->mln_Pred=(struct MinNode *)&env->path_list.mlh_Head; } // Free existing sound list env_free_desktop(&env->sound_list); // Copy new sound list into list if (!(IsListEmpty((struct List *)&opendata->soundlist))) { env->sound_list=opendata->soundlist; env->sound_list.mlh_TailPred->mln_Succ=(struct MinNode *)&env->sound_list.mlh_Tail; env->sound_list.mlh_Head->mln_Pred=(struct MinNode *)&env->sound_list.mlh_Head; } // Bump progress main_bump_progress(prog,progress++,0); // Update priority IPC_Command(&main_ipc, IPC_PRIORITY, env->env->settings.pri_main[1], (APTR)env->env->settings.pri_main[0], 0,0); // Fix lister priorities lister_fix_priority(0); // Bump progress main_bump_progress(prog,progress++,0); } // Failed, free temp lists else { env_free_desktop(&opendata->desktop); env_free_desktop(&opendata->pathlist); env_free_desktop(&opendata->soundlist); env_free_desktop(&opendata->startmenus); env_free_desktop(&opendata->buttons); env_free_desktop(&opendata->listers); } // Free open data structure FreeMemH(opendata); // Bump progress main_bump_progress(prog,progress,0); // Build the user menu (needed even if there is none) display_build_user_menu(); // Initialise progress SetProgressWindowTags(prog,PW_FileCount,1,PW_FileNum,1,TAG_END); // Set library flag for 'Move AppIcons to Tools Menu' SetLibraryFlags((env->env->display_options&DISPOPTF_SHIFT_APPICONS)?LIBDF_REDIRECT_TOOLS:0,LIBDF_REDIRECT_TOOLS); // Set library flag for borderless icons SetLibraryFlags((env->env->desktop_flags&DESKTOPF_NO_BORDERS)?LIBDF_BORDERS_OFF:0,LIBDF_BORDERS_OFF); // No icon caching? SetLibraryFlags((env->env->desktop_flags&DESKTOPF_NO_CACHE)?LIBDF_NO_CACHING:0,LIBDF_NO_CACHING); // Set NewIcons flags SetNewIconsFlags(env->env->env_NewIconsFlags,env->env->env_NewIconsPrecision); // No custom drag? SetLibraryFlags((env->env->desktop_flags&DESKTOPF_NO_CUSTOMDRAG)?LIBDF_NO_CUSTOM_DRAG:0,LIBDF_NO_CUSTOM_DRAG); // Thin borders? SetLibraryFlags((env->env->display_options&DISPOPTF_THIN_BORDERS)?LIBDF_THIN_BORDERS:0,LIBDF_THIN_BORDERS); // Update pathlist environment variable env_update_pathlist(); // Set popup delay SetPopUpDelay(env->env->settings.popup_delay); // Fix MUFS library env_fix_mufs(); // Assign themes path env_fix_themes(); // Initialise sound events InitSoundEvents(TRUE); return success; }