~ctwm/ctwm/trunk

« back to all changes in this revision

Viewing changes to parse.c

  • Committer: Matthew Fuller
  • Date: 2016-02-01 02:00:42 UTC
  • mto: This revision was merged to the branch mainline in revision 433.
  • Revision ID: fullermd@over-yonder.net-20160201020042-uny68cd4qk0is4m5
Rewrite this flow a little so we're not hopping in and out of #ifdef
M4 so much, and things wind up way easier to read.

Show diffs side-by-side

added added

removed removed

Lines of Context:
190
190
        int homelen = 0;
191
191
        char *cp = NULL;
192
192
        char tmpfilename[257];
193
 
#ifdef USEM4
194
 
        static FILE *raw;
195
 
#endif
196
193
 
197
194
        /*
198
195
         * Check for the twmrc file in the following order:
264
261
                }
265
262
 
266
263
                if(cp) {
267
 
                        /*
268
 
                         * Not just assigning straight to raw in USEM4 case so that
269
 
                         * twmrc is already set in the !GoThroughM4 conditional
270
 
                         * below.
271
 
                         */
272
264
                        twmrc = fopen(cp, "r");
273
 
#ifdef USEM4
274
 
                        raw = twmrc;
275
 
#endif
276
 
 
277
265
                }
278
266
        }
279
267
 
280
 
#ifdef USEM4
281
 
        if(raw) {
282
 
#else
283
268
        if(twmrc) {
284
 
#endif
285
 
 
286
269
                int status;
 
270
#ifdef USEM4
 
271
                static FILE *raw;
 
272
#endif
287
273
 
288
274
                if(filename && strncmp(cp, filename, strlen(filename))) {
289
275
                        fprintf(stderr,
291
277
                                ProgramName, filename, cp);
292
278
                }
293
279
#ifdef USEM4
 
280
                raw = NULL;
294
281
                if(CLarg.GoThroughM4) {
 
282
                        /*
 
283
                         * Hold onto raw filehandle so we can fclose() it below, and
 
284
                         * swap twmrc over to the output from m4
 
285
                         */
 
286
                        raw = twmrc;
295
287
                        twmrc = start_m4(raw);
296
288
                }
297
289
                /* else twmrc still set to the actual file from above */
298
290
                status = doparse(m4twmFileInput, "file", cp);
299
291
                wait(0);
300
292
                fclose(twmrc);
301
 
                if(CLarg.GoThroughM4) {
 
293
                if(raw) {
302
294
                        fclose(raw);
303
295
                }
304
296
#else