HDTenEightyP/NetNews huggingface dataset:
From: m912121@spectre.co.rmit.oz.AU (Joydip Das)
Newsgroups: comp.lang.c
Subject: BYACC question ??
Date: 16 Dec 1992 01:38:58 GMT
Organization: RMIT Computer Centre
NNTP-Posting-Host: spectre.co.rmit.oz.au

I am currently working on a project using lex and yacc.  The situation is
that I have to develop this program on a DOS env and then port it to an
UNIX env when it becomes available.  I have managed to get hold of FLEX and
BYACC and want to compile and implement them on DOS (using BCC) and then port
them to the SunOS Unix.   So far I have gone through the flex source modules
and managed to compile them with BCC.  I found that the documentation 
that came with the flex archive was pretty good.  Although I haven't yet
"made" flex.exe I am hoping that I won't have too much problem. (I have
been compiling using ANSI C and all the portability flags on BCC set).

I am now looking at the source modules for byacc, and I am a bit lost.  The
documentation in the code is scarce and not easy to follow.  I accept that 
the people who made the code available are not obliged to provide good
documentation.  But I am a bit lost as to how to go about compiling this code
with all the portability considerations I have mentioned before.  The byacc
pacakage does include a byacc.exe file.  I haven't tried it out yet but again,
the porting problem will be there. 

I am hoping someone out there has had some experience with this sort of stuff.
I am relatively new to this stuff and would really appreciate all the help
I can get.

Thanks in advance.

Joydip.
-------------------------------------------------------------------------------
m912121@spectre.co.rmit.oz.au

--
_______________________________________________________________
Joydip Das 
m912121@chudich.co.rmit.OZ.AU
-----------------------------
Newsgroups: comp.lang.c
From: jlg@cochiti.lanl.gov (J. Giles)
Subject: Re: No, but strncat() is stupid (was: definition of strncpy stupid?)
Organization: Los Alamos National Laboratory
Date: Mon, 14 Dec 1992 19:09:36 GMT

In article <1992Dec11.095325.1871@falcon.aamrl.wpafb.af.mil>, bkottmann@falcon.aamrl.wpafb.af.mil (Brett Kottmann) writes:
|> In article <1992Dec10.175103.11502@newshost.lanl.gov>, jlg@cochiti.lanl.gov (J. Giles) writes:
|> > I can't simply say 
|> > 
|> >    strncat(s1,s2,N);
|> > 
|> > This would *add* N characters to s1, not limit it's total length
|> > to N.  In order to do what I want, I have to:
|> > 
|> >    strncat(s1, s2, N - strlen(s1));
|> > 
|> > Except, I can't do this either.  Previous operations on s1 may 
|> > have left it without null termination - so strlen() won't work.
|> 
|> 	It better have null termination.  strncat uses that to start storing
|> s2.

