/* DoCurROMRES() * ======================================================================= * Handle the Current Driver ROM/RES flag. */ void DoCurROMRES( int button ) { wait_up(); if( button == CURROM ) /* ROM key pressed... */ { if( IsSelected( CURROM ) ) deselect( tree, CURROM ); else { select( tree, CURROM ); if( IsSelected( CURRES ) ) deselect( tree, CURRES ); } } else /* RESident key pressed */ { if( IsSelected( CURRES ) ) deselect( tree, CURRES ); else { select( tree, CURRES ); if( IsSelected( CURROM ) ) deselect( tree, CURROM ); } } DTYPE( xdevice ) = ' '; if( IsSelected( CURROM ) ) DTYPE( xdevice ) = 'P'; if( IsSelected( CURRES ) ) DTYPE( xdevice ) = 'R'; SetChangeFlag(); }
/* InitActiveEdit() * ===================================================================== * Initializes the Active Device display to preset initial values. * the device to display is in xdevice. */ void InitActiveEdit( void ) { /* Set a global index number for the device editor so that we * know which one is currently being displayed. Note that this is * for the active drivers. */ CurHotDriver = DNAME( xdevice ); NoExit( EDELETE ); Disable( EDELETE ); /* Display the device number in text form. */ sprintf( DeviceText, "%d", DDEV( xdevice ) ); TedText( CURNUM ) = &DeviceText[0]; /* Display the driver name in text form ( includes the .SYS ) */ strcpy( DriverText, drivers[ DNAME( xdevice )] ); TedText( CURNAME ) = &DriverText[0]; /* Set the ROM/RES flags */ Deselect( CURROM ); Deselect( CURRES ); if( DTYPE( xdevice ) == 'P' ) /* ROM driver - SCREEN.SYS */ Select( CURROM ); if( DTYPE( xdevice ) == 'R' ) /* Resident Driver */ Select( CURRES ); }
/** * cs_he_initial_get - Get the initial, or parent, value of a config item * @param cs Config items * @param he HashElem representing config item * @param result Buffer for results or error messages * @retval int Result, e.g. #CSR_SUCCESS * * If a config item is inherited from another, then this will get the parent's * value. Otherwise, it will get the config item's initial value. */ int cs_he_initial_get(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *result) { if (!cs || !he) return CSR_ERR_CODE; struct Inheritance *i = NULL; const struct ConfigDef *cdef = NULL; const struct ConfigSetType *cst = NULL; if (he->type & DT_INHERITED) { i = he->data; cdef = i->parent->data; cst = cs_get_type_def(cs, i->parent->type); } else { cdef = he->data; cst = cs_get_type_def(cs, he->type); } if (!cst) { mutt_debug(LL_DEBUG1, "Variable '%s' has an invalid type %d\n", cdef->name, DTYPE(he->type)); return CSR_ERR_CODE; } return cst->string_get(cs, NULL, cdef, result); }
tChyba ROZHODNI() { int analyza2; int analyza; int analyza1; TItem *pt; //ROZHODNI->DTYPE if((analyza = DTYPE()) == S_BEZ_CHYB) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } return S_BEZ_CHYB; } //ROZHODNI->PROM VESTAV EXPR else { //volani funkce na vestavene funkce analyza2 = VESTAV(); if(analyza2 != S_BEZ_CHYB && analyza2 != S_EPS) { return analyza2; } //pokud je epsilon pokracujeme dal if(analyza2 == S_BEZ_CHYB) { return S_BEZ_CHYB; } if((porovnani = malloc(strlen(token.data)+1)) == NULL) { return S_INTERNI_CHYBA; } //ulozeni hodnoty token.data do globalni promenne porovnani strcpy(porovnani, token.data); pt = htSearch(ptrhtGlobal, token.data); //kontrola jestli id je v tabulce globalni if(pt != NULL && pt->druh == ID_FUNCTION) { //pokud ano a je to funkce vola se prom analyza1 = PROM(); if(analyza1 != S_BEZ_CHYB) { return analyza1; } free(porovnani); return S_BEZ_CHYB; } else {//jinak se vola precedencni analyza2 = precedencniSA(); if(analyza2 != S_BEZ_CHYB) { return analyza2; } //instrukce pro prirazeni, tmp1 je vysledek precedencni, tmp3 cilove id generateInstruction( OC_PRIRAZENI, searchFrames(neterminal.polozkaTS.key, ptrhtLocal, ptrhtGlobal), NULL, searchFrames(id, ptrhtLocal, ptrhtGlobal) ); return S_BEZ_CHYB; } } }
/** * cs_he_string_get - Get a config item as a string * @param cs Config items * @param he HashElem representing config item * @param result Buffer for results or error messages * @retval int Result, e.g. #CSR_SUCCESS */ int cs_he_string_get(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *result) { if (!cs || !he) return CSR_ERR_CODE; struct Inheritance *i = NULL; const struct ConfigDef *cdef = NULL; const struct ConfigSetType *cst = NULL; void *var = NULL; if (he->type & DT_INHERITED) { i = he->data; cdef = i->parent->data; cst = cs_get_type_def(cs, i->parent->type); } else { cdef = he->data; cst = cs_get_type_def(cs, he->type); } if ((he->type & DT_INHERITED) && (DTYPE(he->type) != 0)) { var = &i->var; /* Local value */ } else { var = cdef->var; /* Normal var */ } if (!cst) { mutt_debug(LL_DEBUG1, "Variable '%s' has an invalid type %d\n", cdef->name, DTYPE(he->type)); return CSR_ERR_CODE; } return cst->string_get(cs, var, cdef, result); }
/** * cs_get_type_def - Get the definition for a type * @param cs Config items * @param type Type to lookup, e.g. #DT_NUMBER * @retval ptr ConfigSetType representing the type */ const struct ConfigSetType *cs_get_type_def(const struct ConfigSet *cs, unsigned int type) { if (!cs) return NULL; type = DTYPE(type); if ((type < 1) || (type >= mutt_array_size(cs->types))) return NULL; if (!cs->types[type].name) return NULL; return &cs->types[type]; }
/* Device_Assign_Slit() *========================================================================== * Assigns the 6 slits visible an FNODE, where possible. * IN: FNODE *ptr: Start assigning with this node * FNODE *array[]: A 5 slit pointer array. */ void Device_Assign_Slit( DEV_PTR ptr, DEV_PTR array[] ) { int i; DEV_PTR curptr; curptr = ptr; for( i = 0; i < MAX_SLITS; i++ ) { array[ i ] = NULL; Deselect( First_Obj + ( i * 6 ) + 5 ); strcpy( Device_Array[i], fblank4 ); TedText( First_Obj + ( i * 6 ) + 1 ) = Device_Array[i]; TedText( First_Obj + ( i * 6 ) + 2 ) = fblank3; HideObj( First_Obj + ( i * 6 ) + 3 ); HideObj( First_Obj + ( i * 6 ) + 4 ); if( curptr ) { array[i] = curptr; sprintf( Device_Array[i], "%d", DDEV( curptr ) ); TedText( First_Obj + ( i * 6 ) + 1 ) = Device_Array[i]; TedText( First_Obj + ( i * 6 ) + 2 ) = drivers[ DNAME( curptr )]; if( ( DTYPE( curptr ) == 'p' ) || ( DTYPE( curptr ) == 'P' )) ShowObj( First_Obj + ( i * 6 ) + 3 ); if( ( DTYPE( curptr ) == 'r' ) || ( DTYPE( curptr ) == 'R' )) ShowObj( First_Obj + ( i * 6 ) + 4 ); curptr = DNEXT( curptr ); } } }
void SoftmaxLoss::compute_cpu(const vector<bool>& add) { const DTYPE* softmax_data = inputs_[0]->cpu_data(); const DTYPE* label_data = inputs_[1]->cpu_data(); Shape softmax_shape = inputs_[0]->shape(); int num = softmax_shape[0]; int dim = softmax_shape.Count() / num; int spatial_dim = softmax_shape[2] * softmax_shape[3]; DTYPE loss = 0; for (int i = 0; i < num; ++i) { for (int j = 0; j < spatial_dim; j++) { loss -= log(std::max(softmax_data[i * dim + static_cast<int>( label_data[i * spatial_dim + j]) * spatial_dim + j], DTYPE(FLT_MIN))); } } *(outputs_[0]->mutable_cpu_data()) = loss / num / spatial_dim; }
static int get_dtype(struct dirent *de, const char *path) { int dtype = de ? DTYPE(de) : DT_UNKNOWN; struct stat st; if (dtype != DT_UNKNOWN) return dtype; if (lstat(path, &st)) return dtype; if (S_ISREG(st.st_mode)) return DT_REG; if (S_ISDIR(st.st_mode)) return DT_DIR; if (S_ISLNK(st.st_mode)) return DT_LNK; return dtype; }
static enum path_treatment treat_path(struct dir_struct *dir, struct dirent *de, struct strbuf *path, int baselen, const struct path_simplify *simplify) { int dtype; if (is_dot_or_dotdot(de->d_name) || !strcmp(de->d_name, ".git")) return path_none; strbuf_setlen(path, baselen); strbuf_addstr(path, de->d_name); if (simplify_away(path->buf, path->len, simplify)) return path_none; dtype = DTYPE(de); return treat_one_path(dir, path, simplify, dtype, de); }
/** * cs_he_reset - Reset a config item to its initial value * @param cs Config items * @param he HashElem representing config item * @param err Buffer for error messages * @retval int Result, e.g. #CSR_SUCCESS */ int cs_he_reset(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *err) { if (!cs || !he) return CSR_ERR_CODE; /* An inherited var that's already pointing to its parent. * Return 'success', but don't send a notification. */ if ((he->type & DT_INHERITED) && (DTYPE(he->type) == 0)) return CSR_SUCCESS; const struct ConfigSetType *cst = NULL; const struct ConfigDef *cdef = NULL; int rc = CSR_SUCCESS; if (he->type & DT_INHERITED) { struct Inheritance *i = he->data; cst = cs_get_type_def(cs, i->parent->type); cdef = i->parent->data; if (cst && cst->destroy) cst->destroy(cs, (void **) &i->var, cdef); he->type = DT_INHERITED; } else { cst = cs_get_type_def(cs, he->type); cdef = he->data; if (cst) rc = cst->reset(cs, cdef->var, cdef, err); } if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE)) cs_notify_listeners(cs, he, he->key.strkey, CE_RESET); return rc; }
/** * cs_he_native_get - Natively get the value of a HashElem config item * @param cs Config items * @param he HashElem representing config item * @param err Buffer for results or error messages * @retval intptr_t Native pointer/value */ intptr_t cs_he_native_get(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *err) { if (!cs || !he) return INT_MIN; struct Inheritance *i = NULL; const struct ConfigDef *cdef = NULL; const struct ConfigSetType *cst = NULL; void *var = NULL; if (he->type & DT_INHERITED) { i = he->data; cdef = i->parent->data; cst = cs_get_type_def(cs, i->parent->type); } else { cdef = he->data; cst = cs_get_type_def(cs, he->type); } if ((he->type & DT_INHERITED) && (DTYPE(he->type) != 0)) { var = &i->var; } else { var = cdef->var; } if (!cst) { mutt_buffer_printf(err, "Variable '%s' has an invalid type %d", cdef->name, he->type); return INT_MIN; } return cst->native_get(cs, var, cdef, err); }
static enum path_treatment treat_path(struct dir_struct *dir, struct dirent *de, char *path, int path_max, int baselen, const struct path_simplify *simplify, int *len) { int dtype; if (is_dot_or_dotdot(de->d_name) || !strcmp(de->d_name, ".git")) return path_ignored; *len = strlen(de->d_name); /* Ignore overly long pathnames! */ if (*len + baselen + 8 > path_max) return path_ignored; memcpy(path + baselen, de->d_name, *len + 1); *len += baselen; if (simplify_away(path, *len, simplify)) return path_ignored; dtype = DTYPE(de); return treat_one_path(dir, path, len, simplify, dtype, de); }
/** * dump_config_mutt - Dump the config in the style of Mutt * @param cs Config items * @param he HashElem representing config item * @param value Current value of the config item * @param initial Initial value of the config item * @param flags Flags, see #ConfigDumpFlags * @param fp File pointer to write to */ void dump_config_mutt(struct ConfigSet *cs, struct HashElem *he, struct Buffer *value, struct Buffer *initial, ConfigDumpFlags flags, FILE *fp) { if (!he || !value || !fp) return; const char *name = he->key.strkey; if (DTYPE(he->type) == DT_BOOL) { if ((value->data[0] == 'y') || ((value->data[0] == '"') && (value->data[1] == 'y'))) { fprintf(fp, "%s is set\n", name); } else { fprintf(fp, "%s is unset\n", name); } } else { fprintf(fp, "%s=%s\n", name, value->data); } }
/* DeleteDevice() * ======================================================================= * Delete the Active Device in the Edit Device tree. */ void DeleteDevice( void ) { GRECT rect; DEV_PTR temp_device; wait_up(); if( form_alert( 1, alert1 ) == 2 ) { deselect( tree, EDELETE ); return; } if( device_count == 0 ) return; SetChangeFlag(); temp_device = xdevice; if( DNEXT( xdevice ) ) DPREV( DNEXT( xdevice ) ) = DPREV( xdevice ); if( DPREV( xdevice ) ) DNEXT( DPREV( xdevice ) ) = DNEXT( xdevice ); ClearDeviceFont( xdevice ); /* Fix up device count */ device_count--; /* Change display since we're looking at deleted a device * We shall use xdevice - 1 if there is no device. */ if( DNEXT( xdevice ) ) xdevice = DNEXT( xdevice ); else xdevice = DPREV( xdevice ); DNEXT( temp_device ) = DPREV( temp_device ) = ( DEV_PTR )NULL; DDEV( temp_device ) = 0; CurHotDriver = DNAME( xdevice ); NoExit( EDELETE ); Disable( EDELETE ); /* Display the device number in text form. */ sprintf( DeviceText, "%d", DDEV( xdevice ) ); TedText( CURNUM ) = &DeviceText[0]; /* Display the driver name in text form ( includes the .SYS ) */ strcpy( DriverText, drivers[ DNAME( xdevice )] ); TedText( CURNAME ) = &DriverText[0]; /* Set the ROM/RES flags */ Deselect( CURROM ); Deselect( CURRES ); if( DTYPE( xdevice ) == 'P' ) /* ROM driver - SCREEN.SYS */ Select( CURROM ); if( DTYPE( xdevice ) == 'R' ) /* Resident Driver */ Select( CURRES ); Objc_draw( tree, CURNUM, MAX_DEPTH, NULL ); Objc_draw( tree, CURNAME, MAX_DEPTH, NULL ); Objc_draw( tree, CURROM, MAX_DEPTH, NULL ); Objc_draw( tree, CURRES, MAX_DEPTH, NULL ); /* turn on/off the EDELETE button here too */ rect = ObRect( EDELETE ); objc_offset( tree, EDELETE, &rect.g_x, &rect.g_y ); rect.g_x -= 3; rect.g_y -= 3; rect.g_w += 6; rect.g_h += 6; if( DDEV( xdevice ) > 9 ) { MakeExit( EDELETE ); Enable( EDELETE ); } else { NoExit( EDELETE ); Disable( EDELETE ); } Deselect( EDELETE ); Objc_draw( tree, ROOT, MAX_DEPTH, &rect ); /* Check if the device deleted is the current_device. * if so, we have to update the current_device to a new device. */ if( temp_device == current_device ) current_device = xdevice; if( temp_device == device_head ) device_head = xdevice; }
tChyba FUNKCE() { int analyza; //opet lokalni promenna, stejna funkce jako ve funkci nahore TItem *nasel; // FUNKCE-> begin ACT_LIST if(!strcmp(token.data, "begin") && token.stav == s_klicove) { token = getNextToken(); //pres strcmp porovnavam data tokenu (prakticky primo to, co se nacte) if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } //po zavolani funkce se getToken nevola, protoze kazda funkce, nez vrati hodnotu, nacte dalsi token analyza = ACT_LIST(); if(analyza != S_BEZ_CHYB) { return analyza; } return S_BEZ_CHYB; } //FUNKCE->function id PARAMS : DTYPE ; DOPREDNE ; FUNKCE else if(!strcmp(token.data, "function") && token.stav == s_klicove) { //pamatujeme si, ze jsme v definici funkce byla_funkce = true; token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } if(token.stav == s_identifikator) { //pokud id ma nazev stejny jako tyto 2 funkce, jedna se o chybu if(!strcmp(token.data, "length") || !strcmp(token.data, "copy")) { return S_SEMANTICKA_CHYBA_NEDEF; } if((funkce = malloc(strlen(token.data)+1)) == NULL) { return S_INTERNI_CHYBA; } //nulovani poctu parametru funkce TData *dat = (TData*)malloc(sizeof(TData)); dat->param.numParam = 0; strcpy(funkce, token.data); //pokud id funkce j*z je v globalni hash tabulce a nejedna se o doprednou deklaraci -> chyba nasel = htSearch(ptrhtGlobal,funkce); if(nasel != NULL ) { if(nasel->init == true) { return S_SEMANTICKA_CHYBA_NEDEF; } nasel->init = true; } //vlozeni nazvu funkce do globalni hash htInsert(ptrhtGlobal,funkce,dat, TYPEUNDEF , ID_FUNCTION); token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } //funkce na kontrolu a ukladani parametru funkce analyza = PARAMS(); if(analyza != S_BEZ_CHYB) { return analyza; } else if(token.stav == s_dvojtecka) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } //funkce na kontrolu datovych typu analyza = DTYPE(); if(analyza != S_BEZ_CHYB) { return analyza; } if(!strcmp(token.data, "integer")) { dtype = TYPEINT; } else if(!strcmp(token.data, "real")) { //do docasne promene nacteme datovy typ funkce dtype = TYPEDOUBLE; } else if(!strcmp(token.data, "string")) { dtype = TYPESTR; } else if(!strcmp(token.data, "boolean")) { dtype = TYPEBOOL; } token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } else if(token.stav == s_strednik) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } //zjisteni, zda se jedna o doprednou deklaraci funkces analyza = DOPREDNE(); if(analyza != S_BEZ_CHYB) { return analyza; } //pokud neni dopredna, vkladame do globalni hash tabulky a zaroven i do lokalni hash tabulky if(init == true) { htCompleteInsert(ptrhtGlobal,funkce, ID_FUNCTION, dtype, true); htInsert(func[currFuncSize-1].table, funkce, dat, dtype, ID_FUNCTION); }//pokud se jedna o doprednou deklaraci, ukladame jen do globalky hlavicku funkce else if (init == false) { htCompleteInsert(ptrhtGlobal,funkce, ID_FUNCTION, dtype, false); //vlozeni navratove hodnoty do lokalni tabulky } if(token.stav == s_strednik) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } else { //nastaveni ukazatele lokalni tabulky na vrchol zasobniku ptrhtLocal = ptrStack->top->ptrht; listIntrukci = &(ptrStack->top->field); // nastaveni tabulky instrukci v mainu byla_funkce = false; //rekurzivni volani return FUNKCE(); } } } } } //pokud se nacte token, ktery podle pravidla tam nepatri, vrati se syntakticka chyba return S_SYNTAKTICKA_CHYBA; } //FUNKCE->var DEKLARACE FUNKCE else if(!strcmp(token.data, "var") && token.stav == s_klicove) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } //volani funkce na kontrolu a ukladani globalnich id analyza = DEKLARACE(); if(analyza != S_BEZ_CHYB) { return analyza; } return FUNKCE(); } return S_SYNTAKTICKA_CHYBA; }
tChyba DEKLARACE() { int analyza; TItem *pt; //DEKLARACE->id : DTYPE ; DEKLARACE if(token.stav == s_identifikator) { if((id = malloc(strlen(token.data)+1)) == NULL) { return S_INTERNI_CHYBA; } //id se nesmi jmenovat jako tyto funkce if(!strcmp(token.data, "length") || !strcmp(token.data, "copy")) { return S_SEMANTICKA_CHYBA_NEDEF; } //id musi byt deklarovano jinak -> chyba pt = searchFrames(token.data, ptrhtLocal, ptrhtGlobal); if(pt != NULL) { return S_SEMANTICKA_CHYBA_NEDEF; } strcpy(id, token.data); token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } if(token.stav == s_dvojtecka) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } analyza = DTYPE(); if(analyza != S_BEZ_CHYB) { return analyza; } if(!strcmp(token.data, "integer")) { dtype = TYPEINT; } else if(!strcmp(token.data, "string")) { dtype = TYPESTR; } else if(!strcmp(token.data, "real")) { dtype = TYPEDOUBLE; } else if(!strcmp(token.data, "boolean")) { dtype = TYPEBOOL; } //vlozime do globalniho ramce globalni promennou htDeclInsert(ptrhtGlobal,id, dtype, ID_GLOBAL); free(id); token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } else if(token.stav == s_strednik) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } return DEKLARACE(); } } return S_SYNTAKTICKA_CHYBA; } //DEKLARACE->eps else if((!strcmp(token.data, "function") || !strcmp(token.data, "begin")) && token.stav == s_klicove) { return S_BEZ_CHYB; //pokud dalsi token je jeden z vyse uvedenych jedna se o epsilon pravidlo a vracime OK } return S_SYNTAKTICKA_CHYBA; }
//funkce na vkladani parametru tChyba PARAMS() { int analyza; //PARAMS->( id : DTYPE PARAMS if(token.stav == s_leva_zavorka) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } else if(token.stav == s_identifikator) { if((params = malloc(strlen(token.data)+1)) == NULL) { return S_INTERNI_CHYBA; } //do globalni promenne params nacteme id parametru funkce strcpy(params, token.data); token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } if(token.stav == s_dvojtecka) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } analyza = DTYPE(); if(analyza != S_BEZ_CHYB) { return analyza; } if(!strcmp(token.data, "integer")) { dtype = TYPEINT; } else if(!strcmp(token.data, "real")) { dtype = TYPEDOUBLE; } else if(!strcmp(token.data, "string")) { dtype = TYPESTR; } else if(!strcmp(token.data, "boolean")) { dtype = TYPEBOOL; } //vlozeni do pole parametru htParamInsert(ptrhtGlobal,funkce, params, dtype); //vlozeni parametru do lokalni hash htInsert(func[currFuncSize].table, params, NULL, dtype, ID_PARAM); free(params); token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } //rekurzivni volani return PARAMS(); } return S_SYNTAKTICKA_CHYBA; } }//PARAMS->; id : DTYPE PARAMS else if(token.stav == s_strednik) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } if(token.stav == s_identifikator) { if((params = malloc(strlen(token.data)+1)) == NULL) { return S_INTERNI_CHYBA; } //vlozeni klice do globalni promenne strcpy(params, token.data); token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } else if(token.stav == s_dvojtecka) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } analyza = DTYPE(); if(analyza != S_BEZ_CHYB) { return analyza; } if(!strcmp(token.data, "integer")) { dtype = TYPEINT; } else if(!strcmp(token.data, "string")) { dtype = TYPESTR; } else if(!strcmp(token.data, "real")) { dtype = TYPEDOUBLE; } else if(!strcmp(token.data, "boolean")){ dtype = TYPEBOOL; } //vlozeni do globalni, do pole parametru funkce htParamInsert(ptrhtGlobal,funkce, params, dtype); htInsert(func[currFuncSize].table, params, NULL, dtype, ID_PARAM); free(params); token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } return PARAMS(); } } return S_SYNTAKTICKA_CHYBA; } else if(token.stav == s_prava_zavorka) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } return S_BEZ_CHYB; } return S_SYNTAKTICKA_CHYBA; }
#include <hdf5.h> #include <boost/filesystem/path.hpp> #include <HDF5/AtomicTypes.hpp> #include <HDF5/ReferenceType.hpp> #include <HDF5/OpaqueType.hpp> namespace HDF5 { #define DTYPE(Name, Type) \ inline Type Name () { \ Exception::check ("H5open", H5open ()); \ return Type (Exception::check ("H5Tcopy", H5Tcopy ( H5T_ ## Name ))); \ } DTYPE (NATIVE_CHAR, IntegerType) // List generated by GetConsts DTYPE (IEEE_F32BE, FloatType) DTYPE (IEEE_F32LE, FloatType) DTYPE (IEEE_F64BE, FloatType) DTYPE (IEEE_F64LE, FloatType) DTYPE (STD_I8BE, IntegerType) DTYPE (STD_I8LE, IntegerType) DTYPE (STD_I16BE, IntegerType) DTYPE (STD_I16LE, IntegerType) DTYPE (STD_I32BE, IntegerType) DTYPE (STD_I32LE, IntegerType) DTYPE (STD_I64BE, IntegerType) DTYPE (STD_I64LE, IntegerType) DTYPE (STD_U8BE, IntegerType) DTYPE (STD_U8LE, IntegerType)
/** * dump_config - Write all the config to a file * @param cs ConfigSet to dump * @param style Output style, e.g. #CS_DUMP_STYLE_MUTT * @param flags Flags, see #ConfigDumpFlags * @param fp File to write config to */ bool dump_config(struct ConfigSet *cs, enum CsDumpStyle style, ConfigDumpFlags flags, FILE *fp) { if (!cs) return false; struct HashElem *he = NULL; struct HashElem **list = get_elem_list(cs); if (!list) return false; /* LCOV_EXCL_LINE */ bool result = true; struct Buffer *value = mutt_buffer_alloc(256); struct Buffer *initial = mutt_buffer_alloc(256); struct Buffer *tmp = mutt_buffer_alloc(256); for (size_t i = 0; list[i]; i++) { mutt_buffer_reset(value); mutt_buffer_reset(initial); he = list[i]; const int type = DTYPE(he->type); if ((type == DT_SYNONYM) && !(flags & CS_DUMP_SHOW_SYNONYMS)) continue; // if ((type == DT_DISABLED) && !(flags & CS_DUMP_SHOW_DISABLED)) // continue; if (type != DT_SYNONYM) { /* If necessary, get the current value */ if ((flags & CS_DUMP_ONLY_CHANGED) || !(flags & CS_DUMP_HIDE_VALUE) || (flags & CS_DUMP_SHOW_DEFAULTS)) { int rc = cs_he_string_get(cs, he, value); if (CSR_RESULT(rc) != CSR_SUCCESS) { result = false; /* LCOV_EXCL_LINE */ break; /* LCOV_EXCL_LINE */ } const struct ConfigDef *cdef = he->data; if (IS_SENSITIVE(*cdef) && (flags & CS_DUMP_HIDE_SENSITIVE) && !mutt_buffer_is_empty(value)) { mutt_buffer_reset(value); mutt_buffer_addstr(value, "***"); } if ((type == DT_PATH) && (value->data[0] == '/')) mutt_pretty_mailbox(value->data, value->dsize); if ((type != DT_BOOL) && (type != DT_NUMBER) && (type != DT_LONG) && (type != DT_QUAD) && !(flags & CS_DUMP_NO_ESCAPING)) { mutt_buffer_reset(tmp); pretty_var(value->data, tmp); mutt_buffer_strcpy(value, tmp->data); } } /* If necessary, get the default value */ if (flags & (CS_DUMP_ONLY_CHANGED | CS_DUMP_SHOW_DEFAULTS)) { int rc = cs_he_initial_get(cs, he, initial); if (CSR_RESULT(rc) != CSR_SUCCESS) { result = false; /* LCOV_EXCL_LINE */ break; /* LCOV_EXCL_LINE */ } if ((type == DT_PATH) && !(he->type & DT_MAILBOX)) mutt_pretty_mailbox(initial->data, initial->dsize); if ((type != DT_BOOL) && (type != DT_NUMBER) && (type != DT_LONG) && (type != DT_QUAD) && !(flags & CS_DUMP_NO_ESCAPING)) { mutt_buffer_reset(tmp); pretty_var(initial->data, tmp); mutt_buffer_strcpy(initial, tmp->data); } } } if (style == CS_DUMP_STYLE_MUTT) dump_config_mutt(cs, he, value, initial, flags, fp); else dump_config_neo(cs, he, value, initial, flags, fp); } FREE(&list); mutt_buffer_free(&value); mutt_buffer_free(&initial); mutt_buffer_free(&tmp); return result; }
/* * Read a directory tree. We currently ignore anything but * directories, regular files and symlinks. That's because git * doesn't handle them at all yet. Maybe that will change some * day. * * Also, we ignore the name ".git" (even if it is not a directory). * That likely will not change. */ static int read_directory_recursive(struct dir_struct *dir, const char *path, const char *base, int baselen, int check_only, const struct path_simplify *simplify) { DIR *fdir = opendir(path); int contents = 0; if (fdir) { struct dirent *de; char fullname[PATH_MAX + 1]; memcpy(fullname, base, baselen); while ((de = readdir(fdir)) != NULL) { int len, dtype; int exclude; if (is_dot_or_dotdot(de->d_name) || !strcmp(de->d_name, ".git")) continue; len = strlen(de->d_name); /* Ignore overly long pathnames! */ if (len + baselen + 8 > sizeof(fullname)) continue; memcpy(fullname + baselen, de->d_name, len+1); if (simplify_away(fullname, baselen + len, simplify)) continue; dtype = DTYPE(de); exclude = excluded(dir, fullname, &dtype); if (exclude && (dir->flags & DIR_COLLECT_IGNORED) && in_pathspec(fullname, baselen + len, simplify)) dir_add_ignored(dir, fullname, baselen + len); /* * Excluded? If we don't explicitly want to show * ignored files, ignore it */ if (exclude && !(dir->flags & DIR_SHOW_IGNORED)) continue; if (dtype == DT_UNKNOWN) dtype = get_dtype(de, fullname); /* * Do we want to see just the ignored files? * We still need to recurse into directories, * even if we don't ignore them, since the * directory may contain files that we do.. */ if (!exclude && (dir->flags & DIR_SHOW_IGNORED)) { if (dtype != DT_DIR) continue; } switch (dtype) { default: continue; case DT_DIR: memcpy(fullname + baselen + len, "/", 2); len++; switch (treat_directory(dir, fullname, baselen + len, simplify)) { case show_directory: if (exclude != !!(dir->flags & DIR_SHOW_IGNORED)) continue; break; case recurse_into_directory: contents += read_directory_recursive(dir, fullname, fullname, baselen + len, 0, simplify); continue; case ignore_directory: continue; } break; case DT_REG: case DT_LNK: break; } contents++; if (check_only) goto exit_early; else dir_add_name(dir, fullname, baselen + len); } exit_early: closedir(fdir); } return contents; }
/* CurDeviceUpDown() * ======================================================================= * Handles the up/down buttons on displaying an active driver and device. * so that we can decide which driver to transfer fonts to. */ void CurDeviceUpDown( int button ) { MRETS mk; DEV_PTR olddev; GRECT rect; select( tree, button ); do { olddev = xdevice; if( button == CURUP ) { if( DNEXT( xdevice ) ) xdevice = DNEXT( xdevice ); } else { if( DPREV( xdevice ) ) xdevice = DPREV( xdevice ); } if( olddev != xdevice ) { sprintf( DeviceText, "%d", DDEV( xdevice ) ); TedText( CURNUM ) = &DeviceText[0]; CurHotDriver = DNAME( xdevice ); strcpy( DriverText, drivers[ DNAME( xdevice )] ); TedText( CURNAME ) = &DriverText[0]; /* Take care of the ROM/RES flags */ Deselect( CURROM ); Deselect( CURRES ); if( DTYPE( xdevice ) == 'P' ) /* ROM driver */ Select( CURROM ); if( DTYPE( xdevice ) == 'R' ) /* Resident Driver */ Select( CURRES ); Objc_draw( tree, CURNUM, MAX_DEPTH, NULL ); Objc_draw( tree, CURNAME, MAX_DEPTH, NULL ); Objc_draw( tree, CURROM, MAX_DEPTH, NULL ); Objc_draw( tree, CURRES, MAX_DEPTH, NULL ); /* Let's check and redraw the DELETE driver key only * when the device # is >= 9 so that it won't blink. */ if( DDEV( xdevice ) >= 9 ) { /* turn on/off the EDELETE button here too */ rect = ObRect( EDELETE ); objc_offset( tree, EDELETE, &rect.g_x, &rect.g_y ); rect.g_x -= 3; rect.g_y -= 3; rect.g_w += 6; rect.g_h += 6; if( DDEV( xdevice ) > 9 ) { MakeExit( EDELETE ); Enable( EDELETE ); } else { NoExit( EDELETE ); Disable( EDELETE ); } Objc_draw( tree, ROOT, MAX_DEPTH, &rect ); } } Evnt_timer( 100L ); Graf_mkstate( &mk ); }while( mk.buttons ); deselect( tree, button ); }
tChyba ACT_LIST() { int analyza; int dtype2=0; TItem *pt; //ACT_LIST->end if(!strcmp(token.data, "end") && token.stav == s_klicove) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } return S_BEZ_CHYB; } //ACT_LIST->begin ACT_LIST else if(!strcmp(token.data, "begin") && token.stav == s_klicove) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } return ACT_LIST(); } //ACT_LIST->id LEXEM ROZHODNI UKONCOVACI else if(token.stav == s_identifikator) { if((id = malloc(strlen(token.data)+1)) == NULL) { return S_INTERNI_CHYBA; } //kopirovani z token.data do globalni strcpy(id, token.data); token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } analyza = LEXEM(); if(analyza != S_BEZ_CHYB) { return analyza; } //pokud se jedna o deklaraci id, dojde k ulozeni jeho datoveho typu if(!strcmp(token.data, "integer")) { dtype2 = TYPEINT; } else if(!strcmp(token.data, "string")) { dtype2 = TYPESTR; } else if(!strcmp(token.data, "real")) { dtype2 = TYPEDOUBLE; } else if(!strcmp(token.data, "boolean")) { dtype2 = TYPEBOOL; } //pokud je prirazeni zkontroluj ze je v nejake tabulce if(prirovnani == true) { pt = searchFrames(id, ptrhtGlobal, ptrhtLocal); if(pt != NULL) { prirovnani = false; } else { return S_SEMANTICKA_CHYBA_NEDEF; } } analyza = ROZHODNI(); if(analyza != S_BEZ_CHYB) { return analyza; } //pokud byla deklarace, ulozime id do lokalniho ramce if(dtype2 != 0) { htDeclInsert(ptrhtLocal,id, dtype2, ID_LOCAL); free(id); } analyza = UKONCOVACI(); if(analyza != S_BEZ_CHYB) { return analyza; } return S_BEZ_CHYB; } else if(!strcmp(token.data, "var") && token.stav == s_klicove) { //ACT_LIST->var id : DTYPE ; ACT_LIST token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } if(token.stav == s_identifikator) { if((id = malloc(strlen(token.data)+1)) == NULL) { return S_INTERNI_CHYBA; } //nesmi se id jmenovat stejne jak tyto funkce if(!strcmp(token.data, "length") || !strcmp(token.data, "copy")) { return S_SEMANTICKA_CHYBA_NEDEF; } //pokud j*z nazev existuje -> chyba pt = searchFrames(token.data, ptrhtLocal, ptrhtGlobal); if(pt != NULL) { return S_SEMANTICKA_CHYBA_NEDEF; } strcpy(id, token.data); token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } else if(token.stav == s_dvojtecka) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } analyza = DTYPE(); if(analyza != S_BEZ_CHYB) { return analyza; } if(!strcmp(token.data, "integer")) { dtype = TYPEINT; } else if(!strcmp(token.data, "string")) { dtype = TYPESTR; } else if(!strcmp(token.data, "real")) { dtype = TYPEDOUBLE; } else if(!strcmp(token.data, "boolean")) { dtype = TYPEBOOL; } //vlozeni id do lokalniho ramce htDeclInsert(ptrhtLocal,id, dtype, ID_LOCAL); free(id); token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } else if(token.stav == s_strednik) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } return ACT_LIST(); } } } return S_SYNTAKTICKA_CHYBA; } //ACT_LIST->if EXPR then CYKLUS else CYKLUS UKONCOVACI else if(!strcmp(token.data, "if") && token.stav == s_klicove) { //inkrementace labelu -> vime kolik je vnorenych ifu v sobe lab++; //vlozeni hodnoty lab do TItem data TItem *tmp = (TItem*)malloc(sizeof(TItem)); tmp->type = TYPEINT; tmp->init = true; tmp->data = (TData*)malloc(sizeof(TData)); tmp->data->intNumber = lab; token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } //po if nasleduje vyraz, zavolame precedencni na vyhodnoceni analyza = precedencniSA(); if(analyza != S_BEZ_CHYB) { return analyza; } //generovani skoku, tmp1 je logicka hodnota, tmp3 je lab generateInstruction(OC_GOTO, searchFrames(neterminal.polozkaTS.key, ptrhtLocal, ptrhtGlobal), NULL, tmp ); if(!strcmp(token.data, "then") && token.stav == s_klicove) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } analyza = CYKLUS(); if(analyza != S_BEZ_CHYB) { return analyza; } //generovani skoku za else generateInstruction(OC_GOTOAFTER, searchFrames(neterminal.polozkaTS.key, ptrhtLocal, ptrhtGlobal), NULL, tmp ); if(!strcmp(token.data, "else") && token.stav == s_klicove) { //generovani navesti skok do else generateInstruction(OC_ELSE, NULL, NULL, tmp); token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } analyza = CYKLUS(); if(analyza != S_BEZ_CHYB) { return analyza; } //generovani navesti skok za else generateInstruction(OC_AFTER_ELSE, NULL, NULL, tmp); lab--; return UKONCOVACI(); } return S_SYNTAKTICKA_CHYBA; } return S_SYNTAKTICKA_CHYBA; } //ACT_LIST->while EXPR do CYKLUS UKONCOVACI else if(!strcmp(token.data, "while") && token.stav == s_klicove) { //opet na zjisteni jak moc jsme zanoreni lab_while++; TItem *tmp = (TItem*)malloc(sizeof(TItem)); tmp->type = TYPEINT; tmp->init = true; tmp->data = (TData*)malloc(sizeof(TData)); tmp->data->intNumber = lab_while; token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } //generovani navesti skok pred vyhodnoceni podminky generateInstruction(OC_WHILE_PRED, NULL, NULL, tmp); analyza = precedencniSA(); if(analyza != S_BEZ_CHYB) { return analyza; } //generovani skoku, tmp1 je logicka hodnota, tmp3 je lab generateInstruction(OC_GOTO_WHILE, searchFrames(neterminal.polozkaTS.key, ptrhtLocal, ptrhtGlobal), NULL, tmp ); if(!strcmp(token.data, "do") && token.stav == s_klicove) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } analyza = CYKLUS(); if(analyza != S_BEZ_CHYB) { return analyza; } //generovani skoku zpet na zacatek generateInstruction(OC_GOTO_WHILE, searchFrames(neterminal.polozkaTS.key, ptrhtLocal, ptrhtGlobal), NULL, tmp ); //navesti pro skonceni cyklu generateInstruction(OC_WHILE_AFTER, NULL, NULL, tmp); lab_while--; return UKONCOVACI(); } return S_SYNTAKTICKA_CHYBA; } //ACT_LIST->readln ( id ) UKONCOVACI else if(!strcmp(token.data, "readln") && token.stav == s_klicove) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } if(token.stav == s_leva_zavorka) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } else if(token.stav == s_identifikator) { //pokud zadany parametr nebyl deklarovan -> chyba pt = searchFrames(token.data, ptrhtLocal, ptrhtGlobal); if(pt == NULL) { return S_SEMANTICKA_CHYBA_NEDEF; } //pokud je datovy typ parametru boolean -> chyba if(pt->type == TYPEBOOL) { return S_SEMANTICKA_CHYBA_TYPOVA; } //generovani instrukce read, v token.data je id generateInstruction(OC_READ, NULL, NULL, searchFrames(token.data,ptrhtLocal,ptrhtGlobal)); token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } else if(token.stav == s_prava_zavorka) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } analyza = UKONCOVACI(); if(analyza != S_BEZ_CHYB) { return analyza; } return S_BEZ_CHYB; } } else { return S_SEMANTICKA_CHYBA_TYPOVA; } } return S_SYNTAKTICKA_CHYBA; } //ACT_LIST->write TERM UKONCOVACI else if(!strcmp(token.data, "write") && token.stav == s_klicove) { token = getNextToken(); if(token.stav == s_lex_error) { return S_LEXIKALNI_CHYBA; } analyza = TERM(); if(analyza != S_BEZ_CHYB) { return analyza; } analyza = UKONCOVACI(); if(analyza != S_BEZ_CHYB) { return analyza; } return S_BEZ_CHYB; } return S_SYNTAKTICKA_CHYBA; }
/* AddDevice() * ======================================================================= * Add a new device. * int adevice - > devnum to add. * int AHotDriver-> Index into driver list of driver for the device. * */ void AddDevice( void ) { GRECT rect; DEV_PTR temp_device; wait_up(); if( form_alert( 1, alert2 ) == 2 ) { deselect( tree, EADD ); return; } SetChangeFlag(); temp_device = AddNewDevice( adevice ); if( temp_device ) { /* found a slot and added it to the device linked list array. */ DNAME( temp_device ) = AHotDriver; if( IsSelected( AROM ) ) DTYPE( temp_device ) = 'P'; if( IsSelected( ARES ) ) DTYPE( temp_device ) = 'R'; xdevice = temp_device; InitActiveEdit(); /* re-init the inactive devices. * we only need to check for the device, not everything else. */ adevice = MIN_DEV; /* Set the initial device - unless its a device...*/ /* Check to see if the device exists. If it does, increment and check again * until we don't have an active device. */ while( find_device( adevice ) ) adevice++; /* Set a global index number for the device editor so that we * know which one is currently being displayed. Note that this is * for the active drivers. */ /* Display the device number in text form. */ sprintf( ADeviceText, "%d", adevice ); TedText( ANUM ) = &ADeviceText[0]; Objc_draw( tree, CURNUM, MAX_DEPTH, NULL ); Objc_draw( tree, CURNAME, MAX_DEPTH, NULL ); Objc_draw( tree, CURROM, MAX_DEPTH, NULL ); Objc_draw( tree, CURRES, MAX_DEPTH, NULL ); Objc_draw( tree, ANUM, MAX_DEPTH, NULL ); /* turn on/off the EDELETE button here too */ rect = ObRect( EDELETE ); objc_offset( tree, EDELETE, &rect.g_x, &rect.g_y ); rect.g_x -= 3; rect.g_y -= 3; rect.g_w += 6; rect.g_h += 6; if( DDEV( temp_device ) > 9 ) { MakeExit( EDELETE ); Enable( EDELETE ); } else { NoExit( EDELETE ); Disable( EDELETE ); } Deselect( EDELETE ); Objc_draw( tree, ROOT, MAX_DEPTH, &rect ); device_count++; } /* Reset the driver name to NONE */ strcpy( ADriverText, driver_null ); TedText( ANAME ) = &ADriverText[0]; Objc_draw( tree, ANAME, MAX_DEPTH, NULL ); /* Set the ROM/RES flags */ deselect( tree, AROM ); deselect( tree, ARES ); AHotDriver = -1; /* turn off the EADD button here too */ rect = ObRect( EADD ); objc_offset( tree, EADD, &rect.g_x, &rect.g_y ); rect.g_x -= 3; rect.g_y -= 3; rect.g_w += 6; rect.g_h += 6; NoExit( EADD ); Disable( EADD ); Deselect( EADD ); Objc_draw( tree, ROOT, MAX_DEPTH, &rect ); }