summaryrefslogtreecommitdiff
path: root/bcc/input.c
blob: 9ef19e3dfb393b6118460a3bed42161ef7b4cb17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
/* input.c - input for bcc */

/* Copyright (C) 1992 Bruce Evans */

#define ARBITRARY_BACKSLASH_NEWLINES_NOT
#define INSERT_BACKSLASH_NEWLINES_NOT

#include "bcc.h"
#include "gencode.h"
#include "output.h"
#include "os.h"
#include "sc.h"
#include "scan.h"
#include "table.h"
#ifndef VERY_SMALL_MEMORY
#include "parse.h"
#endif

#undef EXTERN
#define EXTERN
#include "input.h"

#define INBUFSIZE 2048
#define NO_EOFHACK

struct fbufstruct		/* file buffer structure */
{
    struct fcbstruct fcb;	/* status after opening an include sub-file */
    char *fname;		/* file name */
    bool_t fname_malloced;	/* nonzero if fname was malloced */
    char pushback[3];		/* allows pushback to 2 before start of fbuf
				 * XXX 3 chars before?
				 * XXX should do everything in fbuf */
    char fbuf[INBUFSIZE + 1];	/* buffer to read into */
};

#ifdef BUILTIN_CPP
struct inclist			/* list of include file directories */
{
    char *incdirname;
    struct inclist *incnext;
};

PRIVATE char filemacro[] = "__FILE__";
PRIVATE struct inclist incabsolute;	/* dummy list for absolute names */
				/* depends on zero (NULL) init */
PRIVATE struct inclist incfirst;
				/* begin include searches here for "" */
				/* at next in list for <> */
				/* -I directories are put in list */
				/* between first and last */
PRIVATE struct inclist inclast =
{
#ifdef DEFAULT_INCLUDE_DIR
    DEFAULT_INCLUDE_DIR,
#endif
    NULL,
};
PRIVATE fastin_t inclevel;	/* nest level of include files */
				/* depends on zero init */
#endif
PRIVATE struct fbufstruct *inputbuf;	/* current input file buffer */
					/* its fcb only to date in includes */
					/* depends on zero (NULL) init */
PRIVATE bool_t suppress_line_numbers;

#ifdef ARBITRARY_BACKSLASH_NEWLINES
FORWARD void backslash P((void));
#endif
#ifdef BUILTIN_CPP
FORWARD void definefile P((char *fname));
FORWARD void leaveinclude P((void));
#endif
FORWARD void inputinit P((char *fname, fd_t fd));
FORWARD void usage P((void));

#ifdef ARBITRARY_BACKSLASH_NEWLINES
PRIVATE void backslash()
{
    static unsigned nbackslash;

    if (nbackslash != 0)
	--nbackslash;
more:
    ++nbackslash;
    while (*(lineptr + 1) == '\\')
    {
	++nbackslash;
	++lineptr;
    }
    if (*(lineptr + 1) != EOL)
    {
	if (--nbackslash != 0)
	    *--lineptr = '\\';	/* force look at current backslash again */
	return;
    }
    ch = *++lineptr;
more1:
    if (!eofile && lineptr >= input.limit)
	skipeol();
    if (ch == EOL)
    {
	--nbackslash;
	if (eofile)
	    eofin("backslash-newline");
	else
	{
	    skipeol();
	    if (ch == EOL && !eofile && lineptr >= input.limit)
		skipeol();
#ifdef COEOL /* XXX - this should go through specialchar() */
	    if (ch == COEOL)
	    {
		ch = *++lineptr;
		if (ch == EOL && !eofile && lineptr >= input.limit)
		    skipeol();
	    }
#endif
	}
	if (ch == '\\')
	    goto more;
	if (nbackslash != 0 && ch == EOL && !eofile)
	    goto more1;
	if (nbackslash != 0)
	{
	    ch = *--lineptr = '\\';
	    if (--nbackslash != 0)
		ch = *--lineptr = '\\';
	}
	return;
    }
    if (ch == '\\')
	goto more;
    if (ch == EOL && !eofile)
	goto more1;
    ch = *--lineptr = '\\';	/* pushback */
    if (--nbackslash != 0)
	ch = *--lineptr = '\\';
}
#endif

PUBLIC void closein()
{
#ifdef FAKE_INBUFSIZE_1
    fclose(input.fp);
#else
    close(input.fd);
#endif
#ifdef BUILTIN_CPP
    while (inclevel != 0)
	leaveinclude();
#endif
}