You've missed my point.  If the length of `s1' is equal to `N', there is
no room for null termination.  Therefore `s1' will not have it.  No matter,
the amount I want strncat to move in that case it zero characters.  So,
strncat() will not have to find any null termination of `s1'.  I was
pointing out the same thing you were - only one step earlier.  Since
`s1' may not be null terminated (it can't be if there's no room), then
strlen() won't work on it.  Of course, you could pretend the allocated
length was one character shorter than it actually was and insure that
there was always room for a terminating null.  That still doesn't solve
the problem that you have to do all the calculations yourself in order
to make sure that you don't run past the end : you still have to do the
redundant `N-strlen(s1)' expression.

Personally, I think that null termination is a bad idea anyway, and
when I have to do character manipulation in C, I use the mem***()
functions exclusively.  In fact, all the character variables I 
declare are structs which explicitly carry the present length, the
allocated length, and the pointer to the actual string.  I then use
string manipulation functions of my own (which use the mem***() stuff)
that automatically maintain the information in the struct.  This is
almost *always* faster than the str***() or the strn***() functions
and is certainly safer.

-- 
J. Giles
From: bketcham@stein.u.washington.edu (Benjamin Ketcham)
Newsgroups: comp.lang.c
Subject: A different C puzzle
Date: 21 Dec 92 04:07:44 GMT
Organization: University of Washington, Seattle

OK, how about this, then:

Write a program that uses every valid character exactly once.  Extra credit
depending on how much it does (eg, can it produce output?).  Partial credit
for the substantially easier problem "Write a program that uses every valid
character exactly twice.".

This is comp.lang.c, so the answer should be in C, naturally, and the "valid
character" set follows from that.

--ben
From: ben.schorr@yob.sccsi.com (Ben Schorr) 
Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.pascal
Subject: Re: Encryption algorythm/code needed...
Date: 19 Dec 92 13:53:00 GMT
Distribution: world
Organization: Ye Olde Bailey BBS - Houston, TX - 713-520-1569
Reply-To: ben.schorr@yob.sccsi.com (Ben Schorr) 

Well...more proof that GOD is a Charger Fan!

Would you believe that Miami, Denver and Houston all lose the SAME
week?  And to tl.edu!poly-vlsi!music.mus.polymtl.ca
From: CT80@music.mus.polymtl.ca (Steph)
Date: 13 Dec 92 21:32:59 GMT

In article <1992Dec8.131745.13670@ncsu.edu> jlnance@eos.ncsu.edu (JAMES LEWIS NANCE) writes:
>
>In article <1992Dec7.160128.18678@sbcs.sunysb.edu>, clane@csws2.ic.sunysb.edu (Charles F Lane) writes:
>|>
>|> >the usernames and passwords.  The code need not be extravagent...  I only
>|> >need to encryp
----
Ye Olde Bailey BBS
Houston,Texas
Node 1: 1 713 520 1569
yob.sccsi.com
Newsgroups: comp.lang.c
Subject: Re: C palindrome puzzle
From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
Date: 10 Dec 92 22:38:27 GMT
 <1992Dec3.232347.23160@csservices.Princeton.EDU> <1992Dec7.220634.8438@crd.ge.com> <1256@zogwarg.etl.army.mil>
Organization: Beckman Instruments, Inc.
Keywords: palindrome, puzzle

In <1256@zogwarg.etl.army.mil> hoey@zogwarg.etl.army.mil (Dan Hoey) writes:

>If you wanted to use 32 for '"' it would be shorter but morally
>inferior.

And wrong. '"' is 34.
--
Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
My opinions are my own, and do not represent those of my employer.
My interaction with our news system is unstable; please mail anything important.
Newsgroups: comp.lang.c
From: zzang@stat.ufl.edu (zzang)
Subject: Calling convention: C vs PASCAL
Originator: zzang@manta
Organization: University of Florida
Distribution: usa
Date: Fri, 11 Dec 92 22:57:56 GMT

Hello,
the C pushs the args from right to left onto 
the stack when calling a function.
the PASCAL pushs the args from left to right.
I was told that the C convention results in
larger as well as slower program.
(due to some cleanup work of the stack
after call??)

can someone tell me why?

Thanks very much,


-- 
Zhuo Zang[~{j0WA~}]
Department of Statistics
University of Florida            Email: zzang@stat.ufl.edu
Newsgroups: comp.lang.c
From: kaleb@jpl-devvax.jpl.nasa.gov (Kaleb Keithley)
Subject: Re: Calling convention: C vs PASCAL
Organization: Jet Propulsion Laboratory (NASA)
Distribution: usa
Date: Sat, 12 Dec 1992 01:11:22 GMT

In article <1992Dec11.225756.26780@eng.ufl.edu> zzang@stat.ufl.edu (zzang) writes:
>Hello,
>the C pushs the args from right to left onto 
>the stack when calling a function.

Correct so far...  For simplicity sake, we'll assume that all parameters
are passed on the stack.

>the PASCAL pushs the args from left to right.

Usually, but not necessarily so.  And it's Pascal, not PASCAL.

>I was told that the C convention results in
>larger as well as slower program.
>(due to some cleanup work of the stack
>after call??)

Maybe, then maybe not.

>can someone tell me why?

Because C supports a variable number of arguments, it's necessary to
push parameters in an order that places the "first" parameter in a known
place on the stack.  

This also means that in C, the "caller" must restore the stack after a
function call, because only the caller knows how many arguments were
pushed on the stack.  The "called" function or procedure can (and does
in the Pascal compilers I've used) restore the stack; because it knows
how many parameters were pushed onto it.

It's basically (no pun intended) a question of where the steps get done.
Both have to do the same thing.  Unless some compiler generates (lots of)
extra dead or no-op instructions in the process, both should be equally
fast.  Delta the efficiency of the runtime and I/O libraries.

-- 

Kaleb Keithley                               kaleb@jpl-devvax.jpl.nasa.gov

Newsgroups: comp.lang.c
From: dkeisen@leland.Stanford.EDU (Dave Eisen)
Subject: Re: Question to test general C knowledge
Organization: Sequoia Peripherals, Inc.
Date: Fri, 18 Dec 92 16:27:32 GMT

In article <1992Dec18.135841.14009@crd.ge.com> volpe@ausable.crd.ge.com writes:
>
>Actually, I prefer the more obfuscated form:
>  4["this is a test"]
>
>And ask them what the type and value is, and WHY this expression is legal.

We all know what the type and value is (well it's if type char and
has value ' ' for those who don't know), but why it is legal is
a philosphical question more than anything else. The best answer
I can think of is "because dmr fucked up." Yes, x[y] is always
*(x + y) so it can make sense if x is a pointer an y is integral *or*
vice versa, but why do this? 

I can't think of a legitimate reason why you'd want to use x[y] where 
x is an integer and y a pointer. And a compiler is certainly capable
of checking types before it replaces x[y] with *(x + y). Or is there
a reason, other than the obvious need for fodder for Obfuscated C
contests, why this construct should be in the language?




-- 
Dave Eisen                               Sequoia Peripherals: (415) 967-5644
dkeisen@leland.Stanford.EDU              Home:                (415) 321-5154
       There's something in my library to offend everybody. 
          --- Washington Coalition Against Censorship
Newsgroups: comp.lang.c
From: darcy@druid.uucp (D'Arcy J.M. Cain)
Subject: Re: user input for inter
Date: Thu, 17 Dec 1992 16:27:18 GMT
Organization: D'Arcy Cain Consulting

John.Gibney@f386.n632.z3.fidonet.org (John Gibney) writes:
> -=> Quoting Ejh@khonshu.colorado.edu to All <=-
> Ej> I shouldn't use scanf in C. Is that right? What should I use instead?
>For simplicity, I tend to use "gets()"...  you can then
>process it as a "string"or you can use the functions
>"atoi()" and/or "atof()" to turn it into numbers.  The

Don't use gets.  Use fgets and sscanf.  The problem with scanf (and for
gets) is not the syntax.  A good programmer can simply make sure he
has it right.  The problem is something the programmer has no control
over - the user.  Both gets and scanf assume that the user is going
to enter exactly what the programmer expects.  It assumes that his
cat will never step onto the keyboard or that he will never leave
a book open on the keyboard by mistake.  Use fgets (or one of the
many getline type functions posted here - I suggest mine) to get
the input and then use sscanf to pick the string apart in memory.

This is also discussed in the FAQ question 11.4.

-- 
D'Arcy J.M. Cain (darcy@druid.com)  |
D'Arcy Cain Consulting              |   There's no government
Toronto, Ontario, Canada            |   like no government!
+1 416 424 2871          DoD#0082   |
Newsgroups: comp.lang.c
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Subject: Re: user input for inter
Organization: University of Helsinki
Date: Wed, 16 Dec 1992 19:26:30 GMT

John.Gibney@f386.n632.z3.fidonet.org (John Gibney) writes:
> Ej> I hear that I shouldn't use scanf in C. Is that right? What
> Ej> should I use instead? 
>
>For simplicity, I tend to use "gets()"...  

That's right.  Avoid using one potentially dangerous function by using
one that is guaranteed to be dangerous.  

Well, I guess it is simple, in a way.  You just don't have to wonder
whether it is or isn't dangerous.  :)

--
Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
   MS-DOS, you can't live with it, you can live without it.
Newsgroups: comp.lang.c
From: jarmo@ksvltd.fi (Jarmo Raiha)
Subject: Re: Calling convention: C vs PASCAL
Organization: KSV Instruments ltd. Helsinki,Finland
Date: Sun, 13 Dec 1992 09:56:24 GMT

kdq@quest.UUCP (Kevin D. Quitt) writes:

>    A quick question to others:  It has always been "common knowledge"
>that these two things are at the heart of C (right-to-left pushing and
>the caller clearing the stack).  I've read the ANSI standard, but I
>couldn't find a mention of these things.  I assume it's got to be
>there, but where?

As far as I remember , there aren't any rules about using a stack.
In fact, you may implement a C-compiler without a stack. It just happens
that a stack fits quite well to C semantics ( and other languages
with nested scope ) ,but nobody says that you really should use a stack.

Jarmo Raiha
From: rankin@eql.caltech.edu (Pat Rankin)
Newsgroups: comp.lang.c
Subject: Re: More File read problems. Help I'm new and confused...
Date: 19 Dec 1992 19:15 PST
Organization: California Institute of Technology
Distribution: world
NNTP-Posting-Host: eql10.caltech.edu
News-Software: VAX/VMS VNEWS 1.41    

>>	   case '\'': while(j==0)
>>			    { (ch=getc(fptr)); if (ch='\'') j=1; }
> 
> Better coding style (at least more ideomatic) is
>			while (getc(fptr) != '\'') ;
> No unneeded variables used.

     This may appear to be better style than the original, but they both
have the same serious bug.  What happens if/when no matching single quote
is encountered before end-of-file?  Such code must always have [at least]
two checks, so the variable is not unneeded unless you want to replace
the empty statement with ``if (feof(fptr)) break;'' (adding ``&& !feof(...''
to the condition instead of `if' will work too).  A local variable is
bound to be more efficient (as long as it's `int' rather than `char' that
is ;-), and may or may not make the code clearer,

		Pat Rankin, rankin@eql.caltech.edu
From: kdq@quest.UUCP (Kevin D. Quitt)
Newsgroups: comp.lang.c
Subject: Re: Questions about token merging and trigraphs
Date: 20 Dec 92 18:25:21 GMT
Reply-To: srhqla!quest!kdq
Organization: Job quest  (805) 251-8210,  So Cal: (800) 400-8210

mcdonald@aries.scs.uiuc.edu (J. D. McDonald) writes:
> >What I don't understand is why so many people are so vehemently
> >opposed to trigraphs.
> 
> Because they break existing 100% correct code and are 100% unnecessary.


    Would you like to post some of the CODE that got broken?
Considering that ?? is *not* legal anywhere in C (except in comments,
strings and header names) I doubt you can do it.


 _
Kevin D. Quitt      96.37% of all statistics are made up.     srhqla!quest!kdq
Newsgroups: comp.lang.c
From: champion@cch.coventry.ac.uk (Alun)
Subject: Re: Question to test general C knowledge
Organization: Coventry University, Coventry, UK.
Date: Fri, 18 Dec 1992 15:46:11 GMT

In article <BzGoGn.A93@cck.coventry.ac.uk> champion@cch.coventry.ac.uk (Alun) writes:
~In article <1992Dec18.093717.7661@jussieu.fr> fred@trot.ibp.fr (Frederic PETROT) writes:
~~d_north@ondec.lonestar.org (David G. North, CCP) writes:
~~>Or better yet, what is the type and value of the following expression:
~~>  "this is a test"[4]
~~
~~try this one (due to a friend of mine):
~~
~~main()
~~{
~~   printf("%c", unix["abc"]);
~~}
~~
~
~Why does this print 'b' ??
~I could understand the indexing with numbers but with [unix] ??

An no longer confused individual has worked this out.
Stupid pre-processor.

Regards
  -Alun
  
-- 
  *I'm as bad as the worst - but thank God(?) I am as good as the best.*
    *People who think they know everything annoy those of us that do.*
A.Champion                |  That's an interesting point, in the sense of
(champion@uk.ac.cov.cch)  |    being very not interesting at all. - The Liar
From: ericwebb@blackwlf.gwinnett.com (eric webb)
Newsgroups: comp.lang.c
Subject: Hello??
Date: Thu, 17 Dec 92 16:40:20 EST
Reply-To: ericwebb@blackwlf.gwinnett.com (eric webb)
Organization: BlackWolf's Den (404)642-9933 v.32bis v.42bis 12/24/96/14.4

Hi.. if anyone can even see this, pls let me know.. I am wondering if I 
am actually getting out!!
 
Thanks..
 
Eric Webb

ericwebb@blackwlf.gwinnett.com


---------------------------------------------------------
  From Eric Webb:  ericwebb@blackwlf.gwinnett.com
     * Party Hard, Life's Short... *
          Feel the shockwave? - TSR
---------------------------------------------------------
Newsgroups: comp.lang.c
From: msb@sq.sq.com (Mark Brader)
Subject: Re: Questions about token merging and trigraphs
Organization: SoftQuad Inc., Toronto, Canada
Date: Sat, 19 Dec 92 08:35:28 GMT

> Actually, it's easier than that.
> You can replace, for example, "??!" with "?\?!".
> The escaped second question mark breaks up the trigraph.
> This means you can write a simple filter (or editor script) ...
> [and] apply it to any code which was not intended to be compiled as
> having trigraphs.

For example, see below.
-- 
Mark Brader, Toronto		sed -e "s;??\\([-=(/)'<!>]\\);?\\\\?\\1;g"
utzoo!sq!msb, msb@sq.com	will fix them...	-- Karl Heuer
From: chelf@lunatix.uucp (Chad Helfenberger)
Newsgroups: comp.lang.c
Subject: Re: Turbo C with built-in assembler??????
Date: 17 Dec 92 16:01:01 GMT
Organization: Lexington Public Access Unix. -KY- (606) 255-9121

In article <BzDyv8.J1F@hyperion.wright.edu> thanatos@hyperion.wright.edu (Terry Chlebek) writes:
>DON'T use the '#pragma inline' (or the -B command line option).  This is
>what tells the compiler to call TASM to process the assembly language
>stuff.  Just use 'asm {...}' for your assembly stuff and the compiler
>will use it's built-in assembler to process it.

Thanks for the tip.  I'm sure that was in the manual, but I couldn't find 
it.

>
>I just load the resident help utility (THELP).  Then you can get help
>from anywhere just by pressing the '5' key on the keypad.
>
>Terry Chlebek
>thanatos@hyperion.wright.edu

Another good suggestion.. Heh.  Thanks.

-- 
Chad Helfenberger
(chelf@lunatix.uucp)
From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
Newsgroups: comp.lang.c
Subject: Re: Questions about token merging and trigraphs
Date: 20 Dec 92 23:27:55 GMT
Organization: McGill Research Centre for Intelligent Machines

In article <mcdonald.613@aries.scs.uiuc.edu>, mcdonald@aries.scs.uiuc.edu (J. D. McDonald) writes:
> In article <mcdonald.610@aries.scs.uiuc.edu> mcdonald@aries.scs.uiuc.edu (J. D. McDonald) writes:

>> BECAUSE OF [trigraphs], it is **IMPOSSIBLE** to write code that is
>> both K&R I and ANSI!!!

Not at all.  Just impossible to write code involving a trigraph
sequence in a string literal.

> I'll retract that statement. It's not impossible, due to the presence
> of octal escapes in strings

You can't use an octal escape to represent a character without tying
yourself to the character code (eg, EBCDIC) in question - which is the
whole point of adding the stupid things in the first place.

					der Mouse

			    mouse@larry.mcrcim.mcgill.edu
Newsgroups: comp.lang.c
From: adesai@iastate.edu (Alpaa Desai)
Subject: unbuffered getchar().
Organization: Iowa State University, Ames IA
Date: Mon, 14 Dec 1992 15:59:36 GMT

A while ago some one had asked if there was a way to get unbuffered getchar().
I saw a couple of solutions for it which were I thought a bit complicated.
Anyway, I found a simple one in Kernighan and Ritchie (second edition) page171.
They have given the entire function getchar().


Newsgroups: comp.lang.c
From: jar@solva.ifi.uio.no (Jo Are Rosland)
Subject: Re: Question to test general C knowledge
X-Md4-Signature: ebf6c992255945e53aafe61d5a5cb641
Organization: Dept. of Informatics, University of Oslo, Norway
	<24406@alice.att.com>
Date: Mon, 14 Dec 1992 00:09:06 GMT
Originator: jar@solva.ifi.uio.no

In article <24406@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
   Part 1: Write a program to do a binary search.
   [...stuff deleted...]

   Part 2: Does your program work?  How do you know?
   That is: either prove it works or write a second
   program to test it.
   [...rest deleted...]

Do I get to bring my copy of "Programming Pearls" (or was that one in
"More Programming Pearls")? :-)

I totally agree with Mr. Koenig.  When hiring programmers there are a
lot of things that should matter more than fluency in some particular
language.  Experience and competence--both within the problem domain
and in general programming issues--are probably more important.
Becoming a master C programmer from scratch probably takes years, but
is that really what's needed?  Becoming a _useful_ C programmer takes
a lot shorter, at least if you have those other qualifications in
place.

Btw, Jon Bentley's books mentioned above should be standard reading
for all (C) programmers, and they don't even mention C with a word.
Eg. the part about "informal" program verification is pure gold.

--
Jo Are Rosland
jar@ifi.uio.no
Newsgroups: comp.lang.c
From: runner@bluemoon.use.com (Jason Petry)
Subject: Re: Question to test general C knowledge
Organization: Blue Moon BBS ((614) 868-998[024])
Date: Sun, 13 Dec 92 23:26:18 EST

volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe) writes:

> |> 
> |> >>> 	int i = 2;
> |> >>> 	i = ++i;

> [..discussion about value of i deleted ..]

> You miss the point. One of them will happen first. Does the second
> one constitute a modification? Look at it this way: When the "++" operator
> is evaluated, the machine throws a card up in the air with the words
> "put 3 in i" on it. That's the side effect associated with the "++" operator.
> And since the value of the "++i" subexpression is "3", when the "=" 
> operator is evaluated, the machine throws up another card in the air with
> the words "put 3 in i" on it. The side effects are applied in the order
> in which they fall. But since both side effects do the same thing, is 
> the object really being "modified" again when the second card falls?
> 
> A clearer example illustrating the issue I raise would be the following:
> 
>     i = (i = 4)
> 
> Is the behavior of that expression undefined? Maybe, depending on
> the definition of "modify". Is any reasonable implementation likely
> to leave anything other than 4 in i? I doubt it. 
> 
> |> 
> |> 					der Mouse
> |> 
> |> 			    mouse@larry.mcrcim.mcgill.edu
> 
> -- 
> ==================
> Chris Volpe
> G.E. Corporate R&D
> volpecr@crd.ge.com

The original question can be solved without considering any sort of 
definition of "modify." The problem concerns the value of expressions and 
when side effects take place. The VALUE of the expression ++i is i's 
current value plus 1, in this case 3. The SIDE EFFECT of the expression is 
to increment the value originally stored in i and store it back into i. 
Because the = operator associates left to right, ++i is definitly 
evaluated first, but the side effect isn't guarunteed to take place until 
a sequence point occurs, in this case after the = operator is evaluated. 
I'm not sure, I don't have a copy of the ANSI C standard handy, but a 
perverse, but nevertheless compliant result value for i after the 
statement is executed might be 4 by this logic:
    1) evaluate ++i, and get 3
    2) evaluate i = 3, causing a sequence point and putting the value of 3
       in i
    3) perform the "postponed" side effect and increment i, storing the 
       same back into i, producing 4.
Whether this is legal or not depends on exactly how the ANSI C stanard 
words the side effects of the ++ preincrement operator. In any case, I 
admit that no sane implementation on standard hardware would produce any
value for i other than 3.

                                  Jason Petry
                                  runner@bluemoon.use.com
                                  runner@bluemoon.rn.com


Newsgroups: comp.lang.c,comp.lang.c++