| 161 | |
| 162 | INLINE FILE_LOCAL |
| 163 | ReturnCode fpp_cppmain(struct Global *global) |
| 164 | { |
| 165 | /* |
| 166 | * Main process for cpp -- copies tokens from the current input |
| 167 | * stream (main file, include file, or a macro) to the output |
| 168 | * file. |
| 169 | */ |
| 170 | |
| 171 | int c; /* Current character */ |
| 172 | int counter; /* newlines and spaces */ |
| 173 | ReturnCode ret; /* return code variable type */ |
| 174 | |
| 175 | long bracelevel = 0; |
| 176 | long parenlevel = 0; |
| 177 | long bracketlevel = 0; |
| 178 | int fake = 0; |
| 179 | |
| 180 | #define MAX_FUNC_LENGTH 50 |
| 181 | |
| 182 | char tempfunc[MAX_FUNC_LENGTH + 1]; |
| 183 | char tempfunc2[MAX_FUNC_LENGTH + 1]; |
| 184 | char define = 0; /* probability of a function define phase in the program */ |
| 185 | char prev = 0; /* previous type */ |
| 186 | char go = 0; |
| 187 | unsigned include = 0; |
| 188 | char initfunc = 0; |
| 189 | |
| 190 | /* Initialize for reading tokens */ |
| 191 | global->tokenbsize = 50; |
| 192 | global->tokenbuf = malloc(global->tokenbsize + 1); |
| 193 | if(!global->tokenbuf) |
| 194 | return(FPP_OUT_OF_MEMORY); |
| 195 | |
| 196 | global->functionname = malloc(global->tokenbsize + 1); |
| 197 | if(!global->functionname) |
| 198 | return(FPP_OUT_OF_MEMORY); |
| 199 | global->functionname[0] = '\0'; |
| 200 | |
| 201 | if(global->showspace) { |
| 202 | global->spacebuf = (char *)malloc(MAX_SPACE_SIZE); |
| 203 | if(!global->spacebuf) |
| 204 | return(FPP_OUT_OF_MEMORY); |
| 205 | } |
| 206 | |
| 207 | if(global->showversion) |
| 208 | fpp_Error(global, VERSION_TEXT); |
| 209 | |
| 210 | /* |
| 211 | * Explicitly output a #line at the start of cpp output so |
| 212 | * that lint (etc.) knows the name of the original source |
| 213 | * file. If we don't do this explicitly, we may get |
| 214 | * the name of the first #include file instead. |
| 215 | */ |
| 216 | if(global->linelines) /* if #line lines are wanted! */ |
| 217 | fpp_sharp(global); |
| 218 | /* |
| 219 | * This loop is started "from the top" at the beginning of each line |
| 220 | * wrongline is set FPP_TRUE in many places if it is necessary to write |
no test coverage detected