#ifdef BUILTIN_CPP
PRIVATE void definefile(fname)
char *fname;
{
    char *def;

    def = ourmalloc(sizeof filemacro - 1 + 2 + strlen(fname) + 1 + 1);
    strcpy(def, filemacro);
    strcat(def, "=\"");
    strcat(def, fname);
    strcat(def, "\"");
    definestring(def);
    ourfree(def);
}
#endif

PUBLIC void errorloc()
{
    register struct fbufstruct *infbuf;

    if ((infbuf = inputbuf) == NULL)
	return;
    outstr(infbuf->fname);
    outbyte(':');
    if (eofile)
	outstr("eof");
    else
    {
	outudec(input.linenumber);
	outbyte('.');
#ifdef BUILTIN_CPP
	if (maclevel == 0)
	    outudec((unsigned) (lineptr - inputbuf->fbuf) - input.lineoffset);
	else
	{
	    outudec((unsigned) (savedlineptr() - inputbuf->fbuf)
		    - input.lineoffset);
	    outstr(" (macro level ");
	    outudec((unsigned) maclevel);
	    outbyte(')');
	}
#else
	outudec((unsigned) (lineptr - inputbuf->fbuf) - input.lineoffset);
#endif
    }
    infbuf->fcb.includer = input.includer;
    while ((infbuf = infbuf->fcb.includer) != NULL)
    {
	outstr(" (from ");
	outstr(infbuf->fname);
	outbyte(':');
	outudec(infbuf->fcb.linenumber);
	outbyte(')');
    }
    outstr(": ");
}

/* gch1() - get next char, advance ptr (only works on current line) */

PUBLIC void gch1()
{
    if (SYMOFCHAR(ch = *++lineptr) != SPECIALCHAR)
	return;
    specialchar();
}

#ifdef BUILTIN_CPP
/* process #include */

PUBLIC void include()
{
    char *dirnameptr;
    char *dirnamend;
    unsigned dirnamelen;
    fd_t fd;
    char *fnameptr;
    char *fullnameptr;
    struct inclist *incptr;
    char terminator;

    while (blanksident())
    {
	if ((gsymptr = findlorg(gsname)) == NULL ||
	    gsymptr->flags != DEFINITION)
	    break;
	entermac();
    }
    if ((terminator = ch) == '<')
	terminator = '>';
    else if (terminator != '"')
    {
	error("bad file name");
	return;
    }
    gch1();
    fnameptr = charptr;
    while (TRUE)
    {
	if (ch == EOL)		/* no escapes in file names */
	    break;
	if (ch == terminator)
	{
	    gch1();
	    blanks();
	    break;
	}
	if (charptr >= chartop)
	    fnameptr = growobject(fnameptr, 1);
#ifdef TS
++ts_n_filename;
++ts_s_filename;
++ts_s_filename_tot;
#endif
	*charptr++ = ch;
	gch1();
    }
    if (charptr >= chartop)
	fnameptr = growobject(fnameptr, 1);
#ifdef TS
++ts_n_filename_term;
++ts_s_filename_term;
++ts_s_filename_tot;
#endif
    *charptr++ = 0;
    dirnamend = NULL;
    if (isabspath(fnameptr, &ch))
	incptr = &incabsolute;
    else
    {
	incptr = &incfirst;
	if (terminator == '>')
	    incptr = incptr->incnext;
	else
	{
	    dirnameptr = inputbuf->fname;
	    if ((dirnamend = strrchr(dirnameptr, DIRCHAR)) == NULL)
		incptr->incdirname = NULL;
	    else
	    {
		*dirnamend = 0;
		incptr->incdirname = dirnameptr;
	    }
	}
    }
    do
    {
	if (incptr->incdirname == NULL)
	{
	    fullnameptr = ourmalloc(strlen(fnameptr) + 1);
#ifdef TS
++ts_n_pathname;
ts_s_pathname += strlen(fnameptr) + 1;
ts_s_pathname_tot += strlen(fnameptr) + 1;
#endif
	    strcpy(fullnameptr, fnameptr);
	}
	else
	{
	    dirnamelen = strlen(incptr->incdirname);
	    fullnameptr = ourmalloc(dirnamelen + (int) (charptr - fnameptr)
				    + 2);
				/* 2 extra for null and maybe DIRCHAR */
#ifdef TS
++ts_n_pathname;
ts_s_pathname += dirnamelen + (charptr - fnameptr) + 2;
ts_s_pathname_tot += dirnamelen + (charptr - fnameptr) + 2;
#endif
	    dirnameptr = fullnameptr + dirnamelen;
	    strcpy(fullnameptr, incptr->incdirname);
	    if (*fullnameptr != 0 && *(dirnameptr - 1) != DIRCHAR)
		strcat(fullnameptr, DIRSTRING);
	    strcat(fullnameptr, fnameptr);
	    if (dirnamend != NULL)
	    {
		*dirnamend = DIRCHAR;
		dirnamend = NULL;
	    }
	}
	fd = open(fullnameptr, 0);
	if (fd >= 0)
	{
#ifdef TS
ts_s_filename_tot -= charptr - fnameptr;
#endif
	    charptr = fnameptr;
	    input.lineptr = lineptr;
	    inputbuf->fcb = input;
	    ++inclevel;		/* XXX - will run out of memory before overflow */
	    inputinit(fullnameptr, fd);
	    inputbuf->fname_malloced = TRUE;
	    return;
	}
#ifdef TS
ts_s_pathname_tot -= strlen(fullnameptr) + 1;
#endif
	ourfree(fullnameptr);
    }
    while ((incptr = incptr->incnext) != NULL);

    fullnameptr = ourmalloc(strlen(fnameptr) + 40);
    strcpy(fullnameptr, "cannot find include file ");
    strcat(fullnameptr, fnameptr);
    error(fullnameptr);
    ourfree(fullnameptr);

#ifdef TS
ts_s_filename_tot -= charptr - fnameptr;
#endif
    charptr = fnameptr;
}
#endif

