HDTenEightyP/NetNews huggingface dataset:
From: hjv@phil.ruu.nl (Hendrik Jan Veenstra)
Subject: Re: Probably a simple realloc() question
Organization: Department of Philosophy, University of Utrecht, The Netherlands
Date: Tue, 29 Sep 1992 02:52:57 GMT

karl@ima.isc.com (Karl Heuer) writes:

>% Do you really mean i+1?  It looks to me as though the loop always halts
>  with i elements having been filled (subscripts 0 through i-1), so you
>  should realloc to i*sizeof(THING).

Yes, I really meant i+1, due to a property of the fill_things function.
Probably poor style, as someone else wrote me. Guess I'll fix it.

>$ If realloc() fails when you try to *shrink* a buffer, you should complain
>  to your vendor.  (It's not a violation of the Standard, but it's definitely
>  poor quality.)

That depends IMO. If realloc first mallocs a block of size newsize and then
frees the oldsize block, it could be that there is no room to malloc newsize
while oldsize is still occupied. I must say that it didn't actually go wrong,
but I was just wondering... always anxious to learn...

>/* #1: Find some way to count them in advance */
>    count = figure_out_how_many_things();
>    ManyThings = malloc(count * sizeof(THING));

It is not possible to write a figure_out_... function I'm afraid.


>/* #2: start small, and grow as needed */
>    ManyThings = malloc(size * sizeof(THING));
>    do {
>	if (i >= size) {
>	    size = 2*size;
>	    ManyThings = realloc(ManyThings, size * sizeof(THING));
>	}
>    } while (!fill_things(ManyThings[i++]));
>    ManyThings = realloc(ManyThings, --i * sizeof(THING));

I'll consider this, although I don't particularly like all those m/re-allocs :)

>/* #3: use a linked list (or some other data structure) */

This looks like a kind of variation on #2. I think I prefer #2 - looks like a
decent method. At least I don't have to shrink memory-usage in this case and
thus don't run the risk you mentioned (about realloc in some implementatons not
returning the freed memory to the OS).
I'll give it another thought. Thanks for the suggestions!


--
Hendrik Jan Veenstra                            hjv@phil.ruu.nl
Department of Philosophy              -------------------------------------
University of Utrecht                     All opinions expressed above
The Netherlands                               are pure coincidence 
Xref: sparky comp.lang.c:14517 comp.lang.c++:14502 comp.os.msdos.apps:5031 comp.os.msdos.programmer:9722
From: cee1@ra.msstate.edu (Charles Evans)
Newsgroups: comp.lang.c,comp.lang.c++,comp.os.msdos.apps,comp.os.msdos.programmer
Subject: A few glitches in Borland C++ 3.1
Date: 4 Oct 92 17:37:58 GMT
Organization: Mississippi State University

First off, let me complement the work of those in Borland C++ 3.1 (AFX).
Truly fine, indeed.  However, I have come across a few glitches (beyound the
3 available patches) in BC++ 3.1

1	When I run Turbo Profiler from Windows, it flips to DOS text, fine;
	however, when I quit and it goes back to Windows all the graphics
	are messed up and smeared. (I have a Trident 8900c if that helps.)
	It's like Windows is not saving a copy of the graphics screen while
	in DOS. A similiar occurace happens in Fractint (DOS) : switching
	to and from the Graphic Fractal screens to descriptions and what-
	have-you in text mode. However, running some program forces Fractint
	to save a screen shot of it upon returning. Anyone else had this 
	problem with going to-and-from Turbo Profiler? Might it be a VESA
	problem? It is running fine on my system (AMD386/40)

2	When the Warning: function must return a value, (DOS IDE) at the 
	top of the Warning box above the name of the Warning (first line),
	there seems to be garbled characters:

	<3 filled boxes> <space> -wrvl <space> <3 filled boxes> 

	not sure of the ASCII character for the 'filled boxes'. Anyway, just
	a minor thing.. Does this occur on others? My file dates are:
	06-10-92 (3:10).

3	When in the Windows IDE and I am changing fonts (especially for 
	smaller fonts), changing fonts garbles the text. And as I continue
	to change fonts, it gets more and more garbled (partial characters
	everywhere).

