MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / get_line

Function get_line

extern/btyacc/reader.c:64–192  ·  view source on GitHub ↗

* Get line * Return: 1 - reg. line finished with '\n'. * 0 - EOF. */

Source from the content-addressed store, hash-verified

62 * 0 - EOF.
63 */
64char *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;

Callers 9

skip_commentFunction · 0.70
nextcFunction · 0.70
copy_stringFunction · 0.70
copy_commentFunction · 0.70
copy_textFunction · 0.70
copy_unionFunction · 0.70
get_literalFunction · 0.70
copy_argsFunction · 0.70
copy_actionFunction · 0.70

Calls 5

getcFunction · 0.85
fcloseFunction · 0.85
no_spaceFunction · 0.85
errorFunction · 0.70
fopenFunction · 0.50

Tested by

no test coverage detected