HDTenEightyP/NetNews huggingface dataset:
From: s912121@minyos.xx.rmit.oz.au (Joydip Das)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Help!! with flex/byacc on Borland C
Date: 6 Oct 92 01:02:01 GMT
Organization: RMIT Computer Centre
NNTP-Posting-Host: minyos.xx.rmit.oz.au

I have recently downloaded the source For flex and byacc.  I was attempting
to compile the source files for flex (i.e.  main.c  ccl.c  dfa.c  etc with
the header files supplied.. flexdef.h etc) under the Borland C++ 3.1 IDE
environment.  I have put all the C sources into a project file and was
compiling each source separately.
At this point I should say that I am a beginner with both the language
and the compiler so please excuse anything obviously ignorant that I may
write.
Anyway, I was attempting to compile flex with the ANSI C and portability
options turned on as this is vital for the work I want to do with flex/byacc
(future portability to others OS).  When I try to compile the sources, I get
a lot of warnings about undeclared prototypes.  As far as I can tell, these
have been declared in flexdef.h  .
There is also a compiler directive in flexdef.h as follows:
    #ifndef PROTO
    #ifdef __STDC__
    #define PROTO(proto) proto
    #else
    #define PROTO(proto) ()
    #endif
    #endif

I am not sure what this definition is for.  Subsequently there are prototypes 
declared within flexdef.h such as:
extern void ntod PROTO(());
and 
extern void make_tables PROTO(());
etc.
and also in the sources, e.g. in main.c there is
void flexinit PROTO((int, char**));

These prototypes do not seem to be recognisable to the compiler.
I am really confused.  Am I doing something stupid or is there something I
don't understand about language/compiler/flex/byacc ?

If anyone can help me with this I would be really grateful.  If anyone has
actually compiled flex and byacc as I am attempting to do, I would really
appreciate a guiding light.

Many, Many Thanks in Advance.

J.D
-----------------------------
m912121@chudich.co.rmit.OZ.AU
From: mike@pacsoft.com (Mike Stefanik)
Newsgroups: comp.lang.c
Subject: Re: Common C errors (was Strange memory allocation...)
Date: 28 Sep 92 06:01:48 GMT
Organization: Pacific Software Group, Riverside, CA

In an article, elliot@Wellspring.COM writes:
>b == a;            /* an attempted assignment */
>
>This statement does nothing, but cannot be flagged as a warning.

This kind of statement will provoke GCC into issuing a warning similar
to "foo.c:9: warning: statement with no effect".  So what exactly do
you mean when you say that it "cannot be flagged as a warning"?

