HDTenEightyP/NetNews huggingface dataset:
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: cc optimizer problem
Date: 22 Aug 92 12:53:37 GMT
Organization: AND Software BV Rotterdam

In article <1992Aug21.145323.25111@newstand.syr.edu> tmyoung@rodan.acs.syr.edu (Thomas M. Young) writes:
|I've got a program that does a bunch of number crunching inside some 
|nested loops.  When I try to optimize the program via the cc -O option,
|the program doesn't execute any of the instructions inside the innermost
|loop.  When compiled with the -g option, the code runs without a hitch.
|Does anybody out there have any idea why this might be happening? I'd
|really like to avoid hand-optimizing this code.

Well, I'd say that your optimizer is broken then. Or the code inside
these loops are really loop invariant, i.e. something like this might
happen:

for (i= 0; i < VERY_LARGE_NUM; i++)
	a= /* very expensive calculations, not involving 
	    * any side effects at all
	    */
a= 0;	/* Simply destroy all the work done in the loop */

Sorry, I can't be more specific without at least peeking to
a snippet of your code.

kind regards,

Jos aka jos@and.nl
From: c152-cs@dv349-5a.berkeley.edu (John W. Horigan)
Newsgroups: comp.lang.c
Subject: Re: Sort help needed
Date: 14 Aug 92 22:49:50 GMT
Organization: University of California, Berkeley

In article <3225@dozo.and.nl> jos@and.nl (Jos Horsmeier) writes:

[ stuff about the meaning of sort stability deleted. HS means Heap sort
  and QS means Quick sort. ]

