Bug in SosMan's getline_test

K

Keith Thompson

Friar Tuck said:
On 12 Sep 2007 at 23:47, pete wrote: [...]
There is no such thing as "the group website".

Isn't the group website cpac.org? It's in one of the group moderator's
signatures and has lots of C resources. It certainly looks official.

comp.lang.c has no moderator. Perhaps you're thinking of
comp.lang.c.moderate. In any case, cpac.org has nothing to do with C;
it's a political site.

[...]
Was the final conclusion of this thread that Dr Sosman's function
clashes with a common library funcion and should be renamed?
[...]

I don't think there was a conclusion. (One could also argue, though
less persuasively, that GNU's getline function should be renamed
because it conflicts with Eric's.)
 
C

Chris Dollin

Friar said:
Isn't the group website cpac.org?
No.

It's in one of the group moderator's

comp.lang.c doesn't have a moderator.
signatures and has lots of C resources. It certainly looks official.

What do you mean, "looks official"?
C (gcc 4.1.3).

I think they meant your native /spoken/ language.
Does anyone know what all these fields in the FILE * structure do?

Something implementation-dependant. Portable code can't care about it.
 
F

Friar Tuck

This group doesn't have a moderator either.

OK, well senior member then.
I wonder what you think a political web site has to do with the C
language.

Whoops, yes, I seem to have remembered the address wrongly. I think it
was .org.uk instead.
snip


The internal structure of a FILE object is implementation dependent.
You will need to ask in a group that discusses your implementation.

Are you sure? I'm fairly confident that the FILE * structure is a
fundamental type in standard C. Maybe there are some basic fields
guaranteed to be present (which ones?) and others may be added as an
extension?
 
F

Friar Tuck


Sorry, .org.uk
comp.lang.c doesn't have a moderator.

Sorry, senior member.
What do you mean, "looks official"?

It has this resources page
http://cpax.org.uk/prg/portable/c/resources.php that gives the
impression it's the official resources page for comp.lang.c though maybe
that's just what comes across from the first paragraph.
I think they meant your native /spoken/ language.

What in any of my posts suggests that my native spoken language isn't
English?? Why is it relevant?
Something implementation-dependant. Portable code can't care about it.

I believe you are mistaken - portable functions like fread etc. take a
FILE * structure for an argument.
 
J

Joachim Schmitz

Friar Tuck said:
Are you sure? I'm fairly confident that the FILE * structure is a
fundamental type in standard C. Maybe there are some basic fields
guaranteed to be present (which ones?) and others may be added as an
extension?
from n1256, 7.19.1 p2:
The types declared are ...; FILE which is an object type capable of
recording all the information needed to control a stream, including its file
position indicator, a pointer to its associated buffer (if any), an error
indicator that records whether a read/write error has occurred, and an
end-of-file indicator that records whether the end of the file has been
reached: ...

Bye, Jojo
 
J

Joachim Schmitz

Friar Tuck said:
I believe you are mistaken - portable functions like fread etc. take a
FILE * structure for an argument.
So what? Of course fread would know (need to) about the (implementation
dependant) internals of FILE, but you don't need to know to be able to use
it.

Bye, Jojo
 
R

Richard Bos

There's no such thing as a "FILE * structure". There's a FILE, which is
an object type, not necessarily a struct, and a FILE *, which is a
pointer to that type.
from n1256, 7.19.1 p2:
The types declared are ...; FILE which is an object type capable of
recording all the information needed to control a stream, including its file
position indicator, a pointer to its associated buffer (if any), an error
indicator that records whether a read/write error has occurred, and an
end-of-file indicator that records whether the end of the file has been
reached: ...

And note that there is no indication whatsoever _how_ a FILE records
this information. It could be a struct; it could also be an array of
unsigned chars.

Richard
 
C

Chris Dollin

Friar said:
OK, well senior member then.

The word you're groping for is "regular". It has no official status.
Are you sure? I'm fairly confident that the FILE * structure is a
fundamental type in standard C.