That's all. Any comments? MUCH FASTER COMPILING! LIKE THE COLOR SYNTAXING!
-- 
+--------------------+-----------------------+------------------------+
|  Charles E. Evans  |  cee1@ra.msstate.edu  |        Fear God        |
|    iDLE CHATTEr    |  cee1@MSSTATE.BITNET  |  Love the brotherhood  |
|    Idle chatteR    |cevans@abe.msstate.edu |  Pray without ceasing  | 
Newsgroups: comp.lang.c
From: choup@bionette.CGRB.ORST.EDU (Ping Chou)
Subject: Re: Differences between ANSI C and VAX C
Organization: Biological Computing Consortium, OSU, Corvallis, OR.
Date: Sat, 3 Oct 1992 02:05:09 GMT

In article <1992Oct2.161210.4045@taumet.com> steve@taumet.com (Steve Clamage) writes:
>mad@spirit.clearpoint.com (Michael Davis) writes:
>
>
>>I hope I'm not too late to be of use--I don't read comp.lang.c very
>>often.  Anyway, one thing that bit me is that global variables are all
>>UPPERCASED during compilation.  If you have a function FooBar and a
>>variable foobar, which should be distinct, VAX C will barf.
>
>While this is certainly an inconvenience, it is allowed by ANSI C.
>Section 3.1.2, Identifiers:
>
>"The implementation may further restrict the significance of an
>external name (an identifier that has external linkage) to six
>characters and may ignore distinctions of alphabetical case for
>such names."
>-- 
>
>Steve Clamage, TauMetric Corp, steve@taumet.com
>Vice Chair, ANSI C++ Committee, X3J16


        I'm not surprised to learn (thank you) that external names are
implementation dependent. What really bothers me is that VAX C treats
global variables as EXTERN by default, and promotes EXTERN names to
uppercase by default. I suppose global variables are STATIC (to the module
in which it is declared) storage class.

Ping
From: dik@cwi.nl (Dik T. Winter)
Newsgroups: comp.lang.c
Subject: Re: Is there is (pascal) WITH equivalent in C?
Date: 7 Oct 92 02:51:41 GMT
Organization: CWI, Amsterdam

I never did see the original question, but nevertheless recognize my code:

In article <scott.718402547@mcl> scott@mcl.ucsb.edu (Scott Bronson) writes:
 > In <20992@plains.NoDak.edu> heilig@plains.NoDak.edu (Zachary Heilig) writes:
 > 
 > >try:
 > >	a.next := a.next^.next;
 > >	a.next^.next^.prev := a;
 > >	      ^^who the hell thought up the ^. awkward operator anyway?
 > 
 > Niklaus Wirth, who do you think?  I like Pascal's "^." pointer indirection
 > much better than C's "(*a).next".

Argh.  "^." is two operators.  The first is "^" for indirection and the second
is "." for selection.
-- 
dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland
home: bovenover 215, 1025 jn  amsterdam, nederland; e-mail: dik@cwi.nl
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c
Subject: Re: SUMMARY:  Preferences toward case sensitivity/insensitivity
Date: 29 Sep 92 21:36:22 GMT
Article-I.D.: ulogic.312
Organization: negligable

I prefer case sensativity.  However insisting on UPPERCASE keywords
in a case-sensitive language is (IMHO) rather stupid.  Anti-ergonomic
to say the least!

Case sensitivity can be useful.  "TOTAL" and "total" is a rather trivial
example.  When you get to longer names it is a convention (in C at least)
to use uppercase to distinguish words e.g.:
	setStudentStatus()

If you allowed someome sharing the same code to be lazy and type
	setstudentstatus()

the code would quickly become unreadable.  When I'm reviewing code
I don't want to have to translate in my head that ABC abc AbC and ABc
are all the same thing -- if they're written the same they are the
same and if they aren't they aren't,  so if someone else is linking
with my code I can recognize setStudentStatus() instead of overlooking
a setstudentstatus() because it doesn't trip my recognition circuits
when scanning the code.

