Saturday, February 13, 2010

comp.lang.c - 25 new messages in 8 topics - digest

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

comp.lang.c@googlegroups.com

Today's topics:

* portable floating-point read/write - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/7c848009bd0fc355?hl=en
* The C FAQ - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c/t/b75c0ae09abf3345?hl=en
* Making FILE opaque - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/5b748373bfa3544c?hl=en
* Warning to newbies - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/9597fd702985dff4?hl=en
* Efficency and the standard library - 9 messages, 5 authors
http://groups.google.com/group/comp.lang.c/t/ad9fea19f2f7dd61?hl=en
* HOW this program is executing plz explain the program - 5 messages, 3
authors
http://groups.google.com/group/comp.lang.c/t/3fb552296fac02d8?hl=en
* Get 101 Question in C, C++, C++ under Windows, MFC, DLL, COM/DOM - 1
messages, 1 author
http://groups.google.com/group/comp.lang.c/t/0e90137c70502f66?hl=en
* Motivation of software professionals - 2 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/21a3fdec4dd53e6a?hl=en

==============================================================================
TOPIC: portable floating-point read/write
http://groups.google.com/group/comp.lang.c/t/7c848009bd0fc355?hl=en
==============================================================================

== 1 of 3 ==
Date: Fri, Feb 12 2010 11:57 pm
From: Michael Foukarakis


On Feb 13, 8:42 am, Nobody <nob...@nowhere.com> wrote:
> On Fri, 12 Feb 2010 03:39:51 -0800, Michael Foukarakis wrote:
> > For integer quantities I use hton[s|l]()/ntoh[s|l](). Generally
> > speaking though, how about encoding into IEEE-754? Here's some code I
> > copied a long time ago from...some fellow which I don't recall.
> >     while(fnorm >= 2.0) { fnorm /= 2.0; shift++; }
> >     while(fnorm < 1.0) { fnorm *= 2.0; shift--; }
>
> This is rather inefficient if the exponent is far from zero (and
> "long double" typically supports binary exponents from -16381 to 16384).

I don't know, the logarithm is a powerful little bugger.

> frexp() and ldexp() are in C89 (the float and long double variants are
> C99), and should have constant time for any sane architecture.

What? Why? :O


== 2 of 3 ==
Date: Sat, Feb 13 2010 2:34 am
From: "christian.bau"


On Feb 12, 10:43 am, Malcolm McLean <malcolm.mcle...@btinternet.com>
wrote:
> Anyone got a routine to portably read/write 64 bit IEEE numbers in
> litle-endian format?
>
> (I mean so that it is compatible with fwrite(&x, sizeof(double), 1,
> fp) ona Windows PC, and won't break should the program be run on a
> machine with a diferent internal floating-point unit).

In theory, this is a very hard problem.
In practice, write two functions

void read_64bit_int (uint64_t *p);
void write_64bit_int (uint64_t *p);

and call

void read_double (double *p) { read_64bit_int ((uint64_t *) p); }
void write_double (double *p) { write_64bit_int ((uint64_t *)
p); }

This should work on everything using IEEE754 floating point
arithmetic.

The same problem with "long double" instead of double is hard in
theory and practice.


== 3 of 3 ==
Date: Sat, Feb 13 2010 3:34 am
From: Michael Foukarakis


On Feb 13, 12:34 pm, "christian.bau"
<christian....@cbau.wanadoo.co.uk> wrote:
> On Feb 12, 10:43 am, Malcolm McLean <malcolm.mcle...@btinternet.com>
> wrote:
>
> > Anyone got a routine to portably read/write 64 bit IEEE numbers in
> > litle-endian format?
>
> > (I mean so that it is compatible with fwrite(&x, sizeof(double), 1,
> > fp) ona Windows PC, and won't break should the program be run on a
> > machine with a diferent internal floating-point unit).
>
> In theory, this is a very hard problem.
> In practice, write two functions
>
>     void read_64bit_int (uint64_t *p);
>     void write_64bit_int (uint64_t *p);
>
> and call
>
>     void read_double (double *p) { read_64bit_int ((uint64_t *) p); }
>     void write_double (double *p) { write_64bit_int ((uint64_t *)
> p); }
>
> This should work on everything using IEEE754 floating point
> arithmetic.

That's trivial. The trouble is when a target system doesn't use IEEE
754 encoding.

>
> The same problem with "long double" instead of double is hard in
> theory and practice.

Pfft. </sarcasm>

==============================================================================
TOPIC: The C FAQ
http://groups.google.com/group/comp.lang.c/t/b75c0ae09abf3345?hl=en
==============================================================================

== 1 of 3 ==
Date: Sat, Feb 13 2010 12:27 am
From: jacob navia


Seebs a écrit :
> On 2010-02-12, jacob navia <jacob@nospam.org> wrote:
>> Linux is even more fragmented that the different Unix flavors at that time.
>
> I wrote a hunk of code which has one meaningful #ifdef in it, which is
> working on every Linux system we know of currently available.

First bet:

It doesn't use any GUI

Second bet:

It doesn't use any sound/video/multimedia

Third bet:

It doesn't use any graphics, or mouse

Obviously, THEN... it is portable. But it would be portable to
Mac/windows/whatever too without much pain.

== 2 of 3 ==
Date: Sat, Feb 13 2010 12:55 am
From: Richard Heathfield


jacob navia wrote:
> Seebs a écrit :
>> On 2010-02-12, jacob navia <jacob@nospam.org> wrote:
>>> Linux is even more fragmented that the different Unix flavors at that
>>> time.
>>
>> I wrote a hunk of code which has one meaningful #ifdef in it, which is
>> working on every Linux system we know of currently available.
>
> First bet:
>
> It doesn't use any GUI

Actually, there's no reason why it shouldn't, given that he is only
claiming portability across "every Linux system we know of currently
available". The same applies to your other two bets...

>
> Second bet:
>
> It doesn't use any sound/video/multimedia
>
> Third bet:
>
> It doesn't use any graphics, or mouse

...but if he were claiming general cross-platform capability, your bets
would be pretty solid, I think. Nevertheless, a system can use such
components and still be /largely/ portable - i.e. the rewrite work for
each platform can be isolated and contained in specific modules, where
it is easily identifiable (and surprisingly small, if the design is good).

> Obviously, THEN... it is portable. But it would be portable to
> Mac/windows/whatever too without much pain.

If the system is written with portability as one of the major
objectives, the pain may indeed be minimal.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within


== 3 of 3 ==
Date: Sat, Feb 13 2010 1:13 am
From: jacob navia


