Changeset d67f97a in git for Singular/links
- Timestamp:
- Jun 2, 2016, 5:21:19 PM (8 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
- Children:
- c7afbd34f1aae46fbf47925ff2246e5f42f4ca08
- Parents:
- 0151564fccc0217ec60e98c6a2303897a948c1b4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/links/asciiLink.cc
r015156 rd67f97a 27 27 28 28 /* declarations */ 29 static BOOLEAN DumpAscii(FILE *fd, idhdl h );30 static BOOLEAN DumpAsciiIdhdl(FILE *fd, idhdl h );29 static BOOLEAN DumpAscii(FILE *fd, idhdl h,char ***list_of_libs); 30 static BOOLEAN DumpAsciiIdhdl(FILE *fd, idhdl h,char ***list_of_libs); 31 31 static const char* GetIdString(idhdl h); 32 32 static int DumpRhs(FILE *fd, idhdl h); 33 33 static BOOLEAN DumpQring(FILE *fd, idhdl h, const char *type_str); 34 34 static BOOLEAN DumpAsciiMaps(FILE *fd, idhdl h, idhdl rhdl); 35 static BOOLEAN CollectLibs(FILE *fd, char *name, char ***list_of_libs); 36 static BOOLEAN DumpLibs(FILE *fd, char ***list_of_libs); 35 37 36 38 extern si_link_extension si_link_root; … … 213 215 FILE *fd = (FILE *) l->data; 214 216 idhdl h = IDROOT, rh = currRingHdl; 215 BOOLEAN status = DumpAscii(fd, h); 217 char **list_of_libs=NULL; 218 BOOLEAN status = DumpAscii(fd, h, &list_of_libs); 216 219 217 220 if (! status ) status = DumpAsciiMaps(fd, h, NULL); … … 219 222 if (currRingHdl != rh) rSetHdl(rh); 220 223 fprintf(fd, "option(set, intvec(%d, %d));\n", si_opt_1, si_opt_2); 224 char **p=list_of_libs; 225 if (p!=NULL) 226 { 227 while((*p!=NULL) && (*p!=(char*)1)) 228 { 229 fprintf(fd,"load(\"%s\",\"try\");\n",*p); 230 p++; 231 } 232 omFree(list_of_libs); 233 } 221 234 fprintf(fd, "RETURN();\n"); 222 235 fflush(fd); … … 227 240 // we do that recursively, to dump ids in the the order in which they 228 241 // were actually defined 229 static BOOLEAN DumpAscii(FILE *fd, idhdl h )242 static BOOLEAN DumpAscii(FILE *fd, idhdl h, char ***list_of_libs) 230 243 { 231 244 if (h == NULL) return FALSE; 232 245 233 if (DumpAscii(fd, IDNEXT(h) )) return TRUE;246 if (DumpAscii(fd, IDNEXT(h),list_of_libs)) return TRUE; 234 247 235 248 // need to set the ring before writing it, otherwise we get in … … 238 251 rSetHdl(h); 239 252 240 if (DumpAsciiIdhdl(fd, h )) return TRUE;253 if (DumpAsciiIdhdl(fd, h,list_of_libs)) return TRUE; 241 254 242 255 if (IDTYP(h) == RING_CMD || IDTYP(h) == QRING_CMD) 243 return DumpAscii(fd, IDRING(h)->idroot );256 return DumpAscii(fd, IDRING(h)->idroot,list_of_libs); 244 257 else 245 258 return FALSE; … … 275 288 } 276 289 277 static BOOLEAN DumpAsciiIdhdl(FILE *fd, idhdl h )290 static BOOLEAN DumpAsciiIdhdl(FILE *fd, idhdl h, char ***list_of_libs) 278 291 { 279 292 const char *type_str = GetIdString(h); 280 293 int type_id = IDTYP(h); 281 294 282 if ((type_id == PACKAGE_CMD) &&(strcmp(IDID(h), "Top") == 0)) 283 return FALSE; 295 if (type_id == PACKAGE_CMD) 296 { 297 if (strcmp(IDID(h),"Top")==0) return FALSE; 298 if (IDPACKAGE(h)->language==LANG_SINGULAR) return FALSE; 299 } 284 300 285 301 // we do not throw an error if a wrong type was attempted to be dumped … … 294 310 if ((type_id == PROC_CMD) && (IDPROC(h)->language == LANG_C)) 295 311 return FALSE; 312 313 // handle libraries 314 if ((type_id == PROC_CMD) 315 && (IDPROC(h)->language == LANG_SINGULAR) 316 && (IDPROC(h)->libname!=NULL)) 317 return CollectLibs(fd,IDPROC(h)->libname,list_of_libs); 296 318 297 319 // put type and name … … 333 355 switch(type) 334 356 { 335 case LIST_CMD: 336 { 337 lists l = IDLIST(h); 338 int i, nl = l->nr + 1; 339 340 for (i=0; i<nl; i++) 341 if (GetIdString((idhdl) &(l->m[i])) == NULL) return NULL; 342 } 343 #ifdef SINGULAR_4_1 344 case CRING_CMD: 345 case CNUMBER_CMD: 346 case CMATRIX_CMD: 347 #endif 348 case PACKAGE_CMD: 349 case INT_CMD: 350 case INTVEC_CMD: 351 case INTMAT_CMD: 352 case STRING_CMD: 353 case RING_CMD: 354 case QRING_CMD: 355 case PROC_CMD: 356 case NUMBER_CMD: 357 case POLY_CMD: 358 case IDEAL_CMD: 359 case VECTOR_CMD: 360 case MODUL_CMD: 361 case MATRIX_CMD: 362 return Tok2Cmdname(type); 363 364 case MAP_CMD: 365 case LINK_CMD: 366 return NULL; 367 368 default: 369 Warn("Error dump data of type %s", Tok2Cmdname(IDTYP(h))); 357 case LIST_CMD: 358 { 359 lists l = IDLIST(h); 360 int i, nl = l->nr + 1; 361 362 for (i=0; i<nl; i++) 363 if (GetIdString((idhdl) &(l->m[i])) == NULL) return NULL; 364 } 365 #ifdef SINGULAR_4_1 366 case CRING_CMD: 367 case CNUMBER_CMD: 368 case CMATRIX_CMD: 369 #endif 370 case BIGINT_CMD: 371 case PACKAGE_CMD: 372 case INT_CMD: 373 case INTVEC_CMD: 374 case INTMAT_CMD: 375 case STRING_CMD: 376 case RING_CMD: 377 case QRING_CMD: 378 case PROC_CMD: 379 case NUMBER_CMD: 380 case POLY_CMD: 381 case IDEAL_CMD: 382 case VECTOR_CMD: 383 case MODUL_CMD: 384 case MATRIX_CMD: 385 return Tok2Cmdname(type); 386 387 case MAP_CMD: 388 case LINK_CMD: 389 return NULL; 390 391 default: 392 Warn("Error dump data of type %s", Tok2Cmdname(IDTYP(h))); 370 393 return NULL; 371 394 } … … 391 414 } 392 415 416 static BOOLEAN CollectLibs(FILE *fd, char *name, char *** list_of_libs) 417 { 418 if (*list_of_libs==NULL) 419 { 420 #define MAX_LIBS 256 421 (*list_of_libs)=(char**)omalloc0(MAX_LIBS*sizeof(char**)); 422 (*list_of_libs)[0]=name; 423 (*list_of_libs)[MAX_LIBS-1]=(char*)1; 424 return FALSE; 425 } 426 else 427 { 428 char **p=*list_of_libs; 429 while (((*p)!=NULL)&&((*p!=(char*)1))) 430 { 431 if (strcmp((*p),name)==0) return FALSE; 432 p++; 433 } 434 if (*p==(char*)1) 435 { 436 WerrorS("too many libs"); 437 return TRUE; 438 } 439 else 440 { 441 *p=name; 442 } 443 } 444 return FALSE; 445 } 446 393 447 394 448 static int DumpRhs(FILE *fd, idhdl h) … … 431 485 if (pi->language == LANG_SINGULAR) 432 486 { 433 if( pi->data.s.body==NULL) iiGetLibProcBuffer(pi);487 /* pi-Libname==NULL */ 434 488 char *pstr = pi->data.s.body; 435 489 fputc('"', fd); … … 454 508 else if (type_id == IDEAL_CMD) { fprintf(fd, "ideal(");need_klammer=TRUE; } 455 509 else if (type_id == MODUL_CMD) { fprintf(fd, "module(");need_klammer=TRUE; } 510 else if (type_id == BIGINT_CMD) { fprintf(fd, "bigint(");need_klammer=TRUE; } 456 511 457 512 if (fprintf(fd, "%s", rhs) == EOF) return EOF;
Note: See TracChangeset
for help on using the changeset viewer.