btw: the older C convention would make that function set_student_status(),
which is takes two additional chars to type, which is why I think they
finally tried to promote the caps-start-words (or is that CapsStartWords)
convention.

Finally I'd like to toss in examples where case actually makes a difference
in meaning to illustrate (it also illustrates a poor choice of function
name for the second one, but it shows the point where case makes
a semantic distinction).

    PowerOfTen(int)		-- return ten to the X power
    PowerOften(int)		-- set how often to apply power to motor

		-Richard Hartman
		hartman@ulogic.COM

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"Fosters!  It's Australian for beer, mate!"
Xref: sparky comp.lang.c:14607 comp.sources.d:1322 comp.unix.wizards:4212 alt.sources:2152 misc.misc:3448
From: david@gdstech.grumman.com (David Nettles)
Newsgroups: comp.lang.c,comp.sources.d,comp.unix.wizards,alt.sources,misc.misc
Subject: ** NEED PD C/C++ COMPILERS **
Keywords: compile
Date: 6 Oct 92 14:37:18 GMT
Reply-To: david@gdstech.UUCP (David Nettles)
Organization: Grumman Data Systems-Woodbury


I am looking for any public domain C/C++ compilers.

My system is as follows:

- *original* IBM-PC/XT with a SOTA286 accellerator daughter-board.
- 640K RAM
- 21.5Mb hard drive

What I would like to see in the compilers:

- Compile to 8086 code
- Have the option to compile to 80286 code
- Capability to handle tiny->large/huge memory models

I do not read here often so please respond via email.
I will make a source list available here of what turns up.

Thanks in advance, folks!
Hope to be hearing from you soon...


David Edward Nettles
-- 
****************************************************************************
   David E. Nettles
   Internet: david@gdstech.grumman.com
   Grumman Data Systems
From: pinkas@skywalker.intel.com (Israel Pinkas)
Newsgroups: comp.lang.c
Subject: Re: unpredictable post-decrement behavior.
Date: 2 Oct 92 01:17:05 GMT
Followup-To: comp.lang.c
Organization: Software Technologies, INTeL Corporation, Santa Clara, CA

herzog@ux5.lbl.gov (Hanan M. Herzog) writes:

>		  product *= (double)(4 * n * n) / ((4 * n * n++) - 1);
>
> Some compilers had no problem with this line at all. However some
> hurled completely upon sight of the 'n++'. A few compilers required
> me to place the 'n++' on the next line in the while loop. So
> the code looked like:
>
>		  product *= (double)(4 * n * n) / ((4 * n * n) - 1);
>		  n++;
>
> Why did some compilers get and others not?

The expression is wrong.  Your compiler is protecting you from yourself.