-- 
Mike Stefanik  mike@pacsoft.com  ...!uunet!pacsoft!mike  (714) 681-2623
Pacific Software Group, Riverside, CA
Newsgroups: comp.lang.c
From: wilson@gauss.cs.jhu.edu (Dwight Wilson)
Subject: Re: 'make' woes (won't catch secondary dependancy)
Organization: The Johns Hopkins University CS Department
Date: Thu, 1 Oct 1992 12:33:59 GMT

In article <GUENTHER.92Sep30231733@amcl5.stolaf.edu> guenther@stolaf.edu (Philip A Guenther) writes:
>In article <BvFB6o.A1w@news.cso.uiuc.edu> gbnewby@uxh.cso.uiuc.edu (Gregory B. Newby) writes:
>
>   I have a header file that #include's another header file.  I
>   would like for my 'make' to catch whether either of them are 
>   modified.  Here is a very simple example of what goes wrong
>   (of course, what I'm doing is a bit more complicated....hence,
>   just putting "test.o: h1.h h2.h" will work in this example,
>   but will not give me the freedom & capability I need to be
>   happy):
>
><string of examples deleted>
>
>You need to set hidden dependencies on in your makefile.  If hidden
>dependencies is set then make queries cpp(1) for files that are
>included by dependency tree files, and they are added to the
>dependency tree.  There are several ways to activate this; the easiest
>(I think) is to give the target .KEEP_STATE somewhere in your
>makefile.  See the man page for other ways to do so.
>
>Note: this is true for SunOS 4.1.x make (but not old-make).  I don't
>know about the others (though I do know that Sun Make (and Gnus Make)
>has several features (pattern matching, for instance) that other makes
>don't.  So Your Mileage May Vary by manufacturer, make and model of
>make. :-)  And yes, I think that your version of Gnu Make is broken.
>

If you can't do this using your version of make, try this:

h1.h: h2.h
   touch h1.h

Of course, this assumes that you don't mind changing the 'last modified'
time of h1.h.

-Dwight
Newsgroups: comp.lang.c
From: nett@technix.mn.org (Jerry Nettleton)
Subject: Re: C Database
Organization: Private System - Saint Paul, MN
Date: Mon, 28 Sep 1992 02:10:41 GMT

In article <717610052snx@ariel.demon.co.uk> abutler@ariel.demon.co.uk (Tony Butler) writes:
>Hi,
>
>I'm trying to write a database application in C, and I want the records
>to be in alphabetic order. The 'obvious' solution is to use a doubly
>linked list to maintain this order. The problem is though that I
>anticipate having a database too big to fit in memory, so I can't load
>it all up, search the database, and add a new record in the appropriate
>place. So the problem is, how do I search this database and add records
>to it - with a linked list, the links point to memory locations, which
>is no good if the records are on disk. Aslo, I would (presumably) want
>to maintain a buffer of x records in memory top speed things up a bit -
>what's the best way to go about this??
>
>Any help would be much appreciated, please email your response.
>
>   Tony.

I'm using Raima Data Manager (db_VISTA III) which supports network
and relational database models.  To maintain a list of records in
ascending or descending alphabetic order, I would use an ordered set.
When you want to find a specific record, you would have to do a
sequential search, but at least it already sorted.  You can also go
to the next or previous member of a set.  The linked list is
maintained as part of being a member of a set in the database.

-- 
Jerry Nettleton
email: nett@technix.mn.org
       ...!uunet!cs.umn.edu!kksys!edgar!technix!nett
From: GM08@DKAUNI2.BITNET (hans friedrich steffani)
Newsgroups: comp.lang.c
Subject: Re: unpredictable post-decrement behavior.
Date: 2 Oct 92 11:42:17 GMT
Organization: University of Karlsruhe, Germany



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

i think ppl who wrote code like this should be fired. this is no
defensive prgramming, difficulty to understand an perhaps in the
result compilerdependet. so dont use constructs like this.

hans friedrich steffani
uni-karlsruhe
gm08@dkauni2.bitnet
steffani@imbaibrs1.bau-verm.uni-karlsruhe.de
Newsgroups: comp.lang.c,comp.windows.x
From: msmcknig@unccsun.uncc.edu (Michael S McKnight)
Subject: Compile help
Organization: University of NC at Charlotte
Date: Tue, 29 Sep 1992 13:13:27 GMT

I am trying to compile a program for Xwindows on an HP-9000.  I have the
following script file made to compile the program and link it in one step:


# To Compile x2.c use this script in place of a makefile when the
# actual file x2.c hasnt changed, but one of the include files did.

cc -I/usr/openwin/include -g  -c  x2.c
cc -I/usr/openwin/include -g -g -o x2 x2.o -L/usr/openwin/lib  -lolgx -lX11 -lm

# end of script


With x2.c being the main program.  This works on a Sun system but when I try
it on the HP I get the following messages:

"/usr/include/stdlib.h", line 78: redeclaration of exit
cc: (warning) unrecognized option -/
cc: (warning) unrecognized option -u
cc: (warning) unrecognized option -r
cc: (warning) unrecognized option -/
cc: (warning) - o penwin/lib overwrites earlier option -o x2
ld: file x2.o cannot be opened
ld: (warning) did not generate an output file


If anyone has any ideas or can offer me any help please send Email directly
to me at one of the following addresses.

Thanks in advance!

_________________________________________________________________________
| Michael McKnight -- msmcknig@unccsun.uncc.edu |    Amiga 3000-25/100  |
|                     msmcknig@mosaic.uncc.edu  |  Insight 386DX-25/105 |
-------------------------------------------------------------------------
|      PP-ASEL -- See, I'm not a 100% geek... I fly airplanes too!      |
-------------------------------------------------------------------------

-- 
_________________________________________________________________________
| Michael McKnight -- msmcknig@unccsun.uncc.edu |    Amiga 3000-25/100  |
|                     msmcknig@mosaic.uncc.edu  |  Insight 386DX-25/105 |
-------------------------------------------------------------------------
Newsgroups: comp.lang.c
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: sscanf right or wrong ?
Organization: Computer Science, University of Melbourne, Australia
Date: Sat, 3 Oct 1992 05:08:48 GMT

tore@bibsyst.no (Tore Morkemo) writes:

>        strcpy(to, "xxxx");
>        sscanf(" eb", "%4[^ ]", to);
>        printf("<%s>\n", til);
>
>    This gives me <xxxx>. Is this right ?

Yes. 

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

sscanf returns the number of successful assignments performed.
If there isn't at least one non-space character, then your sscanf will
not make any successful assignments. The way to ensure that the
destination is correctly initialized is to either initialize it before calling
sscanf, like this:
         to[0] = '\0';
         sscanf(" eb", "%4[^ ]", to);
or to check the return value from sscanf like this:
         if (sscanf(" eb", "%4[^ ]", to) == 0)
             to[0] = '\0';

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
Newsgroups: comp.lang.c,comp.lang.pascal,comp.lang.misc
From: peter@ferranti.com (peter da silva)
Subject: Re: SUMMARY: Preferences toward case sensitivity/insensitivity
Organization: Xenix Support, FICC
Date: Thu, 1 Oct 1992 15:29:54 GMT

In article <1992Sep29.162158.5929@ima.isc.com> karl@ima.isc.com (Karl Heuer) writes:
> I'm not sure I agree that this would "resolve all remaining complaints".
> It's not uncommon for C programmers to use a lowercase name for a variable
> whose *type* has the same name capitalized, e.g.  |Thing thing;| (this is
> usually either a local variable with short scope, or a global variable
> representing the only instance of the type), and I expect some people would
> be miffed at getting a warning for this.

I used to write stuff like !FILE file;!, but I got better.
-- 
Peter da Silva                                          `-_-'
Ferranti Intl. Ctls. Corp.                               'U` 
Sugar Land, TX  77487-5012
+1 713 274 5180                           Heb jij vandaag je wolf al geaaid ?
Newsgroups: comp.lang.c
From: baillie@munta.cs.mu.OZ.AU (Stephen Baillie)
Subject: ANSI behaviour for casting double to long
Summary: Should it blow up?
Keywords: ANSI double long cast
Organization: Computer Science, University of Melbourne, Australia
Date: Sun, 4 Oct 1992 09:08:04 GMT

K&R states that casting a float to an int will cause truncation
of any fractional part of the float, but fails to mention what
happens to overly large floating point numbers when they are
cast to integral types.

For example

fval = 3.0e+20;
ival = (int) fval;

Can anyone enlighten me as to the standard behaviour (if there
is such a thing) for this?  Obviously the example involves converting
a floating point number to something that cannot be represented
in the given format.

This springs up because of a little problem with Microsoft Windows
when I inadvertantly tried to perform a similar operation.  The
behaviour in that case was to cause one's program to break.  The
MSC 7 debugger can be blown away quite spectacularly by this bug
as well!

Obviously I have now put in a check for this overflow condition,
but I was wondering if anyone had any ideas as to what is
supposed to happen?

Thanks for your attention,

Steve.

-- 
"If we shadows have offended, Think but this and all is mended:
 That you have but slumbered here, While these visions did appear.
 And this weak and idle theme, no more yielding but a dream."
baillie@munta.cs.mu.oz.au (Stephen Baillie)
Newsgroups: comp.lang.c
From: sasghm@theseus.unx.sas.com (Gary Merrill)
Subject: Re: ++i = i++ ?
Originator: sasghm@theseus.unx.sas.com
Date: Wed, 30 Sep 1992 17:48:32 GMT
Organization: SAS Institute Inc.


In article <325@ulogic.UUCP>, hartman@ulogic.UUCP (Richard M. Hartman) writes:

|> That's what he said.  Not very useful, but syntactically correct.
|> (with the possible exception of the missing ';', so you would
|> actually have to write:
|> 	for (i=0; i<Count, i++; )
|> for the compiler to buy it....

The compiler buys (or *should* buy) the pre-increment version just fine.
-- 
Gary H. Merrill  [Principal Systems Developer, C Compiler Development]
SAS Institute Inc. / SAS Campus Dr. / Cary, NC  27513 / (919) 677-8000
sasghm@theseus.unx.sas.com ... !mcnc!sas!sasghm
Newsgroups: comp.lang.c
From: berlin@is.morgan.com (Alexander Berlin)
Subject: Re: Determining variable type at run-time (followup q.)
Organization: Morgan Stanley - IS
Date: Thu, 1 Oct 1992 21:36:44 GMT

In article <359@ulogic.UUCP>, hartman@ulogic.UUCP (Richard M. Hartman) writes:

|> Safer would be:
|> 	
|> 		x.type = 2;
|> 		x.value = malloc(strlen(str));
|> 		strcpy(x.value, str);
|> 		OutPut(x);
|> 
Doesn't look very safe to me.
Newsgroups: comp.lang.c
From: mike@taumet.com (Mike Ball)
Subject: Re: Is there is (pascal) WITH equivalent in C?
Organization: TauMetric Corporation, San Diego
Date: Sat, 3 Oct 1992 20:06:57 GMT

In article <1992Oct2.164350.3847@organpipe.uug.arizona.edu> dave@cs.arizona.edu (Dave Schaumann) writes:
>In article <1992Oct2.124350.3244@taumet.com>, mike@taumet (Mike Ball) writes:
>>The with expression is evaluated exactly once, which has semantic
>>consequences exactly similar to the fact that the lhs of a reflexive
>>operator is evaluated once.
>
>Oh, I see -- a WITH expression might have a pointer in it, in which
>case you can't entirely evaluate it at compile-time.  In which case,
>WITH is in effect, a massive clue to the compiler to do some common
>sub-expression elimination.
>
>Now I see why everyone was saying "that's an easy optimization even
>without WITH".  :-/

Not quite.  The expression may contain a side effect, like a function call,
an that must happen only once.  Consider the C equivalent

p[i++] += 1;

and you will see that it is NOT just an optimization, but a semantic
difference.

-- 
Michael S. Ball (mike@taumet.com)
TauMetric Corporation
From: pmor1@cs.aukuni.ac.nz (Peter William       Morrison       )
Newsgroups: comp.lang.c
Subject: Fooling with pi
Summary: I'm trying to generate 1,000,000 digits of pi
Keywords: pi
Date: 30 Sep 92 22:59:27 GMT
Article-I.D.: cs.1992Sep30.225927.2346
Organization: Computer Science Dept. University of Auckland

Hi all. This is my first ever post to the world, and I've got a
challenge for the programming wizards out there (I know you're there,
I can hear you breathing...)
Okay. Here's the game plan. I'm trying to write a program to generate
digits of pi, completely for my own edification, and I've got a few
identities:
    pi/4 = atn(1)
	 = 4*atn(1/5)-atn(1/239)
	 = atn(1/2)+atn(1/5)+atn(1/8)
	 = 12*atn(1/18)+8*atn(1/57)-5*atn(1/239)
	 = 6*atn(1/8)+2*atn(1/57)+atn(1/239)
Now, given all this, and the taylor expansion for atn
(atn(x) = x-x^3/3+x^5/5-x^7/7+...)
can ANYONE out there help, criticise, or just gimme the program?

my email address is (apparently) pmor1@cs.aukuni.ac.nz, but you'll
probably never get through the university's sophisticated perimeter
defense system (i.e. confuse 'em to death) - but give it a go

///////////////////////////////////////////////////////////
//                                                       //
//    The best way to accelerate a Mac is at 11Km/s      //
//          and NO '040 is gonna do that!                //
//                                                       //
///////////////////////////////////////////////////////////
 (and I _don't have_ an employer to disclaim)
Xref: sparky comp.lang.c:14534 comp.lang.pascal:5823 comp.lang.misc:3210
From: leonard@qiclab.scn.rain.com (Leonard Erickson)
Newsgroups: comp.lang.c,comp.lang.pascal,comp.lang.misc
Subject: Re: SUMMARY: Preferences toward case sensitivity/insensitivity
Date: 5 Oct 92 01:17:45 GMT
Reply-To: 70465.203@compuserve.com
Organization: SCN Research/Qic Laboratories of Tigard, Oregon.

peter@ferranti.com (peter da silva) writes:

>In article <9226902.9004@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
>> If foo and FOO are both used in the same scope then either:
>> 	(1) They denote different identifiers, and the compiler issues a
>> 	    warning;
>> 	(2) They denote the same identifier, but the compiler issues a
>> 	    warning; or
>>         (3) The compiler issues an error.

>I'll buy that, though I'd prefer to have this enforced between scopes for
>globals as well. I think this would resolve all remaining complaints about
>BOTH case-sensitive and case-insensitive languages, whether you think MAD
>and mad and Mad are the same word, or not.

Heck, I'd like to have the ability to have the compiler generate warnings
about any time I use a "local" variable that overridea a global one. It 
can even default to being off. But I've seen a few too many bugs caused
by programmers who didn't realize that their variable was *replacing* a
system variable, or one in an included unit.


-- 
Leonard Erickson		      leonard@qiclab.scn.rain.com
CIS: [70465,203]			 70465.203@compuserve.com
FIDO:   1:105/51	 Leonard.Erickson@f51.n105.z1.fidonet.org
(The CIS & Fido addresses are preferred)
From: smr@hitkw14.pki-nbg.philips.de (S.Riehm)
Newsgroups: comp.lang.c
Subject: Re: ++i = i++ ?
Date: 29 Sep 92 14:44:48 GMT

zxmgn01@mailserv.zdv.uni-tuebingen.de (Philipp Knirsch) writes:

>Another nice thing is surely the following line:

>++i = i++;

>Hehehe.. Which value has i when it is first 0 after this line of correct 
>C-Code??

according to my compiler, you have an error!

when the compiler sees the ++i, it evaluates it before the assignment,
making the expression:

	1 = i++;

this kinda gives the compiler a bit of a headache, and it promptly
gives up!

If i was a valid pointer to a list of somethings, then you could
perhaps do it, but then you would be performing pointer addition which
is not generally regarded to be a "GOOD THING". (ie: pointer a +
pointer b)

either way it was fun to think about for about 2 minutes.. thanks for
the break!

catchya

-----------------------------------------------------------------
Stephen Riehm		Configuration Management	   _-_|\ 
smr@pki-nbg.philips.de	Philips Kommunikations Industrie  /     \
Work: +49 911 526 2975	N|rnberg, Germany		  \_.-.*/
Fax:  +49 911 526 2095	"I was there, now I am here!"	       v 
"My company speaks another language, I CAN'T speak on it's behalf"
From: pdh@netcom.com (Phil Howard )
Newsgroups: comp.lang.c
Subject: Re: Freeing dynamic allocated memory
Date: 6 Oct 92 19:08:51 GMT
Article-I.D.: netcom.1992Oct6.190851.26123
Organization: Netcom - Online Communication Services  (408 241-9760 guest)

cpcahil@virtech.uucp (Conor P. Cahill) writes:

>If you want to use the same memory area through several calls to the same
>function, you should maintain a static pointer to the data area.  The
>following function does just that (not code was not compiled, you mileage
>may vary):
>
>	myfunc()
>	{
>		static char	* data;
>
>		if( data == NULL )
>		{
>			data = malloc(xxx);
>			if( data == NULL )
>			{
>				return(-1);
>			}
>		}
>		do real stuff with data
>	}

Another alternative is to have the calling interface for your functions
defined to make the caller give the function a pointer to a memory area
that has NULL filled in.  The function would look there and see the NULL
and decide to allocate memory for its data, and store the pointer to the
allocated memory where the NULL was.  In the next call where the caller
gives the same pointer, the data is ready and the function can work on
that data again.

This would allow the calling program to get the service of that function
on many different instances of data.  For example you could have a group
of functions to do tree insert/search/delete.  The different instances
would be different trees.  The calling program can thus select which tree
an operation is performed on.

The malloc'd data will stay around until it is freed.  Some systems clean
up after sloppy programs, but others might not.  If you have a system with
virtual memory processes like UNIX, the whole virtual memory disappears
after the program exits, so at that point who really cares if the program
was sloppy.
-- 
/***********************************************************************\
| Phil Howard  ---  KA9WGN  ---  pdh@netcom.com   |   "The problem with |
| depending on government is that you cannot depend on it" - Tony Brown |
\***********************************************************************/
From: alpha@waggen.twuug.com (Joe Wright)
Newsgroups: comp.lang.c
Subject: Re: Novice question about memory allocation
Date: 25 Sep 92 16:59:12 GMT
Distribution: usa
Organization: ALPHA, Box 68621, Va. Beach, VA 23455
X-Newsreader: TIN [version 1.1 PL6]

Excuse me.  That should be:

	foo = (int(*)[10])calloc(100, sizeof(*foo));
								^
That is, comma ',', not '*'.   Sorry.
-- 
Joe Wright  alpha@waggen.twuug.com  alpha@wyvern.twuug.com
From: robasky@tortoise.cis.ohio-state.edu (Kimberly Robasky)
Newsgroups: comp.lang.c
Subject: Challenge to gurus... typecasting
Date: 1 Oct 92 14:11:36 GMT
Organization: The Ohio State University Dept. of Computer and Info. Science

I've been reading the postings, and so far nothing has surprised me.  This, 
however, has me baffled.  Can anyone see what is wrong with the following
code?  I have to assume from the nature of the crash that its a typecasting
problem.
( code that follows is ~29 lines):

Kim

-------------------------------------------------------
#include <stdio.h>
#include <alloc.h>

typedef float matrix_4x4[4][4];

matrix_4x4 *make_W_dot(matrix_4x4 *t1, float *t3, int tot_links);

main()
{
  int tot_links=1;
  matrix_4x4 t1[1], *t6;
  float t3[1];

  *t1[0][0] =     1;  *t1[0][1] = 0;  *t1[0][2] =    0;  *t1[0][3] = 0;
  *t1[1][0] =     0;  *t1[1][1] = 1;  *t1[1][2] =    0;  *t1[1][3] = 0;
  *t1[2][0] =     0;  *t1[2][1] = 0;  *t1[2][2] =    1;  *t1[2][3] = 0;
  *t1[3][0] =     0;  *t1[3][1] = 0;  *t1[3][2] =    0;  *t1[3][3] = 1;

  t3[0] = 1.0;

  t6=make_W_dot((matrix_4x4 *)t1, (float *)t3, tot_links);
}

matrix_4x4 *make_W_dot(matrix_4x4 *t1, float *t3, int tot_links)
{
  matrix_4x4 *test;
  matrix_4x4 *A_Wdot;

  if ((test=(matrix_4x4 *)malloc(sizeof(matrix_4x4)*tot_links)) EQ NULL){
    printf("Couldn't allocate memory for matrix W_dot");
    return NULL;
  }/*if*/

  if ((A_Wdot=(matrix_4x4 *)malloc(sizeof(matrix_4x4)*tot_links)) EQ NULL){
    printf("Couldn't allocate memory for matrix W_dot");
    return NULL;
  }/*if*/

  return (test);
}
Newsgroups: comp.lang.c,comp.os.msdos.programmer,comp.os.ms-windows.programmer.misc