Richard Heathfield a écrit :
> jacob navia wrote:
>> Seebs a écrit :
>>> On 2010-02-12, jacob navia <jacob@nospam.org> wrote:
>>>> Linux is even more fragmented that the different Unix flavors at
>>>> that time.
>>>
>>> I wrote a hunk of code which has one meaningful #ifdef in it, which is
>>> working on every Linux system we know of currently available.
>>
>> First bet:
>>
>> It doesn't use any GUI
>
> Actually, there's no reason why it shouldn't, given that he is only
> claiming portability across "every Linux system we know of currently
> available". The same applies to your other two bets...
>

I can use the same code from windows 95 to windows me to windows NT/XP
to VISTA and windows 7, using windows, mouse, graphics, sound, and
many other things with minimal problems. The same isn't true in
linux. You have the KDE/Gnome problem (QT/GDK) and within GDK, the
only that I used, the problem that each version is (of course) incompatible
with the last version. I gave up following GDK and rewriting my
application again

Why this mess?

Because windows is done by microsoft, a monopoly that wants to keep
most customers (and developers) happy to go on selling them stuff.

Linux is free, and the developers of linux GUIs do not care about users
since their user base doesn't pay them at all. So they do as they
find fit, and the users must rewrite all their applications at their
whim.

Obviously there are IMPORTANT part of linux that are rock solid since
there are CUSTOMERS that PAY linux developers to maintain those
parts: network, basic multi tasking, etc. Linux as a SERVER runs pretty
well since IBM/ORACLE/whatever PAY for top notch linux developers.

GUIs are used by "normal" users, and nobody gets payed for them.

Consequence: a mess.

In the linux bazaar, money is the center of attention like in any
other bazzar, even those that look like cathedrals.

The same situation appears in the linux developer tools, that are
at the same level that Unix 20 years ago...

vi+make+gdb

No sane linux developer would PAY for a development system. And
the consequence is that there are hundreds of unfinished "DUE"s:
"Desintegrated Unusable Environments" that promise the world
but deliver just crashes. The only one that halfway works is
Eclipse because IBM PAYED for it.

==============================================================================
TOPIC: Making FILE opaque
http://groups.google.com/group/comp.lang.c/t/5b748373bfa3544c?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Feb 13 2010 12:50 am
From: Keith Thompson


jacob navia <jacob@nospam.org> writes:
> Alan Curry a écrit :
>> In article <lny6iyc4w7.fsf@nuthaus.mib.org>,
>> Keith Thompson <kst-u@mib.org> wrote:
>> |jacob navia <jacob@nospam.org> writes:
>> |> Seebs a écrit :
>> |>> It was recently pointed out that the theoretical construct:
>> |>> struct __file;
>> |>> typedef struct __file FILE;
>> |>> is not a conforming implementation (assuming no definition of
>> |>> struct __file),
>> |>> because FILE is specified to be an object type.
>> |>>
>> |> lcc-win64 makes FILE opaque.
>> |
>> |Opaque in what sense? C99 7.19.1p2 specifically requires FILE to be
>> |an object type.
>>
>> What's the point? File this requirement under "design by committee" and
>> ignore it.
>>
>> If you're looking inside the FILE type because you actually want to do
>> something with the information in there, beyond what the standard
>> interfaces offer, that's different.
>>
>
> I need to make it opaque because the fields, size, and many other things
> aren't fixed.
>
> I want to make things like
>
> FILE *fp = fopen("http://www.q-software-solutions.de","r");
>
> That would open any file in the network. I think users will be
> happier with those features than with a strictly conforming
> stuff.

You didn't directly answer my question, but I suppose that last bit
implies that your implementation isn't conforming. Not the choice I
would have made, but it's between you and your users.

But I'm still curious: How do you actually define FILE, and how does
making it something other than an object type help?

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

==============================================================================
TOPIC: Warning to newbies
http://groups.google.com/group/comp.lang.c/t/9597fd702985dff4?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Feb 13 2010 1:07 am
From: spinoza1111


On Feb 13, 7:07 am, Richard Heathfield <r...@see.sig.invalid> wrote:
> spinoza1111wrote:
> > On Feb 12, 6:23 am, Richard Heathfield <r...@see.sig.invalid> wrote:
>
> <snip>
>
> >> Since you have in the past proved
> >> unwilling to learn from your bugs, I tend only to point out the first
> >> one I see (if that).
>
> > Screw you, asshole. I've been fixing all bugs found. You've been
> > running your mouth.
>
> Actually, no, I've been doing something rather more productive than
> that. I've been developing real software and putting it into real
> production in the real world, where your deconstructionist nonsense
> wouldn't last five minutes. I know you'll find this hard to believe, but
> there's more to life than comp.lang.c.

What I find hard to believe is:

* That you are currently anything but unemployed
* That you are not in fact obsessed with posting here (you don't take
sabbaticals), or SAMS does not pay you

You haven't contributed a single meaningful bug report. Nor have you,
or Seebach, contributed any bug fixes or code that meets the problem
statement.

Whereas I've evolved a solution to a hard problem and fixed bugs as
they've arisen.
>
> --
> Richard Heathfield <http://www.cpax.org.uk>
> Email: -http://www. +rjh@
> "Usenet is a strange place" - dmr 29 July 1999
> Sig line vacant - apply within


==============================================================================
TOPIC: Efficency and the standard library
http://groups.google.com/group/comp.lang.c/t/ad9fea19f2f7dd61?hl=en
==============================================================================

== 1 of 9 ==
Date: Sat, Feb 13 2010 1:25 am
From: spinoza1111


On Feb 13, 2:46 am, spinoza1111 <spinoza1...@yahoo.com> wrote:
...code...

I noticed that in the latest (13 Feb) version of the code, with the
fix to the one-character replace found by Ben B, there were some file
nits: two long lines split and blanks at end of continued macro lines.

Let's see if I can get rid of these problems.

Also, I misspoke. The failure to handle Ben's example was caused by an
earlier change.

Here is the latest code, without the console output.


