Requesting advice how to clean up C code for validating string represents integer

  • Thread starter robert maas, see http://tinyurl.com/uh3t
  • Start date
S

Stephen Sprunk

I'd like to do that, but I don't know of any search engine where I
type in the name of a C library function and get back the status of
that particular function and the various standards (C99, C89/C90,
K&R) and implementations. So occasionally I will read about some
function, try it, find it works, and describe it in my document,
without any to know it isn't standard.

Well, the authoritative way is to download the standard (e.g. n1124.pdf) and
search for the function you're curious about. If it's there, it's standard
:)
I'm not aware of any man pages that tell whether a given function
in c is standard and if so which standard.

If you're on a unix-ish system, try "man func" and look for a "Conforming
To" section. If you're on some other type of system, or if your local man
pages suck, Google for "func man page". For instance, the first hit I see
for 'strlen man page' is:
http://www.die.net/doc/linux/man/man3/strlen.3.html
and that page explicitly says the function is in C89 and C99.

If you work with a lot of unix-ish code, you'll see that a lot of functions
you're used to will be listed as conforming to POSIX and _not_ C89/99. For
example, compare the man pages for open() and fopen().

S
 
C

CBFalconer

I'd like to do that, but I don't know of any search engine where I
type in the name of a C library function and get back the status of
that particular function and the various standards (C99, C89/C90,
K&R) and implementations. So occasionally I will read about some
function, try it, find it works, and describe it in my document,
without any to know it isn't standard.

You are a complete fake. You have been told time after time where
to get the C standard at zero cost, after which detecting that the
function is standard is at most a matter of using grep. Yet you
persist in this silly moaning. No wonder you are unemployable.
 
K

Keith Thompson

I'd like to do that, but I don't know of any search engine where I
type in the name of a C library function and get back the status of
that particular function and the various standards (C99, C89/C90,
K&R) and implementations. So occasionally I will read about some
function, try it, find it works, and describe it in my document,
without any to know it isn't standard.

You can find out by looking it up in a copy of the standard, or a
draft of the standard. You've been told several times how you can get
one in plain text form.

[...]
I'm not aware of any man pages that tell whether a given function
in c is standard and if so which standard.

I've seen man pages that have a "CONFORMING TO" section or something
similar. Look around.
 
R

Robert Maas, see http://tinyurl.com/uh3t

From: "santosh said:
You'll have to buy the actual Standard, ...

That's rather rude of you to tell a person who is totally broke and
appx. $64,000 in debt to credit cards (just for basic living
expenses to stay alive for nearly 7 years before I got into
subsidized housing) that the person "will have to buy" something. I
suggest strongly that you find a lawyer who will very quickly track
down who sent me two hundred spam just in one day, worth two
hundred thousand dollars per California law if we can find who they
are and serve court papers on them. Then I'll be able to afford to
hire a large team of private detectives to track down the rest of
the spammers who have been flooding my mailbox with two hundred
spam per day for the past three years, worth 219 million dollars
so-far. Hey, if you personally know how to track down spammers,
maybe you could make a buck by helping me track down the first of
the spammers? You get paid as soon as we collect from the spammer,
OK? Or as soon as we get court judgement we sell it to a collection
agency at a discount, for example fifty spam from one spammer,
judgement of $50,000, we sell to collection agency for %10,000,
which should give us enough seed money to re-invest in suing more
spammers?
Since I have no way to view PDF here, I'll ignore that pointer.
CBFalconer has a pure text version of the final C99 draft at:
<http://cbfalconer.home.att.net/download/n869_txt.bz2>

Sorry, I read only English. When I copy&paste that URL into the Web
browser (lynx) and fetch the Web page, I see something that ain't English:

BZh91AY&SYgZy#EpDT{ c]>=+v" NzUm<s;<rntx/jhm`u{>|sKk}aYiE
S m9[A]%2 r*m-%TP`(kUR "^:*@$W}x:;o`z"Jo}pm1tcO,lz;G=^_{asAtV>@$")hVZ 5>[(ZV!4
P44V"Ed}[6
%hI&$ZQLI) 5-P hU
HkI *
6RX0TIFm#6)6Hk i]
u] Q)IT4u'n<[@7KWw|=uH>0v:}o3>}oW<]o;I^;v`{J:Zf>j+3
O>{^{F4=T+t.@iBMj9,.h nc22ZgY.AVSlh_7:[FGv=YhIR0iU.#}uNrUV snNAST)RL_Wwf4E;5[+6
FM6kv55mU-}L9t\CUhYEqEu'Y]mRN_}NZ1t%3>=TPRJ$LU>H@rV_ppwwY>{'+;k)mE4-lK -:pvy8wp
w=8`WOZahh$SwnWaFRQXV=:{q]ide%{7''j_f)TERZ/LUVvE:mg\RSinEM0T=skTXmuK\Z(l)JyjRTm
` 5 ( D6U#lia^F`o`.mQ!"kR{=XRmbv5#&osK_l;7'1nlt-d_MM,,cmsor|"d5P%5K7ptw=`}zT4
SJP2AwJ8pkUN{]djn]p$@XPLXRT
aM7[]6vto^ou\0N=N9XVe]0#hMWpo0zw_9>s^>+>wt}us@pxu8WG]]^vr{:h@,zv]:;XzW!unXfW:i$
Q>0VuX
wU\3n()[A;7p>mP.<>{;T@{9e<tw0l6D6N7g|^5U${yJY.
@Y QQAR[ee]e]U@@i]Lazbg<tJu9j
h).B[ll{nF5*N]"LttHl v`]W/: U]d5%jz4'ZvRD *pig\uv|z/]&nw{;\)AEim9l<gN]\xxthI@
&( 4[\D"*FZYwYa@64+iGv"U34P=F1@R(mj
k.
w\}fmwR}iP:;|>

Now if you would be so kind as to translate that to English...

Via Google search, after somebody posted the correct search term to
try, I found something which is English, but it's nearly two
thousand VT100 screens, more than 1.3 megabytes (I downloaded it to
my shell account), so it'll take some time to browse it. What I
might do is hyperize it, i.e. write a CGI script that extracts
sections of text from it to emulate Web pages with links. Then I
would have for C99 virtually something roughly equivalent to
Pitman's Common Lisp HyperSpec. I'm rather dismayed that nobody has
bothered to do that in the 8 years since it was published, that I
would have to be the first to do that if it's ever to be done.
<OT>Why does that last sentence give me the feeling that I'm almost
quoting from Alice's Adventures in Wonderland? Does anybody
recognize the passage?</OT>
 
R

Richard Heathfield

Robert Maas, see http://tinyurl.com/uh3t said:
That's rather rude of you

Please bear in mind that English is almost certainly not Santosh's first
language, and it is very possible - even likely - that you have
misinterpreted him. I believe that what he intended to say was: "if you
want the actual Standard itself, you'll have to buy it" (which is true,
because it's not available for free). Why do I believe this? I'll tell
you. It's because of the rest of what he said in that very sentence,
which you appear to have deliberately ignored:

"You'll have to buy the actual Standard, but the latest working paper,
which includes two added Technical Corrigenda is available for free".
to tell a person who is totally broke

I sympathise, but that's your problem, not his.
Since I have no way to view PDF here, I'll ignore that pointer.

Again, I sympathise. PDF is no substitute for a portable document
format. Unfortunately, that's ISO's release format, and there's no
helping it. Yes, you can get text conversions, but you tend to lose
some important format information (e.g. subscript and superscript info
is lost, so you see sillinesses such as 232 - 1 on occasion).
Sorry, I read only English. When I copy&paste that URL into the Web
browser (lynx) and fetch the Web page, I see something that ain't
English:

At this point, either you're just being silly for the sake of being
silly, or you're saying you don't recognise bzip2 format.
Now if you would be so kind as to translate that to English...

You can do it yourself, using bunzip2. Furrfu.
 
K

Keith Thompson

From: "santosh" <[email protected]>
You'll have to buy the actual Standard, ...

That's rather rude of you to tell a person who is totally broke and
appx. $64,000 in debt to credit cards (just for basic living [15 lines deleted]
which should give us enough seed money to re-invest in suing more
spammers?

My sympathy for your situation is wearing thin. This newsgroup is for
discussion of the C programming language, not a forum for you to whine
about your misfortune. We've all got problems, dude.
Since I have no way to view PDF here, I'll ignore that pointer.


Sorry, I read only English. When I copy&paste that URL into the Web
browser (lynx) and fetch the Web page, I see something that ain't English:
[snip]

The ".bz2" suffix means it's compressed with the "bzip2" compression
program.
[...]
Via Google search, after somebody posted the correct search term to
try, I found something which is English, but it's nearly two
thousand VT100 screens, more than 1.3 megabytes (I downloaded it to
my shell account), so it'll take some time to browse it.

Yes, that's about right. My copy of n869.txt (uncompressed from
n869_txt.bz2) is 1128 kbytes; n1124.txt (exported from n1124.pdf) is
1040 kbytes.
What I
might do is hyperize it, i.e. write a CGI script that extracts
sections of text from it to emulate Web pages with links. Then I
would have for C99 virtually something roughly equivalent to
Pitman's Common Lisp HyperSpec. I'm rather dismayed that nobody has
bothered to do that in the 8 years since it was published, that I
would have to be the first to do that if it's ever to be done.

I've never felt the need for a "hyperized" version of the standard; I
suspect few others have either. Good luck generating one yourself.

Now that you have a copy of a draft of the standard, perhaps you'll
stop complaining that you don't have one.
 
R

Robert Maas, see http://tinyurl.com/uh3t

(which was true at the time I wrote it)
It's a good job you have access to it then, isn't it.

At the time you wrote that, I didn't yet have access. But as soon
as I saw your article the next day or so, things might have
changed. Let me check...
If no one has given you the details before, then go here
http://www.clc-wiki.net/wiki/c_standard and follow the links.

That WebPage doesn't have a links section, however when I first saw
your article, before I had time to post nor time to read the Web
pages linked, I did manage to find these two links that might be
useful, from somewhere in the Wiki page, I have no idea where,
although if I search for the Linkname text I might find them again:

Linkname: c standard - clc-wiki
URL: http://www.clc-wiki.net/wiki/c_standard#Obtaining_the_Standard
Hmm, I seem to have bookmarked a section in that same Wiki page.
It says:
Neither the Standard nor its amendments are available free of charge,
I think that kills the issue for me.

Linkname: Standard C: ISO/IEC 9899:1999(E) + TCs
URL: http://c0x.coding-guidelines.com/
I have no idea where I found that link. Neither the Linkname nor
any significant part of it is on the Wiki page. Blindly going
there... Oh yeah, I remember this site now. It's a flat HTML
version, where the table of contents has been totally linearized,
no structure at all, just a flat list of sections, with a link from
each TOC item to the corresponding actual Web page. For example:

Linkname: The New C Standard: 6.3.2.1
URL: http://c0x.coding-guidelines.com/6.3.2.1.html
717 An lvalue is an expression with an object type or an incomplete
type other than void;^53)

So what's an "object type"??

Linkname: The New C Standard: 6.5.3.4
URL: http://c0x.coding-guidelines.com/6.5.3.4.html
1108 The sizeof operator ...
1111 The result is an integer.
Huh? I thought it was supposed to be a size_t ??

1117 The value of the result is implementation-defined, and its type
(an unsigned integer type) is size_t, defined in <stddef.h> (and other
headers).
OK, that's better (phew!).

1119 EXAMPLE 2 Another use of the sizeof operator is to compute the
number of elements in an array:
sizeof array / sizeof array[0]
That's rather silly. After all, the only place sizeof works for
that is when the declaration of the array is lexically visible, in
which case the number of elements is lexically visible right there
inside the syntax of the declaration, and you can retrieve that
allocation size directly without bothering with that division
operation. Is this for programmers who are paranoid about macros to
emulate constants, so instead of saying:
#define ARRSIZ 14
int foo[ARRSIZ];
for (ix=0; ix<ARRSIZ; ix++) {...}
they write code like this:
int foo[14];
for (ix=0; ix<(sizeof(foo)/sizeof(foo[0])); ix++) {...}

1120 ...
That example is so contrived and frivolous as to degrade C.
Why not an example of how this feature in C can actually help solve
a useful problem, instead of just serve to produce an example of
obfuscated code for the sake of obfuscated code?

** Not a single mention of library functions, which is the major
topic of discussion/debate here (C90 vs. C99 vs. GNU C etc. such as
strtoll). In fact, with this entire document, it's not even
possible to learn what's needed to write a Hello World program.

Let me take a look at the **other** file, 1.3 megabytes, which I
downloaded the other day ... <verbose>shit, it took me a while to
find where I downloaded it to. It wasn't in my C directory, or in
my public_html directory, nor in my HelloWorld directory nor
CookBook directory nor in cgi-bin directory nor at toplevel in my
account nor in the temporary directory where I usually up/down-load
stuff. I finally guessed it might be in my Lisp directory, and
that's where it is, probably because I had been working in lisp
before I took some time off to start lynx, and I hadn't bothered to
change working directory before starting lynx, and after download I
didn't happen to have a good idea where I should move it, so I just
left it there</verbose> ... c9x-draft.txt is what I downloaded, and
chapter 7 is all about libraries, starting with general description
of what header files are used for, and a list of the standard
header files:
[#2] The standard headers are
<assert.h> <inttypes.h> <signal.h> <stdlib.h>
<complex.h> <iso646.h> <stdarg.h> <string.h>
<ctype.h> <limits.h> <stdbool.h> <tgmath.h>
<errno.h> <locale.h> <stddef.h> <time.h>
<fenv.h> <math.h> <stdint.h> <wchar.h>
<float.h> <setjmp.h> <stdio.h> <wctype.h>

[#1] Some of the functions below have branch cuts, across
which the function is discontinuous. For implementations
with a signed zero (including all IEC 60559 implementations)
that follow the specification of annex G, the sign of zero
distinguishes one side of a cut from another so the function
is continuous (except for format limitations) as the cut is
approached from either side. For example, for the square
This is a complete crock!!! To allow a function to have two
different values at exactly the same mathematical value of zero,
they pretend like there are two different zeroes, one zero that is
greater than zero, and another zero which is less than zero. This
stupid mess allows that trick to happen **only** if the branch cut
is at exactly zero. If for example you instead wanted a branch cut
at 3, you're out of luck, because there's no implementation of two
different 3's, one which is greater than 3 and another which is
less than three. Even for zero, hardly any implementation
distinguishes positive zero from negative zero for integers.
Accordingly this matter absolutely **must** be regarded as
"undefined behaviour", so why even bother to say in the spec what
it might be in one implemetation if it isn't even possible to make
it work that way in other implementations?

[#2] Implementations that do not support a signed zero (see
annex F) cannot distinguish the sides of branch cuts.

See what I mean? **UNDEFINED**BEHAVIOUR** !!!!

Why don't they just say that 99.9% of the machines, which use two's
complement arithmetic instead of sign-and-magnitude arithmetic,
can't possibly implement a conforming C using machine arithmetic??

By the way, this document is:
WG14/N869 Committee Draft -- January 18, 1999
That's the best I've found so-far online in ASCII text form.
I sorta hate to have my CookBook/Matrix conform to such a crockshit document.
But the final standard is no better on this matter, right?
According to that statement and your web page that means you do not
understand C. Your cookbook still has this prototype given in what is
meant to be C "int g2(int n1,n2);" despite it having been pointed out to
you and you having read the post and commented about it.

I don't recall either the critique of that nor my response.
Checking Google I see indeed somebody said something was wrong with
that but didn't say what was wrong, so I asked for clarification,
but nobody ever answered, so I still don't know what was supposed
to be wrong, nor even whether there is anything wrong in the first
place or you are just <cliche>pulling my leg</cliche>.

Regarding worms/viruses etc. via subtle hard-to-find bugs in C code:
If you don't understand the language then how do you expect to be
able to develop anything that is robust?

Is that the excuse MicroSoft is using for data-overrun bugs in
Interent Explorer, that not a single programmer in the whole
company knows C nor any other programming language that they might
have used instead of C to code IE?
I've never had to go back over all of any significantly complex program
I've written.

Hey, does the Pope know about you? He's always looking for another
good candidate for Sainthood, and if you have never made a mistake
in your whole life then I think he should seriously consider you,
even if you're not Catholic, after all Jesus wasn't Catholic
either, and the Church rates him even better than a saint.
Depends. Do you want to crash in to the car in front because your
breaks did not apply in time? There are times when speed (or
consistency of speed) is just as important a requirement as any
other.

Anybody who would design a passenger vehicle with the only path
between brake pedal and brake pads being through a complicated
computer program would IMO be a fool. IMO when you step on the
brake pedal, there should be a physical connection between brake
pedal and brake pads, via lever or fluid or whatever, but no
computer in the critical path. It's fine that there's a fluid-level
sensor that feeds into the computer, so if the fluid leaks the
computer has a very good chance of flashing a warning light, but
please don't have the brakes fail just because of a bug in the
program. At worst, the indicator light fails because of bug in
program. But monitoring fluid level to detect leak can be utterly
sssssslllllllllooooooowwwww and still be fast enough to turn on the
indicator within a day after the fluid level passes from totally
full to starting to get low, long before the fluid level get low
enough to affect brake function. A fortran program on an IBM 1620
would be fast enough, if you had a trunk big enough to carry it
around with you, and you didn't mind stopping every half hour to
reset the parity error and restart the program!!
There are far too many misconceptions in your web pages, such as
being able to compare unrelated pointers, ...

So long as the pointers are of the same type, there's nothing
impossible with comparing them, which will tell you whether the
objects pointed-at are this way or the opposite with respect to
each other in memory. If you think a program is not able to compare
the pointers, please explain your reasoning.

I believe it's in fact portable code, in the sense that on any
working implementation of C it'll tell you correctly which of the
two pointers points to lower address. Of course it will give
different results in different implementations, so it's not
portable in the sense of giving identical results in all
implementations, but the sizeof (int) gives different results in
different implementations, so that's hardly a reason to totally
reject that usage, to say being able to compare unrelated pointers
is impossible. It would likewise be impossible to call sizeof (int).
right shifting a negative number 0 fills

It depends on whether you are talking about arithetic shift or
logical shift. Can you cite the paragraph where I said something
confusing to that point?
* being for dynamically allocated objects only, [] being for
"static-allocated" objects only.

I'm sure I never said any such thing. You're misreading, or lying.
 
R

Robert Maas, see http://tinyurl.com/uh3t

From: Keith Thompson said:
You're seriously messing up the attributions. Your news client
should handle this for you.

I don't know why you would think such a thing. My HTTP client is
lynx, and then Google Groups is the HTTP server, which is a
database server, which might loosely be considered a news server.
It shows me the original text of the article I've found using the
GG search engine to find it.
some software inserts a '>' character in front of the word "From"
at the beginning of a line.

Well, there's a keyboard driver on my Macintosh which detects that
I've pressed those two keys, then a callback routine in a text
editor (McSink) which treats them logically as characters to
insert, then a system call which actually inserts them into the
edit buffer, which is seen by the screen-refresh loop. Is that what
you are inquiring about?

Later on, I use mouse actions to mark the section of the edit
buffer that I want to copy, then clover-C to invoke the system COPY
function, then mouse action to click over to the VT100 emulator,
then clover-apostophe to "paste" to modem. At the other end, on the
FreeBSD Unix host, TELNET to a NNTP server is accepting that
incoming data and passing it across a TCP/IP connection to that
NNTP server, after a POST command was previously sent manually
(keyboard driver to callback in VT100 emulator to system call to
output characters to modem, and however Unix collects data from the
other modem and passes it to stdin of whatever program is in
foreground, in this case TELNET).
An "lvalue", in the sense that Chris is using the word (which is
not the way the C standard defines it) is a value to which you can
assign.

That makes no sense at all. A value is the thing assigned, not the
variable that gets assigned to.
You can think of it as an address, or as a location.

At the machine level, yes an address can specify a variable, a
place where values can be stored. More generally, a location (in
computer memory, not in my apartment nor anywhere else in real
space) is where values can be stored. An address can specify both:
- places where new/different values can be stored, and
- places where the data is enforced constant so that no new values
can be stored there.
An "lvalue", in the sense that Chris is using the word (which is not
the way the C standard defines it) is a value to which you can assign.
You can think of it as an address, or as a location. For example, given:
x = y + 1;
the expression x is evaluated for its lvalue (which indicates where to
assign the result of the RHS, without looking at the current
*contents* of x),

Note that "evaluation" is done at compile time, to get a relative
address, then the address is adjusted at load time to get a
absolute user-space address (which is relative to page-mapping at
the system level, transparent to user programs except when you jump
around too much and cause paging to thrash).

(Above is for the example you cite, x a simple variable. In the
case of an array element with runtime-variable index, part of the
address adjustment is done at runtime also.)
Evaluation is what happens when a value is computed from an
expression. It generally happens during program execution.

In the case of simple variables that are static-allocated, even
fixed elements of static-allocated structs, that simply is not
true. *NONE* of the "lvalue-evaluation" (address
calculation/adjustment) happens at run time. To prove it, you could
burn the compiled program into a ROM, whereby the machine address
of x is built right into the machine instruction in the ROM.

Now for stack-allocated simple variables, the machine instruction
is a fixed-offset relative to the stack pointer as an index
register, so in that sense I suppose you could say machine address
calculation (add compiled constant offset to current value of stack
pointer) is done at runtime. Is that what you were babbling about??
So the so-called 'lvalue' is really what in machine language jargon
is called the "effective address". Maybe we should convince the
ISO committee working on C2009 to use that term??
 
R

Robert Maas, see http://tinyurl.com/uh3t

From: Yevgen Muntyan said:
You didn't notice warm feelings from many people here to you?

That's correct, not any warm feelings whatsoever apparent here.
If somebody meant to convey warm feelings toward me, said person
utterly failed at said conveyance.
Only positive-minded careful critical review may help.

I agree. I've seen such very very rarely mixed in with orders of
magnitude more demeaning remarks and vague nearly worthless
critique. Accordingly, not much anybody said has been of help, just
those few tidbits (analagous to gems in a low-yield mine).
Select the language pair:
[C to C++ ]
[C to Lisp ]
[C to Java ]
[C to Perl ]
[C++ to Lisp ]
[C++ to Java ]
[Java to Lisp]
[Perl to Lisp]
[Perl to Java]
[Perl to PHP ]
(Does anybody notice the deliberate directional bias?)
Maybe you should call your page "C and other funny languages for
LISP'ers"? Would help to avoid some confusion perhaps.

Well if and when I ever pull that joke, set up the CGI script that
translates programs from C to other languages, ending up as either
PHP or Common Lisp, never back the other way, your suggestion for
a title might be appropriate. But for now, I don't plan to implement
any such translation. In the short term I'm not even working on
my original idea, which was to have a language-independent workbench
for constructing algorithms, plus automatic translations from the
abstract tree of the workbench to each of the six languages
equally. Both the current matrix document, and the proposed
original workbench for building algorithms interactively, would be
symmetric with respect to the six programming languages. (At the
moment, as a practical matter of covering all the material, I'm
starting by completely covering the least-expressive language,
namely C, together with equivalents in all the other
more-expressive languages, and if that's ever done then I'll move
to completing the second-least expressive language (C++) with
translations to all the other languages except C, etc. until
eventually I try to cove 100% of the most expressive language.)
(Caveat: By "expressive" I'm referring to expressing high-level
abstractions of use to application programming. I'm not referring
to the ability to hack any machine language construct you may
choose to shoot close to your foot and just take your chances
whether a simple mistake shoots a hole right through your foot. In
that category, C is most expressive of the six, only slightly less
expressive than Pocket Forth or Sesame C or assembly language or
pressing the machine-language debugger button on the Macintosh
or ResEdit etc.)
 
K

Keith Thompson

(which was true at the time I wrote it)

Once again, you post hundreds of lines, only a fraction of it relevant.
Please try to restrain yourself.

And once again, *please* learn to quote properly. I've told you this
before. You seem to be constructing your own attribution lines, like this:
> From: John Doe <[email protected]>
> ... stuff that John Doe wrote ...

The standard form is like this, or something similar

John Doe said:
> ... stuff that John Doe wrote ...

Putting an extra "> " in front of the attribution line is very
confusing. It's possible that the "> " is being added by your
software because you use the word "From".

Just let your newsreading software construct the attribution lines for
your.

[...]
Linkname: The New C Standard: 6.3.2.1
URL: http://c0x.coding-guidelines.com/6.3.2.1.html
717 An lvalue is an expression with an object type or an incomplete
type other than void;^53)

So what's an "object type"??

You'll find the answer in 6.2.3p1, the section on "Types".
Linkname: The New C Standard: 6.5.3.4
URL: http://c0x.coding-guidelines.com/6.5.3.4.html
1108 The sizeof operator ...
1111 The result is an integer.
Huh? I thought it was supposed to be a size_t ??

1117 The value of the result is implementation-defined, and its type
(an unsigned integer type) is size_t, defined in <stddef.h> (and other
headers).
OK, that's better (phew!).

So you were able to answer your own question. Why did you find it
necessary to share that with us?
1119 EXAMPLE 2 Another use of the sizeof operator is to compute the
number of elements in an array:
sizeof array / sizeof array[0]
That's rather silly.

No, it isn't; it's a common and useful technique.

[...]
** Not a single mention of library functions, which is the major
topic of discussion/debate here (C90 vs. C99 vs. GNU C etc. such as
strtoll). In fact, with this entire document, it's not even
possible to learn what's needed to write a Hello World program.

Huh? Did you look at section 7, which fully describes the standard
library?
Let me take a look at the **other** file, 1.3 megabytes, which I
downloaded the other day ... <verbose>shit, it took me a while to
find where I downloaded it to.
[...]

Nobody cares where you downloaded the file; please don't waste our
time telling us the boring details.

[...]
[#2] Implementations that do not support a signed zero (see
annex F) cannot distinguish the sides of branch cuts.

See what I mean? **UNDEFINED**BEHAVIOUR** !!!!

Why don't they just say that 99.9% of the machines, which use two's
complement arithmetic instead of sign-and-magnitude arithmetic,
can't possibly implement a conforming C using machine arithmetic??

Two's-complement applies to integer arithmetic, not to floating-point
arithmetic. Most systems these days use IEEE floating-point, which
does support signed zeros.

[...]
Hey, does the Pope know about you?

*Try* to stay on-topic. I'm about to give up on wading through all
the irrelevant crap you post. I'm probably one of the very few who
didn't give up some time ago.

[...]
So long as the pointers are of the same type, there's nothing
impossible with comparing them, which will tell you whether the
objects pointed-at are this way or the opposite with respect to
each other in memory. If you think a program is not able to compare
the pointers, please explain your reasoning.

Section 6.5.8, "Relational operators", describes the behavior of the
<, <=, >, and >= operators. You'll find that applying such an
operator to two pointers that don't point into the same object (or
just past it) invokes undefined behavior.

[...]
* being for dynamically allocated objects only, [] being for
"static-allocated" objects only.

I'm sure I never said any such thing. You're misreading, or lying.

Don't throw around accusations of dishonesty unless you're very sure
of yourself.
 
K

Keith Thompson

I don't know why you would think such a thing.
[details snipped]

Ok, I don't know why your attribution lines are messed up, and I don't
know what you need to do to fix them. Please figure it out. Look at
the other articles in this newsgroup for examples of what attribution
lines *should* look like.

[...]
Well, there's a keyboard driver on my Macintosh which detects that
I've pressed those two keys, then a callback routine
[...]

No, that's not what I'm talking about.

Lines starting with "From " are used as a delimiter in e-mail files.
If you happen to have a line in the middle of a message starting with
"From ", some e-mail and news software will insert a "> or "> " prefix
so it doesn't appear to be the start of a new message. I was guessing
that that might be why your attribution lines look the way they do.

Again, look at the attribution lines in other articles, and find a way
to make yours look like them.

[...]
That makes no sense at all. A value is the thing assigned, not the
variable that gets assigned to.

Let me emphasize again that Chris is using the term "lvalue" in its
original sense, which is not the sense in which it's used by the C
standard.

It does make sense, whether you understand it or not. You just need
to expand your concept of what a "value" can be.

[...]
Now for stack-allocated simple variables, the machine instruction
is a fixed-offset relative to the stack pointer as an index
register, so in that sense I suppose you could say machine address
calculation (add compiled constant offset to current value of stack
pointer) is done at runtime. Is that what you were babbling about??
So the so-called 'lvalue' is really what in machine language jargon
is called the "effective address". Maybe we should convince the
ISO committee working on C2009 to use that term??

I was not babbling about anything. Yes, I think an "effective
address" is similar to the concept of "lvalue" as Chris is using the
term.
 
R

Robert Maas, see http://tinyurl.com/uh3t

Date: Sun, 25 Feb 2007 05:16:47 +0000
From: Flash Gordon <[email protected]>
You have not fixed all of the errors that have been pointed out to you.

I claim to have fixed all the errors which were to my knowledge
pointed out to me prior to the date of your article (Feb.25). I
have a huge backlog of more recent articles bookmarked but not yet
processed:
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <m6dEh.194$Rf7.157@trnddc02>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
(treehouses safe?)
Message-ID: <[email protected]>
(also Chinese factor: to put water on boombox!!)
Message-ID: <030320071207404467%[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
(my mother's step-father)
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
(neither eating is essential)
Message-ID: <[email protected]>
Message-ID: <[email protected]>
(I'm a nice guy who has suffered from shyness most of my life, ...
Message-ID: <[email protected]>
("ya" is a Spanish-language word. Do you know what it means?)
Message-ID: <[email protected]>
(I think that's a great idea!)
Message-ID: <[email protected]>
(Hey, I did cybersex once, in late 2000, with dead2u. ...
Message-ID: <[email protected]>
Message-ID: <[email protected]>
(under Stevens Creek freeway along Evelyn next to creek with ...
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
(If you keep a copy of your sent-mail, the address is there to copy&paste later.)
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
(what was the IP number where it came from?)
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
(hey, I was thinking I might be the only one left)
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
Message-ID: <[email protected]>
(looked at man pages for that)
Message-ID: <[email protected]>
(No manual entry for func)
Message-ID: <[email protected]>
(which "Anna"?)
Message-ID: <[email protected]>
(e-mail, mars)
If my mistake (in my CookBook/Matrix) is noted in any of those
bookmarked articles, I'll be getting to them any day now... But if
it's in some earlier article, either I didn't happen to see it
(Google Groups currently provides no reasonable way to find all
followups to what I previously posted, it's hit-and-miss whether
I'll chance to see some particular followup), or I saw it but
dismissed it as too vague to understand.

If you know of any article pointing out a mistake (in my
CookBook/Matrix) which is not yet corrected and not in that list of
bookmarks, please cite a line or two of text at the point of the
note-of-mistake, so that I can use Google Groups to find the full
article then use those 1-2 lines of text to find the specific place
within that article where the note-of-mistake appears.

If you want, I can issue a quick preliminary ACK as soon as I
see-and-bookmark your article, so you'll know I saw it. If I don't
see it within a couple days after you post it, I might never see
it, like I said due to no reasonable way to find all followups, so
you might then need to connect to my Web site and send me a instant
alert telling me the message-id of the article I see to have
missed. The quick-preliminary-ACK would be via the newsgroup of
course, and you might not see it. If you have a Web site with a
simple means to send you an instant alert, let me know the URL for
instructions how to do that, and I'll give it a try.

Actually, for something so short as just telling me two lines of
text in a note-of-mistake article I somehow overlooked, you might
just tell me in an instant alert in the first place, instead of
posting to a newsgroup and hoping I happen to find it, your choice
which contact method to try.

Not yet implemented, but hot on my mind: I might someday soon
finally implement CGI-SMTP. The server would run as a CGI
application, but would accept SMTP commands (all in one batch
instead of piecemeal-interactive), then it would process all the
commands in sequence and return a corresponding sequence of
responses. (Of course the server can do lookahead if it wants,
giving it an advantage over regular SMTP in blocking spam, such as
issuing a rejection of the RCPT TO command because the subsequent
message body is unacceptable for that recipient.) The client would
then interleave the saved original sequence of commands with the
returned sequence of responses and then act as if it had been a
regular SMTP interchange all along. If I implemented that, would
you use it to contact me directly in matters like errata in my
CookBook/Matrix?
The only was [sic] to get people to fully review it is to fix the
problems already pointed out and then ask for further review.

That's reasonable, except that I'm not aware of any outstanding
already-pointed-out problems, except what might be within the more
recent articles in that bookmark list. I'm going to make a mad dash
to try to catch up with my backlog. Stand by...

Regarding a possible sub-title to my CookBook/Matrix:
Adding, "written by someone inexperienced in C and other
languages" might help.

Not quite that, but maybe something like "this is a working
document, to try to gather together all the relevant information
about how to do the same set of tasks in up to six different
programming languages if possible, and to describe those
task-accomplishing methods (*) clearly/succinctly/unambiguously,
which is a learning experience for both the author and any early
proofreaders (both expert and newbie) that might turn up".

* ("method" used in the general sense, a way to accomplish
something, not in the OOP/Java/C++/CLOS sense)
 
F

Flash Gordon

Robert Maas, see http://tinyurl.com/uh3t wrote, On 20/03/07 09:18:
(which was true at the time I wrote it)


At the time you wrote that, I didn't yet have access. But as soon
as I saw your article the next day or so, things might have
changed. Let me check...

Links have been posted in replies to your messages before, so if you do
not have access it is because YOU have chosen not to have access.
That WebPage doesn't have a links section, however when I first saw

Not one section, but lots of links including in the section you mention
below.
your article, before I had time to post nor time to read the Web
pages linked, I did manage to find these two links that might be
useful, from somewhere in the Wiki page, I have no idea where,
although if I search for the Linkname text I might find them again:

Linkname: c standard - clc-wiki
URL: http://www.clc-wiki.net/wiki/c_standard#Obtaining_the_Standard
Hmm, I seem to have bookmarked a section in that same Wiki page.
It says:
Neither the Standard nor its amendments are available free of charge,
I think that kills the issue for me.

Then you are either incapable of reading more than one sentence, too
lazy to bother reading more than one sentence, too stupid to read more
than one sentence, or trolling. Since the very next sentence tells you
that you can get what you want.

I don't recall either the critique of that nor my response.
Checking Google I see indeed somebody said something was wrong with
that but didn't say what was wrong, so I asked for clarification,
but nobody ever answered, so I still don't know what was supposed
to be wrong, nor even whether there is anything wrong in the first
place or you are just <cliche>pulling my leg</cliche>.

If you cannot be bothered to put it through a compiler or read any
vaguely correct resources that is your problem.

Hey, does the Pope know about you? He's always looking for another
good candidate for Sainthood, and if you have never made a mistake
in your whole life then I think he should seriously consider you,
even if you're not Catholic, after all Jesus wasn't Catholic
either, and the Church rates him even better than a saint.

I never said I was perfect nor that I never have to fix bugs, just that
I never have to go back over all of the program. If I did I would
probably still be on my first C program since that was certainly in the
10s of thousands of lines of C. Obviously I had written a lot of code in
other languages before I started C!
Anybody who would design a passenger vehicle with the only path
between brake pedal and brake pads being through a complicated
computer program would IMO be a fool.

Stay off aircraft and away from flight paths then, since a lot of
aircraft are fly-by-wire (i.e. controlled by computers) then. Have you
been asleep for the past decade?

So long as the pointers are of the same type, there's nothing
impossible with comparing them, which will tell you whether the
objects pointed-at are this way or the opposite with respect to
each other in memory. If you think a program is not able to compare
the pointers, please explain your reasoning.

You show your ignorance and the fact you don't bother to read again. It
has been stated many times in the past that comparing pointers that do
not point in to the same object (or 1 past the end) for anything other
than equality invokes undefined behaviour. It needs no more reason than
the standard state it.

It depends on whether you are talking about arithetic shift or
logical shift.

C does not have "arithmetic shifts" and "logical shifts" it only has
shifts which do not necessarily zero fill..
> Can you cite the paragraph where I said something
confusing to that point?

Yes, just above here.
* being for dynamically allocated objects only, [] being for
"static-allocated" objects only.

I'm sure I never said any such thing. You're misreading, or lying.

I doubt I would have said you said it if you did not, but I'm not going
to bother re-reading your pages until there has been some indication
that you have actually learned something. After all I tend to only
bookmark things which might be either useful or interesting, your web
site is neither.
 
R

Robert Maas, see http://tinyurl.com/uh3t

From: Flash Gordon said:
Functions for networking (getting MACs for NICs is very useful
but IIRC you need to go beyond POSIX on nix boxes to do it),

I intend eventually to include networking (sockets, streams, etc.)
eventually after I finish the more basic stuff (and maybe some
stuff rather soon if I feel like it), and I already have stubs for
those future sections of my CookBook/Matrix:
<http://www.rawbw.com/~rem/HelloPlus/CookBook/Matrix.html>
Input/Output:
...
* [Local interprocess streams]
* [InterNet TCP streams]
* [InterNet datagrams]
<http://www.rawbw.com/~rem/HelloPlus/CookBook/ConPara.html>
Table of contents:
...
* [RPC (remote procedure call), RMI (remote method invocation)]

If POSIX is incompatible with all those topics, I may need to
include it in a separate chapter. Please let me know if in your
opinion that's the case.

To my knowledge, "NIC" means Network Information Center, such as
APNIC, JPNIC, KRNIC, etc. If you're using it to mean something
else, please explain.
functions for graphics,

I have no access to any computer where I would be able to test
graphics in even one of those six languages, much less in all six,
so I won't be including anything whatsoever about graphics in *my*
document. But if you would be willing to write your own chapter on
graphics in all six languages, multiple specific implementations on
multiple specific platforms (Unix/FreeBSD/Solaris/SunOS/etc.,
Linux/RedHat/etc., Mac System 6.0.x, Mac System 7.5.x, Mac System
10.x, and a whole slew of various MS-Windows versions
NT/2000/whatever), I'd be glad to give a cursory browse of it to
verify that it conforms to my basic CookBook/Matrix idea, then
include it virtually in my document as an external chapter-link.
functions for threads etc.

That's already planned, but only in a limited way, because while
it's built into the standard Java port, it's only a vendor-add-on
in the other languages so I'd be able to test it only in a very
limited way, basically only java version 1.2.2 and CMUCL version
18b, AFAIKATM. Hmm, I don't yet have a stub for that section,
adding it now ... done:
<http://www.rawbw.com/~rem/HelloPlus/CookBook/ConPara.html>
Table of contents:
...
* [multi-processing, threads]
If you volunteer to write sub-sections for threads on other
platforms, I'd be glad to link it in if it meets my standards.
If a "CookBook" is going to cover such things, which is not
unreasonable,

Agreed (with caveat that graphics isn't possible for me to
personally cover).
then it will need to cover system specifics.

Not for threads in java, and some other features in various
languages that are portable, but yes to completely cover any one of
those topics for all six languages will require system-specific
coverage for at least one of the languages. In the short run I'll
simply say that in such-and-such language there is no portable way
to accomplish the task, and describe how-to only for the few
languages where it *is* portable. Later, I haven't decided whether
to *ever* include the system-specific info.
Of course, it should clearly mark what is system specific.

Yes, agreed, if I ever include anything like that.

There's also the matter of standard-version-specific, such as
strtoll which is in C1999 but not C1990 (I'm fed up with being
non-y2k-safe in such jargon!! <OT>I'm getting shitloads of spam
that says it was sent in the year 37 or 38, which Yahoo! Mail
treats as if it were sent from the future year 2037 or 3038
respectively, when IMO Yahoo! Mail should blanket reject all such
grossly-mis-dated e-mail said:
If you tell them it is only in the latest standard and they find
it is not in the latest and greatest from <insert provider of
dislike> then they will not only learn that provider as not kept
up but also what it is the provider is not doing.

I agree. Furthermore, if *every* function/operator/method per some
older standard *is* in that particular implementation, and it's
only the newly-standardized stuff that's not present, then the user
knows the company *was* up to date before the standard changed out
from under them, so they should be given some slack, like ten years
to finally finish upgrading their product for the new standard, so
give them two more years slack on the issue of C1999. On the other
hand, if not even the 17-year-old standard (C1989/C1990) is fully
implemented, it's seriously time to find a new vendor who respects
portability issues even a teensy bit.
Providing random information about system specific stuff is bad
for one set of reasons (although non-random clearly marked system
specifics is not). Sticking to C99 only is bad for different
reasons.

Agreed. I'm currently leaning toward treating all ten-or-more-year-old
standard as given fact, and flagging all within-past-ten-years
changes specially to alert users that even a good implementation
(such as GNU C) might not yet have all that new stuff.
This chap has given the impression that he is using some form of
remote system which he probably does not own or control.

That's correct. I use a commercial ISP which is running FreeBSD
Unix, and which is accessible from home only via VT100 dialup.
I have no control whatsoever, and extremely little influence, on
what man pages or upgrades to java etc. the admin chooses to
install or not. Witness only java 1.2.2 installed to date.
Even my laptop (that I got for free, with modem that died so I
can't produce any content there for upload) has java 1.3 something.
As for gcc, man pages don't tell any way to learn which version
number it is, so I have no idea which version I'm using.
Currently that warning belongs on Robert's site!

Not at all. I actually need eager newbies with lots of energy to
try various methods (*) I suggest in my CookBook/Matrix and tell me
whether some text was confusing or unacceptably incomplete or
outright wrong. My instant-alert Web service can be used to report
short errata, or to alert me that longer errata have been e-mailed
so I know to search for it among tes of thousands of spam it's
mixed with. (If you think looking for needle in haystack is hard!!)

* (not OOP sense, more general sense: operator/[generic]function/OOPmethod)

<meta>Hmm, I think in the future when I use the word "method" in
that original general sense, I'll just use SGML/XML markup:
<general>method</general>, and when I use the word in the OOP sense
I'll mark it <oop>method</oop> instead. Would that be clearly
understood by everyone here?</meta>
 
K

Keith Thompson

Date: Sun, 25 Feb 2007 05:16:47 +0000
From: Flash Gordon <[email protected]>
You have not fixed all of the errors that have been pointed out to you.

I claim to have fixed all the errors which were to my knowledge
pointed out to me prior to the date of your article (Feb.25). I
have a huge backlog of more recent articles bookmarked but not yet
processed:
Message-ID: <[email protected]> [snip]
Message-ID: <[email protected]>
(e-mail, mars)

You've posted a list of 48 Message-IDs, but you didn't bother to post
the URL for your "CookBook/Matrix document". I haven't bothered to
bookmark it. If you want anyone to look at your document, tell us
where it is. It wouldn't hurt to mention the URL every time you post
about it.

I'm not saying that I'll look at it, but I certainly won't bother to
track it down if you make it difficult to find it.
 
R

Robert Maas, see http://tinyurl.com/uh3t

From: Flash Gordon said:
It is better to specify anything that is not C89 is not C89 and
what it actually is, be it C99, POSIX, MS, GNU or whatever. The
only standard fully implemented by most compilers is C89, in
particular gcc document that their C99 implementation is not
complete and MS VC++ does not even attempt it, and that covers the
bulk of new users who are not using something written before C99
was even published. So stick to C89 (not C99) as the base and then
specify things in C99 or whatever as appropriate and appropriately
documented.

That's my current wannado. Unfortuately while I've at long last been
able to find and download a text version of:
WG14/N869 Committee Draft -- January 18, 1999
I haven't yet found anything comparable for C1989-90, so even using
'grep' to test for mention in C1989-90 isn't yet feasible.
I would expect that if there are man pages installed then they
are infinitely better than what he is writing.

The 'man' pages here for gcc tell **only** how to run the program,
the many many switches to affect its behaviour, nothing whatsoever
about the grammar of the programming language which it accepts as
input. Perhaps you can suggest an appropriate 'man' page to try??
% man c90
No manual entry for c90
% man c89
Formatting page, please wait...
NAME
c89 -- POSIX.2 C language compiler
...
STANDARDS
The c89 command is believed to comply with IEEE Std 1003.2 (``POSIX.2'').
Nope, that's not what I need to find.
I was suggesting that he *should* read the bibliography and get
some of those books and read them.

Should I check if the Sunnyvale public library has any of them??
What's the chance of that?? <ot>A few months ago I looked for
Dawkin's "The God Delusion" and learned they have just one copy,
with about fifty people on the wait list for it. said:
1) I think we both agree that the OPs site currently has negative value

I'm considering putting you on my "hurt list", people who
deliberately say hurtful things to me but make no comparable effort
to ameliorate whatever is bothering them so much to provoke them to
make such statements. You'll be listed alongside the people who
accuse me of being a pedophile or child molestor, the writer for
the San Jose METRO newspaper who wrote a grossly dishonest and
demeaning article about me, and the social worker (Michele Dove)
who lied to the court to provoke it to take my children away
without due process and who also lied to the psychiatrist doing my
psychlogical evaluation to change his mind where he had said I'm
under stress but he sees no reason why I would be a danger to my
children, but after she lied and told the psychiatrist that I had
been found by the court to have abused my children **before** the
hearing where she was supposed to present her allegations and have
them considered, the psychiatrist added a section to the bottom of
his report that says considering that additional information that I
was already (FALSE!!!) found to have abused my children he
recommends the children be taken away, contrary to his opinion upon
conducting the original psychological evaluation, so when there was
supposed to be a hearing to determine what veracity if any there
was to her false allegations, the judge ruled summarily against me
and refused to give me the right to a trial with witnesses I can
cross-examine.
 
K

Keith Thompson

As for gcc, man pages don't tell any way to learn which version
number it is, so I have no idea which version I'm using.

<OT>
Look harder. "gcc --version".
</OT>
 
C

CBFalconer

.... snip ...


Sorry, I read only English. When I copy&paste that URL into the
Web browser (lynx) and fetch the Web page, I see something that
ain't English:

It's compressed. You download it and expand it with bzip2. Did
you never hear of compression? It saves (in this case) about 80%
of the transfer time.
 
F

Flash Gordon

Keith Thompson wrote, On 20/03/07 21:36:
Date: Sun, 25 Feb 2007 05:16:47 +0000
From: Flash Gordon <[email protected]>
You have not fixed all of the errors that have been pointed out to you.
I claim to have fixed all the errors which were to my knowledge
pointed out to me prior to the date of your article (Feb.25). I
have a huge backlog of more recent articles bookmarked but not yet
processed:
Message-ID: <[email protected]> [snip]
Message-ID: <[email protected]>
(e-mail, mars)

You've posted a list of 48 Message-IDs, but you didn't bother to post
the URL for your "CookBook/Matrix document". I haven't bothered to
bookmark it. If you want anyone to look at your document, tell us
where it is. It wouldn't hurt to mention the URL every time you post
about it.

I'm not saying that I'll look at it, but I certainly won't bother to
track it down if you make it difficult to find it.

Well, I looked since he posted a link to part of it else-thread. It
still has:
int g2(int n1,n2);
so he has not addressed all the comments. If he still can't be bothered
to try compiling the code and can't get something this basic correct I
still don't think it worth looking at. Well worth avoiding, and well
worth pointing out to any unsuspecting passers by how bad it is, but not
of use for anyone who wants to learn anything about C.
 
C

CBFalconer

That's correct, not any warm feelings whatsoever apparent here.
If somebody meant to convey warm feelings toward me, said person
utterly failed at said conveyance.

Maybe you should consider the possibility that the reaction is
connected with your own posts? Or that the c.l.c. universe
consists entirely of unfeeling clods, whose prime purpose in life
is to distribute demeaning comments?
 

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

Forum statistics

Threads
473,772
Messages
2,569,590
Members
45,100
Latest member
MelodeeFaj
Top