~ubuntu-branches/ubuntu/gutsy/avr-libc/gutsy

« back to all changes in this revision

Viewing changes to libc/stdio/fgetc.c

  • Committer: Bazaar Package Importer
  • Author(s): Hakan Ardo
  • Date: 2006-05-01 12:03:39 UTC
  • mto: (3.1.1 edgy)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20060501120339-q93dxulpunby36dj
Tags: upstream-1.4.4
ImportĀ upstreamĀ versionĀ 1.4.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2002, Joerg Wunsch
 
1
/* Copyright (c) 2002, 2005, Joerg Wunsch
2
2
   All rights reserved.
3
3
 
4
4
   Redistribution and use in source and binary forms, with or without
27
27
  POSSIBILITY OF SUCH DAMAGE.
28
28
*/
29
29
 
30
 
/* $Id: fgetc.c,v 1.3 2003/01/07 22:17:24 joerg_wunsch Exp $ */
 
30
/* $Id: fgetc.c,v 1.5 2005/09/06 18:49:15 joerg_wunsch Exp $ */
31
31
 
32
32
#include <stdio.h>
33
33
 
48
48
        }
49
49
 
50
50
        if (stream->flags & __SSTR) {
51
 
                rv = *stream->buf++;
 
51
                rv = *stream->buf;
52
52
                if (rv == '\0') {
53
53
                        stream->flags |= __SEOF;
54
54
                        return EOF;
 
55
                } else {
 
56
                        stream->buf++;
55
57
                }
56
58
        } else {
57
 
                rv = stream->get();
58
 
                if (rv == -1) {
59
 
                        stream->flags |= __SERR;
 
59
                rv = stream->get(stream);
 
60
                if (rv < 0) {
 
61
                        /* if != _FDEV_ERR, assume it's _FDEV_EOF */
 
62
                        stream->flags |= (rv == _FDEV_ERR)? __SERR: __SEOF;
60
63
                        return EOF;
61
64
                }
62
65
        }