// ***************************************************************
// * *
// * replace() demo *
// * *
// * Demonstrates how to replace non-NUL-defined strings in C *
// * using a simple function, and bypassing string.h. *
// * *
// * C H A N G E R E C O R D --------------------------------- *
// * DATE PROGRAMMER DESCRIPTION OF CHANGE *
// * -------- ---------- --------------------------------- *
// * 02 07 10 Nilges Version 1.0 *
// * *
// * 02 07 10 Nilges Bug: partial matches not handled *
// * correctly: need to iterate search *
// * for match. *
// * *
// * 02 07 10 Nilges 1. Santosh suggested tests *
// * 2. Heathfield put the boot in re *
// * including malloc *
// * *
// * 02 07 10 Nilges 1. Remove string.h use and code *
// * strlen by hand *
// * 2. Add comment block and comments*
// * inline. *
// * 3. free() storage *
// * 4. Use macro for testing *
// * 5. Bug: calculation of *
// * lngNewLength used incorrect *
// * index (intIndex3 instead of 2)*
// * which caused a memory leak. *
// * *
// * 02 07 10 Nilges 1. Bug: Ike Naar test failed. *
// * At end of scan loop, main *
// * string pointer was not *
// * correctly updated from index3 *
// * *
// * 02 07 10 Nilges Added new Santosh test *
// * *
// * 02 07 10 Nilges Added new Ike Naar test *
// * *
// * 02 08 10 Nilges 1. Added some new comments *
// * 2. Make "check for a complete *
// * match "structured" by means *
// * of a tested assignment *
// * 3. Get rid of "replace at end" *
// * evilness: the only time this *
// * flag is meaningful is in the *
// * LAST segment. *
// * 4. Return replace count *
// * 5. TESTER macro assertion added *
// * *
// * 02 10 10 Nilges 1. Bug fix: in a partial match, *
// * the main scan index is set to *
// * one past the end, which misses*
// * full matches that start *
// * between the first character of*
// * the partial match and its end.*
// * *
// * No longer updating the main *
// * scan index (ptrIndex1) to the *
// * point of partial match *
// * failure: setting it one past *
// * the first character of the *
// * partial match. *
// * *
// * 2. Line up expected & actual *
// * results per excellent *
// * suggestion (who made this?) *
// * *
// * 3. After a partial match, update *
// * the main handle search index *
// * (ptrIndex1) to the first *
// * occurrence of the handle *
// * character after the start of *
// * the partial match, or to the *
// * index of the unmatched char. *
// * *
// * 021310 Nilges Bug: failed to handle a one-char *
// * replace (of a by x in b) since *
// * we set ptrIndex2 to point to NUL *
// * which made it appear that there *
// * was a match. When the main index *
// * to the master string (ptrIndex1) *
// * goes off the end of a cliff, we *
// * needed to break out of the search *
// * loop. *
// * *
// * This also entailed setting the *
// * target index ptrIndex2 to 0 at the*
// * beginning of each search so that *
// * it is not erroneously used to *
// * indicate that there's an insert *
// * needed at the end. *
// * *
// * I have also added additional tests*
// * to verify that the code works *
// * when the string and target end *
// * at the same time. *
// * ----------------------------------------------------------- *
// * *
// * "In the near future we shall have to live with the *
// * superstition that programming is 'so easy that even a *
// * Republican can do it!'" *
// * *
// * - E. W. Dijkstra *
// * *
// * *
// ***************************************************************
#include <stdio.h>
#include <stdlib.h>
// ***** Segmentation *****
struct TYPsegmentstruct
{ char * strSegment;
long lngSegmentLength;
struct TYPsegmentstruct * ptrNext; };
// ---------------------------------------------------------------
// Calculate string length
//
//
long strLength(char *strInstring)
{
char *ptrInstring;
for (ptrInstring = strInstring; *ptrInstring; ptrInstring++);
return ptrInstring - strInstring;
}

// ---------------------------------------------------------------
// Replace target by replacement string in master string
//
//
// Caution: the string returned by this function should be freed.
//
//
char * replace(char * strMaster,
char * strTarget,
char * strReplacement,
long * ptrReplacements)
{
char * ptrIndex0;
char * ptrIndex1;
char * ptrIndex2;
char * ptrIndex3;
char * ptrIndex4;
char * strNew;
char * strNewStart;
long lngNewLength;
long lngCount;
long lngReplacementLength;
struct TYPsegmentstruct * ptrSegmentStructStarts;
struct TYPsegmentstruct * ptrSegmentStruct;
struct TYPsegmentstruct * ptrSegmentStructPrev;
lngReplacementLength = strLength(strReplacement);
if (!*strTarget)
{
printf("Error in calling replace(): target can't be null");
abort();
}
ptrIndex1 = strMaster;
ptrSegmentStructPrev = 0;
lngNewLength = 0;
*ptrReplacements = 0;
while(*ptrIndex1)
{
ptrIndex0 = ptrIndex1;
ptrIndex2 = 0;
while (-1)
{
// --- Check for (one character) handle
for(;
*ptrIndex1 && *ptrIndex1 != *strTarget;
ptrIndex1++);
if (!*ptrIndex1) break;
// --- Check for complete match while remembering the
// --- last position of the handle
ptrIndex4 = 0;
for(ptrIndex2 = strTarget + 1,
ptrIndex3 = ptrIndex1 + 1;
*ptrIndex3
&&
*ptrIndex2
&&
*ptrIndex3 == *ptrIndex2;
ptrIndex3++, ptrIndex2++)
{
if (*ptrIndex3 == *strTarget
&&
ptrIndex4 == 0) ptrIndex4 = ptrIndex3;
}
// End test: check complete match, update main ptr past
// partial match while checking for end of loop
if ((!*ptrIndex2 ? ((*ptrReplacements)++, -1) : 0)
||
(!*ptrIndex3 ? (ptrIndex1 = ptrIndex3, -1) : 0))
break;
// Update the main search pointer
ptrIndex1 = (ptrIndex4 == 0 ? ptrIndex3 : ptrIndex4);
}
// --- Create new segment
if (!(ptrSegmentStruct =
malloc(sizeof(struct TYPsegmentstruct))))
abort();
ptrSegmentStruct->strSegment = ptrIndex0;
ptrSegmentStruct->lngSegmentLength =
ptrIndex1 - ptrIndex0;
ptrSegmentStruct->ptrNext = 0;
if (ptrSegmentStructPrev != 0)
ptrSegmentStructPrev->ptrNext = ptrSegmentStruct;
else
ptrSegmentStructStarts = ptrSegmentStruct;
ptrSegmentStructPrev = ptrSegmentStruct;
// --- Update mallocation length
lngNewLength += ptrSegmentStruct->lngSegmentLength +
(ptrIndex2 && !*ptrIndex2
?
lngReplacementLength
:
0);
// --- Get past end of target string & iterate
if (*ptrIndex1) ptrIndex1 = ptrIndex3;
}
// --- Allocate just enough storage for the new string
if (!(strNewStart = malloc(lngNewLength + 1))) abort();
// --- Build the new string whilst freeing the list
strNew = strNewStart;
ptrSegmentStruct = ptrSegmentStructStarts;
while (ptrSegmentStruct)
{
for (ptrIndex1 = ptrSegmentStruct->strSegment,
lngCount = 0;
lngCount < ptrSegmentStruct->lngSegmentLength;
ptrIndex1++, lngCount++, strNew++)
*strNew = *ptrIndex1;
if (ptrSegmentStruct->ptrNext
||
ptrIndex2 != 0 && !*ptrIndex2)
for (ptrIndex1 = strReplacement;
*ptrIndex1;
ptrIndex1++, ++strNew)
*strNew = *ptrIndex1;
ptrSegmentStructPrev = ptrSegmentStruct;
ptrSegmentStruct = ptrSegmentStruct->ptrNext;
free(ptrSegmentStructPrev);
}
*strNew = '\0';
return strNewStart;
}