A C compiler is free to evaluate the expression in any order that it wishes
to, as long as the result is correct.  a*b*c may be evaluated by performing
either multiply first.  (ANSI C requires the compiler to evaluate (a*b)*c
by multiplying a and b first, but that's different.)

In your case, the compiler was free to evaluate any of the sub-expressions
first.  The n++ could cause any number of results.  For example:

	i=5;
	j=i++*i++;

can result in assigning either 25 or 30 to j.  (36 would be wrong.)

-Israel
--
Israel Pinkas		pinkas@stps18.intel.com		408-765-4210

	"Everybody's askaird of death, until it hits you ...
	 then you don't care"		-Archie Bunker
From: rawat@cs.iastate.edu (Jai Rawat)
Newsgroups: comp.lang.c
Subject: Best way to simulate sets in C?
Keywords: set, data structures, C
Date: 29 Sep 92 02:43:54 GMT
Organization: Iowa State University, Ames IA

Hi!
Just wanted to gather the opinions of some experienced people?
Q. What is the best way to simulate a set in C?
   case 1. It is going to be used many times in the program.
   case 2. It is going to be used just once. e.g. you read an integer
	   and there are only five different values that are valid
	   input for it. You want to check if what you read was valid
	   and if not, give an error message.(Don't suggest switch..
	   what if i want to read a string insted?)
I would appreciate direct replies, because i don't read this newsgroup
very frequently.

Thanx.

-- Jai.
Newsgroups: comp.lang.c
From: amorgan@Xenon.Stanford.EDU (Crunchy Frog)
Subject: Re: unpredictable post-decrement behavior.
Organization: Computer Science Department, Stanford University.
Date: Fri, 2 Oct 1992 17:42:15 GMT

In article <1992Oct2.121045.24203@alw.nih.gov> 
  gregh@alw.nih.gov (Gregory Humphreys) writes:
>
>Well, Hans, I'm glad you are the authority on aesthetic C constructs.

Aesthetics has nothing to do with it.

>Personally, as I program C every day at my job, I use constructs like the
>above all the time.  I find them much easier to use and understand.

For the 100th time.

a = n * n++;

is *wrong*.  It is not easier to understand.  It is not compact.  It is
invalid.  If you use this construct you *should* be shot.

>Greg Humphreys    |  "Playing not to win is like sleeping with your 

C Frog
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c
Subject: Re: ++i = i++ ?
Date: 2 Oct 92 17:13:29 GMT
Article-I.D.: ulogic.368
Organization: negligable

In article <1992Oct1.131327.11992@microware.com> adam@microware.com (Adam Goldberg) writes:
>hartman@ulogic.UUCP (Richard M. Hartman) writes:
>
>>The expression results you keep referring to as boolean (true or false) and
>>discarded are actually int and discarded.  e.g. for the statment:
>>	i;
>
>>where i has the value of 5, the statement value is 5, not "true".
>
>>not that this affects the original question any....
>
>Not exactly.  According to my K&R (2nd ed), Section A9.4:
>
>     In both forms of the if statement, the expression, which must have
>     arithmatic or pointer type, is evaluated, including all side-effects,
>     and if it compares UNEQUAL TO 0, the first substatment is executed
>     [the if clause].  In the second form [if..then..else], the second
>     substatement is executed if the expression IS 0 [the else clause].
>     [emphasis added].
>
>To my reading, 0 is defined as false, and != 0 is defined as true.

Start from the beginning:
	"In both forms of the if statement, the expression...."
	 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
			      ||||||||||||

The paragraph you are referencing is obviously talking about how the
"if" statement evaluates it's condition clause, NOT the value of
a statement in general.

However, as has been pointed out in a parallel branch, I tend to use
the word "statement" where "expression" would be more exact.

In the example which we were discussion, the statement in question
was the third part of the "for" syntax:
	for (expr; expr; expr)
			 ^^^^

The _second_ part is presumably handled in the manner which you
describe, but the third part has an int value (the result of the
expression "i++"), which value is then thrown away making this
whole debate somewhat moot.


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
But I am frightened for you, children,		|
that the life that we are living is in vain,	|	-Richard Hartman	
and the sunshine we've been waiting for		|	hartman@uLogic.COM
has turned to rain....				|
From: murakami@idas.imslab.co.jp (Mr.Murakami)
Newsgroups: comp.lang.c
Subject: Re: Help in porting c progams to mac
Date: 29 Sep 92 02:34:58 GMT
Organization: Information and Mathematical Science Lab. Inc., Tokyo, Japan

In article <armando.717696702@hp9k>, armando@hp9k.lag.itesm.mx (Armando Ibarra Medina) writes:
> WE ARE SOFTWARE DEVELOPERS HERE  IN MEXICO, OUR SOFTWARE IS IN DOS,
> BUT NOW WE WANT TO USE  IT IN MAC, AND WE ARE NOT FAMILIAR WITH SUCH 
> ENVIROMENT, SO WE ARE ASKING FOR ADVISE ON THE NEXT SUBJECTS:
> A) COMPILER
  MPW(Apple) or Think C(Symantec)

> B) LINKING
  MPW(Apple) or Think C(Symantec)

