Saturday, April 17, 2010

comp.lang.c - 18 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:

* An exercise, regarding the implementation of an "if" - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/e21de5b677e11cbd?hl=en
* English and C - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.c/t/eee9a73d267c1066?hl=en
* adding two hex numbers - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/29688d45a35bc095?hl=en
* cast - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/041a2b73cefbd536?hl=en
* Lessons on development of 64-bit C/C++ applications - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/9ff77afdcf84086f?hl=en
* seebs/schildt - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/0c84debf9a4f144b?hl=en
* chroot() and popen() won't get along - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.c/t/f10540f417427208?hl=en

==============================================================================
TOPIC: An exercise, regarding the implementation of an "if"
http://groups.google.com/group/comp.lang.c/t/e21de5b677e11cbd?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Apr 16 2010 2:00 pm
From: Eric Sosman


On 4/16/2010 4:34 PM, Eric Sosman wrote:
> On 4/15/2010 5:21 PM, Stefan Ram wrote:
>> [...]
>> Of course, it would be very interesting if anyone could
>> find a solution without using an array (I don't think that
>> this can be done).
>
> Here's a filthy, filthy dirty approach (I hope I've matched
> the parentheses correctly(: [...]

Oh, drat! I mis-matched them. Here's a correction, and
I've also added a little bit of defensive coding:

double f(int c, double x) {
return ((double(*)(double))(void*)(((uintptr_t)
(void*)log)^((((uintptr_t)(void*)sin)^((uintptr_t)
(void*)log))*!c)))(x);
}

--
Eric Sosman
esosman@ieee-dot-org.invalid


== 2 of 2 ==
Date: Fri, Apr 16 2010 2:42 pm
From: ram@zedat.fu-berlin.de (Stefan Ram)


Eric Sosman <esosman@ieee-dot-org.invalid> writes:
>double f(int c, double x) {
> return ((double(*)(double))(void*)(((uintptr_t)
> (void*)log)^((((uintptr_t)(void*)sin)^((uintptr_t)
> (void*)log))*!c)))(x);
>}

I was impressed by the ingenuity of all the answers! I have
chosen to respond to the above one, just to reformat it for
(my personal )readability. I have a certain formatting style
that is treating all brackets (parenthesis, braces) in the
same way, and I hope it will help me to read the above.

I am also adding »const« which I do not deem to be part of
the interface of a function, but just of its implementation.

double f( int const c, double const x )
{ return
( ( double( * )( double ) )
( void * )
( ( ( uintptr_t )( void * )log )
^
( ( ( ( uintptr_t )( void * )sin )
^
( ( uintptr_t )( void * )log ))
*
!c )
)
)
( x ); }


==============================================================================
TOPIC: English and C
http://groups.google.com/group/comp.lang.c/t/eee9a73d267c1066?hl=en
==============================================================================

== 1 of 4 ==
Date: Fri, Apr 16 2010 3:14 pm
From: Joachim Pense


Am 16.04.2010 19:49, schrieb J de Boyne Pollard:
>> "Software development and writing are both
>> the art of knowing what you're going to
>> do, and then lucidly expressing your ideas."
>
> Software development is more the art of knowing what the computer is
> going to do. (-:

I think that's not Software development, that's wizardry.

Joachim


== 2 of 4 ==
Date: Fri, Apr 16 2010 7:38 pm
From: Andrew Poelstra


On 2010-04-16, Joachim Pense <snob@pense-mainz.eu> wrote:
> Am 16.04.2010 19:49, schrieb J de Boyne Pollard:
>>> "Software development and writing are both
>>> the art of knowing what you're going to
>>> do, and then lucidly expressing your ideas."
>>
>> Software development is more the art of knowing what the computer is
>> going to do. (-:
>
> I think that's not Software development, that's wizardry.
>

Isn't it both?

--
Andrew Poelstra
http://www.wpsoftware.net/andrew


== 3 of 4 ==
Date: Fri, Apr 16 2010 11:53 pm
From: Malcolm McLean


On Apr 16, 8:58 am, Nick Keighley <nick_keighley_nos...@hotmail.com>
wrote:
> On 15 Apr, 14:55, Malcolm McLean <malcolm.mcle...@btinternet.com>
> wrote:
>
> > On 15 Apr, 13:20, blm...@myrealbox.com <blm...@myrealbox.com> wrote:
> > > Picky speakers of English might point out that "I have went" is, um,
> > > "incorrect"?  "non-standard"?
>
> > Stigmatised. Adult speakers don't make grammatical errors in their
> > native language, almost by definition.
>
> I suspect only because you define "native language" as the language he
> speaks grammatically as an adult.
>
Are the rules applied consistently (eg if he says "can't hardly" is it
always "can't hardly"), and are they accepted by at least one other
person (does someone else say "can't hardly")?

If so he's speaking grammatically.


== 4 of 4 ==
Date: Fri, Apr 16 2010 11:58 pm
From: Seebs


On 2010-04-17, Malcolm McLean <malcolm.mclean5@btinternet.com> wrote:
> Are the rules applied consistently (eg if he says "can't hardly" is it
> always "can't hardly"), and are they accepted by at least one other
> person (does someone else say "can't hardly")?
>
> If so he's speaking grammatically.

This seems like it belongs in alt.usage.english.

I would say that, in general, if you assert that any speech according
to *a* grammar is grammatical, that reduces "grammatical" to the point
of near-irrelevance. In particular, it removes grammar from the list
of things a language has, because the existence of a pair of people who
use all the same words but don't use them in a way other people can
understand would render them perfectly "grammatical".

To bring this onto the general topic of C: The existence of a compiler
which accepts a particular program does not make that program "valid C".
What's usually at issue is whether we can have reasonable confidence
that C compilers in general would accept something, or even just a future
compiler from the same vendor.

Similarly, what's usually at issue with language is whether you have
reasonable confidence that an arbitrarily-selected native speaker of the
language you think you are speaking will be able to figure out how
to parse your sentences. If they can't, then if you are speaking
grammatically at all, you are speaking a different languauge than they
are hearing.

I tend to view "proper grammar" as rather a lot like "strictly conforming
C". It's not really required most of the time, but there is a HUGE advantage
to the writer in knowing what the rules are, even if the very next decision
you make is that you are going to break them.

-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!

==============================================================================
TOPIC: adding two hex numbers
http://groups.google.com/group/comp.lang.c/t/29688d45a35bc095?hl=en
==============================================================================

== 1 of 3 ==
Date: Fri, Apr 16 2010 4:13 pm
From: Phil Carmody


Keith Thompson <kst-u@mib.org> writes:
> Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
>> Keith Thompson <kst-u@mib.org> writes:
> [...]
>> > For historical reasons, many compilers will (after printing a warning)
>> > generate an implicit conversion, making the above equivalent to the
>> > legal declaration
>> >
>> > unsigned int *x = (unsigned int)0x37a00000;
>>
>> ITYM: unsigned int *x = (unsigned int*)0x37a00000;
>
> Yes, you're right.
>
> Sheesh, we're nitpicking about punctuation now? 8-)} 8-)}

Nope, I thought we were trying to help newbs. Sorry if it was
taken the wrong way.

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: Fri, Apr 16 2010 5:55 pm
From: Keith Thompson


Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
> Keith Thompson <kst-u@mib.org> writes:
> > Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
> >> Keith Thompson <kst-u@mib.org> writes:
> > [...]
> >> > For historical reasons, many compilers will (after printing a warning)
> >> > generate an implicit conversion, making the above equivalent to the
> >> > legal declaration
> >> >
> >> > unsigned int *x = (unsigned int)0x37a00000;
> >>
> >> ITYM: unsigned int *x = (unsigned int*)0x37a00000;
> >
> > Yes, you're right.
> >
> > Sheesh, we're nitpicking about punctuation now? 8-)} 8-)}
>
> Nope, I thought we were trying to help newbs. Sorry if it was
> taken the wrong way.

Um, did you miss the smileys?

It was a significant correction, and I thank you for making it.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


== 3 of 3 ==
Date: Fri, Apr 16 2010 10:34 pm
From: Phil Carmody


Keith Thompson <kst-u@mib.org> writes:
> Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
>> Keith Thompson <kst-u@mib.org> writes:
>> > Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
>> >> Keith Thompson <kst-u@mib.org> writes:
>> > [...]
>> >> > For historical reasons, many compilers will (after printing a warning)
>> >> > generate an implicit conversion, making the above equivalent to the
>> >> > legal declaration
>> >> >
>> >> > unsigned int *x = (unsigned int)0x37a00000;
>> >>
>> >> ITYM: unsigned int *x = (unsigned int*)0x37a00000;
>> >
>> > Yes, you're right.
>> >
>> > Sheesh, we're nitpicking about punctuation now? 8-)} 8-)}
>>
>> Nope, I thought we were trying to help newbs. Sorry if it was
>> taken the wrong way.
>
> Um, did you miss the smileys?
>
> It was a significant correction, and I thank you for making it.

Sorry, I was a bit on the braindamaged side yesterday.

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

==============================================================================
TOPIC: cast
http://groups.google.com/group/comp.lang.c/t/041a2b73cefbd536?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Apr 16 2010 4:20 pm
From: Phil Carmody


Lew Pitcher <lpitcher@teksavvy.com> writes:
> On April 16, 2010 12:18, in comp.lang.c, nospam@nspam.invalid wrote:
> Bill,
>
> I've looked over your function, and (disregarding a couple of minor WTFs

Minor what-the-fuck's?

What the fuck is a minor what-the-fuck?

If it was minor it, quite simply, wasn't a 'what-the-fuck'.

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

==============================================================================
TOPIC: Lessons on development of 64-bit C/C++ applications
http://groups.google.com/group/comp.lang.c/t/9ff77afdcf84086f?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Apr 16 2010 5:04 pm
From: "Herbert Rosenau"


On Fri, 9 Apr 2010 13:50:14 UTC, SaticCaster <karpov2007@gmail.com>
wrote:

> http://www.viva64.com/articles/x64-lessons/

This stinks! It tells about something that does not exist. There is no
language named C/C++ - but 2 differen ones whereas one is named C and
another that is named C++.

Anyway it lies it were about X64 - instead it is only about one
particular compiler of one particular operating system. So it is
completely useless as it tells about a non existent language for an
particular operating system.

A book that is unable to distinguish different languages and thinks
that one paricular compiler will be the only exiastent one for a
paricular computer architecture is not worth to read anyway.


--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2R Deutsch ist da!

==============================================================================
TOPIC: seebs/schildt
http://groups.google.com/group/comp.lang.c/t/0c84debf9a4f144b?hl=en
==============================================================================

== 1 of 3 ==
Date: Fri, Apr 16 2010 6:15 pm
From: J de Boyne Pollard


> > The result is they're still stuck in a stolen clone of the
> > world of 1970s unix, a FAR more retardo world than Windows.
> > And the fact that Windows is pretty goddamn retarded only
> > goes to show you.
>
> It's far harder to write operating systems than it looks.
> Ignoring device drivers, it would only take a few weeks to
> write something on a bare PC capable of putting up windows,
> running programs in them, closing them down. It's getting
> the details right that is the killer.

Actually, it's the design that's the killer. Copying an
existing design is comparatively easy. Witness ReactOS,
FreeDOS, and -- yes -- Linux. Whereas coming up with a
new design is comparatively harder. Witness OSFree and
Hurd.

== 2 of 3 ==
Date: Fri, Apr 16 2010 8:13 pm
From: spinoza1111


On Apr 16, 10:25 pm, BruceS <bruce...@hotmail.com> wrote:
> On Apr 16, 7:41 am,spinoza1111<spinoza1...@yahoo.com> wrote:
> <snip>
>
> > In the corporate programming world, that word "abrasive" meant in my
> > experience "fair game for criticism behind his back since he knows his
> > job and we don't".
>
> > For example, knowing how Or is evaluated and usefully reminding a
> > programmer in a structured walkthrough is often found to be "abrasive"
> > and "showing off".
>
> IME, the term has very little to do with *what* the person says, and
> everything to do with *how* he says it.  I've worked with programmers
> that were well respected but considered abrasive, others that were
> mixed that same abrasiveness with incompetence, and many who've
> avoided abrasive behavior entirely.  I've been in a code review in
> which one reviewer bluntly pointed out that OO had a concept of
> "inheritance" (the org tends to very flat class models) without being
> abrasive.  He seemed to be addressing defects in the code rather than
> in the coder.  This is not an easy skill, nor a common one.

I agree that this person's conduct is not abrasive. However, in my
experience, it is sometimes called "abrasive" by people whose lack of
knowledge has been exposed. In your example, the designers of the
overly flat software are apt in corporate environments to say that the
critic is "academic" (because he's using knowledge) and "abrasive"
because he's criticized them). But to CALL a person "abrasive" in a
technical discussion out of the blue is to be "abrasive".


== 3 of 3 ==
Date: Fri, Apr 16 2010 8:15 pm
From: spinoza1111


On Apr 16, 10:29 pm, Malcolm McLean <malcolm.mcle...@btinternet.com>
wrote:
> On 16 Apr, 14:52,spinoza1111<spinoza1...@yahoo.com> wrote:
>
> > The result is they're still stuck in a stolen clone of the world of
> > 1970s unix, a FAR more retardo world than Windows. And the fact that
> > Windows is pretty goddamn retarded only goes to show you.
>
> It's far harder to write operating systems than it looks.
> Ignoring device drivers, it would only take a few weeks to write
> something on a bare PC capable of putting up windows, running programs
> in them, closing them down. It's getting the details right that is the
> killer.

Which is why Andrew Tanenbaum (from whom Torvalds stole Minix) was
right about Linux.

==============================================================================
TOPIC: chroot() and popen() won't get along
http://groups.google.com/group/comp.lang.c/t/f10540f417427208?hl=en
==============================================================================

== 1 of 4 ==
Date: Fri, Apr 16 2010 6:16 pm
From: blacklight


Well, before continuing I'd like to specify a pair of things:

1. Of course I posted to comp.unix.programmer too, but nobody was able
to help me there. They mostly said to me "is your executable file
statically linked? Does it have any dependencies not taken inside the
chroot'ed environment?" but I get these errors even if my "exe" has
only a write() syscall.

2. Yeah, I read the manual pages, more than once, but there's really
nothing about this. And if the manual has nothing about this kind of
issue, I cannot imagine the solution reading it. I'm someone who likes
the RTFM philosophy too, but if the RTFM philosophy does not take to a
solution, then it's not smart to insist.

3. Some other guys on comp.unix.programmer told me "popen() uses the
local shell in order to execute the file, copy it inside the chroot'ed
environment". Well, I had already tried to copy sh and zsh inside the
chroot'ed environment, and inside its bin/ directory too, but always
without any results. Another piece of suggestion I got was "try with
the pipe-fork-exec sequence". Well, I actually tried it. Again, this is
my situation:

+-> /p
|---> /p/popen
|---> /p/exe

This, very simply, is exe.c:


#include <unistd.h>
#include <stdlib.h>

int
main ( int argc, char *argv[] )
{
write (1, "asd", 4);
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */


This is popen.c:


#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>

typedef int pipe_t[2];

int
main ( int argc, char *argv[] )
{
char ch;
pipe_t pp;

if (chroot(".") < 0)
return EXIT_FAILURE;

if (pipe(pp) < 0)
return EXIT_FAILURE;

if (!fork()) {
close(pp[0]);
close(1);
dup(pp[1]);

execl ("exe", "exe", NULL);
exit(0);
} else {
close(pp[1]);
close(0);
dup(pp[0]);

while (read(0, &ch, 1) > 0)
write (1, &ch, 1);
write (1, "\n", 1);

close(pp[0]);
wait ((int*) 0);
}

return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */

Even this implementation took no results. Note: if I remove the
chroot() call, everything works properly. I even tried in the exec call
to invoke the first argument as /p/exe, as ./exe, as /exe, but nothing,
always no results. Now the question is: how the fuck can I execute an
external command in a chroot'ed environment?

Michael Foukarakis <electricdelta@gmail.com> wrote:
> On Apr 15, 8:27 pm, blacklight <blackli...@devio.us> wrote:
>> So, how do I invoke an
>> executable file in a chroot() environment?
>>
>
> You either need a shell for popen(), or execve(). Read the manuals,
> more carefully this time.
>
> On Apr 15, 8:33 pm, Eric Sosman <esos...@ieee-dot-org.invalid> wrote:
>>
>> You want comp.unix.programmer.
>
> Aren't you just an adorable fluffy tropical cookie.

--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT d? a? C++++ U++++ P++++ L+++++ E--- W+++ !w PS+++ PE-- Y++ PGP++ X++
R+ tv-- b+>+++ DI++ G++ e+++ h* r++ z**
------END GEEK CODE BLOCK------

-ONLY- email me using my PGP key
# http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE8468AFB46DBC195

Admin of
# http://0x00.ath.cx


== 2 of 4 ==
Date: Fri, Apr 16 2010 6:36 pm
From: Ian Collins


On 04/17/10 01:16 PM, blacklight wrote:
> Well, before continuing I'd like to specify a pair of things:
>
> 1. Of course I posted to comp.unix.programmer too, but nobody was able
> to help me there. They mostly said to me "is your executable file
> statically linked? Does it have any dependencies not taken inside the
> chroot'ed environment?" but I get these errors even if my "exe" has
> only a write() syscall.
>
> 2. Yeah, I read the manual pages, more than once, but there's really
> nothing about this. And if the manual has nothing about this kind of
> issue, I cannot imagine the solution reading it. I'm someone who likes
> the RTFM philosophy too, but if the RTFM philosophy does not take to a
> solution, then it's not smart to insist.
>
> 3. Some other guys on comp.unix.programmer told me "popen() uses the
> local shell in order to execute the file, copy it inside the chroot'ed
> environment". Well, I had already tried to copy sh and zsh inside the
> chroot'ed environment, and inside its bin/ directory too, but always
> without any results. Another piece of suggestion I got was "try with
> the pipe-fork-exec sequence". Well, I actually tried it. Again, this is
> my situation:

That's three. A pair is two.

You had quite a few decent answers on c.u.p, so why don't you follow up
there, where this question belongs?

--
Ian Collins


== 3 of 4 ==
Date: Fri, Apr 16 2010 8:09 pm
From: pacman@kosh.dhis.org (Alan Curry)


In article <hqb25s$v2j$1@speranza.aioe.org>,
blacklight <blacklight@devio.us> wrote:
|Well, before continuing I'd like to specify a pair of things:
|
|1. Of course I posted to comp.unix.programmer too, but nobody was able
|to help me there. They mostly said to me "is your executable file
|statically linked? Does it have any dependencies not taken inside the
|chroot'ed environment?" but I get these errors even if my "exe" has
|only a write() syscall.

You have so far given no answer to the question of whether it was statically
linked, and quite a bit of evidence that you don't know what static linking
is. Well here's some bad news: that was a very relevant question, and dodging
it has prevented you (and the poor fools trying to help you) from
investigating the most likely cause of your problem. You better go read up on
the concepts of dynamic linking and static linking if you want to do
something more than uselessly rant at us.

Hint 1: man ldd
--
Alan Curry


== 4 of 4 ==
Date: Fri, Apr 16 2010 10:37 pm
From: Phil Carmody


blacklight <blacklight@devio.us> writes:
> Well, before continuing I'd like to specify a pair of things:
>
> 1. Of course I posted to comp.unix.programmer too, but nobody was able
> to help me there. They mostly said to me "is your executable file
> statically linked? Does it have any dependencies not taken inside the
> chroot'ed environment?" but I get these errors even if my "exe" has
> only a write() syscall.
>
> 2. Yeah, I read the manual pages, more than once, but there's really
> nothing about this.

Lie. It's as bold as bold can be. You don't even need to page down
on a 24-line console to see what it says about it.

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