// ---------------------------------------------------------------
// Statement-format test macro
//
//
#define TESTER(resultPtr, master, target, replacement, expected,
expectedReplacements, replacements) \
{ \
printf("Replace \"%s\" by \"%s\" in \"%s\"\n", \
(target), (replacement), (master)); \
printf("Expect \"%s\":\n \"%s\"\n", \
(expected), \
resultPtr = replace((master), \
(target), \
(replacement), \
&(replacements))); \
printf("Replacements expected: %d: replacements: %d\n", \
(expectedReplacements), \
(replacements)); \
if (!(strLength(resultPtr) \
== \
strLength(master) \
+ \
(strLength(replacement)-strLength(target)) \
* \
replacements)) \
printf("Assertion failed\n"); \
printf("\n\n"); \
free(resultPtr); \
}

// ---------------------------------------------------------------
// Main procedure
//
//
int main()
{
char *ptrResult;
long lngReplacements;
printf("\nReplace\n\n\n");
TESTER(ptrResult,
"1111123bbb1111123bbb11123bb11111231111112111111123",
"111123",
"ono",
"1onobbb1onobbb11123bb1ono1111112111ono",
4,
lngReplacements)
TESTER(ptrResult,
"bbb1111123bbbbb",
"111123",
"ono",
"bbb1onobbbbb",
1,
lngReplacements)
TESTER(ptrResult,
"a stupid error",
"stupid error",
"miracle",
"a miracle",
1,
lngReplacements)
TESTER(ptrResult,
"a stupid error",
"stupid",
"miracle",
"a miracle error",
1,
lngReplacements)
TESTER(ptrResult,
"the stupid error",
"the stupid error",
"a miracle",
"a miracle",
1,
lngReplacements)
TESTER(ptrResult,
"the miracle",
"the",
"a",
"a miracle",
1,
lngReplacements)
TESTER(ptrResult,
"a miraclsnirpKamunkle",
"snirpKamunkle",
"e",
"a miracle",
1,
lngReplacements)
TESTER(ptrResult,
"a miraclesnirpKamunkle",
"a miracle",
"",
"snirpKamunkle",
1,
lngReplacements)
TESTER(ptrResult,
" a miraclesnirpKamunkle",
"a miracle",
"",
" snirpKamunkle",
1,
lngReplacements)
TESTER(ptrResult,
" a miraclesnirpKamunklea miraclea miracle",
"a miracle",
"",
" snirpKamunkle",
3,
lngReplacements)
TESTER(ptrResult,
"a miracle a miraclesnirpKamunkle a Miraclea
miracleamiracle",
"a miracle",
"",
" snirpKamunkle a Miracle",
4,
lngReplacements)
TESTER(ptrResult,
"a stupid errord",
"stupid error",
"miracle",
"a miracled",
1,
lngReplacements)
TESTER(ptrResult,
"a stupid errod",
"stupid error",
"miracle",
"a stupid errod",
0,
lngReplacements)
TESTER(ptrResult,
"a sstupid error",
"stupid error",
"miracle",
"a smiracle",
1,
lngReplacements)
TESTER(ptrResult,
"a stupid errorstupid error",
"stupid error",
"miracle",
"a miraclemiracle",
2,
lngReplacements)
TESTER(ptrResult,
"a stupid error stupiderror",
"stupid error",
"miracle",
"a miracle stupiderror",
1,
lngReplacements)
TESTER(ptrResult,
"bbbbbbbbbb",
"b",
"a",
"aaaaaaaaaa",
10,
lngReplacements)
TESTER(ptrResult,
"In the halls of R'yleh great %s lies dreaming",
"%s",
"Cthulu",
"In the halls of R'yleh great Cthulu lies dreaming",
1,
lngReplacements)
TESTER(ptrResult,
"%s%s%s%s%s%s",
"%s",
"Cthulu",
"CthuluCthuluCthuluCthuluCthuluCthulu",
6,
lngReplacements)
TESTER(ptrResult,
"banana",
"ana",
"oat",
"boatna",
1,
lngReplacements)
TESTER(ptrResult,
" a stupid errorstupid errorHeystupid errors",
"stupid error",
"+",
" a ++Hey+s",
3,
lngReplacements)
TESTER(ptrResult,
"foo barfoo barf",
"foo bar",
"bas",
"basbasf",
2,
lngReplacements)
TESTER(ptrResult,
"abab",
"ba",
"ba",
"abab",
1,
lngReplacements)
TESTER(ptrResult,
"abab",
"bab",
"boop",
"aboop",
1,
lngReplacements)
TESTER(ptrResult,
"banana",
"ana",
"ono",
"bonona",
1,
lngReplacements)
TESTER(ptrResult,
"a",
"x",
"b",
"a",
0,
lngReplacements)
TESTER(ptrResult,
"x",
"x",
"b",
"b",
1,
lngReplacements)
TESTER(ptrResult,
"egregious",
"egregious",
"egregious",
"egregious",
1,
lngReplacements)
TESTER(ptrResult,
"egregious",
"egregious",
"x",
"x",
1,
lngReplacements)
printf("\n\nTesting complete: check output carefully: \"Assertion
failed\" should not occur!\n\n");
return 0;
}


== 2 of 9 ==
Date: Sat, Feb 13 2010 2:30 am
From: spinoza1111


On Feb 13, 5:25 pm, spinoza1111 <spinoza1...@yahoo.com> wrote:

...latest code...

Most posters will probably know that in downloading the code you
probably must:

1. Remove all spaces after the continuation markers in the TESTER
macro (at least on the Microsoft compiler: isn't this a bug that the
backslash may not be followed by a space, or was this horse puckey
blessed by the standard?)

2. Rejoin all lines split past position 67 if this is what your
browser does:

2.1 The TESTER header
2.2 The test of "a miracle a miraclesnirpKamunkle a Miraclea
miracleamiracle": note that in the latest post, I screwed up the
repair of this line which is why you should get ONE unexpected result
in your test of the latest code. Sensible and well-intentioned
developers will be able to figure this one out on their own, although
Heathfield will probably start foaming at the mouth
2.3 The last printf

At this point the code still does what appears to be unnecessary work
in the form of examining partial matches that occur starting to the
left of another partial match. This is because it notes only the one-
character "handle" of the left-partial match.

However, we know that

* No match can contain a match inside of it because it is
impossible for a proper substring of a string to match the containing
string, where a "proper" substring of X, X', is one of length(X)-n
where n>0. In simple English, a string cannot contain itself as a
proper substring. I think.