-- 
$B4d@P@83h<T(J		Yukio Murakami@idas.imslab.co.jp
From: operator@julian.uwo.ca (Operator)
Newsgroups: comp.lang.c
Subject: problem with format of while, for if, and nested ifs
Date: 28 Sep 92 13:39:36 GMT
Organization: University of Western Ontario, London


if I had the following code what would be the correct format??


while ( condition )
   {
   for ( condition )
      {
       if ( several conditions )
          {
          if ( condition )
             {
             statement;
             statement;
             }
          if ( condition )
             {
             statement;
             statement;
             }
          if ( condition )
             {
             statement;
             statement;
             }
          }
      }
   statement;
   }
   
             
what would be the correct format for this???

the problem I have is that it hangs and never leaves the first if statement.
I would appreciate the help

Thanks!!
From: tore@bibsyst.no (Tore Morkemo)
Newsgroups: comp.lang.c
Subject: sscanf right or wrong ?
Date: 2 Oct 92 11:31:00 GMT
Reply-To: tore@bibsyst.no (Tore Morkemo,Systemavd.)
Organization: Bibliotek-Systemer A/S

Hi !

I've got this question about sscanf:
    If I'm using a scanset starting with a caret, should it always put a '\0'
    into the resulting string ?
    I've got this example "running" on SCO 3.2.4 :

        char to[10];

        strcpy(to, "xxxx");
            // I want all the characters up to the first space, but not
            // more than 4.
        sscanf("eb 123", "%4[^ ]", to);
        printf("<%s>\n", til);

    This gives me <eb>, which is correct, but if the first character
    is a space `to' is unchanged. In my opinion sscanf should have
    set to[0] to '\0'.

        strcpy(to, "xxxx");
        sscanf(" eb", "%4[^ ]", to);
        printf("<%s>\n", til);

    This gives me <xxxx>. Is this right ? sscanf returns 0 meaning that
    it tells me there is something wrong here. The manual says :

      At least one character must match for this conversion to be
      considered successful.

    Could anyone tell me if sscanf is wrong or right ? If it is correct,
    is there a way to get what I want using sscanf ? (and please don't
    tell me this can be done better without sscanf, I know that.)


Tore.    

*-----------------------------------------------------------------------------*
 Tore Morkemo, Bibliotek-Systemer A/S, Box 2093 Stubber|d, 3271 Larvik, Norway
        Tel: +47 34 16 800  Fax: +47 34 16 822  email: tore@bibsyst.no
*-----------------------------------------------------------------------------*
Newsgroups: comp.lang.c
From: jsteele@netcom.com (John Steele)
Subject: Re: Curses to write to stderr, possible?
Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
Date: Sat, 3 Oct 1992 00:56:24 GMT

In <9227705.8627@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:

>hartman@ulogic.UUCP (Richard M. Hartman) writes:

>>If you can isolate the curses stuff in subroutines you could
>>always play games w/ the file pointers....
>>
>>
>>	displaySomething(...)
>>	{
>>	FILE *old = stdout;
>>	stdout = stderr;

>Note that this scheme will not work with most K&R C compilers, and I
>suspect that many ANSI C compilers might still reject it, because
>stdout is usually #defined as something like &__iob[1].

True.  This is what freopen() is usally used for.  Quick extraction from
MS Quick Help:


Include:   <stdio.h>

Syntax:    FILE *freopen( char *filename, char *mode, FILE *stream );
           mode: r, w, a, r+, w+, a+, t, b
                 (appended to <mode> to indicate type)

Returns:   a pointer to the newly opened file if successful, or a
           NULL pointer if not.

The freopen function closes the file currently associated with
<stream> and reassigns <stream> to the file specified by
<filename>. The freopen function is typically used to redirect the
preopened files stdin, stdout, and stderr to files specified by
the user.


John
-- 
#include <disclaimer.h>			/* route all flames to /dev/null  */
/**************************************************************************/
/*   Systems Analyst      | John Steele     email: jsteele@netcom.com     */
/* Video Business Systems |                                               */
/*   1-800-255-3088       |    Most people spell COBOLSUX incorrectly...  */
/**************************************************************************/
Newsgroups: comp.lang.c
From: halderen@fwi.uva.nl (Berry van Halderen (I88))
Subject: Re: Is there is (pascal) WITH equivalent in C?
Organization: FWI, University of Amsterdam
Date: Tue, 29 Sep 1992 08:23:42 GMT

adam@microware.com (Adam Goldberg) writes:

>ray@astro.ocis.temple.edu (Ray Lauff) writes:

>>When programming in (sigh) Pascal there is a WITH statement which
>>allows all the references to a structure to be referenced without
>>repeating the struct variable name.  Is there such a thing in C?
>>I don't believe there is, but I may be wrong...

>Not really, however, if you have something that looks like this:

Yughk! The  with  statement is rather confusing in a piece of code,
not only for humans but also for compilers. This is why the  with
statement has been removed by wirth in his follow-up-to-pascal language
modula.
Conclusion (?): You don't want a with construct in C.
But for something similar. suppose you have a lot of references to
"p->a.b" which is a struct with several fields. Then you can simply
define:  #define P (p->a.b)
and start using P as the with construct. Okay, it's dirty, but you
don't _need_ a with construct, and c is a _small_ basic language.

\Berry
-- 
/* 1st law for prg optimalization:       x       Berry A.W. van Halderen    */
/*  Don't do it.                        |x|      Email: halderen@fwi.uva.nl */
/* 2nd law for prg optimalization:       --                                 */
/*  For experts only: Don't do it yet.   x       University of Amsterdam    */
From: kdq@quest.UUCP (Kevin D. Quitt)
Newsgroups: comp.lang.c
Subject: Re: Is there is (pascal) WITH equivalent in C?
Date: 1 Oct 92 17:30:31 GMT
Reply-To: srhqla!quest!kdq
Organization: Job quest  (805) 251-8210,  So Cal: (800) 400-8210

ae24@iamk4516.mathematik.uni-karlsruhe.de (Peter Januschke) writes:
> jos@and.nl (Jos Horsmeier) writes:
> > ...IMHO the WITH construct
> > in Pascal is silly, it just saves a couple of keystrokes, ... 
> 
> That's just not true. Most non-optimising compilers would generate better
> and faster code from a WITH construct than from the corresponding construct
> without WITH.

Fortunately though, nobody these days has to work with non-optimizing
compilers, right? ;-)


 _
Kevin D. Quitt                                 Job Quest (800) 400-8210
srhqla!quest!kdq                               Learn How to Get a Job in SoCal

                96.37% of all statistics are made up.
Newsgroups: comp.lang.c,comp.sources.wanted,comp.msdos.programmer,comp.misc
From: gbm@jmp.com (Gary McKenney)
Subject: Re: Wanted: C-isam library for Turbo C or Microsoft C
Organization: JMP & Associates, Ltd. - Atlanta, Ga.
Date: Fri, 2 Oct 1992 13:28:40 GMT

In article <1992Sep30.171329.10078@di.unipi.it> Nico Tranquilli <@> writes:
>Does anyone have (or know where to find) C-Isam libraries for
>Microsoft C 6.00 or Turbo C 2.0 compiler ?

A good set of routines is C-Tree from FairCom.  

Code is very portable and reliable.  I've been using it for years.
(There, you have my testimonial..)

You can order it through Programmer's Paradise for $476.00
1-800-445-7899

Gary McKenney
From: zmahx11@ic.ac.uk (Arrigo G.B. Triulzi)
Newsgroups: comp.lang.c
Subject: MSC 6.0a internal error on TC code
Date: 5 Oct 92 14:51:35 GMT
Organization: Imperial College Mathematics Department

I recently bought the book "Advanced Graphics Programming in C and C++" and included with it was a set
of disks with example source code. The author stated that the programs would compile (and were
compiled) with TC 2.0 but they would work under MSC 6.0.
Actually if you write a few "translations" of TC functions into MSC functions (e.g. clrscr()) most of the
"simple" programs  work fine except one.
On the function movedata() the MSC compiler (vers. 6.0a) comes up with an C1001 Internal Error, etc.
Now, assuming the TC version works, why do I get an internal compiler error?
(For people with the book: The file is msetjset.c showing the Mandelbrot to Julia set correspondence)
A final point, there are no error messages until the C1001 line.

Any pointers to valid solutions?

Thanks,

	Arrigo

------
Arrigo G.B. Triulzi (a.triulzi@ma.ic.ac.uk)
Maths Dept. - Imperial College of Science & Tech. - London - UK
Newsgroups: comp.lang.c