/* initialise current input file */

PRIVATE void inputinit(fname, fd)
char *fname;
fd_t fd;
{
    register struct fbufstruct *newinputbuf;

    /* don't allocate after saying input.includer = inputbuf (to save a reg)
     * or an error in the alloc would cycle trying to print the include list
     */
    newinputbuf = (struct fbufstruct *) ourmalloc(sizeof *inputbuf);
#ifdef TS
++ts_n_inputbuf;
ts_s_inputbuf += sizeof *inputbuf;
ts_s_inputbuf_tot += sizeof *inputbuf;
#endif
    input.fd = fd;
#ifdef FAKE_INBUFSIZE_1
    input.fp = fdopen(fd, "r");
#endif
    input.linenumber = 0;
    input.lineoffset = 0;
    input.includer = inputbuf;
    inputbuf = newinputbuf;
    newinputbuf->fname = fname;
    newinputbuf->fname_malloced = FALSE;
#ifdef BUILTIN_CPP
    undefinestring(filemacro);
    definefile(fname);
    if (orig_cppmode && !suppress_line_numbers)
	outcpplinenumber(1, fname, input.includer == NULL ? "" : " 1");
#endif
    *(input.limit = newinputbuf->fbuf) = EOL;

    /* dummy line so processing can start with skipline() */
    ch = *(lineptr = newinputbuf->fbuf - 1) = EOL;
}

PUBLIC void linecontol()
{
   char linename[256];
   char * ptr;
   int i=0;

   blanks();
   input.linenumber = atoi(lineptr)-1;
   while( SYMOFCHAR(ch) == INTCONST ) gch1();
   blanks();
   if( ch != '"' ) return;
   for(ptr=lineptr+1; *ptr
                   && *ptr != EOL
		   && *ptr != '"'
		   && i<sizeof(linename)-1; i++, ptr++)
      linename[i] = *ptr;
   linename[i] = '\0';

    if (inputbuf->fname_malloced)
{
#ifdef TS
ts_s_pathname_tot -= strlen(inputbuf->fname) + 1;
#endif
	ourfree(inputbuf->fname);
}
    inputbuf->fname_malloced = TRUE;
    ptr = ourmalloc(strlen(linename)+1);
    strcpy(ptr, linename);
    inputbuf->fname = ptr;

    ptr=lineptr;
#ifdef BUILTIN_CPP
    undefinestring(filemacro);
    definefile(inputbuf->fname);
#endif
    ch = *(lineptr = ptr);
}

#ifdef BUILTIN_CPP
/* switch from include file to file which included it */