* Therefore, if we find the character handle of the target
inside a partial or complete occurrence of the target, this is an
overlapping string starting at the handle.

It seemed like a good idea, perhaps because I am evading the issue of
Boyer, Moore, Knuth, Pratt, Morris and Snoid, this afternoon to put in
a subsearch for the n-character overlapping target inside the match
loop. But this proved to complexify the code both conceptually and in
the sense that the target matcher had to contain extra instructions:
"do we have a potential overlap?" and "is it matching as well as the
main scan?"

Buys you nothing. You might as well check the left overlap in the next
cycle of the loop.

I believe I have possibly arrived at the most efficient solution
possible without auxiliary tables, because my solution appears to
examine pairs of characters the least amount of times needed. Wow. But
that's one of those beautiful theories forever being set upon by
ruffians in the form of facts.


In view of the face that NO OTHER POSTER (to my knowledge) has met the
requirements (code a string replace function without string.h usage) I
hereby declare victory, and award myself the Golden Spinoza Order of
Purity and Truth har har.

Seriously, I have demonstrated, I believe, that Republicans can't code
worth dick, but they can (if Peter Seebach is still a Republican) say
"there is a bug in my code but I'm fucked if I'll fix it", and they
sure can backstab and lie. That is: there is an entire programming
world-view, a Gestalt, that is complete malarkey and normalized
deviance. It consists of the inchoate saws and maxims that have
accumulated over time, that have sifted down from on-high from capable
early developers, but which have become little more than a cargo
cult.

My code is hard to read, it is said (on dit). In a sense, it is. I
find it hard to read at times myself.

An entire story exists in the cargo cult of the programmer who is in
some versions of the story "too clever by half" and in others only
thinks he is, and who writes an enormous program that nobody can
figure out. The social function of the story is to normalize
differences in ability, and to cover up the fact that many companies
try to solve ill-defined and very hard problems with computers, often
in order to exploit their workers or cheat customers. It omits the
existence of real code written by ordinary members of the white collar
proletariat which solved in an unsung fashion a hard problem...such as
the assembler for the 8K IBM 1401 that was written by a Univ of Chi
graduate student that put the IBM assembler to shame.

When looking for work in the 1990s, I answered an ad from Rockwell-
Wescom, a telecom manufacturer in Chicago. During my interview, the
manager said "some guy many years ago figured out how to use our call
data to reconstruct calls by simulating the PBX: he was pretty
strange." I said, "that was me". I'd become a legend of the dreamtime.
I didn't get a job because, the manager said, I was "too good to be
true". There had to be something wrong with a guy who'd solved a
problem nobody else could solve but was looking for work in his
forties.

Whereas at a shipping conference in 2003 I was greeted with
recognition by the staff of a shipbuilding firm for whom I'd created a
key program in the 1980s. This was because their culture was one of
openness and trust, not myth, and it's important that at the
conference, they said that they weren't bothering to bid for work in
Iraq. It was an ethical firm, of the sort that is in my experience
rare.

Code in some instance might look challenging because the problem is
actually a bit hard. Likewise it was hard for NASA engineers to solve
the problem of O-ring temperatures in cold temperatures in the
Challenger space shuttle, and later for them to solve the problem of
foam insulation dropping off Columbia at launch.

"They say it couldn't be done. So, I didn't do it."

In a post-Enlightenment culture of real science that has sifted down
to low-level technicians distinguished only by their conformity,
passive-aggression, frightened political conservatism (or passive-
aggressive "libertarianism") and/or religious Fundamentalism, the
former science (including Dijkstra's misinterpreted admonitions
concerning simplicity and "the humble programmer") become a cargo cult
of excuses for normalized deviance.

In a recent collection of writings on popular music by my fat pal
Theodore Adorno, he sets out the contrast starkly between classical
and popular music, and this is applicable to programming.

Popular music, he wrote, seems free and liberating, but in actuality
is almost always oversimplified in structure (and this is still true
of pop music years after he wrote it). The dissonances and syncopation
rely for their effect, he wrote, on the fact that for the listener
they are not actual artistic and standalone statements, but instead
sardonic POINTERS (references) back to classical music, light
classical music, and more traditional pop music.

The pop composer, even Irving Berlin or Copland, relies for his effect
on a backreference which says inside the music "listen, I flatted that
note, but you can if you like normalize my deviance by treating what I
said as unserious".

Consider the difference between Phillip Glass or Ygor Stravinsky on
the one hand, and Alban Berg on the other. The audience, according to
a 1980s Time magazine article about Glass, happily "sighed" when
Glass's cheap backreferences to the most innocuous classical music
with an easy-listening rock beat started to drone. Likewise, the
anxious bourgeois applauded Stravinsky (and Picasso) in the 1920s when
they reverted to classical models by means of snarky backreferences
with just enough dissonance to make the audience feel hip.

Whereas Beethoven meant to write the entire symphony in such a way
that ANY change would damage the whole (whereas my formatting and
naming conventions are not something I can willingly discard). (I
really felt for Tom Hulce's Amadeus in the eponymous movie when he was
told to discard notes by the Emperor).

That is, the division is between serious and unserious in programming
as well as music (PJ Plauger's phrase applies: programming on
purpose).

A Pop culture, a cargo cult and culture, creates people like Seebach,
who lie and backstab as standard procedure, allows them to claim that
the bad is good, by formulaic protocol-statements and shibboleths that
have the same function as dissonance in Pop music: saying "oh and by
the way I don't look for %s" is a gesture possible only in a culture
sodden with Pop crap created to make money.

This isn't to say that there couldn't be "serious" Pop music, such as
Robert Johnson's blues, which Adorno knew nothing about. But note that
Johnson wasn't commercially successful. Instead, rich men like Jagger
and McCartney stole what he did. Like Copland and Berlin, they relied
for their best effects on a form of plagiarism that mocks its source.


== 3 of 9 ==
Date: Sat, Feb 13 2010 2:43 am
From: Tim Streater


On 13/02/2010 10:30, spinoza1111 wrote:

> My code is hard to read, it is said (on dit). In a sense, it is. I
> find it hard to read at times myself.

Then it's shitty code, pure and simple.

--
Tim

"That the freedom of speech and debates or proceedings in Parliament
ought not to be impeached or questioned in any court or place out of
Parliament"

Bill of Rights 1689


== 4 of 9 ==
Date: Sat, Feb 13 2010 3:05 am
From: "io_x"