> I just
>had to say that the _worst case_ behavior of HS is better than the
>_worst case_ behaviour of QS, i.e. the big Oh still is O(n*log(n))
>I should have avoided the use of the word `stable'. sorry ...
>
>(because of this O(n*log(n)) behavior, even in the worst case,
> I prefer HS... no religious wars please ;-)
>
>kind regards,
>
>Jos aka jos@and.nl

But any reasonable implementation of Quick sort will use randomly
chosen pivots or some other simple, easy to implement pivot selection
algorithm.  With these types of Quick sort algorithms the worst case
behavior is so _fantastically_ unlikely that with any reasonably
sized data set you wouldn't see O(n^2) behavior within the lifetime
of the universe.  But heaps are kinda neat... :)

John Horigan
jhorigan@cook.berkeley.edu
UC Berkeley, Dept. of Materials Science & Mineral Engineering
Organization: Distributed Workstation Services, Carnegie Mellon, Pittsburgh, PA
Newsgroups: comp.lang.c
Date: Fri, 21 Aug 1992 15:10:59 -0400 
From: Richard Dale Romero <rickr+@CMU.EDU>
Subject: Re: C interpreter for Unix
Distribution: world

Excerpts from netnews.comp.lang.c: 21-Aug-92 C interpreter for Unix
Giuseppe Surace@edy.elet (142)


>   Does anyone know if in the free software exist a 'C interpeter' for Unix
>   systems.

> 			Thanx in advance
> 			  Giuseppe Surace


> Keywords: 


Possibly UPS is what you are looking for.  It's a debugger that includes
the ability to interpret C code.  There is a mailing list
ups-users@ukc.ac.uk, with the subscription requests going to
ups-users-request@ukc.ac.uk.  (This info is a bit old, though, and I'm
not sure how accurate.)  I don't have an anon ftp site for it, though.
Try using archie.  The most current version (which is not very) as far
as I can tell is 2.31.

Rick Romero
Carnegie Mellon University
From: jfw@ksr.com (John F. Woods)
Newsgroups: comp.lang.c
Subject: Re: Pointer/address reluctance
Date: 14 Aug 92 17:23:39 GMT
Article-I.D.: ksr.14807

linden@positive.Eng.Sun.COM (Peter van der Linden) writes:
>Can anyone explain the reluctance that some of the experts here
>have in equating "pointer" with "address"?

Because as soon as someone slips and admits that "addresses" are one possible
scheme for implementing "pointers", dozens of non-experts start posting
ancient misunderstandings and silliness based on how things work on their
peecee, thus driving all of the experts to drink heavily.  Good Scotch is
quite expensive, so the insistance upon the abstract nature of pointers is
a cost-saving measure.
From: rick@rick.infoserv.com (Rick Klement)
Newsgroups: comp.lang.c
Subject: Re: Question about lex
Date: 14 Aug 92 03:52:19 GMT
Organization: Rick's Place, San Jose, CA, USA

In article <1992Aug13.145803.3008@ccd.harris.com>, djs@controls.ccd.harris.com (Dan J. Smith) writes:
> I'm trying to call the lex output functions generated by two different lex input
> files from the same program. But, they both generate output functions called
> yylex and have the same global variables so this does not work.
> 
> My question is: Is there any way to link two lex output files into
> the same program. I've had several ideas but they turned into dead ends pretty 
> quickly.

That's what

	sed 's/yy/zz/g' some_lex_output_file.c >modified_lex_output_file.c

is for...
-- 
Rick Klement - email:   rick@infoserv.com

#include <standard.disclaimer>
A respected software manager once said: "There may even be some
Computer Science graduates that can actually do useful programming." or
something like that. I know who but I'm not telling...
Newsgroups: comp.lang.c
From: odysseas@umbc4.umbc.edu (Odysseas Pentakalos (GRAD))
Subject: Linked list problem
Organization: School of Medicine, University of Maryland at Baltimore    
Distribution: comp.lang.c
Date: Thu, 20 Aug 1992 19:24:02 GMT

	Hi,

		I am having an unusual problem with a c program I am
writing. I am creating a linked list and storing the pointer of the
top of the list in variable top which works fine. I have also
declared a global 2 - dimensional array prob_cases[100][500]. The
program creates the linked list first by reading data from a file and
then it initializes the prob_case array for further processing. The
pointer top contains the address to the linked list before the
initialization of the array but it looses the value after the nested
loop which initializes the array. 

/* Value before initialization */
  top->name="pDIE"
	
for(y=0;y<=MAX_CASES;y++)
    for(z=0;z<MAXNODES;z++)
       prob_cases[y][z] = 0;

/* Value after initialization */
  top=(Nill)

	I would really appreciate any help on this problem.


						Thanks, Mike

	Please reply to mars@medinfo.medinfo.ab.umd.edu since I am using 
a friends address to post this article






-- 
______________________________________________________________________________
 Odysseas Pentakalos				odysseas@umbc5.umbc.edu or
 University of Md. Electrical Engineering Dept. odysseas@plato.engr.umbc.edu
 (301) 455-3508					(301) 788-6703
Xref: sparky comp.lang.c:12648 comp.std.c:2489
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c,comp.std.c
Subject: Re: scrcpy implementation question
Date: 22 Aug 92 10:45:54 GMT
Followup-To: comp.lang.c
Distribution: comp
Organization: AND Software BV Rotterdam

In article <PINKAS.92Aug21114508@caraway.intel.com> pinkas@caraway.intel.com (Israel Pinkas) writes:
|
|A compiler group working for us has told us that they plan to make the
|following optimization for the strcpy library function:
|
|If the sizes of the src and dst are known at compile time (e.g. they are
|both declared in the current file as static or auto arrays), and if the
|addresses are aligned correctly, then strcpy will be inlined as a partially
|unrolled loop of word moves.  In order to avoid checking every byte, they
|plan to copy past the terminator ('\0'), and copy a number of bytes equal
|to the smaller of the src or dst.

[ example why things would break, deleted ... ]

|Does anybody know if strcpy is allowed to copy past the end of the string?
|We looked at K&R2 and at the ANSI spec, but were unable to find anything
|definite.

I think it's just plain silly to implement strcpy like that. The
standard indeed doesn't say much aobut this (simple) function:

4.11.2.3 The strcpy function

The strcpy function copies the string pointed to by s2 (including the
terminatin null character) into the array pointed to by s1. If copying 
takes place between objects that overlap, the behavior is undefined.

[ end quote ]

I'm willing to stick out my neck, by rephrasing the last sentence:

The behavior _shall_ be defined if copying takes place between non-
overlapping objects. (I know ice is thin here ... )
As you said, it would certainly break lots of code (at least lots
of my code would break.)

My conclusion is that strcpy is _not_ allowed to copy past the terminating
'\0' character, but I can't actually prove this. I'd wish the standard
would have said something like: `if and only if copying takes place ...'

kind regards,

Jos aka jos@and.nl
From: robert@isgtec.com (Robert Osborne)
Newsgroups: comp.lang.c
Subject: Re: Macros for ANSI prototypes
Date: 17 Aug 92 14:15:15 GMT