PRIVATE void leaveinclude()
{
    --inclevel;
    if (inputbuf->fname_malloced)
{
#ifdef TS
ts_s_pathname_tot -= strlen(inputbuf->fname) + 1;
#endif
	ourfree(inputbuf->fname);
}
#ifdef TS
ts_s_inputbuf_tot -= sizeof *inputbuf;
#endif
    ourfree((char *) inputbuf);
#ifndef NO_EOFHACK
    if(input.fd>=0)
#endif
       close(input.fd);
#ifdef FAKE_INBUFSIZE_1
    fclose(input.fp);
#endif
    inputbuf = input.includer;
    input = inputbuf->fcb;
    undefinestring(filemacro);
    definefile(inputbuf->fname);
    ch = *(lineptr = input.lineptr);
    skipline();
    if (orig_cppmode && !suppress_line_numbers)
	outcpplinenumber(input.linenumber, inputbuf->fname, " 2");
}
#endif

/* open input and output files and get options */

PUBLIC void openio(argc, argv)
int argc;
char *argv[];
{
    register char *arg;
    int argn;
    fd_t fd;
    char *fname;
#ifdef BUILTIN_CPP
    struct inclist *incnew;
    struct inclist *incptr;
#endif
    bool_t flag[128];

#if 0
    lineptr = "\n";		/* empty line in case error message */
#endif
    fd = 0;			/* standard input */
    memset(flag, 0, sizeof flag);
#ifdef I80386
    flag['3'] = sizeof (int) >= 4;
#endif
    fname = "stdin";
#ifdef BUILTIN_CPP
    (incptr = &incfirst)->incnext = &inclast;
#endif
    initout();
    for (argn = 1; argn < argc; ++argn)
    {
	arg = argv[argn];
	if (*arg != '-')
	{
	    if (fd != 0)
		fatalerror("more than one input file");
	    fname = arg;
	    if ((fd = open(arg, 0)) < 0)
		fatalerror("cannot open input");
	}
	else
	    switch (arg[1])
	    {
#ifdef I8088
	    case '0':		/* generate 16-bit code */
#endif
#ifdef I80386
	    case '3':		/* generate 32-bit code */
#endif
	    case 'c':		/* caller saves */
#ifdef DBNODE
	    case 'd':		/* print debugging information in asm output */
#endif
#ifdef BUILTIN_CPP
	    case 'E':		/* acting as cpp */
#endif
	    case 'f':		/* pass first argument in register */
#ifdef DYNAMIC_LONG_ORDER
	    case 'l':		/* long big-endian */
#endif
	    case 'P':		/* if acting as cpp, suppress line numbers */
#ifdef POSINDEPENDENT
	    case 'p':		/* generate almost-position-independent code */
#endif
	    case 't':		/* print source code in asm output */
	    case 'w':		/* watch location counter */
#ifndef VERY_SMALL_MEMORY
	    case '7':		/* accept ancient K&R code */
#endif
	    case 'O':		/* Optimisation. */
		if (arg[2] == 0)
		    flag[(int)arg[1]] = TRUE;
		else if (arg[2] == '-' && arg[3] == 0)
		    flag[(int)arg[1]] = FALSE;
		else
		    usage();
		if (arg[1] == '0')	/* flag 0 is negative logic flag 3 */
		    flag['3'] = TRUE + FALSE - flag['0'];
		break;
#ifdef BUILTIN_CPP
	    case 'D':
		definestring(arg + 2);
		break;
	    case 'I':
		(incnew = (struct inclist *) ourmalloc(sizeof *incnew))
			  ->incdirname = arg + 2;
#ifdef TS
++ts_n_includelist;
ts_s_includelist += sizeof *incnew;
#endif
		incnew->incnext = incptr->incnext;
		incptr = incptr->incnext = incnew;
		break;
	    case 'U':
		undefinestring(arg + 2);
		break;
#endif
	    case 'o':
		if (arg[2] != 0 || ++argn >= argc)
		    usage();
		openout(argv[argn]);
		break;
	    default:
		usage();
		break;
	    }
    }
#ifdef BUILTIN_CPP
#ifdef I8088
#ifdef I80386
    if (flag['3'])
    {
	i386_32 = TRUE;
	definestring("__AS386_32__");
	definestring("__i386__");
    }
    else
#endif
    {
	definestring("__AS386_16__");
	definestring("__8086__");
    }
#endif
#ifdef MC6809
    definestring("__AS09__");
#endif
    if (flag['c'])
    {
	callersaves = TRUE;
	definestring("__CALLER_SAVES__");
    }
#ifdef DBNODE
    dbnodeon = flag['d'];
#endif
    orig_cppmode = cppmode = flag['E'];
    if (flag['f'])
    {
	arg1inreg = TRUE;
#ifdef I8088
	definestring("__FIRST_ARG_IN_AX__");
#endif
#ifdef MC6808
	definestring("__FIRST_ARG_IN_X__");
#endif
    }
    arg1op = arg1inreg ? ROOTLISTOP : LISTOP;
#ifdef DYNAMIC_LONG_ORDER
    if (flag['l'])
    {
	long_big_endian = TRUE;
	definestring("__LONG_BIG_ENDIAN__");
    }
#endif
    suppress_line_numbers = flag['P'];
#ifdef POSINDEPENDENT
    if (flag['p'])
    {
	posindependent = TRUE;
	definestring("__POS_INDEPENDENT__");
    }
#endif
#ifndef VERY_SMALL_MEMORY
    if (flag['7'])
    {
	ancient = TRUE;
	definestring("__ANCIENT__");
    }
#endif
    if (flag['O'])
    {
	optimise = TRUE;
	definestring("__OPTIMISED__");
    }
#ifdef NOFLOAT
    definestring("__HAS_NO_FLOATS__");
#endif

#else /* !BUILTIN_CPP */

#ifdef I80386
    if (flag['3']) i386_32 = TRUE;
#endif
    if (flag['c']) callersaves = TRUE;
#ifdef DBNODE
    dbnodeon = flag['d'];
#endif
    if (flag['f']) arg1inreg = TRUE;
    arg1op = arg1inreg ? ROOTLISTOP : LISTOP;
#ifdef DYNAMIC_LONG_ORDER
    if (flag['l']) long_big_endian = TRUE;
#endif
    suppress_line_numbers = flag['P'];
#ifdef POSINDEPENDENT
    if (flag['p']) posindependent = TRUE;
#endif
    if (flag['O']) optimise = TRUE;

#endif
    ctext = flag['t'];
#ifdef DBNODE
    if (ctext) dbnodeon = 1;
#endif
    watchlc = flag['w'];
    setoutbufs();
    inputinit(fname, fd);
}

