Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

input.c File Reference

#include "c.h"

Include dependency graph for input.c:

Include dependency graph

Go to the source code of this file.

Functions

void fillbuf (void)
void input_init (int argc, char *argv[])
void nextline (void)
void pragma (void)
void resynch (void)

Variables

int bsize
unsigned char buffer [MAXLINE+1+BUFSIZE+1]
unsigned char * cp
char * file
char * firstfile
unsigned char * limit
char * line
int lineno


Function Documentation

void fillbuf void   ) 
 

Definition at line 35 of file input.c.

References assert, bsize, buffer, BUFSIZE, cp, error(), exit(), EXIT_FAILURE, feof, fread(), limit, line, MAXLINE, n, s, and stdin.

Referenced by foldline(), gettok(), gettokens(), input_init(), nextline(), resynch(), scon(), and trigraph().

00035                    {
00036     if (bsize == 0)
00037         return;
00038     if (cp >= limit)
00039         cp = &buffer[MAXLINE+1];
00040     else
00041         {
00042             int n = limit - cp;
00043             unsigned char *s = &buffer[MAXLINE+1] - n;
00044             assert(s >= buffer);
00045             line = (char *)s - ((char *)cp - line);
00046             while (cp < limit)
00047                 *s++ = *cp++;
00048             cp = &buffer[MAXLINE+1] - n;
00049         }
00050     if (feof(stdin))
00051         bsize = 0;
00052     else
00053         bsize = fread(&buffer[MAXLINE+1], 1, BUFSIZE, stdin);
00054     if (bsize < 0) {
00055         error("read error\n");
00056         exit(EXIT_FAILURE);
00057     }
00058     limit = &buffer[MAXLINE+1+bsize];
00059     *limit = '\n';
00060 }

Here is the call graph for this function:

void input_init int  argc,
char *  argv[]
 

Definition at line 61 of file input.c.

References argc, argv, bsize, buffer, cp, file, fillbuf(), limit, lineno, main_init(), MAXLINE, and nextline().

Referenced by init().

00061                                         {
00062     static int inited;
00063 
00064     if (inited)
00065         return;
00066     inited = 1;
00067     main_init(argc, argv);
00068     limit = cp = &buffer[MAXLINE+1];
00069     bsize = -1;
00070     lineno = 0;
00071     file = NULL;
00072     fillbuf();
00073     if (cp >= limit)
00074         cp = limit;
00075     nextline();
00076 }

Here is the call graph for this function:

void nextline void   ) 
 

Definition at line 16 of file input.c.

References cp, fillbuf(), line, lineno, nextline(), and resynch().

Referenced by getchr(), gettok(), input_init(), nextline(), resynch(), and scon().

00016                     {
00017     do {
00018         if (cp >= limit) {
00019             fillbuf();
00020             if (cp >= limit)
00021                 cp = limit;
00022             if (cp == limit)
00023                 return;
00024         } else {
00025             lineno++;
00026             for (line = (char *)cp; *cp==' ' || *cp=='\t'; cp++)
00027                 ;
00028             if (*cp == '#') {
00029                 resynch();
00030                 nextline();
00031             }
00032         }
00033     } while (*cp == '\n' && cp == limit);
00034 }

Here is the call graph for this function:

void pragma void   )  [static]
 

Definition at line 79 of file input.c.

References cp, gettok(), ID, symbol::ref, src, strcmp(), t, tsym, and use().

Referenced by resynch().

00079                          {
00080     if ((t = gettok()) == ID && strcmp(token, "ref") == 0)
00081         for (;;) {
00082             while (*cp == ' ' || *cp == '\t')
00083                 cp++;
00084             if (*cp == '\n' || *cp == 0)
00085                 break;
00086             if ((t = gettok()) == ID && tsym) {
00087                 tsym->ref++;
00088                 use(tsym, src);
00089             }   
00090         }
00091 }

Here is the call graph for this function:

void resynch void   )  [static]
 

Definition at line 94 of file input.c.

References Aflag, cp, file, fillbuf(), firstfile, limit, line, lineno, nextline(), pragma(), stringn(), strncmp(), and warning().

Referenced by nextline().

