Wednesday, April 14, 2010

comp.lang.c - 10 new messages in 7 topics - digest

comp.lang.c
http://groups.google.com/group/comp.lang.c?hl=en

comp.lang.c@googlegroups.com

Today's topics:

* Generic linked list with internal storage? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/d36ff63bef634bcc?hl=en
* Test of a preprocessor symbol defined as nothing vs. zero - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c/t/8e4236bf3f19c661?hl=en
* Millionaire Coaching Club! - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/dbd2166b2d5e5705?hl=en
* ╬◆Paypal Wholesale Various World-famous Brand Products-----Sport Shoes,Jeans,
Handbags,jacket,T-shirt,Accessories,etc.╬ www.fjrjtrade.com ╬ - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c/t/23ce49d8c45eb950?hl=en
* Video is very funny..hhhhhhhhhhhh - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/e42285bea296aefd?hl=en
* seebs/schildt III - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/9a32c827a2765bc1?hl=en
* Is this a correct implementation of strstr ? - 3 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/e69b0f022e4c27e1?hl=en

==============================================================================
TOPIC: Generic linked list with internal storage?
http://groups.google.com/group/comp.lang.c/t/d36ff63bef634bcc?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Apr 13 2010 6:25 pm
From: Seebs


On 2010-04-14, Tim Rentsch <txr@alumni.caltech.edu> wrote:
> The "common initial sequence rule" is required to work _only_ if
> the struct object in question is contained in an actual union
> object of the appropriate type. Not just if the union _type_
> exists and is visible, but if the struct _object_ is actually in
> a union _object_. If it's a freestanding struct, not contained
> in a union object of a type that includes both structs, all bets
> are off.

This surprises me, although I think you're right.

Speaking only for myself, I would *prefer* that the spec simply
give the guarantee that, if the types of the first N members of
two structure types are the same types in the same order, then you
can use a pointer to one as a pointer to the other so long as
you only access those members. In practice, it's what people
seem to mostly expect, and I don't think the lost optimizations
will be all that big a deal. In particular, "restrict" lets us
specify the thing we're most likely to care about -- that the
two arguments to a function which are both pointers to structures
necessarily point to different structures.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!


== 2 of 2 ==
Date: Tues, Apr 13 2010 6:48 pm
From: Tim Rentsch


Seebs <usenet-nospam@seebs.net> writes:

> On 2010-04-13, Gene <gene.ressler@gmail.com> wrote:
>> #include <stdio.h>
>> struct common { int a, b; };
>> struct big_struct { struct common com; double c; };
>> struct small_struct { struct common com; };
>>
>> int main(void)
>> {
>> struct big_struct big;
>> struct small_struct *otherp = (void *)&big;
>> big.com.a = 0;
>> otherp->com.a = 11;
>> printf("big.com.a = %d\n", big.com.a);
>> return 0;
>> }
>>
>> Ben says his gcc prints 0 (rather than 11 as mine does).
>
> The interesting question, I guess, is whether simply declaring the
> union (even if you don't use it) changes this.

Declaring a union type (including defining its members) makes
no difference. Only if the struct objects in question are
actually inside an actual union object does that provision
come into play.

> Or, for that matter,
> having the addresses of one or more of these taken and passed
> to something outside this module.

Practically speaking that might have an effect, but the
technical answer is still undefined behavior. The second line
of main(), putting '(void*)&big' into 'otherp', is already
undefined behavior; however, even if that works (as indeed
it is likely to) the accesses through 'otherp' are also
undefined behavior, for the reason you later point out --
an object of one type is being accessed through a different
(and not an otherwise allowed) type.


>> But hypothetically, the conversion could involve pointer arithmetic,
>> no?
>
> So far as I can tell, no -- the pointer to the initial member has to
> be the same as the pointer to the whole structure/union. (We spent a
> while looking for this, but it's defined under the equality operator.)
>
>> If so, even this is, again, a not-certain-to-be-portable way to
>> implement generic lists, the OP's question.
>
> Yeah. I think the problem is that strict aliasing rules have to be
> subverted, and I think some compilers are smart enough to check whether
> or not you've demonstrated that they're being subverted.

With some minor exceptions, it's always undefined behavior
to access an object of one type using a different type
if the object isn't in a union object that has both
types in it. Everyone knows about the exceptions for
accessing through (char*), and there a a couple of
others. But independent structs never qualify, outside
of the case where they are both in a union and the
actual object is in an actual union object.

==============================================================================
TOPIC: Test of a preprocessor symbol defined as nothing vs. zero
http://groups.google.com/group/comp.lang.c/t/8e4236bf3f19c661?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 13 2010 6:54 pm
From: Tim Rentsch


Nick <3-nospam@temporary-address.org.uk> writes:

> Oliver Jackson <chexmofo@hotmail.com> writes:
>
>> On Apr 13, 11:52 am, Nick <3-nos...@temporary-address.org.uk> wrote:
>>> Tim Rentsch <t...@alumni.caltech.edu> writes:
>>> > Disclaimer: this idea doesn't work if the definition for FOO is
>>> > other than a simple numeric value 0 (or blank), and can fail
>>> > miserably if it's something more complicated. And, stylistically,
>>> > it's a total crock. However, you did say "any suggestions?".
>>>
>>> > #define CROCKIFY(x) x ## 15
>>> > #define C_TEST(x) CROCKIFY(x) == 13
>>>
>>> > After these macro definitions, the preprocessor test
>>>
>>> > #if C_TEST(FOO)
>>>
>>> > will include the following lines if FOO is defined as 0, and not
>>> > include the following lines if FOO is defined just as an empty
>>> > definition.
>>>
>>> > It also has the additional benefit of being very likely to generate
>>> > compilation errors if FOO is defined as anything other than blank or
>>> > a simple number (or identifier). Of course some people might not
>>> > think of that as a benefit.
>>>
>>> That's positively, err, something.
>>
>> Thank you for contributing, Nick. I have given your post a 5-star
>> rating in Google Groups. It's posts like yours that make this
>> newsgroup such a valuable resource, and I think it's important that we
>> all take a moment to acknowledge that. Bless you, sir!
>
> I can't quite work out whether you are sarcastically getting at me for a
> silly comment, or agreeing with me!
>
> I felt that Tim's wonderful abuse of octal/decimal was well worth
> pulling out of a thread and drawing more attention to. It's not like we
> have too much C code posted here.

I'm glad you liked it. How often do we get a code example
that so obviously satisfies the 80/20 rule as the use here
of octal/decimal does?

==============================================================================
TOPIC: Millionaire Coaching Club!
http://groups.google.com/group/comp.lang.c/t/dbd2166b2d5e5705?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 13 2010 7:11 pm
From: deaniac83


no spams allowed

On Tue, 3 Nov 2009 13:46:22 -0800 (PST), Barnie <arniey32@gmail.com>
wrote:

>Get coaching from an internet millionaire at his club. Guranteed to
>make you money or your money back! What is there to lose? Check ou the
>club at http://maverickeasy.com/

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

==============================================================================
TOPIC: ╬◆Paypal Wholesale Various World-famous Brand Products-----Sport Shoes,
Jeans, Handbags,jacket,T-shirt,Accessories,etc.╬ www.fjrjtrade.com
http://groups.google.com/group/comp.lang.c/t/23ce49d8c45eb950?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 13 2010 7:45 pm
From: ckedsdfs

╬◆Paypal Wholesale Various World-famous Brand Products-----Sport
Shoes,Jeans, Handbags,jacket,T-shirt,Accessories,etc.╬ www.fjrjtrade.com

Free shipping Wholesale Cheap DIESEL Jeans ARMANI Jeans (paypal
payment www.fjrjtrade.com)

Free Shipping Wholesale World-famous Brand Products: Sneakers, Hoody,
Jacket, T-shirt, Jersey, Bag, Purse, Watch <www.fjrjtrade.com>


Cheap Wholesale Air max shoes:
max87,max90,max95,max97,max2003,max2004,max2005, max2006,max180,
max360, max ltd,TN1,TN2,TN3,TN6,tn8 <www.fjrjtrade.com>

Nike Shox Shoes: Shox shoes,Shox NZ,Shox OZ,Shox VC,Shox MONSTER,Shox
TUROB,Shox R2,Shox R3,Shox R4,Shox R5,Shox TL,Shox TL1,Shox TL2,Shox
TL3,Shox TL4,Shox TL5 <www.fjrjtrade.com>

Discount Wholesale Evisu,True Religion,bape,d&g,artful dodger,red
monkey,LRG, D&G jeans,APE jean,BBC jeans,antik jean.RCOWER,ENYCEROCK
Jean,Rock Republic Jeans,DIESEL Jeans,ARMANI Jeans,RMC Jeans,RRTFUL
DODGER Jeans,ANTIK Jeans (www.fjrjtrade.com)

FREE SHIPPING !!! WHOLESALE Woman Apparel: Bikini,Juicy T-
shirt,Locaste T-shirt,ED T-shirt,Juicy Suit (www.fjrjtrade.com)

LV,Chanel,BREITLING watch,Omega, Tag Heuer.Rolex Watch, Gucci
Watch,Luxury Watch,digital watch,LCD watch, Lover watch,analog
watch,wrist watch Quartz Analog Watches Others Digital Watches
Specialty Watches Analog-Digital Watches Mechanical Watches brand
watch,Movado Watches,Baume Mercier (www.fjrjtrade.com)


we are one of the wholesale suppliers in China ,and offer brand name
products at factory price,cheap
main products catalogues:

sport shoes:
Af1 shoes,ice cream shoes,Nike shoes,kobe,RIFT,James,air Jordan:
(1,2,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,9,9.5,10,11,12,13,14,14.5,15,16,17,18,-19,20,20.5,21,22,23)
Air max shoes:max
87,max90,max95,max97,max2003,max2004,max2005,max2006,,max180,max360,TN1,TN2-,
TN3,TN6,tn8,max ltd
Nike Shox shoes:shox,shox shoes,shox nz,shox oz,shox vc,shox
MONSTER,shox TUROB,shox R2,shox R3,shox R4,shox R5,shox tl,shox
TL1,shox TL2,shox TL3,shox TL4,shox TL5 Dunk shoes,puma shoes,DIESEL
shoes,DSQUARED shoes,Adidas, Adidas y-3,timberland,ugg boots,bape
shoes,prada shoes,D&G Shoes,gucci shoes,soccer shoes,Rigf shoes,kids
shoes,boot shoes,LV shoes,sandal shoes,converse shoes,chanel
shoes,Garnet,McGrady,Wade shoes,Kate,Duncan,HOGAN
shoes,SIMTH,lacoste,BALLY,BIKKEN BERGS,BOSS,VERSCE,ARMANI
(www.fjrjtrade.com)

jeans: Evisu,True Religion,bape,d&g,artful dodger,red monkey,LRG D&G
jeans,APE jean,BBC jeans,antik jean.RCOWER,ENYCEROCK Jean,,Rock
Republic Jeans,DIESEL Jeans,ARMANI Jeans,RMC Jeans,RRTFUL DODGER
Jeans,ANTIK Jeans
(www.fjrjtrade.com)

Hoody: bape,bbc,LRG,clh,ed hardy,GGG,Spider Jacket,G-Unit Jackets, G-
Star Jackets & North Jackets of Face 10 Deep Hoody,ed hardy hoody
(www.fjrjtrade.com)

jacket: ED hardy jacket,adidas jacket.red monkey jacket,MONCLER,G-
STAR,PRADA,SPYDER,AF coat,BABY PHAT,DSQ,artful dodger
(www.fjrjtrade.com)

T-shirt: bbc,crocodile,ed
hardy,Polo,lacoste,bape,ggg,BURBERRY,evisu,lrg,artful,
dodger,polo t- shirt,lacoste T-shirt,VERSACA,ARMANI,DIOR,tommy
(www.fjrjtrade.com)

short: BBC pants,bape pants,red monkey short,evisu short,sport
wear,Socks,BOSS shirt,JUICY,

woman apparel:Bikini,Juicy T-shirt,Locaste T-shirt,ED T-shirt,Juicy
Suit
(www.fjrjtrade.com)

Jersey: MLB NHL NFL NBA Jerseys, Football Jersey, Hats,
Clothing,mlb jerseys, nhl jerseys, nfl jerseys, nba jerseys, mlb
apparel, nhl merchandise, baseball jerseys, hockey jerseys, mlb
jackets, mlb merchandise, nhl apparel, nfl merchandise, nba
merchandise, nba merchandise, baseball jerseys, hockey jerseys,
customized jerseys, custom jerseys, personalized jerseys
HAT:knitted hat,bucket hat,fashion hat,straw hat,baseball hat,cowboy
hat,sports hat Hats & Caps Scarves & Shawls Holiday Gift & Decoration
Gloves & Mittens Hair Ornaments Promotion Gifts
(www.fjrjtrade.com)

BAG: Ladies' Handbags,louis vuitton,chanel
handbag,fendi,versace,GUCCI,fashion
bag,LOEUE,D&G,MIUMIU,JUICY,GUESS,VERSACA,tous,lacoste,SMITH,HERMES,FENDI,MA-
RC,PRADA
bag,,paper bag ,designer handbags,designer bag,mulberry bag,
Backpacks
Luggage,purse, Trolley Bags & Cases Travel Bags Popular Handbag
Laides' Fashion Designer Luxurious Leather Brand Name Handbag,coach
purses and coach wallet Authentic replica coach bag,tote bag,plastic
bag,gift bag,travel bag
(www.fjrjtrade.com)

WATCH: LV,Chanel,BREITLING watch,Omega, Tag Heuer.Rolex Watch, Gucci
Watch,
Luxury Watch,digital watch,LCD watch, Lover watch,analog watch,wrist
watch Quartz
Analog Watches Others Digital Watches Specialty Watches Analog-
Digital Watches
Mechanical Watches brand watch,Movado Watches,Baume Mercier
(www.fjrjtrade.com)

Accessories:
Handbag/Purse,belt,hat,scarf
LV,Chanel,Gucci,Coach,CHLOE,Dior,Juicy,Prada,Guess,D&G,Versace,Fendi

Glassess: LV Glassess,Chanel Glassess,GUCCI
Glassess,VERSACE,OKELY,POLICE,FENDI,BURBERRY,DIOR,RayBan,ARMANI,PRADA,D&G
Glassess

all the products listed on our website all are in stock! we have
more
in stock, Either you are large wholesaler or small business owner, we
have customized
programmers to suit your needs.

Hope sincerely to have glad and long term business relationship with
you.
If you are interested in our products and have any problem, welcome
to
contact us. we will be honest to answer your all problem .
web:www.fjrjtrade.com


==============================================================================
TOPIC: Video is very funny..hhhhhhhhhhhh
http://groups.google.com/group/comp.lang.c/t/e42285bea296aefd?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 13 2010 8:15 pm
From: cedwynn


no attachment

On Wed, 31 Mar 2010 10:30:06 -0700 (PDT), safwan alahmadi
<safoo.alahmadi@gmail.com> wrote:

>
>
>hhhhhhhhhhhh
>
>Video is very funny
>
>http://www.youtube.com/watch?v=-cKvPp71QFY

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

==============================================================================
TOPIC: seebs/schildt III
http://groups.google.com/group/comp.lang.c/t/9a32c827a2765bc1?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 13 2010 8:21 pm
From:


Schildt: Always makes time for exercise. He believes that the mind will fail
if the body
is not properly taken care of. He has room dedicated in his well appointed
home
for engaging in regular physical exertion. May invest in a lap pool this
summer.

Seebs: No longer leaves his dank basement apartment long enough to take
meals with the
rest of his family upstairs. Diet is mainly sugary drinks, booze, and fried
snack chips. Morbidly obese.


==============================================================================
TOPIC: Is this a correct implementation of strstr ?
http://groups.google.com/group/comp.lang.c/t/e69b0f022e4c27e1?hl=en
==============================================================================

== 1 of 3 ==
Date: Tues, Apr 13 2010 11:17 pm
From: Phil Carmody


Eric Sosman <esosman@ieee-dot-org.invalid> writes:
> On 4/13/2010 5:45 PM, Phil Carmody wrote:
>> Ian Collins<ian-news@hotmail.com> writes:
>>> On 04/14/10 09:19 AM, Phil Carmody wrote:
>>>> Ian Collins<ian-news@hotmail.com> writes:
>>>>> On 04/14/10 09:01 AM, candide wrote:
>>>>>> I request your opinion about the following attempt to implement the
>>>>>> standard function strstr. Here is the code :
>>>>>
>>>>> No, it looks like you are writing strchr.
>>>>>>
>>>>>>
>>>>>> char *mystrchr(const char *s, int c)
>>>>>> {
>>>>>> while ((unsigned char)*s != (unsigned char)c) {
>>>>>
>>>>> Why the casts?
>>>>
>>>> Because without them
>>>>
>>>> char buff[LINELEN];
>>>> while(get_line_from_post(buff, sizeof(buff))) {
>>>> /* detect mangled indents from googoogroups */
>>>> char *mangledchars=buff;
>>>> while ((mangledchars=mystrchr(mangledchars, 160)) != NULL)
>>>> *mangledchars=' ';
>>>> }
>>>>
>>>> may fail to fix any non-breaking spaces.
>>>
>>> Eh?
>>
>> If chars are signed, then you'll be comparing char -96 with int 160,
>> and not find any matches.
>
> Yabbut, it's still wrong. The second argument to strchr()
> is an int which is "converted to a char" (7.21.5.2p2), not to
> an unsigned char.

I was addressing just mystrchr as posted, not strchr. However, as
you continue, the comparison is a most enlightening one.

> So the given code behaves differently from
> the Standard's description for any char value C and int value I
> such that
>
> (C == (char)I) != ((unsigned char)C == (unsigned char)I)
>
> Can such a C,I pair exist? Yes, certainly, if I is less than
> CHAR_MIN or greater than CHAR_MAX, because then (char)I is ill-
> defined and can produce a peculiar result (6.3.1.3p2). That
> peculiar result need not be closely related to the (well-defined)
> result of converting to unsigned char, so the two comparisons
> could come out differently -- in which case, the fix is to remove
> the `unsigned' from both casts and allow the peculiar behavior
> to occur. It's what the Standard requires.

I don't know quite how much 'the standard is occasionally a bit dumb'
was supposed to be in that, but with my 'the standard is occasionally
a bit dumb'-tinted spectacles, I certainly detected some.

So, got any portable C code for turning latin-1 NBSPs from googoogroups
into ' ' using strchr to find the errant chars?

Phil
--
I find the easiest thing to do is to k/f myself and just troll away
-- David Melville on r.a.s.f1


== 2 of 3 ==
Date: Tues, Apr 13 2010 11:30 pm
From: Phil Carmody


Ian Collins <ian-news@hotmail.com> writes:
> On 04/14/10 09:45 AM, Phil Carmody wrote:
>> Ian Collins<ian-news@hotmail.com> writes:
>>> On 04/14/10 09:19 AM, Phil Carmody wrote:
>>>> Ian Collins<ian-news@hotmail.com> writes:
>>>>> On 04/14/10 09:01 AM, candide wrote:
>>>>>> I request your opinion about the following attempt to implement the
>>>>>> standard function strstr. Here is the code :
>>>>>
>>>>> No, it looks like you are writing strchr.
>>>>>>
>>>>>>
>>>>>> char *mystrchr(const char *s, int c)
>>>>>> {
>>>>>> while ((unsigned char)*s != (unsigned char)c) {
>>>>>
>>>>> Why the casts?
>>>>
>>>> Because without them
>>>>
>>>> char buff[LINELEN];
>>>> while(get_line_from_post(buff, sizeof(buff))) {
>>>> /* detect mangled indents from googoogroups */
>>>> char *mangledchars=buff;
>>>> while ((mangledchars=mystrchr(mangledchars, 160)) != NULL)
>>>> *mangledchars=' ';
>>>> }
>>>>
>>>> may fail to fix any non-breaking spaces.
>>>
>>> Eh?
>>
>> If chars are signed, then you'll be comparing char -96 with int 160,
>> and not find any matches.
>
> So?

So it won't do what was requred of it.

> a simple cast to char would be fine:

Now that's weasely wording. The cast you like is 'simple', but the
two casts from the OP are so horrible they must be avoided no matter
what?

> while (*s != (char)c)
>
> As the standard says (my emphasis):
>
> "The strchr function locates the first occurrence of c *(converted to
> a char)* in string s".

But, on the DS-2010, (char)'\xA0' is 127. That's going to replace all
the DEL characters instead!

Phil
--
I find the easiest thing to do is to k/f myself and just troll away
-- David Melville on r.a.s.f1


== 3 of 3 ==
Date: Tues, Apr 13 2010 11:37 pm
From: Phil Carmody


Seebs <usenet-nospam@seebs.net> writes:
> On 2010-04-13, candide <candide@free.invalid> wrote:
>> In fact, the code is not mine so I can't tell you why. I suppose the
>> casts are needed for the function to have a correct behaviour in order
>> to locate some character in the extended character set (accent for
>> instance).
>
> I don't think they are, actually. The "unsigned char" thing is needed
> when using is*() functions, and for processing things like the result of
> getchar(), etcetera, but in the case of strchr, it seems as though plain
> char is right.

The values of the hex and octal escapes in character constants are
unsigned char too. (That are mapped onto ints as they become the
actual character constants.)

Phil
--
I find the easiest thing to do is to k/f myself and just troll away
-- David Melville on r.a.s.f1


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c?hl=en

To unsubscribe from this group, send email to comp.lang.c+unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate