* Get line * Return: 1 - reg. line finished with '\n'. * 0 - EOF. */
| 62 | * 0 - EOF. |
| 63 | */ |
| 64 | char *get_line() { |
| 65 | extern int Eflag; |
| 66 | FILE *f; |
| 67 | int c; |
| 68 | int i; |
| 69 | |
| 70 | /* VM: input from main or include file */ |
| 71 | NextLine:; |
| 72 | f = inc_file ? inc_file : input_file; |
| 73 | i = 0; |
| 74 | |
| 75 | if (saw_eof || (c = getc(f)) == EOF) { |
| 76 | |
| 77 | /* VM: end of include file */ |
| 78 | if(inc_file) { |
| 79 | fclose(inc_file); |
| 80 | inc_file = NULL; |
| 81 | lineno = inc_save_lineno; |
| 82 | goto NextLine; |
| 83 | } |
| 84 | |
| 85 | if (line) FREE(line); |
| 86 | saw_eof = 1; |
| 87 | return line = cptr = 0; |
| 88 | } |
| 89 | if (line == 0 || linesize != (LINESIZE + 1)) { |
| 90 | if (line) FREE(line); |
| 91 | linesize = LINESIZE + 1; |
| 92 | if (!(line = MALLOC(linesize))) no_space(); |
| 93 | } |
| 94 | ++lineno; |
| 95 | while ((line[i] = c) != '\n') { |
| 96 | if (++i + 1 >= linesize) |
| 97 | if (!(line = REALLOC(line, linesize += LINESIZE))) |
| 98 | no_space(); |
| 99 | if ((c = getc(f)) == EOF) { |
| 100 | c = '\n'; |
| 101 | saw_eof = 1; |
| 102 | } |
| 103 | } |
| 104 | line[i+1] = 0; |
| 105 | |
| 106 | /* VM: process %ifdef line */ |
| 107 | if(strncmp(&line[0], "%ifdef ", 7)==0) { |
| 108 | char var_name[80]; |
| 109 | int ii=0; |
| 110 | char **ps; |
| 111 | for(i=7; line[i]!='\n' && line[i]!=' '; i++, ii++) { |
| 112 | var_name[ii] = line[i]; |
| 113 | } |
| 114 | var_name[ii] = 0; |
| 115 | if(in_ifdef) { |
| 116 | error(lineno, 0, 0, "Cannot have nested %%ifdef"); |
| 117 | } |
| 118 | /* Find the preprocessor variable */ |
| 119 | for(ps=&defd_vars[0]; *ps; ps++) { |
| 120 | if(strcmp(*ps,var_name)==0) { |
| 121 | break; |
no test coverage detected