00094                           {
00095     for (cp++; *cp == ' ' || *cp == '\t'; )
00096         cp++;
00097     if (limit - cp < MAXLINE)
00098         fillbuf();
00099     if (strncmp((char *)cp, "pragma", 6) == 0) {
00100         cp += 6;
00101         pragma();
00102     } else if (*cp >= '0' && *cp <= '9') {
00103     line:   for (lineno = 0; *cp >= '0' && *cp <= '9'; )
00104             lineno = 10*lineno + *cp++ - '0';
00105         lineno--;
00106         while (*cp == ' ' || *cp == '\t')
00107             cp++;
00108         if (*cp == '"') {
00109             file = (char *)++cp;
00110             while (*cp && *cp != '"' && *cp != '\n')
00111                 cp++;
00112             file = stringn(file, (char *)cp - file);
00113             if (*cp == '\n')
00114                 warning("missing \" in preprocessor line\n");
00115             if (firstfile == 0)
00116                 firstfile = file;
00117         }
00118     } else if (strncmp((char *)cp, "line", 4) == 0) {
00119         for (cp += 4; *cp == ' ' || *cp == '\t'; )
00120             cp++;
00121         if (*cp >= '0' && *cp <= '9')
00122             goto line;
00123         if (Aflag >= 2)
00124             warning("unrecognized control line\n");
00125     } else if (Aflag >= 2 && *cp != '\n')
00126         warning("unrecognized control line\n");
00127     while (*cp)
00128         if (*cp++ == '\n')
00129             if (cp == limit + 1)
00130                 nextline();
00131             else
00132                 break;
00133 }

Here is the call graph for this function:


Variable Documentation

int bsize [static]
 

Definition at line 7 of file input.c.

Referenced by fillbuf(), and input_init().

unsigned char buffer[MAXLINE+1+BUFSIZE+1] [static]
 

Definition at line 8 of file input.c.

unsigned char* cp
 

Definition at line 9 of file input.c.

Referenced by addrtree(), AngleVectors(), backslash(), bbcall(), bbincr(), BotGetMessageTeamGoal(), BotMatch_CheckPoint(), branch(), code(), compound(), ConvertFilePath(), CXYWnd::Copy(), definelab(), definept(), doAddress(), doBlockbeg(), EmitBrushes(), emitcode(), error(), fcon(), fillbuf(), funcdefn(), gencode(), getchr(), getopt(), gettok(), icon(), input_init(), locus(), lookup(), nextline(), CXYWnd::Paste(), ppnumber(), pragma(), reachable(), resynch(), scon(), stabline(), stringify(), toAngles(), angles_t::toForward(), toMatrix(), angles_t::toVectors(), and use().

char* file
 

Definition at line 10 of file input.c.

Referenced by _assert(), _YYnull(), acaller(), afunction(), apoint(), bbfile(), BotSetupChatAI(), BotSetupWeaponAI(), DoesFileExist(), Eclass_InitForSourceDirectory(), emitdata(), findcount(), findfunc(), FS_FileExists(), FS_FOpenFileRead(), FS_ForceFlush(), FS_GetModList(), FS_Seek(), FS_SV_FileExists(), gather(), input_init(), Patch_Write(), PC_Directive_include(), process(), ReadBytes(), ReadMagic(), resynch(), idCameraDef::save(), stabinit(), Terrain_Write(), unzClose(), unzCloseCurrentFile(), unzeof(), unzGetCurrentFileInfo(), unzGetCurrentFileInfoPosition(), unzGetGlobalComment(), unzGetGlobalInfo(), unzGetLocalExtrafield(), unzGoToFirstFile(), unzGoToNextFile(), unzlocal_GetCurrentFileInfoInternal(), unzLocateFile(), unzOpenCurrentFile(), unzReadCurrentFile(), unzReOpen(), unzSetCurrentFileInfoPosition(), unztell(), idFixedPosition::write(), idInterpolatedPosition::write(), idSplinePosition::write(), WriteBytes(), and Z_Malloc().

char* firstfile
 

Definition at line 11 of file input.c.

Referenced by resynch().

unsigned char* limit
 

Definition at line 12 of file input.c.

char* line
 

Definition at line 13 of file input.c.

Referenced by _assert(), _YYnull(), AAS_DebugLine(), AAS_DrawPlaneCross(), AAS_PermanentLine(), AAS_ShowArea(), AAS_ShowBoundingBox(), BotExportTest(), BotImport_DebugLineDelete(), BotImport_DebugLineShow(), Cbuf_Execute(), CG_Tracer(), Com_ParseRestOfLine(), Con_Dump_f(), ConcatArgs(), fillbuf(), GetClearedHunkMemory(), GetClearedMemory(), HL_UnparseEntities(), nextline(), PC_SourceError(), PC_SourceFileAndLine(), PC_SourceWarning(), Q1_UnparseEntities(), Q2_UnparseEntities(), Q3_UnparseEntities(), resynch(), Sin_UnparseEntities(), trap_PC_SourceFileAndLine(), UnparseEntities(), and Z_Malloc().

int lineno
 

Definition at line 14 of file input.c.

Referenced by input_init(), nextline(), printfile(), and resynch().


Generated on Thu Aug 25 15:54:48 2005 for Quake III Arena by  doxygen 1.3.9.1