The treacherous slash

Q:The info page for Extended Char Intro says an encoding is filesystem-safe when the character ‘/’ is used in the encoding _only_ to represent itself. What else could it possibly represent?

Latest GLIBC release

Q:The home page currently states that the latest version is 2.8, yet 2.7 is the latest version available on the ftp site. Why is that?
A: It may be that the release manager has not yet uploaded the release tarballs. Please check with the release manager on the Release page.

Old Crypt Add-on

Q:I get the following error about an old crypt add-on when I configure GLIBC. What's going on?

*** It seems that you're using an old `crypt' add-on.  crypt is now
*** part of glibc and using the old add-on will not work with this
*** release.  Start again with fresh sources and without the old
*** `crypt' add-on.

A:You must specify --enable-add-ons=foo, or --enable-add-ons (which defaults to nptl,libidn) to avoid the automatic search for addons from adding crypt. Don't enable 'crypt' and don't unpack any ancient crypt add-on tarballs into your source tree.

fgetc function / compliance to standard

Q:Does the behaviour of fgetc violate the c standard?

#include <stdio.h>
#include <unistd.h>

int main(void)
{
    int c;
    FILE *fp = fopen("file.txt", "r");
    for(;;) {
        c = fgetc(fp);
        if(c == EOF)
            sleep(1);
        else
            putchar(c);
    }   

    return 0;
}

This program reads until EOF, then sleeps. When I append new data to file.txt, it continues reading.

The c99 standard says in §7.19.7.1:

If the end-of-file indicator for the input stream pointed to by stream is not set and a
next character is present, the fgetc function obtains that character as an unsigned
char converted to an int and advances the associated file position indicator for the
stream (if defined).

If the end-of-file indicator for the stream is set, or if the stream is at end-of-file, the end-
of-file indicator for the stream is set and the fgetc function returns EOF. Otherwise, the
fgetc function returns the next character from the input stream pointed to by stream.

My manpage for feof / clearerr says:

The end-of-file indicator can only be cleared by the function clearerr().

When the program reaches end of file, the end-of-file indicator must be set and next time fgetc is used, it must return EOF again, even if there is new data available. Does this mean that glibc violates the standards or did I get something wrong?

None: Feedback (last edited 2012-07-09 18:03:30 by KřištofŽelechovjski)