/* advance over EOL sentinel to new line */

PUBLIC void skipeol()
{
#ifdef FAKE_INBUFSIZE_1
    static int ich;
#endif
#ifdef INSERT_BACKSLASH_NEWLINES
    static int bs_state;
    static bool_t skip_printing_nl;
#endif
    int nread;
    debug(7, "skipeol %s:%d", inputbuf->fname, input.linenumber);

    if (eofile)
	return;
    if (lineptr < input.limit)
    {
	++input.linenumber;
	ch = *++lineptr;
	if (ctext && !asmmode)
	{
	    comment();
	    outudec(input.linenumber);
	    outbyte(' ');
	    outline(lineptr);
	}
#ifdef BUILTIN_CPP
#ifndef ASM_BARE
	if (!virtual_nl && (orig_cppmode || asmmode))
#else
	if (orig_cppmode && !asmmode)
#endif
#ifdef INSERT_BACKSLASH_NEWLINES
	    if (!skip_printing_nl)
#endif
		outbyte('\n');
#else	/* !BUILTIN_CPP */
	if (asmmode)
#ifdef INSERT_BACKSLASH_NEWLINES
	    if (!skip_printing_nl)
#endif
		outbyte('\n');
#endif

#ifdef INSERT_BACKSLASH_NEWLINES
	if (bs_state == 1 && *(lineptr - 1) == EOL)
#endif
	    input.lineoffset = (int) (lineptr - inputbuf->fbuf);
	return;
    }
    input.lineoffset -= (int) (lineptr - inputbuf->fbuf);
#ifdef FAKE_INBUFSIZE_1
    lineptr = inputbuf->fbuf;
#ifdef INSERT_BACKSLASH_NEWLINES
    switch (bs_state)
    {
case0:
    case 0:
	bs_state = nread = (ich = getc(input.fp)) == EOF ? 0 : 1;
	skip_printing_nl = FALSE;
	break;
    case 1:
	if (ich == '\\')
	    goto case0;		/* avoid chance of splitting \EOL */
	ich = '\\';
	nread = 1;
	bs_state = 2;
	++input.lineoffset;
	break;
    case 2:
	ich = EOL;
	nread = 1;
	bs_state = 0;
	skip_printing_nl = TRUE;
	++input.lineoffset;
	--input.linenumber;
	break;
    }
#else
    nread = (ich = getc(input.fp)) == EOF ? 0 : 1;
#endif
    *lineptr = ich;
#else
#ifndef NO_EOFHACK
    if(input.fd<0)
        nread=0;
    else
    {
#endif
        nread = read(input.fd, lineptr = inputbuf->fbuf, INBUFSIZE);
#ifndef NO_EOFHACK
#ifdef BUILTIN_CPP
        if( nread == 0 && inclevel > 0 )
	{
	   close(input.fd);
	   input.fd = -1;
	   memcpy(inputbuf->fbuf, "\n", 1);
	   nread = 1;
	}
#endif
    }
#endif
#endif
    if (nread < 0)
	fatalerror("input error");
    *(input.limit = lineptr + nread) = EOL;
    ch = *lineptr;
    if (nread == 0)
    {
#ifdef BUILTIN_CPP
	if (inclevel == 0)
	{
	    eofile = TRUE;
	    checknotinif();
	}
	else
	{
	    leaveinclude();
	    skipeol();
	}
#else
	eofile = TRUE;
#endif
	return;
    }
    if (ctext && !asmmode)
    {
	comment();
	outudec(input.linenumber);
	outbyte(' ');
	outline(lineptr);
    }
}