"spinoza1111" <spinoza1111@yahoo.com> ha scritto nel messaggio
news:45109f35-05da-46a8-82fd-d9d0afb34a34@p13g2000pre.googlegroups.com...
// ---------------------------------------------------------------
// Statement-format test macro
//
//
#define TESTER(resultPtr, master, target, replacement, expected,
expectedReplacements, replacements) \
{ \
printf("Replace \"%s\" by \"%s\" in \"%s\"\n", \
(target), (replacement), (master)); \
printf("Expect \"%s\":\n \"%s\"\n", \
(expected), \
resultPtr = replace((master), \
(target), \
(replacement), \
&(replacements))); \
printf("Replacements expected: %d: replacements: %d\n", \
(expectedReplacements), \
(replacements)); \
if (!(strLength(resultPtr) \
== \
strLength(master) \
+ \
(strLength(replacement)-strLength(target)) \
* \
replacements)) \
printf("Assertion failed\n"); \
printf("\n\n"); \
free(resultPtr); \
}

I can not be agree on your way of build test function
like a macro: that is indebuggable.
Macro for me are for build one language or for doing little
substitution like in "P" ---> "printf"

this is my propose: write only when find one error
--------------------------------
#define P printf
#define R return

// origin has to came from malloc memory
int tester(char* origin, char* whatSost, char* sost, char* expected)
{char *p;
unsigned len;
int i;

if(origin==0||whatSost==0||sost==0||expected==0)
R 0;
p=Replace(&len, origin, whatSost, sost);
if(p==0) R 0;
if(Strcmp(expected, p)!=0 || len!=Strlen(p))
{P("I find one error:\n");
P("Origin=%s|WhatS=%s|Sost=%s\n", origin, whatSost, sost);
P("Expect \"%s\":\nResult \"%s\"\n", expected, p);
P("lenResult=%u strlenResult=%u\n", len, Strlen(p));
Free(p);
R 0;
}
Free(p);
R 1;
}

// ---------------------------------------------------------------
// test for Replace() function
//
int test1(void)
{ unsigned r;
P("\n\nTest1\n");
r=1;
r*=tester("a stupid error","stupid error","miracle","a miracle");
r*=tester("a stupid error","stupid","miracle","a miracle error");
r*=tester("the stupid error","the stupid error","a miracle",
"a miracle");
r*=tester("the miracle","the","a","a miracle");
r*=tester("a miraclsnirpKamunkle","snirpKamunkle","e",
"a miracle");
r*=tester("a miraclesnirpKamunkle","a miracle",
"","snirpKamunkle");
r*=tester(" a miraclesnirpKamunkle","a miracle",
""," snirpKamunkle");
r*=tester(" a miraclesnirpKamunklea miraclea miracle","a miracle",
""," snirpKamunkle");
r*=tester("a miracle a miraclesnirpKamunkle a Miraclea miraclea miracle",
"a miracle",""," snirpKamunkle a Miracle");
r*=tester("a stupid errord","stupid error","miracle","a miracled");
r*=tester("a stupid errod","stupid error","miracle","a stupid errod");
r*=tester("a sstupid error","stupid error","miracle","a smiracle");
r*=tester("a stupid errorstupid error","stupid error","miracle",
"a miraclemiracle");
r*=tester("a stupid error stupiderror","stupid error","miracle",
"a miracle stupiderror");
r*=tester("bbbbbbbbbb","b","a","aaaaaaaaaa");
r*=tester("In the halls of R'yleh great %s lies dreaming","%s",
"Cthulu","In the halls of R'yleh great Cthulu lies dreaming");
r*=tester("%s%s%s%s%s%s","%s","Cthulu",
"CthuluCthuluCthuluCthuluCthuluCthulu");
r*=tester("banana","ana","oat","boatna");
r*=tester(" a stupid errorstupid errorHeystupid errors","stupid error",
"+"," a ++Hey+s");
r*=tester("foo barfoo barf","foo bar","bas","basbasf");
r*=tester("abab","ba","ba","abab");
r*=tester("a", "a", "b", "b");

if(r==0) {P("Test 1: Some error occurs\a\n\n"); R 0;}
else P("Test 1: Find No error\n\n");
R 1;
}


== 5 of 9 ==
Date: Sat, Feb 13 2010 3:22 am
From: Richard Heathfield


spinoza1111 wrote:
<snip>

I see you've ditched malloc.h, so here are my next two observations:

> // Calculate string length
> //
> //
> long strLength(char *strInstring)
> {
> char *ptrInstring;
> for (ptrInstring = strInstring; *ptrInstring; ptrInstring++);
> return ptrInstring - strInstring;
> }

Simpler, and slightly more informative to the caller:

long strLength(const char *s)
{
long len = 0;
while(*s++) ++len;
return len;
}

Other suggested improvements: (a) use an unsigned type, such as unsigned
long (strings might have 0 length, but they can never be negatively
long); and (b) drop the function completely, in favour of strlen.

<snip>

