1/* 2 * Copyright (c) 1987, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint
|
36#endif /* not lint */ 37 38#include <ctype.h> 39#include <limits.h> 40#include <stdio.h> 41#include <string.h> 42 43#include "ctags.h" 44 45static void takeprec __P((void)); 46 47char *lbp; /* line buffer pointer */ 48 49int 50PF_funcs() 51{ 52 bool pfcnt; /* pascal/fortran functions found */ 53 char *cp; 54 char tok[MAXTOKEN]; 55 56 for (pfcnt = NO;;) { 57 lineftell = ftell(inf); 58 if (!fgets(lbuf, sizeof(lbuf), inf)) 59 return (pfcnt); 60 ++lineno; 61 lbp = lbuf; 62 if (*lbp == '%') /* Ratfor escape to fortran */ 63 ++lbp; 64 for (; isspace(*lbp); ++lbp) 65 continue; 66 if (!*lbp) 67 continue; 68 switch (*lbp | ' ') { /* convert to lower-case */ 69 case 'c': 70 if (cicmp("complex") || cicmp("character")) 71 takeprec(); 72 break; 73 case 'd': 74 if (cicmp("double")) { 75 for (; isspace(*lbp); ++lbp) 76 continue; 77 if (!*lbp) 78 continue; 79 if (cicmp("precision")) 80 break; 81 continue; 82 } 83 break; 84 case 'i': 85 if (cicmp("integer")) 86 takeprec(); 87 break; 88 case 'l': 89 if (cicmp("logical")) 90 takeprec(); 91 break; 92 case 'r': 93 if (cicmp("real")) 94 takeprec(); 95 break; 96 } 97 for (; isspace(*lbp); ++lbp) 98 continue; 99 if (!*lbp) 100 continue; 101 switch (*lbp | ' ') { 102 case 'f': 103 if (cicmp("function")) 104 break; 105 continue; 106 case 'p': 107 if (cicmp("program") || cicmp("procedure")) 108 break; 109 continue; 110 case 's': 111 if (cicmp("subroutine")) 112 break; 113 default: 114 continue; 115 } 116 for (; isspace(*lbp); ++lbp) 117 continue; 118 if (!*lbp) 119 continue; 120 for (cp = lbp + 1; *cp && intoken(*cp); ++cp) 121 continue; 122 if ((cp = lbp + 1)) 123 continue; 124 *cp = EOS; 125 (void)strcpy(tok, lbp); 126 getline(); /* process line for ex(1) */ 127 pfnote(tok, lineno); 128 pfcnt = YES; 129 } 130 /*NOTREACHED*/ 131} 132 133/* 134 * cicmp -- 135 * do case-independent strcmp 136 */ 137int 138cicmp(cp) 139 char *cp; 140{ 141 int len; 142 char *bp; 143 144 for (len = 0, bp = lbp; *cp && (*cp &~ ' ') == (*bp++ &~ ' '); 145 ++cp, ++len) 146 continue; 147 if (!*cp) { 148 lbp += len; 149 return (YES); 150 } 151 return (NO); 152} 153 154static void 155takeprec() 156{ 157 for (; isspace(*lbp); ++lbp) 158 continue; 159 if (*lbp == '*') { 160 for (++lbp; isspace(*lbp); ++lbp) 161 continue; 162 if (!isdigit(*lbp)) 163 --lbp; /* force failure */ 164 else 165 while (isdigit(*++lbp)) 166 continue; 167 } 168}
|