darcy@druid.uucp (D'Arcy J.M. Cain) writes:
> robert@isgtec.com (Robert Osborne) writes:
> >dave@cs.arizona.edu (Dave Schaumann) writes:
> >> In stead of obfuscating your code with macros that turn on and off
> >> functio prototypes as the particular compiler requires, wouldn't it be
> >> better to simply include one of the tools freely available to
> >> automatically massage prototyped code into K&R acceptability.
> >
> >What if the code needs to be compiled simultaneously on eight
> >architecutures; 4 K&R and 4 ANSI?
> 
> You may misunderstand what Dave (from *my* understanding) is saying.
> [...] The K&R code just becomes one of the stages of the
> compilation. [...]
> 
>     ANSI C --> K&R C --> Assembler --> a.out
> 
> You see the K&R is simply an intermediate stage and is thrown out after
> along with the .s and .o files.

Gaak!  This is gross.

You can't throw away the K&R step because you need the source for
debuggers.

The K&R systems are used also for development; there are enough
problems with the compilers and with the speed of compile without
adding yet another preprocessing step.

It would only take one major bug introduced by the ANSI to K&R
step to remove the developer time savings.

The ANSI source and the K&R source are now distinct between
platforms.   This does NOT leave me with any warm fuzzies.

I do not consider this even remotely as elegant as the prototype macros.

Rob.
--
Robert A. Osborne   ...!uunet.ca!isgtec!robert or robert@isgtec.com
Newsgroups: comp.lang.c
From: goudreau@batman.rtp.dg.com (Bob Goudreau)
Subject: Re: Pointer/address reluctance
Date: Wed, 19 Aug 92 16:00:15 GMT
Organization: Data General Corporation, RTP, NC.

In article <l92qdfINNfkn@exodus.Eng.Sun.COM> linden@positive.Eng.Sun.COM (Peter van der Linden) writes:
>
>> Beg your pardon?  I can find no definition of a thing called "address"
>> in the standard. 
>
> Check out section 3.4, page 56, line 32.
>
> It defines an address constant.  You can't have a <baz> constant unless 
> you have <baz>, now can you?

And why not?  The class of objects covered by the name "address constant"
are in fact neither addresses nor constants (see the definition of
constants in section 3.1.3).  They are, rather, pointers:

	"An _address_constant_ is a pointer to an lvalue ..."

I repeat, I can find no definition of a thing called "address" in the
standard.  You're sidestepping that issue by talking about two terms in
the standard that happen to use the word "address" as adjectival
prefixes in their names ("address constant" and "address[-of] operator").
But these are just part of the *names* of these terms, not part of their
actual definitions, which both use "pointer" when talking about the real
objects in question.  The names used by the standard have historical
roots (in K&R), but it could just as well have invented completely new
and arbitrary labels.


> Also check out line 35 in the same section,
> which refers to "the address & and indirection * unary operators".

Again, the first subject of that sentence is an *operator*, not an
address.  The *name* of that operator happens to be "address[-of]
operator", but "gitchigumee operator" would have worked just as well, as
long as its definition ("The result of the ... operator is a pointer ...")
remained unchanged.  To reiterate the first example:

	"An _address_constant_ is a pointer to an lvalue ..."

The thing in question *is* a pointer (not an "address"); the *name*
of that kind of thing is "address constant" (not "address").


> No, the concept of "address" is in the standard, so it seems somewhat
> tendentious to shun it.

Once again, please back up your claim by citing a reference in the
standard to that concept.

----------------------------------------------------------------------
Bob Goudreau			Data General Corporation
goudreau@dg-rtp.dg.com		62 Alexander Drive	
+1 919 248 6231			Research Triangle Park, NC  27709, USA
Newsgroups: comp.lang.c,comp.unix.questions
From: jmolinari@hamp.hampshire.edu
Subject: cursor keys with curses library
Organization: Hampshire College
Date: Sun, 23 Aug 1992 05:37:39 GMT

	How can I accept cursor keys with the curses library?  I know I have
to set cbreak() mode (or raw(); could somebody tell me the difference?).

		Thank you!

			reply: jmolinari@hamp.hampshire.edu
			(if you post your answer, please let me know)
From: yong@intermec.com (Yong Qin Lu)
Newsgroups: comp.lang.c
Subject: Borland C3.0 Makefile Question ???
Date: 18 Aug 92 19:25:04 GMT
Organization: Intermec Corporation, Everett, Wa.

Reply-To: yong@intermec.com (Yong Qin Lu)
Followup-To: 
Distribution: 
Organization: Intermec Corporation, Everett WA
Keywords: 

   Hello:

	Can someone tell me how to make a file inside a make file for 
   Borland C 3.0?

 	For example:  I get one make file call 'immake.mak', and I want to
   call 'make -fimutil.mak' in this file, where imutil.mak is another 
   make file.  But Borland will give me the error message said:
   "Fatal: Unable to execute command make". 
   
        Thank You Very Much

	Yong-Qin Lu
Newsgroups: comp.lang.c
From: tomg@stud.cs.uit.no (Tom Grydeland)
Subject: Re: sort routines
Organization: University of Tromsoe
Date: Thu, 13 Aug 1992 18:15:41 GMT

In article <1992Aug13.170424@axion.bt.co.uk>, pkeddie@axion.bt.co.uk (Paul Keddie) writes:
|> 
|> How do people sort a single linked list in a C program ? I know there
|> is thw qsort routine but that seems to assume you know the maximum possible
|> size of the list. 

The qsort library routine is for sorting an array of values, giving a
comparison routine as one of the arguments.

|> Do you just have to resort to writing your own routine, and if so which is the
|> best for a single linked list data structure (insertion,bubble.etc).

As far as I know, the best solution for sorting a single linked list is the
mergesort. It's a recursion-based sorting which follows the general solution:

0) If the list is just one element, it's sorted, return.

1) If not, split your list in two approximately equal sublists.

2) Mergesort (here's the recursion!) each one separately.

3) Merge the two sorted sublists, and you have a sorted list to return.

As long as you assure that you never pass an empty list as an argument to
your merge routine, you'll be able to write it fairly simple.
If you can't keep all of the list in main memory at once, we're gone into
the diffuse field of external sorting, where you'll be better off studying
vol.3 of Knuth(73), Sorting and Searching.

Good luck.


|> Cheers Paul

-- 
//Tom Grydeland(tomg@stud.cs.uit.no)._._._._._._._._._._._._._._._._._._._._._
|A._| . . ._| | |_._._. . ._|_._._._._. ._|_. ._ _._. ._| | . ._|_. | . ._._. |
| ._|_| |_. | | | | ._._|_. |_._. . |_. | | | ._._| |_._._._| | ._. ._| . . |_|
|_._._._._|_._._._._._._|_._._._._|_._._._._._._._._._._._._|_._._|_|_._|_|_.B|
Newsgroups: comp.lang.c
From: ejk@dlogics.com (Edward Kaszubowski)
Subject: Re: POWER OF LARGE NUMBERS
Organization: Datalogics, Inc.
Date: Thu, 20 Aug 92 18:06:38 GMT

billb@crpmks.uucp (Bill Bochnik (Info Systems)) writes:

>Just for amusement, what was the repeating formula for calculating PI to any 
>desired number of digits?  Thanks.

the series   4   4   4   4   4   4
             - - - + - - - + - - - + .....   will give you pi.
             1   3   5   7   9   11

However, I do know that this is a slow algorithm, there are others that
are much more efficient.  (and more complicated)

code:
   pi = 0
   for loop = 1 to infinity step by 2
     if (loop + 1) is divisible by 4
       pi = pi - 4/loop
     otherwise
       pi = pi + 4/loop

-- 

   ---------------------------------------------------------
   |  Edward J. Kaszubowski      ejk@dlogics.dlogics.com   |
   |  Systems Engineer II        Datalogics Inc.           |
From: jfw@ksr.com (John F. Woods)
Newsgroups: comp.lang.c
Subject: Re: Byte Order Question
Date: 21 Aug 92 14:50:17 EDT

john@bnrmtl.bnr.ca (John Hickin) writes:
>Forgive me if this is a FAQ but here goes.
>Suppose int's are 2 bytes.  Then division of a positive number by 256 should
>retrieve the most significant byte of the int.  What about a right shift by 8?
>My suspicion is that the result of the shift of a positive number could depend
>on whether the byte order is big or little endian.  Is my suspicion correct?

The shift operators are defined by value and not by representation.  Byte order
doesn't enter in to it (nor does int size, so long as the shift count is
smaller than the size of an int in bits).

A right-shift of 8 of a positive int, or of an unsigned int, is equivalent to
division by 256.  If the int is negative, consult your doctor, er, compiler
manual before using.  (ANSI C describes the result as "implementation-defined";
earlier compilers described the result as "whatever happens".)
Newsgroups: comp.lang.c
Subject: Help : Graphics Formats
From: ebolog@elaine.ee.und.ac.za (EDWIN BOLOGNA : THIRD)
Date: 20 Aug 92 12:56:55 +0200
Organization: Electronic Eng., Univ. Natal, Durban, South Africa


Does anyone out there happen to have PAS, C, or ASM source code to decode
.GIF, .PCX, .FLI, .GL, etc. graphic formats.

Any information at all on any of these formats will be greatly appreciated.

        Desperate fellow programmer (And very Greatful for any information)

                E.B. (EBOLOG@ELAINE.EE.UND.AC.ZA)

PS : Please be kind hearted and Assist !
From: tb06@pl118b.CC.Lehigh.EDU (TERRENCE MONROE BRANNON)
Newsgroups: comp.lang.c
Subject: Re: C interpreter for Unix
Date: 22 Aug 92 02:40:11 GMT
Organization: Lehigh University, Bethlehem, PA



   >   Does anyone know if in the free software exist a 'C interpeter' for Unix
   >   systems.

The Free Software Foundation has someone working on this -- it is not
available for public release right now as far as I know.
--
Terrence Brannon	tb06@pl122a.eecs.lehigh.edu
medical biology via acupuncture and particle physics
primitive knowledge reign supreme over nearly every1
From: sbhatia@mary.fordham.edu (SABU)
Subject: function pointers
Organization: Fordham University
News-Software: VAX/VMS VNEWS 1.41    
Date: Sat, 22 Aug 1992 23:16:00 GMT
X-Posted-From: mary.fordham.edu
X-Posted-Through: sol.ctr.columbia.edu


Hi,

    the question deals with function pointers. The problem is as follows
I have a function compute() with the following prototype-:

   int compute(int *, int (*func()));

and it is called by another function say
   call().

int call I have the following statement
     compute(&x, lattice);

where the variables etc, have been appropraitely declared.

My question is can I have a call to compute like-:

   compute(&x, NULL)

and within  compute I have a statement like

if(func == NULL)
..
else
..
In essence I want to either pass a function or a null pointer to indicate
an alternate processing approach.

If valid is this a portable way to do it????


thanks,



sabu.

////////////////////////////////////////////////////////////////////////
/   Internet:  SBHATIA@mary.fordham.edu                                /
/   BITnet:    SBHATIA@FORDMULC                                        /
/                                                                      /
/                                                                      /
////////////////////////////////////////////////////////////////////////
From: dave@cs.arizona.edu (Dave Schaumann)
Newsgroups: comp.lang.c
Subject: Re: generic interpreter
Date: 17 Aug 92 16:40:05 GMT
Reply-To: dave@cs.arizona.edu (Dave Schaumann)
Organization: University of Arizona

In article <DAVIS.92Aug17105356@pacific.mps.ohio-state.edu>, davis@pacific ("John E. Davis") writes:
>   I am looking for an extensible interpreter (preferably in C). I want an
>interpreter which has all the code in it for while loops, if then statements,
>etc.  All I need to do is to add the `intrinsic' (in C) functions which the
>interpreter will eventually call.  This seems like such a useful generic thing
>that someone must have done it already.  If such a thing exists, I would
>appreciate about hearing about it.

Check out `hoc', which is an interpreter for a C-like language.  It is
described in great detail in one of the chapters of _The UNIX Programming
Environment_ by Kernighan & Pike.

It's probably not exactly what you want, but the text develops the program
through about 6 steps (starting with just a simple 4-function calculator).
Modifying it to your needs should not be too hard.

I also remember hearing a while ago that the source was available for ftp
(though the legality of this may be questionable...).

-- 
What signature?
From: jfw@ksr.com (John F. Woods)
Newsgroups: comp.lang.c
Subject: Re: Array of pointers to structures
Date: 18 Aug 92 16:45:13 GMT

jsanders@symcom.math.uiuc.edu (John Eric Sanders) writes:
>struct strig 
>{  char elment[80]; } ;
>struct strig *ptr[100];
>However, I can't seem to access a particular character, which I need to.
>For example, I want to access the 5th character of the 75th line of
>data, but *ptr[74].elment[4] = 'n' doesn't seem to work.  Should it?

Let's take this one bit at a time.
ptr[74] is a pointer to a struct strig (namely, the 75th pointer in the
array).  To use this pointer to access the "elment" element of the structure,
you use the -> operator, as in 
	ptr[74]->elment
From that array, you want to select the 5th character, so you use
	ptr[74]->elment[5]
No indirection operator (unary *) is required here; in particular, due to
operator precedence, your code was trying to treat ptr[74] as a structure,
rather than a structure pointer (. binds more tightly than unary *).

>Do I have a bum compiler?

Could well be, but you haven't proven it yet :-).

>I was doing some tests and found that
>ptr[5]->elment[2] is not equal to (*ptr[5]).elment[2], like the book
>I have says it should be.

Now, we know what the first says (see above), what does the second say:
take the 6th element of the ptr array, which is a pointer to struct strig,
indirect through it to obtain a structure, select the elment element of that
structure, and the 3rd character thereof.  Gee, that looks like it ought to
be the same to me.  Oh dear.  Are you sure that you have initialized all of
the pointers in the array ptr?  If not, then both of these will point into
random memory, which could potentially change in between attempts to look
into it in two different ways (or even just generate some form of exception).