| 279 | } |
| 280 | |
| 281 | idhdl enterid(const char * s, int lev, int t, idhdl* root, BOOLEAN init, BOOLEAN search) |
| 282 | { |
| 283 | if (s==NULL) return NULL; |
| 284 | if (root==NULL) return NULL; |
| 285 | idhdl h; |
| 286 | s=omStrDup(s); |
| 287 | // idhdl *save_root=root; |
| 288 | if (t==PACKAGE_CMD) |
| 289 | { |
| 290 | if (root!=&(basePack->idroot)) |
| 291 | { |
| 292 | root=&(basePack->idroot); |
| 293 | } |
| 294 | } |
| 295 | // is it already defined in root ? |
| 296 | if ((h=(*root)->get_level(s,lev))!=NULL) |
| 297 | { |
| 298 | if ((IDTYP(h) == t)||(t==DEF_CMD)) |
| 299 | { |
| 300 | if (IDTYP(h)==PACKAGE_CMD) |
| 301 | { |
| 302 | if (strcmp(s,"Top")==0) |
| 303 | { |
| 304 | goto errlabel; |
| 305 | } |
| 306 | else return h; |
| 307 | } |
| 308 | else |
| 309 | { |
| 310 | if (BVERBOSE(V_REDEFINE)) |
| 311 | { |
| 312 | const char *f=VoiceName(); |
| 313 | if (strcmp(f,"STDIN")==0) |
| 314 | Warn("redefining %s (%s)",s,my_yylinebuf); |
| 315 | else |
| 316 | Warn("redefining %s (%s) %s:%d",s,my_yylinebuf,f, yylineno); |
| 317 | } |
| 318 | if (s==IDID(h)) IDID(h)=NULL; |
| 319 | if((t!=PROC_CMD)||(IDPROC(h)->language!=LANG_C)) |
| 320 | { |
| 321 | killhdl2(h,root,currRing); |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | else |
| 326 | goto errlabel; |
| 327 | } |
| 328 | // is it already defined in currRing->idroot ? |
| 329 | else if (search && (currRing!=NULL)&&((*root) != currRing->idroot)) |
| 330 | { |
| 331 | if ((h=currRing->idroot->get_level(s,lev))!=NULL) |
| 332 | { |
| 333 | if ((IDTYP(h) == t)||(t==DEF_CMD)) |
| 334 | { |
| 335 | if (BVERBOSE(V_REDEFINE)) |
| 336 | { |
| 337 | const char *f=VoiceName(); |
| 338 | if (strcmp(f,"STDIN")==0) |