> if (!*strTarget)
> {
> printf("Error in calling replace(): target can't be null");
> abort();

If you intend this to be a general purpose solution, calling abort() is
not a good idea.

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within


== 6 of 9 ==
Date: Sat, Feb 13 2010 3:53 am
From: spinoza1111


On Feb 13, 6:43 pm, Tim Streater <timstrea...@waitrose.com> wrote:
> On 13/02/2010 10:30,spinoza1111wrote:
>
> > My code is hard to read, it is said (on dit). In a sense, it is. I
> > find it hard to read at times myself.
>
> Then it's shitty code, pure and simple.

That is the common view. I regard it as self-indulgent. Who says you
can read code?
>
> --
> Tim
>
> "That the freedom of speech and debates or proceedings in Parliament
> ought not to be impeached or questioned in any court or place out of
> Parliament"
>
> Bill of Rights 1689

== 7 of 9 ==
Date: Sat, Feb 13 2010 4:20 am
From: spinoza1111


On Feb 13, 7:22 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
> spinoza1111wrote:
>
> <snip>
>
> I see you've ditched malloc.h, so here are my next two observations:

"When everything is ended, you come." - Shakespeare, Henry IV part 2

...dishonestly, like Falstaff, seeking glory. I find it hard to
believe that you've been keeping grave observations in reserve, since
you found no bugs, and would have been as my arch-enemy happy to do so
(stylistic observations about pseudo-portability don't count, and
there were several juicy bugs, none of which you were able to find).
>
> > // Calculate string length
> > //
> > //
> > long strLength(char *strInstring)
> > {
> >     char *ptrInstring;
> >     for (ptrInstring = strInstring; *ptrInstring; ptrInstring++);
> >     return ptrInstring - strInstring;
> > }
>
> Simpler, and slightly more informative to the caller:
>
> long strLength(const char *s)
> {
>    long len = 0;
>    while(*s++) ++len;
>    return len;
>
> }

I'm massively underwhelmed. It's "simpler" only in having fewer
characters in the source code, and this isn't what we mean by
simplicity; mathematics isn't "simple and readable" in the way we
want. Your code saves one assignment: I'll alert the media.

Integrating the increment of s with the test is what you would call
"confusing code" if anyone other than you'd written it, because you're
a narcissist. It defeats what purpose there is in the C for loop,
which was to disambiguate the three parts of a loop. It did so poorly,
but your use manages to make a bad situation worse.

If you can write "len", you can write "length". "len" could be
anything.

Initializing len in its declaration-definition will not even compile
on some C compilers. I thought you wrote portable code. Oh well.

OK, how many errors do we have in your code, if we use your own thug's
standard for errors as "I don't like it?"

Three.


>
> Other suggested improvements: (a) use an unsigned type, such as unsigned
> long (strings might have 0 length, but they can never be negatively
> long); and (b) drop the function completely, in favour of strlen.

Oh, I dunno. Some strings of nonsense (such as yours) should never
have been typed and have what we might call negative entropy, and we
could represent this as a negative string length.

>
> <snip>
>
> >     if (!*strTarget)
> >     {
> >         printf("Error in calling replace(): target can't be null");
> >         abort();
>
> If you intend this to be a general purpose solution, calling abort() is
> not a good idea.

Yes. Monkey and typewriter, but yes. However, you may have noticed if
you were awake that the code is "packaged" as a proof of concept (the
concept being "writing a replace even outside the string library is
not rocket science, but it is too hard for Republicans and Limey
sods").

And Lo! Heathfield labors mightily to stay inside the Game:
But the combat is already over, to each side's shame or fame:
The shadows lengthen on the pitch, he cries play up for me
And so the Combatants turn once more to their game of reading C.
The crowd is hush'd, and expectant Pall falls upon one and all
And then the mighty Heathfield upon the Gods doth cry his call
And show us his solution, alas, 'tis...Trivi-all.
He's missed the point, the boat, the bus, and the London train
If this were not so funny it would give the Gentle pain:
He's rolled offside off the Pitch and onto the green grass
To tell me how to write a string length function, Lord, what an Ass!
In tones of grave and pompous Preaching he groans Admonishment:
Expecting us his Flock to receive him with Astonishment:
But alas in the remains of a day so drear there is silence in the
Crowd:
And then a Titter, then a Chortle, third a Guf-faw, then both long and
Loud
Resounds the Laughter of the Gods which dismays all Philistines
From Hill, to Dale, to Glen, to Pale, are hearden its load Screams:
And so it is, and was, and ever it shall be cried
That Heathfield has struck out and has kicked the ball, offside.

Oh, that was Lofty.

>
> <snip>
>
> --
> Richard Heathfield <http://www.cpax.org.uk>
> Email: -http://www. +rjh@
> "Usenet is a strange place" - dmr 29 July 1999
> Sig line vacant - apply within

== 8 of 9 ==
Date: Sat, Feb 13 2010 4:23 am
From: Richard


Tim Streater <timstreater@waitrose.com> writes:

> On 13/02/2010 10:30, spinoza1111 wrote:
>
>> My code is hard to read, it is said (on dit). In a sense, it is. I
>> find it hard to read at times myself.
>
> Then it's shitty code, pure and simple.

Some of the best code I have dealt with turned out to need a while to
acclimatise to.

One should NEVER program to the lowest common denominator such as Bill
Cunningham for example.

There appears to be some strange opinion here that ALL code is
constantly being read by hundreds of people as the brilliance of your
output is ported and modded to 1000s of platforms and new projects. It
isn't. Far better to have a small routine complex but EFFICIENT that
"easy to read" and a dog. Complex? Comment it.

--
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c


== 9 of 9 ==
Date: Sat, Feb 13 2010 4:18 am
From: Richard


Richard Heathfield <rjh@see.sig.invalid> writes:

> spinoza1111 wrote:
> <snip>
>
> I see you've ditched malloc.h, so here are my next two observations:
>
>> // Calculate string length
>> //
>> //
>> long strLength(char *strInstring)
>> {
>> char *ptrInstring;
>> for (ptrInstring = strInstring; *ptrInstring; ptrInstring++);
>> return ptrInstring - strInstring;
>> }
>
> Simpler, and slightly more informative to the caller:
>
> long strLength(const char *s)
> {
> long len = 0;
> while(*s++) ++len;
> return len;
> }

An unnecessary increment on every loop. Potentially expensive for long
blocks. Nilges might be faster in many cases.

==============================================================================
TOPIC: HOW this program is executing plz explain the program
http://groups.google.com/group/comp.lang.c/t/3fb552296fac02d8?hl=en
==============================================================================

== 1 of 5 ==
Date: Sat, Feb 13 2010 1:39 am
From: manish sahu


#include<stdio.h>
#include<conio.h>

main()
{
int i,j;

clrscr();
scanf("%d%d"+scanf("%d%d",&i,&j));
printf("%d %d",i,j);
getch();
return 0;
}


== 2 of 5 ==
Date: Sat, Feb 13 2010 2:19 am
From: santosh


manish sahu wrote:
> #include<stdio.h>
> #include<conio.h>
>
> main()
> {
> int i,j;
>
> clrscr();
> scanf("%d%d"+scanf("%d%d",&i,&j));
> printf("%d %d",i,j);
> getch();
> return 0;
> }

The program above is broken. Firstly conio.h and the functions
clrscr() and getch() are not standard functions, but that's a minor
issue. Even if all three are commented out, your program is still
broken.

The single argument to the first scanf() call invokes undefined
behaviour, as it attempts to add an arbitrary int value (the return
value of the second scanf() call) to the pointer value to the first
character of a string literal. Adding integer values to a pointer
value is not defined in standard C, but even assuming it results in
simply another pointer value, the problem is now you're supplying a
pointer value to an unknown region of memory, which may or may not
contain a sensible format string for scanf() to interpret. It may not
even contain a sensible string. If scanf() does encounter any format
specifiers, it will attempt to perform the indicated conversion, but
you don't supply scanf() any storage locations to store them in.

It's just completely messed up. Don't learn from such code. You can't
learn anything sensible from poking at it. Learn proper C from a good
book.


== 3 of 5 ==
Date: Sat, Feb 13 2010 2:24 am
From: jacob navia


santosh a écrit :
> Adding integer values to a pointer
> value is not defined in standard C,

WHAT??????

Please santosh!!


You should write ON HUNDRED TIMES

"I should turn on my brain before posting"

PointerValue+integer --> PointerValue+integer*element_size-->new pointer value!!!

== 4 of 5 ==
Date: Sat, Feb 13 2010 2:32 am
From: santosh


jacob navia wrote:
> santosh a �crit :
> > Adding integer values to a pointer
> > value is not defined in standard C,
>
> WHAT??????
>
> Please santosh!!
>
>
> You should write ON HUNDRED TIMES
>
> "I should turn on my brain before posting"
>
> PointerValue+integer --> PointerValue+integer*element_size-->new pointer value!!!

Right. Sincere apologies to the OP. I was thinking about conversion of
integer value to a pointer value.


== 5 of 5 ==
Date: Sat, Feb 13 2010 4:18 am
From: jacob navia


santosh a écrit :
> jacob navia wrote:
>> santosh a �crit :
>>> Adding integer values to a pointer
>>> value is not defined in standard C,
>> WHAT??????
>>
>> Please santosh!!
>>
>>
>> You should write ON HUNDRED TIMES
>>
>> "I should turn on my brain before posting"
>>
>> PointerValue+integer --> PointerValue+integer*element_size-->new pointer value!!!
>
> Right. Sincere apologies to the OP. I was thinking about conversion of
> integer value to a pointer value.

Yes, the rest of your post seemed OK.
Anyway this can happen to anyone.

jacob

==============================================================================
TOPIC: Get 101 Question in C, C++, C++ under Windows, MFC, DLL, COM/DOM
http://groups.google.com/group/comp.lang.c/t/0e90137c70502f66?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Feb 13 2010 3:10 am
From: Shantanu


Get 101 Question in C, C++, C++ under Windows, MFC, DLL, COM/DOM for
interview and exam preparation. Hurry it is free.

http://www.mybestnotes.co.in
Link : Home >> Questions >> C, C++, etc.


==============================================================================
TOPIC: Motivation of software professionals
http://groups.google.com/group/comp.lang.c/t/21a3fdec4dd53e6a?hl=en
==============================================================================

== 1 of 2 ==
Date: Sat, Feb 13 2010 4:07 am
From: James Kanze


On 12 Feb, 22:21, Brian <c...@mailvault.com> wrote:
> On Feb 12, 3:36 pm, James Kanze <james.ka...@gmail.com> wrote:
> > On Feb 12, 11:42 am, Leif Roar Moldskred

> > <le...@huldreheim.homelinux.org> wrote:
> > > In comp.lang.java.programmer Arved Sandstrom <dces...@hotmail.com> wrote:
> > > > This is what I am getting at, although we need to have
> > > > Brian's example as a baseline. In this day and age,
> > > > however, I'm not convinced that a person could even give
> > > > away a free car (it wouldn't be free in any case, it
> > > > would still get taxed, and you'd have to transfer title)
> > > > and be completely off the hook, although 99 times out of
> > > > 100 I'd agree with Brian that it's not a likely scenario
> > > > for lawsuits.
> > > Where Brian's example falls down is that the previous
> > > owner of the car is, in effect, just a reseller: he isn't
> > > likely to have manufactured the car or modified it to any
> > > degree. However, let us assume that he _has_ done
> > > modifications to the car such as, say, replacing the fuel
> > > tank. If he messed up the repair and, without realising
> > > it, turned the fuel car into a potential firebomb, he
> > > would be liable for this defect even if he gave the car
> > > away free of charge.

> > He doesn't even have to have done that much. If he knows
> > that the brakes doen't work, and he lets you drive it, he's
> > legally responsible.

> I have no problem with that. Some though believe that if you
> give away a car and aren't aware of a problem with the car,
> that you are still liable. I don't think I'm obligated to
> have a car looked at by a mechanic before giving it away. If
> it is safe to the best of my knowledge, then I should just
> tell whoever wants the car about it's history and encourage
> them to have the car checked out.

Yes. There are two things that could make you liable: deceit or
negligence. If you make claims you know aren't true, it's
deceit. As a private individual giving something away,
negligence (to the point of making you liable) is practically
impossible. As Jerry pointed out, even in the case of a large
company, with expertise in the field, it's very, very difficult.

IMHO, if you don't take well known and provenly effective
preventive measures, you're negligent. But Jerry is a lot
better versed in the legal issues than I am, so I'll take his
word for it that if everyone's doing it, you're off the hook.
And there are certainly enough software firms delivering junk to
count as almost everyone. (Although it probably depends on the
domain. Almost every firm delivering software to NASA is taking
adequate steps; for that matter, most of the telecoms software
I've seen was "correctly" developed as well.)

--
James Kanze


== 2 of 2 ==
Date: Sat, Feb 13 2010 4:19 am
From: James Kanze


On 12 Feb, 22:37, Arved Sandstrom <dces...@hotmail.com> wrote:
> Seebs wrote:
> > On 2010-02-12, Leif Roar Moldskred <le...@huldreheim.homelinux.org> wrote:
> >> In comp.lang.java.programmer Brian <c...@mailvault.com> wrote:
> >>> That is true in a traditional model of exchanging money
> >>> for a product or service. If you don't pay for the good
> >>> or service, you have no "rights."

> >> That's quite simply not correct.

> > It had better become correct, if we don't want to trash all
> > our economies again.

> > If you have liabilities to people who grabbed free stuff off
> > the internet labeled as providing no warranty, no one can
> > afford to give anything away, and it turns out that there's
> > a huge economic efficiency boost to allowing people to give
> > away software. Solution: Let people give away software
> > with no liability or warranty.

> I don't think we know anything of the sort. If software is
> needed it gets written, free or with a price tag. And you
> can't ignore the huge economic inefficiencies occasioned by
> having copious amounts of turgid broken crap available for
> free, that wastes everyone's time.

The problem is that we already have copious amounts of turgid
broken crap available commercially. I don't see why adding free
software to the mix changes anything.

Logically, I think that most of the techniques necessary for
making really high quality software would be difficult to apply
in the context of a free development. And at least up to a
point, they actually reduce the cost of development. So
theoretically, the quality of commercial software should be
considerably higher than that of free software. Practically,
when I actually check things out... g++ is one of the better C++
compilers available, better than Sun CC or VC++, for example.
Valgrind is at least as good as any of the commercial memory
checkers under Linux. And Subversion is at least as good as any
of the version management tools, excepted ClearCase (and the two
really address different models of development).

> I think you'd find that if there was much less free stuff
> available that we'd have a _different_ economic model, not
> necessarily a _worse_ one.

There used to be a lot less free stuff available, and it was
worse. (It doesn't make sense to me, either, but those are the
facts.)

> I look at warranties differently than you do. To me a warranty
> means that I used proper development practices, I can make
> informed statements that the published software is actually
> fit for a stated use, and that I care enough about the program
> to offer some support.

Clearly. The problem is that most commercial firms don't do
that.

> I have no idea why you think that warranties and liabilities
> are going to lead to the financial ruination of countless
> developers. People in other sectors sell millions or tens of
> millions of other imperfect things, with warranties, and they
> seem to be making a living.

I think that part of the problem is that a mistake in a program
will affect every instance of the program. Most recalls for
cars, on the other hand, only affect a small subset of the total
production.

--
James Kanze


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

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