| 1 | /* input_file.c - Deal with Input Files -
|
|---|
| 2 | Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2001
|
|---|
| 3 | Free Software Foundation, Inc.
|
|---|
| 4 |
|
|---|
| 5 | This file is part of GAS, the GNU Assembler.
|
|---|
| 6 |
|
|---|
| 7 | GAS is free software; you can redistribute it and/or modify
|
|---|
| 8 | it under the terms of the GNU General Public License as published by
|
|---|
| 9 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 10 | any later version.
|
|---|
| 11 |
|
|---|
| 12 | GAS is distributed in the hope that it will be useful,
|
|---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 15 | GNU General Public License for more details.
|
|---|
| 16 |
|
|---|
| 17 | You should have received a copy of the GNU General Public License
|
|---|
| 18 | along with GAS; see the file COPYING. If not, write to the Free
|
|---|
| 19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|---|
| 20 | 02111-1307, USA. */
|
|---|
| 21 |
|
|---|
| 22 | /* Confines all details of reading source bytes to this module.
|
|---|
| 23 | All O/S specific crocks should live here.
|
|---|
| 24 | What we lose in "efficiency" we gain in modularity.
|
|---|
| 25 | Note we don't need to #include the "as.h" file. No common coupling! */
|
|---|
| 26 |
|
|---|
| 27 | #include <stdio.h>
|
|---|
| 28 | #include <string.h>
|
|---|
| 29 | #include "as.h"
|
|---|
| 30 | #include "input-file.h"
|
|---|
| 31 | #include "safe-ctype.h"
|
|---|
| 32 |
|
|---|
| 33 | static int input_file_get PARAMS ((char *, int));
|
|---|
| 34 |
|
|---|
| 35 | /* This variable is non-zero if the file currently being read should be
|
|---|
| 36 | preprocessed by app. It is zero if the file can be read straight in. */
|
|---|
| 37 | int preprocess = 0;
|
|---|
| 38 |
|
|---|
| 39 | /* This code opens a file, then delivers BUFFER_SIZE character
|
|---|
| 40 | chunks of the file on demand.
|
|---|
| 41 | BUFFER_SIZE is supposed to be a number chosen for speed.
|
|---|
| 42 | The caller only asks once what BUFFER_SIZE is, and asks before
|
|---|
| 43 | the nature of the input files (if any) is known. */
|
|---|
| 44 |
|
|---|
| 45 | #define BUFFER_SIZE (32 * 1024)
|
|---|
| 46 |
|
|---|
| 47 | /* We use static data: the data area is not sharable. */
|
|---|
| 48 |
|
|---|
| 49 | static FILE *f_in;
|
|---|
| 50 | static char *file_name;
|
|---|
| 51 |
|
|---|
| 52 | /* Struct for saving the state of this module for file includes. */
|
|---|
| 53 | struct saved_file
|
|---|
| 54 | {
|
|---|
| 55 | FILE * f_in;
|
|---|
| 56 | char * file_name;
|
|---|
| 57 | int preprocess;
|
|---|
| 58 | char * app_save;
|
|---|
| 59 | };
|
|---|
| 60 | |
|---|
| 61 |
|
|---|
| 62 | /* These hooks accomodate most operating systems. */
|
|---|
| 63 |
|
|---|
| 64 | void
|
|---|
| 65 | input_file_begin ()
|
|---|
|
|---|