Added -clobber switch to mhstore(1) [Bug #11160].
[mmh] / docs / historical / mh-6.8.5 / zotnet / tws / RCS / lexstring.c,v
1 head    1.5;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.5
9 date    92.12.15.00.20.22;      author jromine; state Exp;
10 branches;
11 next    1.4;
12
13 1.4
14 date    90.04.05.15.05.05;      author sources; state Exp;
15 branches;
16 next    1.3;
17
18 1.3
19 date    90.02.23.11.14.31;      author sources; state Exp;
20 branches;
21 next    1.2;
22
23 1.2
24 date    90.02.01.14.45.29;      author sources; state Exp;
25 branches;
26 next    1.1;
27
28 1.1
29 date    90.02.01.14.45.07;      author sources; state Exp;
30 branches
31         1.1.1.1;
32 next    ;
33
34 1.1.1.1
35 date    90.02.23.10.43.44;      author sources; state Exp;
36 branches;
37 next    ;
38
39
40 desc
41 @@
42
43
44 1.5
45 log
46 @endif sugar
47 @
48 text
49 @#include <stdio.h>
50 #include <ctype.h>
51 #ifndef lint
52 static char ident[] = "@@(#)$Id: lexstring.c,v 1.4 1990/04/05 15:05:05 sources Exp jromine $";
53 #endif  /* lint */
54
55 #define YYLERR yysvec
56 #define YYTYPE int
57 #define YYLMAX 256
58
59 struct yysvf { 
60 #ifndef hpux
61         struct yywork *yystoff;
62 #else   /* hpux */
63         int yystoff;
64 #endif  /* hpux */
65         struct yysvf *yyother;
66         int *yystops;
67 };
68
69 struct yywork { 
70         YYTYPE  verify;
71         YYTYPE  advance; 
72 }; 
73
74 extern int yyvstop[];
75 extern struct yywork yycrank[];
76 extern struct yysvf yysvec[];
77 extern char yymatch[];
78 extern char yyextra[];
79
80 #ifdef LEXDEBUG
81 static int debug = 0;
82 #endif  /* LEXDEBUG */
83
84 #ifdef ONECASE
85 static char case_map[] = {
86      0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
87     10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
88     20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
89     30,  31,  32,  33,  34,  35,  36,  37,  38,  39,
90     40,  41,  42,  43,  44,  45,  46,  47,  48,  49,
91     50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
92     60,  61,  62,  63,  64,  97,  98,  99, 100, 101,
93    102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
94    112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
95    122,  91,  92,  93,  94,  95,  96,  97,  98,  99,
96    100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
97    110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
98    120, 121, 122, 123, 124, 125, 126, 127,
99    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
100    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
101    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
102    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
103    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
104    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
105    0, 0, 0, 0, 0, 0, 0, 0
106 };
107 #endif  /* ONECASE */
108
109 lex_string( strptr, start_cond)
110         char    **strptr;
111         int     start_cond;
112 {
113         register struct yysvf *state, **lsp;
114         register struct yywork *tran;
115         register int statenum;
116         register int ch;
117         register char   *cp = *strptr;
118         register int    *found;
119         struct  yysvf *yylstate[YYLMAX];
120
121         /* start off machines */
122         lsp = yylstate;
123         statenum = 1 + start_cond;
124         state = yysvec + statenum;
125         for (;;){
126 # ifdef LEXDEBUG
127                 if (debug) {
128                         fprintf(stderr,"%d ",statenum - 1);
129                 }
130 # endif
131 #ifndef hpux
132                 tran = state->yystoff;
133 #else   /* hpux */
134                 tran = &yycrank[state->yystoff];
135 #endif  /* hpux */
136                 if(tran == yycrank)
137                         /* may not be any transitions */
138                         if (state->yyother == 0 ||
139 #ifndef hpux
140                             state->yyother->yystoff == yycrank)
141 #else   /* hpux */
142                             state->yyother->yystoff == 0)
143 #endif  /* hpux */
144                                 break;
145
146 #ifdef ONECASE
147                 ch = case_map[*cp++];
148 #else   /*  not ONECASE */
149                 ch = *cp++;
150 #endif  /* ONECASE */
151 # ifdef LEXDEBUG
152                 if (debug) {
153                         fprintf(stderr,"(");
154                         allprint(ch);
155                         fprintf(stderr, ")");
156                 }
157 # endif
158 tryagain:
159 #ifndef hpux
160                 if ( tran > yycrank){
161 #else   /* hpux */
162                 if ( (int)tran > (int)yycrank){
163 #endif  /* hpux */
164                         tran += ch;
165                         if (tran->verify == statenum){
166                                 if ((statenum = tran->advance) == 0){
167                                         /* error transitions */
168                                         --cp;
169                                         break;
170                                 }
171                                 state = statenum + yysvec;
172                                 *lsp++ = state;
173                                 goto contin;
174                         }
175
176 #ifndef hpux
177                 } else if(tran < yycrank) {
178 #else   /* hpux */
179                 } else if( (int)tran < (int)yycrank) {
180 #endif  /* hpux */
181                         tran = yycrank+(yycrank-tran) + ch;
182 # ifdef LEXDEBUG
183                         if (debug) {
184                                 fprintf(stderr," compressed");
185                         }
186 # endif
187                         if (tran->verify == statenum){
188                                 if ((statenum = tran->advance) == 0)
189                                         /* error transitions */
190                                         break;
191
192                                 state = statenum + yysvec;
193                                 *lsp++ = state;
194                                 goto contin;
195                         }
196                         tran += (yymatch[ch] - ch);
197 # ifdef LEXDEBUG
198                         if (debug) {
199                                 fprintf(stderr,"(fb ");
200                                 allprint(yymatch[ch]);
201                                 fprintf(stderr,")");
202                         }
203 # endif
204                         if (tran->verify == statenum){
205                                 if((statenum = tran->advance) == 0)
206                                         /* error transition */
207                                         break;
208
209                                 state = statenum + yysvec;
210                                 *lsp++ = state;
211                                 goto contin;
212                         }
213                 }
214                 if ((state = state->yyother) &&
215 #ifndef hpux
216                     (tran = state->yystoff) != yycrank){
217 #else   /* hpux */
218                     (tran = &yycrank[state->yystoff]) != yycrank){
219 #endif  /* hpux */
220                         statenum = state - yysvec;
221 # ifdef LEXDEBUG
222                         if (debug) {
223                                 fprintf(stderr,"fb %d", statenum - 1);
224                         }
225 # endif
226                         goto tryagain;
227                 } else
228                         break;
229
230 contin:
231 # ifdef LEXDEBUG
232                 if (debug) {
233                         fprintf(stderr,">");
234                 }
235 # endif
236                 ;
237         }
238 # ifdef LEXDEBUG
239         if (debug) {
240                 fprintf(stderr,"\nStopped in state %d (",*(lsp-1)-yysvec-1);
241                 allprint(ch);
242                 fprintf(stderr, ") ");
243         }
244 # endif
245         while (lsp-- > yylstate){
246                 if (*lsp != 0 && (found= (*lsp)->yystops) && *found > 0){
247                         if(yyextra[*found]){
248                                 /* must backup */
249                                 ch = -*found;
250                                 do {
251                                         while (*found && *found++ != ch)
252                                                 ;
253                                  } while (lsp > yylstate &&
254                                           (found = (*--lsp)->yystops));
255                         }
256 # ifdef LEXDEBUG
257                         if (debug) {
258                                 fprintf(stderr," Match \"");
259                                 for ( cp = *strptr;
260                                       cp <= ((*strptr)+(lsp-yylstate));
261                                       cp++)
262                                         allprint( *cp );
263                                 fprintf(stderr,"\" action %d\n",*found);
264                         }
265 # endif
266                         *strptr += (lsp - yylstate + 1);
267                         return(*found);
268                 }
269         }
270         /* the string didn't match anything - if we're looking at
271          * eos, just return 0.  Otherwise, bump the string pointer
272          * and return -1.
273          */
274 # ifdef LEXDEBUG
275         if (debug) {
276                 fprintf(stderr," No match\n");
277         }
278 #endif  /* LEXDEBUG */
279         if ( **strptr ) {
280                 (*strptr)++;
281                 return (-1);
282         }
283         return (0);
284 }
285
286 #ifdef LEXDEBUG
287 allprint(c)
288         char c;
289 {
290         if ( c < 32 ) {
291             putc( '^', stderr );
292             c += 32;
293         } else if ( c == 127 ) {
294             putc( '^', stderr );
295             c = '?';
296         }
297         putc( c, stderr );
298 }
299 #endif  /* LEXDEBUG */
300 @
301
302
303 1.4
304 log
305 @add ID
306 @
307 text
308 @d4 2
309 a5 2
310 static char ident[] = "@@(#)$Id:$";
311 #endif  lint
312 d14 1
313 a14 1
314 #else hpux
315 d16 1
316 a16 1
317 #endif hpux
318 d34 1
319 a34 1
320 #endif LEXDEBUG
321 d59 1
322 a59 1
323 #endif ONECASE
324 d85 1
325 a85 1
326 #else hpux
327 d87 1
328 a87 1
329 #endif hpux
330 d93 1
331 a93 1
332 #else hpux
333 d95 1
334 a95 1
335 #endif hpux
336 d100 1
337 a100 1
338 #else  not ONECASE
339 d102 1
340 a102 1
341 #endif ONECASE
342 d113 1
343 a113 1
344 #else hpux
345 d115 1
346 a115 1
347 #endif hpux
348 d130 1
349 a130 1
350 #else hpux
351 d132 1
352 a132 1
353 #endif hpux
354 d169 1
355 a169 1
356 #else hpux
357 d171 1
358 a171 1
359 #endif hpux
360 d230 1
361 a230 1
362 #endif LEXDEBUG
363 d251 1
364 a251 1
365 #endif LEXDEBUG
366 @
367
368
369 1.3
370 log
371 @merged VJ and HPUX changes
372 @
373 text
374 @d3 3
375 @
376
377
378 1.2
379 log
380 @hpux patches
381 @
382 text
383 @a25 1
384 extern struct yywork *yytop;
385 d33 25
386 d64 1
387 d72 2
388 a73 1
389         state = yysvec+1+start_cond;
390 d76 3
391 a78 2
392                 if(debug)
393                         fprintf(stderr,"state %d\n",state-yysvec-1);
394 d95 3
395 a98 3
396 #ifdef ONECASE
397                 if (isupper(ch) )
398                         ch = tolower(ch);
399 a99 1
400 tryagain:
401 d101 2
402 a102 2
403                 if(debug){
404                         fprintf(stderr,"char ");
405 d104 1
406 a104 1
407                         putchar('\n');
408 d107 1
409 d114 2
410 a115 2
411                         if (tran <= yytop && tran->verify+yysvec == state){
412                                 if ((state = tran->advance+yysvec) == YYLERR){
413 d120 1
414 a129 1
415                         /* r < yycrank */
416 d132 3
417 a134 2
418                         if (debug)
419                                 fprintf(stderr,"compressed state\n");
420 d136 2
421 a137 2
422                         if(tran <= yytop && tran->verify+yysvec == state){
423                                 if ((state = tran->advance+yysvec) == YYLERR)
424 d141 1
425 d147 2
426 a148 2
427                         if(debug){
428                                 fprintf(stderr,"try fall back character ");
429 d150 1
430 a150 1
431                                 putchar('\n');
432 d153 2
433 a154 2
434                         if(tran <= yytop && tran->verify+yysvec == state){
435                                 if(tran->advance+yysvec == YYLERR)
436 d158 2
437 a159 1
438                                 *lsp++ = state = tran->advance+yysvec;
439 d169 1
440 d171 3
441 a173 3
442                         if(debug)
443                                 fprintf(stderr,"fall back to state %d\n",
444                                         state-yysvec-1);
445 d181 2
446 a182 4
447                 if(debug){
448                         fprintf(stderr,"state %d char ",state-yysvec-1);
449                         allprint(ch);
450                         putchar('\n');
451 d188 2
452 a189 2
453         if(debug){
454                 fprintf(stderr,"stopped at %d with ",*(lsp-1)-yysvec-1);
455 d191 1
456 a191 1
457                 putchar('\n');
458 d206 2
459 a207 2
460                         if(debug){
461                                 fprintf(stderr,"\nmatch ");
462 d212 1
463 a212 1
464                                 fprintf(stderr," action %d\n",*found);
465 d224 3
466 a226 2
467         if(debug)
468                 fprintf(stderr,"\nno match\n");
469 @
470
471
472 1.1
473 log
474 @Initial revision
475 @
476 text
477 @d9 1
478 d11 3
479 d53 1
480 d55 3
481 d61 1
482 d63 3
483 d81 1
484 d83 3
485 d97 1
486 d99 3
487 d134 1
488 d136 3
489 @
490
491
492 1.1.1.1
493 log
494 @Fixes from Van Jacobson
495 @
496 text
497 @d22 1
498 a29 25
499 #ifdef ONECASE
500 static char case_map[] = {
501      0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
502     10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
503     20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
504     30,  31,  32,  33,  34,  35,  36,  37,  38,  39,
505     40,  41,  42,  43,  44,  45,  46,  47,  48,  49,
506     50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
507     60,  61,  62,  63,  64,  97,  98,  99, 100, 101,
508    102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
509    112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
510    122,  91,  92,  93,  94,  95,  96,  97,  98,  99,
511    100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
512    110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
513    120, 121, 122, 123, 124, 125, 126, 127,
514    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
515    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
516    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
517    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
518    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
519    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
520    0, 0, 0, 0, 0, 0, 0, 0
521 };
522 #endif ONECASE
523
524 a35 1
525         register int statenum;
526 d43 1
527 a43 2
528         statenum = 1 + start_cond;
529         state = yysvec + statenum;
530 d46 2
531 a47 3
532                 if (debug) {
533                         fprintf(stderr,"%d ",statenum - 1);
534                 }
535 d56 1
536 d58 2
537 a59 3
538                 ch = case_map[*cp++];
539 #else  not ONECASE
540                 ch = *cp++;
541 d61 1
542 d63 2
543 a64 2
544                 if (debug) {
545                         fprintf(stderr,"(");
546 d66 1
547 a66 1
548                         fprintf(stderr, ")");
549 a68 1
550 tryagain:
551 d71 2
552 a72 2
553                         if (tran->verify == statenum){
554                                 if ((statenum = tran->advance) == 0){
555 a76 1
556                                 state = statenum + yysvec;
557 d82 1
558 d85 2
559 a86 3
560                         if (debug) {
561                                 fprintf(stderr," compressed");
562                         }
563 d88 2
564 a89 2
565                         if (tran->verify == statenum){
566                                 if ((statenum = tran->advance) == 0)
567 a92 1
568                                 state = statenum + yysvec;
569 d98 2
570 a99 2
571                         if (debug) {
572                                 fprintf(stderr,"(fb ");
573 d101 1
574 a101 1
575                                 fprintf(stderr,")");
576 d104 2
577 a105 2
578                         if (tran->verify == statenum){
579                                 if((statenum = tran->advance) == 0)
580 d109 1
581 a109 2
582                                 state = statenum + yysvec;
583                                 *lsp++ = state;
584 a114 1
585                         statenum = state - yysvec;
586 d116 3
587 a118 3
588                         if (debug) {
589                                 fprintf(stderr,"fb %d", statenum - 1);
590                         }
591 d126 4
592 a129 2
593                 if (debug) {
594                         fprintf(stderr,">");
595 d135 2
596 a136 2
597         if (debug) {
598                 fprintf(stderr,"\nStopped in state %d (",*(lsp-1)-yysvec-1);
599 d138 1
600 a138 1
601                 fprintf(stderr, ") ");
602 d153 2
603 a154 2
604                         if (debug) {
605                                 fprintf(stderr," Match \"");
606 d159 1
607 a159 1
608                                 fprintf(stderr,"\" action %d\n",*found);
609 d171 2
610 a172 3
611         if (debug) {
612                 fprintf(stderr," No match\n");
613         }
614 @