It isn't.
Maybe there are some basic fields
guaranteed to be present (which ones?) and others may be added as an
extension?

No.
 
C

Chris Dollin

Friar said:
On 14 Sep 2007 at 7:41, Chris Dollin wrote:

It has this resources page
http://cpax.org.uk/prg/portable/c/resources.php that gives the
impression it's the official resources page for comp.lang.c though maybe
that's just what comes across from the first paragraph.

I get no such impression.
What in any of my posts suggests that my native spoken language isn't
English?? Why is it relevant?

Don't ask me; ask the person who asked the question. Probably they
thought that what you said suggested you hadn't understood them in
a way that suggests ESL.
I believe you are mistaken - portable functions like fread etc. take a
FILE * structure for an argument.

`fread` isn't portable; it is specific to each implementation. That's
why it's there in the Standard; you can't portably write one yourself.
(Well, you can -- but it's useless.)
 
K

Keith Thompson

Friar Tuck said:
Sorry, .org.uk

You're thinking of cpax.org.uk, but that site has absolutely no
official standing with respect to this newsgroup.
Sorry, senior member.

Richard Heathfield is a regular participant in this newsgroup. So am
I. So are a number of others. Since this is an unmoderated
newsgroup, nobody has any official status, because there is no
official status to be had.
It has this resources page
http://cpax.org.uk/prg/portable/c/resources.php that gives the
impression it's the official resources page for comp.lang.c though maybe
that's just what comes across from the first paragraph.

I'm sure that Richard did not intend to give that impression.

The FAQ site, <http://www.c-faq.com/>, is the closest thing we have to
an "offical" site for the newsgroup, but even it has no real official
standing. I could set up my own FAQ site tomorrow. I don't because
(a) it would be a lot of work, and (b) Steve Summit has already done
such a fine job of it.
What in any of my posts suggests that my native spoken language isn't
English?? Why is it relevant?

The question was, I believe, intended to point out that you had
misunderstood something that should have been reasonably clear.
Somebody mentioned the 'getline' function that's part of the GNU
library. You responded by saying that there's no such standard
library function -- but nobody had said that there was. The 'getline'
function in question is specific the GNU library (glibc), and the
person who mentined it said so explicitly.

Making this point by questioning whether English is your native
language was perhaps a bit rude. But I'll mention that there are
plenty of people with other native languages who write excellent
English, better than some native speakers. Such people sometimes make
surprising errors.
I believe you are mistaken - portable functions like fread etc. take a
FILE * structure for an argument.

No, he's not mistaken. That's why the fread function cannot be
implemented in portable code. Each (hosted) implementation must
provide the function, so code that uses it can be portable, but the
function itself can and must use implementation-specific techniques
(unless it's implemented entirely in terms of other standard
functions).
 
R

Richard Heathfield

Keith Thompson said:
I'm sure that Richard did not intend to give that impression.

Actually, I'd /love/ to give the impression that my site is "official"
in some way, because that would indicate that my Web skills are just as
amazing as all my other skills - but apathy always wins out. :)

From the sidelines, I've been watching this discussion with some
amusement, and I saw no particular need to interfere (that cpac
political thing was a real eye-opener, btw!), but a word in season
seems to be indicated here, so here we go:

Anyone who looks at my Web site and genuinely thinks it to be the
official comp.lang.c Web site has got to be off his rocker. Completely
out to lunch. A brick, two windows, several roofing slates, two
teenagers, a loft hatch, and twenty square feet of dry rot short of a
house.

Message ends.
 
B

Barry Schwarz

There's no such thing as a "FILE * structure". There's a FILE, which is
an object type, not necessarily a struct, and a FILE *, which is a
pointer to that type.



And note that there is no indication whatsoever _how_ a FILE records
this information. It could be a struct; it could also be an array of
unsigned chars.

And in a reply with insufficient quoting

On Fri, 14 Sep 2007 11:48:08 +0000, Richard Heathfield

Discussing the internal nature of a FILE object
Richard Bos said:



