/* This subroutine gets the next line from the input file.
 *
 * $Log: getline.c,v $
 * Revision 1.2  1997/06/04 01:10:43  david
 * ANSI-fied the program.
 *
 */

#include <stdio.h>
#include "xasm.h"

static char *RcsId = "$Id: getline.c,v 1.2 1997/06/04 01:10:43 david Exp $";

char *getline(void)
{
static char linebuf[133]; /* Current input line */
int i, c;
for ( i = 0; i < sizeof( linebuf ) - 1; i++ )
   {
   if ( (c = fgetc( infd )) == EOF )
      return( NULL );
   if (	c == '\r' )
      {
      i--; /* Back up pointer for next iteration */
      continue;
      }
   if (	c == '\n' )
      {
      line++; /* Increment line # */
      break;
      }
   linebuf[i] = c;
   }
linebuf[i] = '\0'; /* Terminate string */
return( linebuf ); /* Return pointer to line buffer */
}