PUBLIC void specialchar()
{
#ifdef BUILTIN_CPP
    if (maclevel != 0)
    {
	if (ch == EOL)		/* it might also be backslash or COEOL */
	    leavemac();
	if (ch != EOL)
	    return;
    }
#endif
more:
#ifdef ARBITRARY_BACKSLASH_NEWLINES
    if (ch == '\\')
	backslash();
#endif
    if (!eofile && lineptr >= input.limit)
    {
	skipeol();
#ifdef ARBITRARY_BACKSLASH_NEWLINES
	if (ch == '\\')
	    backslash();
#endif
    }
#ifndef ARBITRARY_BACKSLASH_NEWLINES
    if (ch == '\\')
    {
	if (*(lineptr + 1) == EOL)
	{
	    if (lineptr + 1 >= input.limit)
	    {
		++lineptr;
		skipeol();
		ch = *--lineptr = '\\';	/* pushback */
	    }
	    if (*(lineptr + 1) == EOL)
	    {
		if (eofile)
		    eofin("backslash-newline");
		else
		{
		    ++lineptr;
		    skipeol();
		    if (SYMOFCHAR(ch) == SPECIALCHAR)
		    {
#ifdef COEOL
			if (ch != COEOL
			    || SYMOFCHAR(ch = *++lineptr) == SPECIALCHAR)
#endif
			    goto more;
		    }
		}
	    }
	}
#endif
    }
#ifdef COEOL
    if (ch == EOL && !eofile)
    {
	if (*(lineptr + 1) == EOL && lineptr + 1 >= input.limit)
	{
	    ++lineptr;
	    skipeol();		/* refill buffer */
	    ch = *--lineptr = EOL;	/* pushback */
	}
	if (*(lineptr + 1) == COEOL)
	    *++lineptr = EOL;	/* discard COEOL */
    }
#endif
}

PRIVATE void usage()
{
    fatalerror(
#ifdef BUILTIN_CPP
#  ifdef MC6809
"usage: cc1 [-cdfptw[-]] [-Ddefine] [-Iincdir] [-Uundef] [-o outfile] [infile]"
#  else 
#    ifdef I80386
"usage: cc1 [-03cdfltw[-]] [-Ddefine] [-Iincdir] [-Uundef] [-o outfile] [infile]"
#    else 
"usage: cc1 [-cdfltw[-]] [-Ddefine] [-Iincdir] [-Uundef] [-o outfile] [infile]"
#    endif
#  endif
#else 
#  ifdef I80386
"usage: cc1 [-03cdfltw[-]] [-o outfile] [infile]"
#  else 
"usage: cc1 [-cdfltw[-]] [-o outfile] [infile]"
#  endif
#endif
   );
}