Annotation of OpenXM_contrib2/asir2000/builtin/miscf.c, Revision 1.25
1.7 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.8 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.7 noro 27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
47: *
1.25 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/builtin/miscf.c,v 1.24 2004/10/27 08:21:47 noro Exp $
1.7 noro 49: */
1.1 noro 50: #include "ca.h"
51: #include "parse.h"
1.17 noro 52: #if !defined(VISUAL) && defined(DO_PLOT)
1.1 noro 53: #include <X11/Xlib.h>
54: #include <X11/cursorfont.h>
55: #endif
56:
1.12 noro 57: #if defined(VISUAL)
58: #include <stdlib.h>
59: #include <windows.h>
60: #endif
61:
1.24 noro 62: void Pset_secure_mode();
63: void Pset_secure_flag();
1.1 noro 64: void Pquit(), Pdebug(), Pnmono(), Pnez(), Popt(), Pshell(), Pheap();
1.20 noro 65: void Ptoplevel();
1.21 ohara 66: void Perror(), Perror3(), Pversion(), Pcopyright(), Pflist(), Pdelete_history(), Ppause(), Pxpause();
1.1 noro 67: void Pr2g(), Pread_cmo(), Pwrite_cmo();
68: void Pgc(),Pbatch(),Psend_progress();
69: void Pnull_command();
70: void Pgetenv();
1.9 noro 71: void Pget_addr(),Phex_dump();
72: void Ppeek(),Ppoke();
1.12 noro 73: void Psleep();
1.18 noro 74: void Premove_module();
75: void Pmodule_list();
1.19 takayama 76: void Pmodule_definedp();
1.22 noro 77: void Ptest();
1.1 noro 78:
79: void delete_history(int,int);
80:
81: struct ftab misc_tab[] = {
1.24 noro 82: {"set_secure_mode",Pset_secure_mode,-1},
83: {"set_secure_flag",Pset_secure_flag,-2},
1.18 noro 84: {"module_list",Pmodule_list,0},
85: {"remove_module",Premove_module,1},
1.19 takayama 86: {"module_definedp",Pmodule_definedp,1},
1.12 noro 87: {"sleep",Psleep,1},
1.1 noro 88: {"null_command",Pnull_command,-99999},
89: {"getenv",Pgetenv,1},
90: {"end",Pquit,0},
91: {"quit",Pquit,0},
92: {"debug",Pdebug,0},
93: {"shell",Pshell,-2},
94: {"heap",Pheap,-1},
1.11 noro 95: {"version",Pversion,-99999},
1.21 ohara 96: {"copyright",Pcopyright,0},
1.1 noro 97: {"nmono",Pnmono,1},
1.20 noro 98: {"toplevel",Ptoplevel,-1},
1.1 noro 99: {"error",Perror,1},
100: {"error3",Perror3,3},
101: {"nez",Pnez,1},
1.18 noro 102: {"flist",Pflist,-1},
1.1 noro 103: {"delete_history",Pdelete_history,-2},
104: {"pause",Ppause,0},
105: {"gc",Pgc,0},
106: {"batch",Pbatch,2},
107: {"send_progress",Psend_progress,-2},
1.9 noro 108: {"get_addr",Pget_addr,1},
109: {"hex_dump",Phex_dump,2},
110: {"peek",Ppeek,1},
111: {"poke",Ppoke,2},
1.16 noro 112: #if !defined(VISUAL) && defined(DO_PLOT)
1.1 noro 113: {"xpause",Pxpause,0},
114: #endif
115: #if 0
116: {"opt",Popt,1},
117: #endif
118: {0,0,0},
119: };
1.24 noro 120:
121: void Pset_secure_mode(NODE arg,Q *rp)
122: {
123: int s;
124: if ( argc(arg) )
125: setsecuremode(QTOS((Q)ARG0(arg)));
126: s = getsecuremode();
127: STOQ(s,*rp);
128: }
129:
130: void Pset_secure_flag(NODE arg,Q *rp)
131: {
1.25 ! noro 132: int ac,s,status;
! 133: Obj f;
! 134: char *fname;
1.24 noro 135:
136: ac = argc(arg);
137: if ( !ac )
138: error("set_secure_flag : a function name must be specified");
139: if ( ac == 2 )
140: s = QTOS((Q)ARG1(arg));
141: else
142: s = 1;
1.25 ! noro 143: f = ARG0(arg);
! 144: if ( !f )
! 145: error("set_secure_flag : invalid argument");
! 146: switch ( OID(f) ) {
! 147: case O_STR:
! 148: fname = BDY((STRING)f); break;
! 149: case O_P:
! 150: fname = NAME(VR((P)f)); break;
! 151: default:
! 152: error("set_secure_flag : invalid argument"); break;
! 153: }
! 154: status = setsecureflag(fname,s);
! 155: if ( status < 0 )
! 156: error("set_secure_flag : function not found");
1.24 noro 157: STOQ(s,*rp);
158: }
1.22 noro 159:
160: void Ptest(arg,rp)
161: NODE arg;
162: Q *rp;
163: {
164: int r;
165:
166: r = equalr(CO,ARG0(arg),ARG1(arg));
167: STOQ(r,*rp);
168: }
1.12 noro 169:
170: void Psleep(arg,rp)
171: NODE arg;
172: Q *rp;
173: {
174: int ms;
175:
176: ms = QTOS((Q)ARG0(arg));
177: #if defined(VISUAL)
178: Sleep(ms);
179: #else
180: usleep(ms*1000);
181: #endif
182: *rp = ONE;
183: }
1.1 noro 184:
1.18 noro 185: void Pmodule_list(rp)
186: LIST *rp;
187: {
188: char *name;
189: NODE r,r1,m;
190: STRING s;
191:
192: r = 0;
193: for ( m = MODULE_LIST; m; m = NEXT(m) ) {
194: MKSTR(s,((MODULE)BDY(m))->name);
195: MKNODE(r1,s,r); r = r1;
196: }
197: MKLIST(*rp,r);
198: }
199:
200: void Premove_module(arg,rp)
201: NODE arg;
202: Q *rp;
203: {
204: NODE pm,m;
205: char *name;
206:
207: asir_assert(ARG0(arg),O_STR,"remove_module");
208: name = BDY((STRING)ARG0(arg));
209: for ( pm = 0, m = MODULE_LIST; m; pm = m, m = NEXT(m) )
210: if ( !strcmp(name,((MODULE)BDY(m))->name) ) {
211: if ( !pm )
212: MODULE_LIST = NEXT(MODULE_LIST);
213: else
214: NEXT(pm) = NEXT(m);
215: *rp = ONE;
216: return;
1.19 takayama 217: }
218: *rp = 0;
219: }
220:
221: void Pmodule_definedp(arg,rp)
222: NODE arg;
223: Q *rp;
224: {
225: NODE m;
226: char *name;
227:
228: asir_assert(ARG0(arg),O_STR,"module_definedp");
229: name = BDY((STRING)ARG0(arg));
230: /* bug: the linear search is used here. The list of module shoud be sorted
231: and cashed, and binary search should be used. */
232: for (m = MODULE_LIST; m; m = NEXT(m) )
233: if ( !strcmp(name,((MODULE)BDY(m))->name) ) {
234: *rp = ONE;
235: return ;
1.18 noro 236: }
237: *rp = 0;
238: }
239:
1.1 noro 240: void Pgetenv(arg,rp)
241: NODE arg;
242: STRING *rp;
243: {
244: char *e,*f;
245: int len;
246:
247: e = (char *)getenv(BDY((STRING)ARG0(arg)));
248: if ( e ) {
249: len = strlen(e);
250: f = (char *)MALLOC_ATOMIC(len+1);
251: strcpy(f,e);
252: MKSTR(*rp,f);
253: } else
254: *rp = 0;
255: }
256:
257: void Pnull_command(arg,rp)
258: NODE arg;
259: Q *rp;
260: {
261: *rp = 0;
262: }
263:
264: void Pquit(rp)
265: pointer *rp;
266: {
267: if ( !NEXT(asir_infile) )
268: asir_terminate(2);
269: else {
270: closecurrentinput();
1.5 noro 271: if ( !asir_infile->fp && strcmp(asir_infile->name,"string") )
1.1 noro 272: asir_terminate(2);
273: }
274: *rp = 0;
275: }
276:
277: void Pdebug(rp)
278: pointer *rp;
279: {
280: debug(0); *rp = 0;
281: }
282:
283: void Pshell(arg,rp)
284: NODE arg;
285: Q *rp;
286: {
287: char *com = 0;
288: char *pstr = 0;
289: int status;
290:
291: if ( arg ) {
292: asir_assert(ARG0(arg),O_STR,"shell");
293: com = BDY((STRING)ARG0(arg));
294: if ( NEXT(arg) )
295: pstr = BDY((STRING)ARG1(arg));
296: }
297: status = system(com);
298: STOQ(status,*rp);
299: }
300:
301: void Pnmono(arg,rp)
302: NODE arg;
303: Q *rp;
304: {
305: Obj obj;
306: int n;
307:
308: obj = (Obj)ARG0(arg);
309: if ( !obj || OID(obj) > O_R )
310: *rp = 0;
311: else
312: switch (OID(obj)) {
313: case O_N: case O_P:
314: n = nmonop((P)obj); STOQ(n,*rp); break;
315: case O_R:
316: n = nmonop(NM((R)obj)) + nmonop(DN((R)obj));
317: STOQ(n,*rp); break;
318: }
319: }
320:
321: void Pheap(arg,rp)
322: NODE arg;
323: Q *rp;
324: {
325: int h0,h;
326: void GC_expand_hp(int);
327:
328: h0 = get_heapsize();
329: if ( arg ) {
330: h = QTOS((Q)ARG0(arg));
331: if ( h > h0 )
332: GC_expand_hp(h-h0);
333: }
334: h = get_heapsize();
335: STOQ(h,*rp);
336: }
337:
338: unsigned int get_asir_version();
1.11 noro 339: char *get_asir_distribution();
1.1 noro 340:
1.11 noro 341: void Pversion(arg,rp)
342: NODE arg;
343: Obj *rp;
1.1 noro 344: {
345: unsigned int version;
1.11 noro 346: char *distribution;
347: Q q;
348: STRING str;
349: NODE n;
350: LIST l;
1.1 noro 351:
352: version = get_asir_version();
1.11 noro 353: distribution = get_asir_distribution();
1.13 noro 354: UTOQ(version,q);
1.11 noro 355: if ( !argc(arg) )
356: *rp = (Obj)q;
357: else {
358: MKSTR(str,distribution);
359: n = mknode(2,q,str);
360: MKLIST(l,n);
361: *rp = (Obj)l;
362: }
1.21 ohara 363: }
364:
365: char *scopyright();
366:
367: void Pcopyright(rp)
368: STRING *rp;
369: {
370: MKSTR(*rp,scopyright());
1.1 noro 371: }
372:
373: extern int nez;
374:
375: void Pnez(arg,rp)
376: NODE arg;
377: pointer *rp;
378: {
379: nez = ARG0(arg) ? 1 : 0; *rp = 0;
380: }
381:
382: void Perror(arg,rp)
383: NODE arg;
384: Q *rp;
385: {
386: char *s;
387:
388: if ( !arg || !ARG0(arg) || (OID((Obj)ARG0(arg)) != O_STR) )
389: s = "";
390: else
391: s = BDY((STRING)ARG0(arg));
392: error(s);
1.20 noro 393: *rp = 0;
394: }
395:
396: void Ptoplevel(arg,rp)
397: NODE arg;
398: Q *rp;
399: {
400: char *s;
401:
402: if ( !arg || !ARG0(arg) || (OID((Obj)ARG0(arg)) != O_STR) )
403: s = "";
404: else
405: s = BDY((STRING)ARG0(arg));
406: toplevel(s);
1.1 noro 407: *rp = 0;
408: }
409:
410: void Perror3(arg,rp)
411: NODE arg;
412: Q *rp;
413: {
414: int code;
415: char *reason,*action;
416:
417: asir_assert(ARG0(arg),O_N,"error3");
418: asir_assert(ARG1(arg),O_STR,"error3");
419: asir_assert(ARG2(arg),O_STR,"error3");
420: code = QTOS((Q)ARG0(arg));
421: reason = BDY((STRING)ARG1(arg));
422: action = BDY((STRING)ARG2(arg));
1.3 noro 423: #if defined(VISUAL)
1.1 noro 424: set_error(code,reason,action);
1.3 noro 425: #endif
1.1 noro 426: error("");
427: *rp = 0;
428: }
429:
1.18 noro 430: void Pflist(arg,rp)
431: NODE arg;
1.1 noro 432: LIST *rp;
433: {
434: char *n;
435: STRING name;
1.18 noro 436: char *mname;
437: NODE t,r,r0,m;
1.1 noro 438: LIST l;
439:
1.18 noro 440: if ( argc(arg) ) {
441: /* module name is specified */
442: asir_assert(ARG0(arg),O_STR,"flist");
443: mname = BDY((STRING)ARG0(arg));
444: r0 = 0;
445: for ( m = MODULE_LIST; m; m = NEXT(m) ) {
446: if ( !strcmp(mname,((MODULE)BDY(m))->name) ) {
447: t = ((MODULE)BDY(m))->usrf_list;
448: for ( r0 = 0; t; t = NEXT(t) )
449: if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
450: n = NAME((FUNC)BDY(t)); MKSTR(name,n);
451: MKNODE(r,name,r0); r0 = r;
452: }
453: }
1.1 noro 454: }
1.18 noro 455: } else {
456: for ( t = usrf, r0 = 0; t; t = NEXT(t) )
457: if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
458: n = NAME((FUNC)BDY(t)); MKSTR(name,n);
459: MKNODE(r,name,r0); r0 = r;
460: }
461: for ( t = ubinf; t; t = NEXT(t) )
462: if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
463: n = NAME((FUNC)BDY(t)); MKSTR(name,n);
464: MKNODE(r,name,r0); r0 = r;
465: }
466: for ( t = sysf; t; t = NEXT(t) )
467: if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
468: n = NAME((FUNC)BDY(t)); MKSTR(name,n);
469: MKNODE(r,name,r0); r0 = r;
470: }
471: }
1.1 noro 472: MKLIST(l,r0); *rp = l;
473: }
474:
475: void Pdelete_history(arg,rp)
476: NODE arg;
477: Q *rp;
478: {
479: switch ( argc(arg) ) {
480: case 0: default:
481: delete_history(0,(int)APVS->n);
482: break;
483: case 1:
484: delete_history(QTOS((Q)ARG0(arg)),1);
485: break;
486: }
487: *rp = 0;
488: }
489:
490: void delete_history(start,n)
491: int start,n;
492: {
493: int i,max;
494:
495: max = APVS->n;
496: if ( start < 0 || start >= max )
497: return;
498: if ( start + n > max )
499: n = max - start;
500: for ( i = 0; i < n; i++ )
501: APVS->va[start+i].priv = 0;
502: }
503:
504: void Ppause(rp)
505: LIST *rp;
506: {
507: char buf[BUFSIZ];
508:
509: fgets(buf,BUFSIZ,stdin);
510: *rp = 0;
511: }
512:
513: void Pgc(rp)
514: LIST *rp;
515: {
516: GC_gcollect();
517: *rp = 0;
518: }
519:
520: int exec_file(char *,char *);
521:
522: void Pbatch(arg,rp)
523: NODE arg;
524: Q *rp;
525: {
526: int ret;
527:
528: ret = exec_file(BDY((STRING)ARG0(arg)),BDY((STRING)ARG1(arg)));
529: STOQ(ret,*rp);
530: }
531:
1.16 noro 532: #if !defined(VISUAL) && defined(DO_PLOT)
1.1 noro 533: void Pxpause(rp)
534: Q *rp;
535: {
536: if ( !init_display() )
537: *rp = 0;
538: else {
539: grab_pointer(); *rp = ONE;
540: }
541: }
542:
543: static Display *display;
544: static Window rootwin;
545:
546: init_display()
547: {
548: char *dname;
549: unsigned int tmp;
550: static int initialized;
551: int argc;
552: char *argv[1];
553:
554: if ( initialized )
555: return 1;
556: else
557: initialized = 1;
558: dname = (char *)getenv("DISPLAY");
559:
560: display = XOpenDisplay(dname);
561: if ( !display ) {
562: fprintf(stderr,"Can't open display\n");
563: return 0;
564: }
565: rootwin = RootWindow(display,DefaultScreen(display));
566: }
567:
568: grab_pointer()
569: {
570: XEvent ev;
571: static Cursor cursor;
572:
573: if ( !cursor )
574: cursor = XCreateFontCursor(display,XC_leftbutton);
575: XGrabPointer(display,rootwin,True,ButtonPressMask,GrabModeAsync,GrabModeAsync,None,cursor,CurrentTime);
576: while ( 1 ) {
577: XNextEvent(display,&ev);
578: if ( ev.xany.type == ButtonPress )
579: break;
580: }
581: XUngrabPointer(display,CurrentTime);
582: XSync(display,False);
583: return;
584: }
585: #endif
586:
587: void Psend_progress(NODE arg,Q *rp)
588: {
589: #if defined(VISUAL)
590: short per;
591: char *msg;
592:
593: per = (short)QTOS((Q)BDY(arg)); arg = NEXT(arg);
594: if ( arg )
595: msg = BDY((STRING)BDY(arg));
596: else
597: msg = "";
598: send_progress(per,msg);
599: #endif
1.9 noro 600: *rp = 0;
601: }
602:
603: void Pget_addr(arg,rp)
604: NODE arg;
605: Q *rp;
606: {
607: pointer obj;
608: unsigned int u,l;
609: N n;
610:
611: obj = ARG0(arg);
612: if ( sizeof(pointer) == sizeof(unsigned int) ) {
613: UTOQ((unsigned int)obj,*rp);
614: } else {
615: /* a pointer must fit in long */
616: u = ((unsigned long)obj)>>32;
617: l = ((unsigned long)obj)&(unsigned long)0xffffffff;
618: if ( u ) {
619: n = NALLOC(2); PL(n) = 2; BD(n)[0] = l; BD(n)[1] = u;
620: NTOQ(n,1,*rp);
621: } else {
622: UTOQ(l,*rp);
623: }
624: }
625: }
626:
627: unsigned char *qtoaddr(q)
628: Q q;
629: {
630: unsigned char *addr;
631: N n;
632:
633: if ( !q )
634: return 0;
635: n = NM(q);
636: if ( (sizeof(pointer) == sizeof(unsigned int)) || (PL(n) == 1) )
637: addr = (char *)BD(n)[0];
638: else {
639: /* a pointer must fit in long */
640: addr = (char *)((((unsigned long)BD(n)[1])<<32)
641: | ((unsigned long)BD(n)[0]));
642: }
643: return addr;
644: }
645:
646: void Phex_dump(arg,rp)
647: NODE arg;
648: Q *rp;
649: {
650: unsigned char *start;
651: int len,i;
652:
653: *rp = 0;
654: start = qtoaddr((Q)ARG0(arg));
655: len = QTOS((Q)ARG1(arg));
656: for ( i = 0; i < len; i++ ) {
657: if ( !(i%16) )
658: fprintf(asir_out,"%08x: ",start+i);
659: fprintf(asir_out,"%02x",start[i]);
660: if ( !((i+1)%16) )
661: fprintf(asir_out,"\n");
662: else if ( !((i+1)%4) )
663: fprintf(asir_out," ");
664: }
665: if ( i%16 )
666: fprintf(asir_out,"\n");
667: }
668:
669: void Ppeek(arg,rp)
670: NODE arg;
671: Q *rp;
672: {
673: unsigned int b;
674: unsigned char *a;
675:
676: a = qtoaddr((Q)ARG0(arg));
677: b = (unsigned int) (*a);
678: UTOQ(b,*rp);
679: }
680:
681: void Ppoke(arg,rp)
682: NODE arg;
683: Q *rp;
684: {
685: unsigned char *addr;
686:
687: addr = qtoaddr((Q)ARG0(arg));
688: *addr = (unsigned char)QTOS((Q)ARG1(arg));
1.1 noro 689: *rp = 0;
690: }
691:
692: #if 0
693: static int optimize;
694: static struct oN oPSN[1000];
695: static struct oQ oPSZ[1000],oMSZ[1000];
696: static szinit = 0;
697:
698: void Popt(arg,rp)
699: NODE arg;
700: pointer *rp;
701: {
702: optimize = ARG0(arg) ? 1 : 0; *rp = 0;
703: }
704:
705:
706: void sz_init() {
707: int i;
708: Q t;
709:
710: for ( i = 1; i < 1000; i++ ) {
711: oPSN[i].p = 1; oPSN[i].b[0] = i;
712: t = &oPSZ[i];
713: OID(t) = O_N; NID(t) = N_Q; SGN(t) = 1; NM(t) = &oPSN[i]; DN(t) = 0;
714: t = &oMSZ[i];
715: OID(t) = O_N; NID(t) = N_Q; SGN(t) = -1; NM(t) = &oPSN[i]; DN(t) = 0;
716: }
717: szinit = 1;
718: }
719:
720: optobj(p)
721: Obj *p;
722: {
723: Obj t;
724: int n;
725: DCP dc;
726:
727: if ( t = *p )
728: switch ( OID(t) ) {
729: case O_N:
730: if ( (NID(t)==N_Q) && INT(t) && (PL(NM((Q)t))==1) ) {
731: n = QTOS((Q)t);
732: if ( !szinit )
733: sz_init();
734: if ( n < 1000 )
735: *p = (Obj)(SGN((Q)t)>0?&oPSZ[n]:&oMSZ[n]);
736: }
737: break;
738: case O_P:
739: for ( dc = DC((P)t); dc; dc = NEXT(dc) ) {
740: optobj(&DEG(dc)); optobj(&COEF(dc));
741: }
742: break;
743: case O_R:
744: optobj(&NM((R)t)); optobj(&DN((R)t)); break;
745: default:
746: break;
747: }
748: }
749: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>