📄 fini.c
字号:
/* fini.c Copyright (C) 1995 Free Software Foundation, Inc. Contributed by James Craig Burley.This file is part of GNU Fortran.GNU Fortran is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Fortran is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Fortran; see the file COPYING. If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA02111-1307, USA. */#define USE_HCONFIG#include "proj.h"#include "malloc.h"#undef MAXNAMELEN#define MAXNAMELEN 100typedef struct _name_ *name;struct _name_ { name next; name previous; name next_alpha; name previous_alpha; int namelen; int kwlen; char kwname[MAXNAMELEN]; char name_uc[MAXNAMELEN]; char name_lc[MAXNAMELEN]; char name_ic[MAXNAMELEN]; };struct _name_root_ { name first; name last; };struct _name_alpha_ { name ign1; name ign2; name first; name last; };static FILE *in;static FILE *out;static char prefix[32];static char postfix[32];static char storage[32];static const char *xspaces[]={ "", /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ "\t", /* 8 */ "\t ", /* 9 */ "\t ", /* 10 */ "\t ", /* 11 */ "\t ", /* 12 */ "\t ", /* 13 */ "\t ", /* 14 */ "\t ", /* 15 */ "\t\t", /* 16 */ "\t\t ", /* 17 */ "\t\t ", /* 18 */ "\t\t ", /* 19 */ "\t\t ", /* 20 */ "\t\t ", /* 21 */ "\t\t ", /* 22 */ "\t\t ", /* 23 */ "\t\t\t", /* 24 */ "\t\t\t ", /* 25 */ "\t\t\t ", /* 26 */ "\t\t\t ", /* 27 */ "\t\t\t ", /* 28 */ "\t\t\t ", /* 29 */ "\t\t\t ", /* 30 */ "\t\t\t ", /* 31 */ "\t\t\t\t", /* 32 */ "\t\t\t\t ", /* 33 */ "\t\t\t\t ", /* 34 */ "\t\t\t\t ", /* 35 */ "\t\t\t\t ", /* 36 */ "\t\t\t\t ", /* 37 */ "\t\t\t\t ", /* 38 */ "\t\t\t\t ", /* 39 */ "\t\t\t\t\t", /* 40 */ "\t\t\t\t\t ", /* 41 */ "\t\t\t\t\t ", /* 42 */ "\t\t\t\t\t ", /* 43 */ "\t\t\t\t\t ", /* 44 */ "\t\t\t\t\t ", /* 45 */ "\t\t\t\t\t ", /* 46 */ "\t\t\t\t\t ", /* 47 */ "\t\t\t\t\t\t", /* 48 */ "\t\t\t\t\t\t ", /* 49 */ "\t\t\t\t\t\t ", /* 50 */ "\t\t\t\t\t\t ", /* 51 */ "\t\t\t\t\t\t ", /* 52 */ "\t\t\t\t\t\t ", /* 53 */ "\t\t\t\t\t\t ", /* 54 */ "\t\t\t\t\t\t ", /* 55 */ "\t\t\t\t\t\t\t", /* 56 */ "\t\t\t\t\t\t\t ", /* 57 */ "\t\t\t\t\t\t\t ", /* 58 */ "\t\t\t\t\t\t\t ", /* 59 */ "\t\t\t\t\t\t\t ", /* 60 */ "\t\t\t\t\t\t\t ", /* 61 */ "\t\t\t\t\t\t\t ", /* 62 */ "\t\t\t\t\t\t\t ", /* 63 */ "\t\t\t\t\t\t\t\t", /* 64 */ "\t\t\t\t\t\t\t\t ", /* 65 */ "\t\t\t\t\t\t\t\t ", /* 66 */ "\t\t\t\t\t\t\t\t ", /* 67 */ "\t\t\t\t\t\t\t\t ", /* 68 */ "\t\t\t\t\t\t\t\t ", /* 69 */ "\t\t\t\t\t\t\t\t ", /* 70 */ "\t\t\t\t\t\t\t\t ", /* 71 */ "\t\t\t\t\t\t\t\t\t", /* 72 */ "\t\t\t\t\t\t\t\t\t ", /* 73 */ "\t\t\t\t\t\t\t\t\t ", /* 74 */ "\t\t\t\t\t\t\t\t\t ", /* 75 */ "\t\t\t\t\t\t\t\t\t ", /* 76 */ "\t\t\t\t\t\t\t\t\t ", /* 77 */ "\t\t\t\t\t\t\t\t\t ", /* 78 */ "\t\t\t\t\t\t\t\t\t ", /* 79 */ "\t\t\t\t\t\t\t\t\t\t", /* 80 */ "\t\t\t\t\t\t\t\t\t\t ", /* 81 */ "\t\t\t\t\t\t\t\t\t\t ", /* 82 */ "\t\t\t\t\t\t\t\t\t\t ", /* 83 */ "\t\t\t\t\t\t\t\t\t\t ", /* 84 */ "\t\t\t\t\t\t\t\t\t\t ", /* 85 */ "\t\t\t\t\t\t\t\t\t\t ", /* 86 */ "\t\t\t\t\t\t\t\t\t\t ",/* 87 */ "\t\t\t\t\t\t\t\t\t\t\t", /* 88 */ "\t\t\t\t\t\t\t\t\t\t\t ", /* 89 */ "\t\t\t\t\t\t\t\t\t\t\t ", /* 90 */ "\t\t\t\t\t\t\t\t\t\t\t ", /* 91 */ "\t\t\t\t\t\t\t\t\t\t\t ", /* 92 */ "\t\t\t\t\t\t\t\t\t\t\t ",/* 93 */ "\t\t\t\t\t\t\t\t\t\t\t ", /* 94 */ "\t\t\t\t\t\t\t\t\t\t\t ", /* 95 */ "\t\t\t\t\t\t\t\t\t\t\t\t", /* 96 */ "\t\t\t\t\t\t\t\t\t\t\t\t ", /* 97 */ "\t\t\t\t\t\t\t\t\t\t\t\t ", /* 98 */ "\t\t\t\t\t\t\t\t\t\t\t\t ",/* 99 */ "\t\t\t\t\t\t\t\t\t\t\t\t ", /* 100 */ "\t\t\t\t\t\t\t\t\t\t\t\t ", /* 101 */ "\t\t\t\t\t\t\t\t\t\t\t\t ", /* 102 */ "\t\t\t\t\t\t\t\t\t\t\t\t ", /* 103 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t", /* 104 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t ",/* 105 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 106 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 107 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 108 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 109 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 110 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 111 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t", /* 112 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 113 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 114 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 115 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 116 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 117 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 118 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 119 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t", /* 120 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 121 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 122 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 123 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 124 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 125 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 126 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 127 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t", /* 128 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 129 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 130 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 131 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 132 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 133 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 134 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 135 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t", /* 136 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 137 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 138 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 139 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 140 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 141 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 142 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 143 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t", /* 144 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 145 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 146 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 147 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 148 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 149 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 150 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 151 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t", /* 152 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 153 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 154 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 155 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 156 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 157 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 158 */ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ", /* 159 */};void testname (bool nested, int indent, name first, name last);void testnames (bool nested, int indent, int len, name first, name last);intmain (int argc, char **argv){ char buf[MAXNAMELEN]; char last_buf[MAXNAMELEN] = ""; char kwname[MAXNAMELEN]; char routine[32]; char type[32]; int i; int count; int len; struct _name_root_ names[200]; struct _name_alpha_ names_alpha; name n; name newname; char *input_name; char *output_name; char *include_name; FILE *incl; int fixlengths; int total_length; int do_name; /* TRUE if token may be NAME. */ int do_names; /* TRUE if token may be NAMES. */ int cc; bool do_exit = FALSE; for (i = 0; ((size_t) i) < ARRAY_SIZE (names); ++i) { /* Initialize length/name ordered list roots. */ names[i].first = (name) &names[i]; names[i].last = (name) &names[i]; } names_alpha.first = (name) &names_alpha; /* Initialize name order. */ names_alpha.last = (name) &names_alpha; if (argc != 4) { fprintf (stderr, "Command form: fini input output-code output-include\n"); exit (1); } input_name = argv[1]; output_name = argv[2]; include_name = argv[3]; in = fopen (input_name, "r"); if (in == NULL) { fprintf (stderr, "Cannot open \"%s\"\n", input_name); exit (1); } out = fopen (output_name, "w"); if (out == NULL) { fclose (in); fprintf (stderr, "Cannot open \"%s\"\n", output_name); exit (1); } incl = fopen (include_name, "w"); if (incl == NULL) { fclose (in); fprintf (stderr, "Cannot open \"%s\"\n", include_name); exit (1); } /* Get past the initial block-style comment (man, this parsing code is just _so_ lame, but I'm too lazy to improve it). */ for (;;) { cc = getc (in); if (cc == '{') { while (((cc = getc (in)) != '}') && (cc != EOF)) ; } else if (cc != EOF) { while (((cc = getc (in)) != EOF) && (! ISALNUM (cc))) ; ungetc (cc, in); break; } else { assert ("EOF too soon!" == NULL); exit (1); } } fscanf (in, "%s %s %s %s %s %d %d", prefix, postfix, storage, type, routine, &do_name, &do_names); if (storage[0] == '\0') storage[1] = '\0'; else /* Assume string is quoted somehow, replace ending quote with space. */ { if (storage[2] == '\0') storage[1] = '\0'; else storage[strlen (storage) - 1] = ' '; } if (postfix[0] == '\0') postfix[1] = '\0'; else /* Assume string is quoted somehow, strip off ending quote. */ postfix[strlen (postfix) - 1] = '\0'; for (i = 1; storage[i] != '\0'; ++i) storage[i - 1] = storage[i]; storage[i - 1] = '\0'; for (i = 1; postfix[i] != '\0'; ++i) postfix[i - 1] = postfix[i]; postfix[i - 1] = '\0'; fixlengths = strlen (prefix) + strlen (postfix); while (TRUE) { count = fscanf (in, "%s %s", buf, kwname); if (count == EOF) break; len = strlen (buf); if (len == 0) continue; /* Skip empty lines. */ if (buf[0] == ';') continue; /* Skip commented-out lines. */ for (i = strlen (buf) - 1; i > 0; --i) cc = buf[i]; /* Make new name object to store name and its keyword. */ newname = (name) malloc (sizeof (*newname)); newname->namelen = strlen (buf); newname->kwlen = strlen (kwname); total_length = newname->kwlen + fixlengths; if (total_length >= 32) /* Else resulting keyword name too long. */ { fprintf (stderr, "%s: %s%s%s is 31+%d chars long\n", input_name, prefix, kwname, postfix, total_length - 31); do_exit = TRUE; } strcpy (newname->kwname, kwname); for (i = 0; i < newname->namelen; ++i) { cc = buf[i]; if (ISALPHA (cc)) { newname->name_uc[i] = toupper (cc); newname->name_lc[i] = tolower (cc); newname->name_ic[i] = cc; } else newname->name_uc[i] = newname->name_lc[i] = newname->name_ic[i]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -