Annotation of OpenXM_contrib2/asir2000/parse/lex.c, Revision 1.17
1.4 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.5 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.4 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.17 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/parse/lex.c,v 1.16 2001/06/15 07:56:06 noro Exp $
1.4 noro 49: */
1.1 noro 50: #include <ctype.h>
51: #include "ca.h"
52: #include "al.h"
53: #include "base.h"
54: #include "parse.h"
55: #include <sys/types.h>
56: #include <sys/stat.h>
1.10 noro 57: #if defined(VISUAL)
58: #include "ytab.h"
59: #else
1.1 noro 60: #include "y.tab.h"
1.10 noro 61: #endif
1.1 noro 62:
63: extern IN asir_infile;
64: extern struct oTKWD kwd[];
65:
66: int afternl();
67: int myatoi();
68: int aftercomment();
69:
70: extern int main_parser;
71: extern char *parse_strp;
1.11 noro 72: extern int recv_intr;
1.1 noro 73:
74: static int skipspace();
75: static int Getc();
76: static void Ungetc();
77: static void Gets();
78:
1.2 noro 79: #define NBUFSIZ (BUFSIZ*10)
80: #define TBUFSIZ (BUFSIZ)
81:
82: #define REALLOC_NBUF \
83: if ( i >= nbufsize ) {\
84: nbufsize += NBUFSIZ;\
85: if ( nbuf == nbuf0 ) {\
86: nbuf = (char *)MALLOC_ATOMIC(nbufsize);\
87: bcopy(nbuf0,nbuf,nbufsize-NBUFSIZ);\
88: } else\
89: nbuf = REALLOC(nbuf,nbufsize);\
90: }
91:
92: #define REALLOC_TBUF \
93: if ( i >= tbufsize ) {\
94: tbufsize += TBUFSIZ;\
95: if ( tbuf == tbuf0 ) {\
96: tbuf = (char *)MALLOC_ATOMIC(tbufsize);\
97: bcopy(tbuf0,tbuf,tbufsize-TBUFSIZ);\
98: } else\
99: tbuf = REALLOC(tbuf,tbufsize);\
100: }
101:
102: #define READ_ALNUM_NBUF \
103: while ( 1 ) {\
104: c = Getc();\
105: if ( isalnum(c) ) {\
106: REALLOC_NBUF nbuf[i++] = c;\
107: } else\
108: break;\
109: }
110:
111: #define READ_DIGIT_NBUF \
112: while ( 1 ) {\
113: c = Getc();\
114: if ( isdigit(c) ) {\
115: REALLOC_NBUF nbuf[i++] = c;\
116: } else\
117: break;\
118: }
119:
1.1 noro 120: yylex()
121: {
122: #define yylvalp (&yylval)
123: register int c,c1;
124: register int *ptr;
125: char *cptr;
126: int d,i,j;
1.2 noro 127: char nbuf0[NBUFSIZ],tbuf0[TBUFSIZ];
128: char *nbuf, *tbuf;
129: int nbufsize, tbufsize;
1.1 noro 130: N n,n1;
131: Q q;
132: Obj r;
133:
1.2 noro 134: /* initialize buffer pointers */
135: nbuf = nbuf0; tbuf = tbuf0;
136: nbufsize = NBUFSIZ; tbufsize = TBUFSIZ;
137:
1.1 noro 138: switch ( c = skipspace() ) {
139: case EOF :
140: asir_terminate(2); break;
141: case '0' :
142: while ( ( c = Getc() ) == '0' );
143: if ( c == '.' ) {
144: Ungetc(c); c = '0';
145: } else if ( c == 'x' ) {
146: for ( i = 0; i < 8; i++ )
147: nbuf[i] = '0';
1.2 noro 148: READ_ALNUM_NBUF
149: Ungetc(c); REALLOC_NBUF nbuf[i] = 0;
1.1 noro 150: hexton(nbuf,&n1);
151: NTOQ(n1,1,q); r = (Obj)q;
152: yylvalp->p = (pointer)r;
153: return ( FORMULA );
154: } else if ( c == 'b' ) {
155: for ( i = 0; i < 32; i++ )
156: nbuf[i] = '0';
1.2 noro 157: READ_ALNUM_NBUF
158: Ungetc(c); REALLOC_NBUF nbuf[i] = 0;
1.1 noro 159: binaryton(nbuf,&n1);
160: NTOQ(n1,1,q); r = (Obj)q;
161: yylvalp->p = (pointer)r;
162: return ( FORMULA );
163: } else if ( !isdigit(c) ) {
164: yylvalp->p = 0; Ungetc(c);
165: return ( FORMULA );
166: }
167: break;
168: case '\'' :
169: for ( i = 0; ; i++ ) {
170: c = Getc();
171: if ( c == '\'' )
172: break;
173: if ( c == '\\' )
174: c = Getc();
1.2 noro 175: REALLOC_TBUF tbuf[i] = c;
1.1 noro 176: }
1.2 noro 177: REALLOC_TBUF tbuf[i] = 0;
1.1 noro 178: cptr = (char *)MALLOC(strlen(tbuf)+1); strcpy(cptr,tbuf);
179: yylvalp->p = (pointer)cptr;
180: return LCASE; break;
181: case '"' :
182: i = 0;
183: do {
184: c = Getc();
185: if ( c == '\\' ) {
186: c1 = Getc();
187: if ( c1 == 'n' )
188: c1 = '\n';
1.2 noro 189: REALLOC_NBUF nbuf[i++] = c1;
190: } else {
191: REALLOC_NBUF nbuf[i++] = c;
192: }
1.1 noro 193: } while ( c != '"' );
1.2 noro 194: nbuf[i-1] = 0; /* REALLOC_NBUF is not necessary */
1.1 noro 195: cptr = (char *)MALLOC(strlen(nbuf)+1);
196: strcpy(cptr,nbuf); yylvalp->p = (pointer) cptr;
197: return ( STR ); break;
198: case '>': case '<': case '=': case '!':
199: if ( (c1 = Getc()) == '=' )
200: switch ( c ) {
201: case '>': yylvalp->i = (int)C_GE; break;
202: case '<': yylvalp->i = (int)C_LE; break;
203: case '=': yylvalp->i = (int)C_EQ; break;
204: case '!': yylvalp->i = (int)C_NE; break;
205: default: break;
206: }
207: else if ( (c == '<' && c1 == '<') || (c == '>' && c1 == '>') )
208: return c;
209: else {
210: Ungetc(c1);
211: switch ( c ) {
212: case '>': yylvalp->i = (int)C_GT; break;
213: case '<': yylvalp->i = (int)C_LT; break;
214: default: return c; break;
215: }
216: }
217: return CMP; break;
218: case '+': case '-': case '*': case '/': case '%': case '^':
219: case '|': case '&':
220: switch ( c ) {
221: case '+': yylvalp->p = (pointer)addfs; break;
222: case '-': yylvalp->p = (pointer)subfs; break;
223: case '*': yylvalp->p = (pointer)mulfs; break;
224: case '/': yylvalp->p = (pointer)divfs; break;
225: case '%': yylvalp->p = (pointer)remfs; break;
226: case '^': yylvalp->p = (pointer)pwrfs; break;
227: default: break;
228: }
229: if ( (c1 = Getc()) == c )
230: switch ( c ) {
231: case '+': case '-': return SELF; break;
232: case '|': return OR; break;
233: case '&': return AND; break;
234: default: Ungetc(c1); return c; break;
235: }
236: else if ( c1 == '=' )
237: return BOPASS;
238: else if ( (c == '-') && (c1 == '>') )
239: return POINT;
240: else {
241: Ungetc(c1); return c;
242: }
243: break;
244: default :
245: break;
246: }
247: if ( isdigit(c) ) {
248: for ( i = 0; i < DLENGTH; i++ )
249: nbuf[i] = '0';
1.2 noro 250: REALLOC_NBUF nbuf[i++] = c;
251: READ_DIGIT_NBUF
1.1 noro 252: if ( c == '.' ) {
253: double dbl;
254: Real real;
255: double atof();
256: extern int bigfloat;
257:
1.2 noro 258: REALLOC_NBUF nbuf[i++] = c;
259: READ_DIGIT_NBUF
1.1 noro 260: if ( c == 'e' ) {
1.2 noro 261: REALLOC_NBUF nbuf[i++] = c;
262: c = Getc();
263: if ( (c == '+') || (c == '-') ) {
264: REALLOC_NBUF nbuf[i++] = c;
265: } else
266: Ungetc(c);
267: READ_DIGIT_NBUF
1.1 noro 268: }
1.2 noro 269: Ungetc(c); REALLOC_NBUF nbuf[i] = 0;
1.1 noro 270: #if PARI
271: if ( !bigfloat ) {
272: dbl = (double)atof(nbuf+DLENGTH);
273: MKReal(dbl,real); r = (Obj)real;
274: } else
275: strtobf(nbuf,(BF *)&r);
276: #else
277: dbl = (double)atof(nbuf+DLENGTH);
278: MKReal(dbl,real); r = (Obj)real;
279: #endif
280: } else {
281: Ungetc(c);
282: i -= DLENGTH; d = (i%DLENGTH?i/DLENGTH+1:i/DLENGTH);
283: n = NALLOC(d); PL(n) = d;
284: for ( j = 0, ptr = BD(n); j < d; j++ ,i -= DLENGTH )
285: ptr[j] = myatoi(nbuf+i);
286: bnton(DBASE,n,&n1);
287: NTOQ(n1,1,q); r = (Obj)q;
288: /* optobj(&r); */
289: }
290: yylvalp->p = (pointer)r;
291: return ( FORMULA );
292: } else if ( isalpha(c) ) {
1.2 noro 293: i = 0;
294: tbuf[i++] = c;
295: while ( 1 ) {
296: c = Getc();
297: if ( isalpha(c)||isdigit(c)||(c=='_') ) {
298: REALLOC_TBUF tbuf[i++] = c;
299: } else
300: break;
301: }
302: REALLOC_TBUF tbuf[i] = 0; Ungetc(c);
1.1 noro 303: if ( isupper(tbuf[0]) ) {
304: cptr = (char *)MALLOC(strlen(tbuf)+1); strcpy(cptr,tbuf);
305: yylvalp->p = (pointer)cptr;
306: return UCASE;
307: } else {
308: for ( i = 0; kwd[i].name && strcmp(tbuf,kwd[i].name); i++ );
309: if ( kwd[i].name ) {
310: yylvalp->i = asir_infile->ln;
311: return kwd[i].token;
312: } else {
313: cptr = (char *)MALLOC(strlen(tbuf)+1); strcpy(cptr,tbuf);
314: yylvalp->p = (pointer)cptr;
315: return LCASE;
316: }
317: }
318: } else if ( c == '@' ) {
319: if ( isdigit(c = Getc()) ) {
1.2 noro 320: i = 0;
321: nbuf[i++] = c;
322: READ_DIGIT_NBUF
323: Ungetc(c); REALLOC_NBUF nbuf[i] = 0;
324: yylvalp->i = atoi(nbuf);
1.1 noro 325: return ANS;
326: } else if ( c == '@' ) {
327: yylvalp->i = MAX(0,APVS->n-1);
328: return ANS;
329: } else if ( c == '>' || c == '<' || c == '=' || c == '!' ) {
330: if ( (c1 = Getc()) == '=' )
331: switch ( c ) {
332: case '>': yylvalp->i = (int)L_GE; break;
333: case '<': yylvalp->i = (int)L_LE; break;
334: case '=': yylvalp->i = (int)L_EQ; break;
335: case '!': yylvalp->i = (int)L_NE; break;
336: default: break;
337: }
338: else {
339: Ungetc(c1);
340: switch ( c ) {
341: case '>': yylvalp->i = (int)L_GT; break;
342: case '<': yylvalp->i = (int)L_LT; break;
343: case '=': yylvalp->i = (int)L_EQ; break;
344: case '!': yylvalp->i = (int)L_NOT; return FOP_NOT; break;
345: default: break;
346: }
347: }
348: return LOP;
349: } else if ( c == '|' || c == '&' ) {
350: if ( (c1 = Getc()) != c )
351: Ungetc(c1);
352: switch ( c ) {
353: case '|': yylvalp->i = (int)L_OR;
354: return FOP_OR; break;
355: case '&': yylvalp->i = (int)L_AND;
356: return FOP_AND; break;
357: }
358: } else if ( isalpha(c) ) {
1.2 noro 359: i = 0;
360: tbuf[i++] = '@';
361: tbuf[i++] = c;
362: while ( 1 ) {
363: c = Getc();
364: if ( isalpha(c) ) {
365: REALLOC_TBUF tbuf[i++] = c;
366: } else
367: break;
368: }
369: Ungetc(c); REALLOC_TBUF tbuf[i] = 0;
1.1 noro 370: if ( !strcmp(tbuf,"@p") )
371: return GFPNGEN;
1.17 ! noro 372: else if ( !strcmp(tbuf,"@s") )
! 373: return GFSNGEN;
1.1 noro 374: else if ( !strcmp(tbuf,"@i") ) {
375: extern pointer IU;
376:
377: yylvalp->p = IU;
378: return FORMULA;
379: } else if ( !strcmp(tbuf,"@true") ) {
380: yylvalp->p = F_TRUE;
381: return FORMULA;
382: } else if ( !strcmp(tbuf,"@false") ) {
383: yylvalp->p = F_FALSE;
384: return FORMULA;
385: } else if ( !strcmp(tbuf,"@impl") ) {
386: yylvalp->i = (int)L_IMPL;
387: return FOP_IMPL;
388: } else if ( !strcmp(tbuf,"@repl") ) {
389: yylvalp->i = (int)L_REPL;
390: return FOP_REPL;
391: } else if ( !strcmp(tbuf,"@equiv") ) {
392: yylvalp->i = (int)L_EQUIV;
393: return FOP_EQUIV;
394: } else {
395: cptr = (char *)MALLOC(strlen(tbuf)+1); strcpy(cptr,tbuf);
396: yylvalp->p = (pointer)cptr;
397: return LCASE;
398: }
399: } else {
400: Ungetc(c);
401: return GF2NGEN;
402: }
403: } else
404: return ( c );
1.6 noro 405: }
406:
407: void purge_stdin()
408: {
1.7 noro 409: #if defined(__FreeBSD__)
1.6 noro 410: fpurge(stdin);
411: #elif defined(linux)
412: stdin->_IO_read_end = stdin->_IO_read_base;
413: stdin->_IO_read_ptr = stdin->_IO_read_base;
1.10 noro 414: #elif defined(VISUAL_LIB)
415: w_purge_stdin();
1.16 noro 416: #elif defined(sparc) || defined(__alpha) || defined(__SVR4) || defined(mips) || defined(VISUAL) || defined(_IBMR2)
1.6 noro 417: stdin->_ptr = stdin->_base; stdin->_cnt = 0;
1.15 noro 418: #elif defined(__MACH__) && defined(__ppc__)
419: stdin->_r = 0; stdin->_p = stdin->_bf._base;
1.6 noro 420: #else
421: --->FIXIT
422: #endif
1.1 noro 423: }
424:
425: static int skipspace() {
426: int c,c1;
427:
428: for ( c = Getc(); ; )
429: switch ( c ) {
1.14 noro 430: case ' ': case '\t': case '\r':
1.1 noro 431: c = Getc(); break;
432: case '\n':
433: c = afternl(); break;
434: case '/':
435: if ( (c1 = Getc()) == '*' )
436: c = aftercomment();
437: else {
438: Ungetc(c1); return c;
439: }
440: break;
441: default:
442: return c; break;
443: }
444: }
445:
446: int afternl() {
447: int c,ac,i,quote;
448: char *ptr;
449: char *av[BUFSIZ];
450: static int ilevel = 0;
451: char buf[BUFSIZ];
452:
453: if ( !ilevel )
454: asir_infile->ln++;
455: while ( (c = Getc()) == '#' ) {
456: Gets(buf);
457: for ( quote = 0, ptr = buf; *ptr; ptr++ )
458: if ( *ptr == '"' )
459: quote = quote ? 0 : 1;
460: else if ( quote && (*ptr == ' ') )
461: *ptr = '_';
462: stoarg(buf,&ac,av);
463: if ( ac == 3 )
464: if ( (i = atoi(av[2])) == 1 )
465: ilevel++;
466: else if ( i == 2 )
467: ilevel--;
468: if ( !ilevel )
469: asir_infile->ln = atoi(av[0]);
470: }
471: return c;
472: }
473:
474: int aftercomment() {
475: int c,c1;
476:
477: for ( c = Getc(); ; ) {
478: c1 = Getc();
479: if ( (c == '*') && (c1 == '/') )
480: return Getc();
481: else
482: c = c1;
483: }
484: }
485:
486: int myatoi(s)
487: char *s;
488: {
489: int i,r;
490: for ( i = 0, r = 0; i < DLENGTH; i++ ) r = r * 10 + ( s[i] - '0' );
491: return ( r );
492: }
493:
494: extern int ox_do_copy;
495:
496: void yyerror(s)
497: char *s;
498: {
499: if ( main_parser )
500: if ( ox_do_copy ) {
501: /* push errors to DebugStack */
502: } else {
503: if ( asir_infile->fp == stdin )
504: fprintf(stderr,"%s\n",s);
505: else
506: fprintf(stderr,"\"%s\", near line %d: %s\n",asir_infile->name,asir_infile->ln,s);
507: }
508: else
509: fprintf(stderr,"exprparse : %s\n",s);
510: }
511:
512: int echoback;
513:
514: extern int read_exec_file, do_fep, do_file;
515:
516: int readline_getc();
517: void readline_ungetc();
518: int Egetc();
519: void Eungetc();
520:
521: unsigned char encrypt_char(unsigned char);
522: unsigned char decrypt_char(unsigned char);
523:
524: int Egetc(fp)
525: FILE *fp;
526: {
527: int c;
528:
529: if ( fp ) {
1.13 noro 530: #if FEP
531: if ( do_fep && isatty(fileno(fp)) )
532: c = readline_getc();
533: else
534: #endif
535: c = getc(fp);
1.11 noro 536: #if defined(VISUAL)
537: if ( recv_intr ) {
538: #include <signal.h>
539: if ( recv_intr == 1 ) {
540: recv_intr = 0;
541: int_handler(SIGINT);
542: } else {
543: recv_intr = 0;
544: ox_usr1_handler(0);
545: }
546: }
547: #endif
1.1 noro 548: if ( c == EOF )
549: return c;
550: if ( asir_infile->encoded )
551: c = decrypt_char((unsigned char)c);
552: return c;
1.3 noro 553: } else if ( read_exec_file )
554: return EOF;
555: else {
1.1 noro 556: c = *parse_strp++;
557: if ( !c )
558: return EOF;
559: else
560: return c;
561: }
562: }
563:
564: void Eungetc(c,fp)
565: int c;
566: FILE *fp;
567: {
568: if ( fp ) {
569: if ( asir_infile->encoded )
570: c = (int)encrypt_char((unsigned char)c);
1.13 noro 571: #if FEP
572: if ( do_fep && isatty(fileno(fp)) )
573: readline_ungetc();
574: else
575: #endif
576: ungetc(c,fp);
1.1 noro 577: } else
578: *--parse_strp = c;
579: }
580:
581: static int Getc() {
582: int c;
583:
584: if ( main_parser ) {
585: while ( 1 ) {
586: if ((c = Egetc(asir_infile->fp)) == EOF)
587: if ( NEXT(asir_infile) ) {
588: closecurrentinput();
1.9 noro 589: /* if the input is the top level, generate error */
590: if ( !NEXT(asir_infile) )
591: error("end-of-file detected during parsing");
592: else
593: c = Getc();
1.1 noro 594: break;
595: } else if ( read_exec_file || do_file )
596: asir_terminate(2);
597: else {
598: if ( asir_infile->fp )
599: clearerr(asir_infile->fp);
600: }
601: else
602: break;
603: }
604: if ( echoback )
605: fputc(c,asir_out);
606: } else
607: c = *parse_strp++;
608: return ( c );
609: }
610:
611: static void Ungetc(c) {
612: if ( main_parser ) {
613: Eungetc(c,asir_infile->fp);
614: if ( echoback )
615: fputc('',asir_out);
616: } else
617: *--parse_strp = c;
618: }
619:
620: static void Gets(s)
621: char *s;
622: {
623: int c;
624:
625: while ( (c = Getc()) != '\n' )
626: *s++ = c;
627: *s = 0;
628: }
1.12 saito 629:
630: #if FEP
631:
632: static char *readline_line;
633: static int readline_nc,readline_index;
634: char *readline_console();
635:
636: int readline_getc()
637: {
638: char buf[BUFSIZ];
639:
640: if ( !readline_nc ) {
641: if ( readline_line )
642: free(readline_line);
643: sprompt(buf);
644: readline_line = readline_console(buf);
645: readline_nc = strlen(readline_line);
646: readline_index = 0;
647: }
648: readline_nc--;
649: return readline_line[readline_index++];
650: }
651:
652: void readline_ungetc()
653: {
654: readline_nc++; readline_index--;
655: }
656:
657: char *readline_console(prompt)
658: char *prompt;
659: {
660: char *line;
661: int exp_result;
662: char *expansion;
663:
664: while ( 1 ) {
665: line = (char *)readline(prompt);
666: if ( line && *line ) {
667: using_history();
668: exp_result = history_expand(line,&expansion);
669: if ( !exp_result ) {
670: free(expansion);
671: for ( ; isspace(*line); line++ );
672: add_history(line);
673: break;
674: } else if ( exp_result > 0 ) {
675: free(line);
676: line = expansion;
677: break;
678: }
679: }
680: }
681: return line;
682: }
683: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>