Only if it's a union. :)

Care to expand?

Do you infer that the file position information must be stored in a
long, the pointer information in a pointer object, etc? It is
certainly possible for an array of unsigned char to contain this data
without any other type of object.

By the way, since the buffer need not be a defined C object, what type
of pointer do you think would be appropriate?


Remove del for email
 
K

Keith Thompson

Barry Schwarz said:
Care to expand?

O n l y i f i t ' s a u n i o n . : - )

I believe RH was making one of his little jokes. Note:

It could be a struct; it could *also* be an array of unsigned
chars.

The only way it could be *both* is if it's a union.

Actually, that's not *strictly* correct (a union containing a struct
is not a struct), but it's close enough for humorous purposes.
 
P

pete

Keith said:
The question was, I believe, intended to point out that you had
misunderstood something that should have been reasonably clear.
Somebody mentioned the 'getline' function that's part of the GNU
library. You responded by saying that there's no such standard
library function -- but nobody had said that there was. The 'getline'
function in question is specific the GNU library (glibc), and the
person who mentined it said so explicitly.

Making this point by questioning whether English is your native
language was perhaps a bit rude.

Yes, it was.

Most of OP's writings seem to consist of bizarre assumptions,
stated as facts.

OP's camel case spelling of "SosMan" in the subject line
is an unusual affectation, which makes me wonder
if the doctorate in "Dr Sosman" is also a delusion.
 
E

Eric Sosman

Friar said:
I believe I have found a bug in Dr Sosman's getline_test program, which
is one of the official newsgroup programs. [...]

Just back from a week without Usenet access, let me
try to clear up a few points that have appeared in this
thread. In no particular order:

- Tuck's problem stems from running my getline_test program
with somebody else's getline() function. There is no official
specification for what a getline() function should behave nor
for how a program should call it, so my program's failure when
used with an unexpected getline() does not demonstrate that my
program is buggy. Try to write a foo_test program to exercise
every function called foo() ever posted to this newsgroup, and
you'll understand the problem.

- Name collisions are a fact of life in C programs made up
of bits and pieces from multiple, uncoordinated sources. The
language (like many others) provides little to help an integrator
avoid the problem or deal with it when it arises. The Standard
helps only a little, by dividing the universe of names into three
parts like a digital Caesar: Names that can only be used as the
Standard dictates, names that can only be used by implementations,
and names that can only be used by programmers. Writers of utility
functions don't fit comfortably into any of these three classes,
and inevitably bump into each other.

- My decision to use the name getline() has been criticized
as "a poor one." As outlined above, no name choice is 100% safe;
it is not possible to anticipate all the names all the other
programmers in the world might choose to use. That's one of the
reasons source is provided: you can edit it and override my decision
if you think it poor. I suggest the critic should change the name
to getstuffed().

- The whole digression about puts() vs. printf() vs. who
can spot the missing newline while writing his name in the snow
is a sad reflection on c.l.c. and the people who make it up.
Sadder still, it is not the first such asinine sub-thread.

- If there is an official c.l.c. web site I have never heard
of it. (One wonders what office's proclamation could bestow
"official" status on a web site, anyhow. If someone suddenly
pops up and announces that http://127.0.0.1/ is now the official
web site of alt.swedish.chef.bork.bork.bork, my first reaction
is to wonder who died and made him Emperor.) In any case, there
is nothing at all "official" about my code, wherever hosted.

- Speaking of code: I hope you will use different standards
when judging my getline() and my getline_test. The former is an
attempt to write something small and simple, with reasonable
portability and an emphasis on ease of use. The latter is a
unit test that tries to exercise the function and verify that
it has worked properly; ease of use is not very important, and
neither is smallness or simplicity. In this case, portability
is compromised, too (it tries to test a circumstance that may
not be possible to produce on all systems, so some sacrifice of
portability is required in any event).

- My father was a doctor, and his father was a doctor, and
several of my friends and acquaintances are doctors, but I am
not even a fud.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top