Exemple #1
0
main()
{
	int c ;
	char *s ;
	int lines = 4000 ;

	for ( ;; )
	{
		c = Sgetchar( 0 ) ;
		if ( c == SIO_EOF )
			exit( 0 ) ;
		if ( c == SIO_ERR )
			exit( 1 ) ;
		putchar( c ) ;
		if ( c == '\n' )
		{
			lines-- ;
			if ( lines == 0 )
				break ;
		}
	}
	while ( s = Srdline( 0 ) )
		puts( s ) ;
	exit( 0 ) ;
}
Exemple #2
0
main()
{
	char *s ;
	int count=0 ;

	while ( s = Srdline( 0 ) )
	{
		puts( s ) ;
		count++ ;
	}
	Sdone( 0 ) ;
	exit( 0 ) ;
}
Exemple #3
0
/*
 * next_line returns the next line of the file or NULL if the end of file
 * is reached.
 * Comment lines and empty lines are skipped.
 */
char *next_line( int fd )
{
   for ( ;; )
   {
      char *p ;
      char *line = Srdline( fd ) ;

      if ( line == NULL )
         return( NULL ) ;

      line_count++ ;

      for ( p = line ;; p++ )
         if ( *p == NUL || *p == COMMENT_BEGIN )
            break ;                                /* skip this line */
         else if ( isspace( *p ) )
            continue ;                             /* skip white space */
         else
            return( line ) ;
   }
}
Exemple #4
0
main()
{
	int c ;
	char *s ;
	int errval ;

	for ( ;; )
	{
		if ( RANDOM() % 1 )
		{
			s = Srdline( 0 ) ;
			if ( s == NULL )
				break ;
			if ( RANDOM() % 16 < 5 )
			{
				errval = Sundo( 0, SIO_UNDO_LINE ) ;
				if ( errval == SIO_ERR )
					exit( 1 ) ;
			}
			else
				puts( s ) ;
		}
		else
		{
			c = Sgetchar( 0 ) ;
			if ( c == SIO_EOF )
				break ;
			if ( RANDOM() % 16 < 5 )
			{
				errval = Sundo( 0, SIO_UNDO_CHAR ) ;
				if ( errval == SIO_ERR )
					exit( 2 ) ;
			}
			else
				putchar( c ) ;
		}
	}
	exit( 0 ) ;
}