HDTenEightyP/NetNews huggingface dataset:
From: davis@pacific.mps.ohio-state.edu ("John E. Davis")
Subject: generic interpreter
Reply-To: davis@amy.tch.harvard.edu  (John E. Davis)
Organization: "Dept. of Physics, The Ohio State University"
Date: Mon, 17 Aug 1992 15:53:56 GMT


[ I posted this to comp.sources.wanted but it is not clear to me who reads
  such a group; I suspect that I will do much better here. ]
        
Hi,

   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.

   I wrote something like this for a stack based calculator a year ago. But
since I wrote it from scratch I suspect it is not very elegant and it is
probably slow. The calculator lets the user to define variable and functions.
This calculator also allows looping and conditional branching.  For exaample,
here is the code for the factorial function in the calculator language:

( dup 1 -  ;; entry stack consists of [n-1, n,...]

      {
         dup 2 exchn   ;; bury a copy for later pulling product to top
         *
         exch          ;; perform product and exchange for buried copy
         1 -           ;; decrement and loop until this goes 0 or negative
         
      } while          ;; while always removes top element upon exiting
) !


The syntax for the function definition is

   ( statement_1 statement_2 ... statement_n ) function_name

 (By the way, if there is want the source code for this calculator, let me know
and I will post it.  The C soource is only 650 lines long.)

Thanks,
--
     _____________
#___/John E. Davis\_________________________________________________________
#
# internet: davis@amy.tch.harvard.edu
#   bitnet: davis@ohstpy
#   office: 617-735-6746
#
From: billb@crpmks.uucp (Bill Bochnik (Info Systems))
Newsgroups: comp.lang.c
Subject: Re: POWER OF LARGE NUMBERS
Date: 19 Aug 92 14:29:21 GMT
Reply-To: billb@crpmks.UUCP (Bill Bochnik (Info Systems))
Organization: Ciba-Geigy Corporation

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

-- 
Bill Bochnik			| It's hard to be a James Bond in an Abbott
Systems Analyst 		|	and Costello world.
Ciba-Geigy Corporation		| Signed and sealed, they deliver oblivion.
philabs!crpmks!billb		| It's worse than that, he's dead Jim.
Newsgroups: comp.lang.c,comp.programming
From: andy@research.canon.oz.au (Andy Newman)
Subject: Re: A LITTLE BRAINTEASER...
Organization: Canon Information Systems Research Australia
Date: Thu, 13 Aug 1992 06:37:48 GMT

aet@mullian.ee.mu.OZ.AU (bert thompson) writes:
>hi!
>
>i have a small problem that's been bugging for a while now.
>
>here's a program that reverses input from the keyboard:
>
>main()
>	char ch = getchar();
        ^^^^^^^
	NOT AGAIN!
>	if (ch == EOF)
>		;
>	else {
>		main();
>		putchar(ch);
>	}
>}
>
>the interesting thing about the program is that it uses no data structures
>(structs, arrays, pointers, etc..), to do its thing. everything is thrown
>on the stack.

Another interesting thing about this program is that its broken!

So how may machines does this work on? Want to run it on something
without memory protection and let the little sucker recurse and
recurse...

If that sounds cryptic remember....

	getchar() returns an *int*, you char may not be able to store
	EOF (which is v.often a -ve number).

Should we start a FFP (Frequently Found Problems?)
-- 
Andy Newman (andy@research.canon.oz.au)		"int - God's own type"
Newsgroups: comp.lang.c,comp.programming
From: matthys@cs.ruu.nl (Matthys Kuiper)
Subject: Re: A LITTLE BRAINTEASER...
Date: Thu, 13 Aug 1992 07:23:29 GMT
Organization: Utrecht University, Dept. of Computer Science

In <17063@ulysses.att.com> kpv@ulysses.att.com (Phong Vo) writes:

>In article <1992Aug12.103013.4999@cs.ruu.nl> matthys@cs.ruu.nl (Matthys Kuiper) writes:
>>In <aet.713608023@munagin> aet@mullian.ee.mu.OZ.AU (bert thompson) writes:
>>>is it possible to write a program that reverse the order of input lines
>>>without using data structures.
>>>the rules of the game are you can use anything but data structures, or more
>>>specifically you cannot use the heap.
>>
>>Below is my solution in Pascal. The translation of this program
>>into C is horrible to read and not included in this posting.
><code deleted>
>
>The code probably isn't right either since functions such as readln() may very well
>does some form of dynamic memory allocation to store the lines.
No, readln(input) just skips till the end of a line; it does not have to store any
of the skipped characters.
To solve the problem you must assume something
about the heap usage of basic I/O routines. I assume that reading and/or skipping
basic characters does not use the heap.

-- 
Matthijs F. Kuiper   Department of Computer Science
kuiper@cs.ruu.nl     Padualaan 14/ Postbox 80.089 
		     3508 TB Utrecht/ The Netherlands
Newsgroups: comp.lang.c
From: jeffrey@squid.tram.com (Jeffrey L Bromberger)
Subject: Re: Optimizing code for tests
Organization: Tramway Unix Systems
Date: Wed, 12 Aug 1992 15:31:58 GMT
Keywords: CC GCC f77

In article <1992Aug11.162502.8848@squid.tram.com> I wrote:

>with the random number generator; it may be fast, but 50% of my time
>is spent there...

So far, all I have gotten in reply is "50%?!?!?"  I have gotten
comments like:

Don't use rand()      I already don't
Use *this* one        I've got a nice one, thanks
It should be small    So it is...

Maybe I'll have to explain.  The generator is not at fault.  The
problem is that it gets called nearly 2^15 times for each simulated
"event".  Make that now 30,000 events repeated over 30,000 simulated
years (for a small run) and you're talking about (Carl Sagan Mode ON)
Millyuns and Millyuns :-)
of calls to the generator.  Prof tells me it's the fastest of all
routines, clocking in at 0.04msec per run.  It still adds up.

One suggestion I'd like to know more about, but have no idea where to
follow it up is "make the generator in-line code".  Any pointers on
this idea?  Does it just involve moving a copy of the generator code
everywhere it's called (as opposed to having it's own function)?

>What I am trying to optimize are my comparisons.
>So, is it really worth my while to worry about which path is fastest?

Honestly, everyone (except for one passing remark) seems to be
avoiding the question I posed.  Is the compiler really doing anything
different speed-wise if the test passes or fails?  Should I just give
up on this point?  Stick to it just for the sake of coherent style?

Thanks!

j
-- 
Jeffrey L. Bromberger ------- System Manager ------- Tramway Unix Systems
jeffrey@squid.tram.com      Anywhere!{van-bc,limbic,icus}!tram!jeffrey
Newsgroups: comp.lang.c
From: rsahu@triton.unm.edu (Raikanta Sahu)
Subject: Another simple C question
Date: Sun, 23 Aug 92 03:14:59 GMT
Organization: University of New Mexico, Albuquerque
Distribution: unm

Here is another problem I am facing in compilation with our RISC compiler
in triton @ unm.
------------------------------------------------------------------------
#include <stdio.h>

main(argc, argv)
int argc ;
char *argv[] ;
{

  char infile[50] ;

 if(argc == 1)
 {
    printf("Give input file : ") ;
    scanf("%s", infile) ;
  }
  else
    infile = argv[1] ;

 getinput(infile) ;

}
------------------------------------------------------------------------

Here is the message of the compiler : 



ccom: Error: check.c, line 16: illegal lhs of assignment operator
          infile = argv[1] ;
      ---------------------^

Isn't it legal to assign a pointer to a character to a character array ?
Somebody mentioned to me that RISC is not an ANSI compatible compiler. Is
that so ?

-sahu,r 
Newsgroups: comp.lang.c
From: udalski@astro.Princeton.EDU (Andrzej Udalski)
Subject: Memory alignment of struct elements
Originator: news@nimaster
Organization: Princeton University
Date: Wed, 12 Aug 1992 13:31:32 GMT

I am writing the software for a big database and the space is very
important. If I try to use a 

struct { char ch ; float f }

the compiler (both in SunOS 4.0.1 and Interactive SYSVR3) allocates
8 bytes for it, starting the "f" element at fifth byte of the structure.
This makes both reading and writing such records from/to a binary database 
file (consisting of 5-byte-long records) very inconvinient, requiring
a declaration of character array of 5 bytes and using "memcpy()". Is there 
a way to force the compiler to align the struct elements following their 
true length?

Any help will be appreciated.

Andrzej Udalski,
Warsaw Univ. Observatory,
Warsaw, Poland.


Newsgroups: comp.lang.c
From: ekender@vax.clarku.edu
Subject: Request for Structure Help !
Organization: Clark University
Date: 20 AUG 92 20:52:57 GMT

    I would appreciate it if anyone could point me in the right direction. I have been assigned a mailing list problem. The strange part (to me) is that the prof wants me to use the following structure:
   typedef struct {
         int count;
         char string[0];
         } string_t;

Why would you use this type of typedef to store the character string data? The
program also needs to use an array of pointers to structures, mabey this will
help. Any help will be appreciated. Thanks, Eric. (EKENDER@VAX.CLARKU.EDU).
From: lepine@sirius.gsi.fr (Thibault Lepine)
Newsgroups: comp.lang.c
Subject: looking for TERSE compression algorithm
Date: 19 Aug 92 22:51:20 GMT
Organization: GSI Generale de Service Informatique
X-Newsreader: Tin 1.1 PL4


   I am looking for an compression algorithm named TERSE. We are writing
   a file transfer with an AS/400 and this method can be used with a macro
   instruction. 
    any idea or suggestions will be welcome!
		  T.lepine


		  e-mail: lepine@gsi.fr
From: pkeddie@axion.bt.co.uk (Paul Keddie)
Newsgroups: comp.lang.c
Subject: sort routines
Date: 13 Aug 92 16:04:24 GMT
Reply-To: pkeddie@axion.bt.co.uk (Paul Keddie)
Organization: British Telecom Research Labs


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. 

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

Cheers Paul
Software Maintenance Group, Software Technology Division, BT
Research Labs, Martlesham Heath, Ipswich, IP5 7RE, UK
E-mail:  pkeddie@axion.bt.co.uk
Phone:  +44 473 649154
Fax:    +44 473 643019
From: tim@shovel.Prime.COM (Tim Cantin)
Newsgroups: comp.lang.c
Subject: Re: Knight's tour
Date: 12 Aug 92 17:44:16 GMT
Followup-To: comp.lang.c
Organization: Prime Computer R&D

In message <1992Aug12.160827.11332@seas.smu.edu>, pedersen@seas.smu.edu (Ted Pedersen) writes:

> Organization: SMU School Of Engineering and Applied Science
> Anyone out there have any nice Knight's Tour code (or know where it can be readily obtained)?

School project you don't feel like coding, eh Ted? *grin*
-T

-- 
#include "stddisclaimer.h"
/* Tim Cantin          {uunet, csnet-relay}!primerd!tim || tim@s35.prime.com
   Prime Computer Inc. 10-21, 500 Old Conn. Path, Framingham, MA 01701 (USA) */
flames > /dev/null 2>&1
Newsgroups: comp.lang.c
From: werner@getrz.gez.ch (Werner Schweizer)
Subject: c compiler
Organization: Grapha Electronic AG, Zofingen
X-Newsreader: Tin 1.1 PL4
Date: Tue, 18 Aug 1992 09:46:03 GMT

[ Article crossposted from comp.os.coherent ]
[ Author was Christof Frey ]
[ Posted on Fri, 14 Aug 1992 14:33:50 GMT ]

tsecfr@getrz.gez.ch (Christof Frey) writes:
: Is ther a ANSI-C compiler available for coherent ?
: 
: Thanks
: Chris

Please reply by e-mail


--

Grapha Electronic AG            Werner Schweizer        +41 62 504 356
Untere Bruehlstrasse 15         werner@gez.ch
CH-4800 Zofingen
Switzerland

Newsgroups: comp.lang.c
From: tim@rcsl.demon.co.uk (Tim Frost)
Subject: INCLUDE file not found
Distribution: world
Organization: Roundhill Computer Systems Limited
Date: Thu, 13 Aug 1992 22:58:18 +0000


In article <br.pct.14.713737167@RLG.Stanford.EDU> br.pct@RLG.Stanford.EDU writes:

>  Is there a BUG in processing nested include files in C600 ? Thanks for any
>  help

A common reason for failure to include nested files is that the FILES= value
in CONFIG.SYS is set too low.  If you do not have this line, the default
value is 8, which is way too low.


:::: Tim Frost :::::::::::::: Roundhill Computer Systems Limited ::::
:::::::::::::::::::::::::::::::::::: Marlborough SN8 1SU England ::::
:::: tim@rcsl.demon.co.uk :::::::: +44 (0) 672 84 535 (fax: 525) ::::
From: linden@positive.Eng.Sun.COM (Peter van der Linden)
Newsgroups: comp.lang.c
Subject: Pointer/address reluctance
Date: 13 Aug 1992 14:46:34 GMT
Organization: Sun Microsystems, Mt. View, Ca.
NNTP-Posting-Host: positive

Can anyone explain the reluctance that some of the experts here
have in equating "pointer" with "address"?

The ANSI C standard displays no such inhibition, e.g. Section 3.4
line 32 mentions "An address constant is a pointer to ..."



--
linden@eng.sun.com|| P. van der Linden and his uncustomary theories.
Go Giants!! Don't || When solving a "panic" you must first ask yourself what you
stop at Florida...|| were doing that could possibly frighten an operating system.
From: bsullivn@sc.sni.ie (Bryan O'Sullivan)
Newsgroups: comp.lang.c
Subject: Re: generic interpreter
Date: 18 Aug 92 09:33:18 GMT
Article-I.D.: sc.162
Reply-To: bryan@sc.sni.ie
Organization: Siemens-Nixdorf Software Development Centre, Dublin
X-Newsreader: Tin 1.1 PL3



davis@pacific.mps.ohio-state.edu (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.

Try taking a look at either John Ousterhout's (ouster@sprite.berkeley.edu)
Tcl language or Guido von Rossum's (guido@cwi.nl) Python.  The former looks
a little like a cross between C and LISP, and seems to be very nicely
built.  I've only read a couple of papers on the latter, and it doesn't
appeal to me quite as much.

	-- Bryan

-- 
Bryan O'Sullivan                                             +353-1-767551 x225
Siemens-Nixdorf Informationssysteme AG                          bryan@sc.sni.ie
Software Development Centre                    "Theory like mist on eyeglasses.
Dublin                                          Obscure facts." -- Charlie Chan
Newsgroups: comp.lang.c,comp.sys.ibm.pc
From: cblaise@moose.uvm.edu.UUCP (Chris Blaise)
Subject: Re: Using ANSI.SYS codes from C?  (Turbo)
Originator: cblaise@moose.uvm.edu
Organization: University of Vermont -- Division of EMBA Computer Facility
Date: Thu, 20 Aug 1992 19:30:06 GMT

From article <1992Aug18.013912.12547@cs.umb.edu>, by cteague@ra.cs.umb.edu (Charles F. Teague II):
> 
>   Is there any way to use ANSI.SYS escape sequences from C?  (TurboC++v1.0)
> I'm hoping to use this just to get a simple coloring of my text, without
> using conio.h, and staggering cprintf()s with textcolor() and/or textattr().
> 
>   I've tried several different output fns, and none of them seem to be able
> to do what a simple echo command in a batch file can do:  change the text
> color by using ansi codes.  If anyone can help me out, I'd appreciate it.
> 


	Yes, it is possible.  I created my header file using Qedit,
> character (control-P <esc>).  My ANSIVT.H file looks something like:

 #define CURSORUP(X)    "<esc>["X"A"
 and other VT escape codes...

 Color works out like:

 #define RED 		"<esc>[31m"
 
 Works out real slick....
 
 TTYL
 Chris

simply because it was easier to make the <esc
Xref: sparky comp.lang.c:12652 comp.std.c:2490
From: johnl@iecc.cambridge.ma.us (John R. Levine)
Newsgroups: comp.lang.c,comp.std.c
Subject: Re: strcpy implementation question
Date: 22 Aug 92 13:21:32 GMT
Distribution: comp
Organization: I.E.C.C.

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

In my copy of the C standard, section 4.1.1 says "a string is a contiguous
sequence of characters terminated by and including the first null
character."  Section 4.11.2.3 says "The strcpy function copies the string
pointed to by s2 (including the terminating null character) into the array
pointed to by s1."

But it doesn't say "(including the terminating null character and any other
garbage convenient for the compiler implementer)".  You have to stop at the
null byte.

-- 
John R. Levine, IECC, POB 349, Cambridge MA 02238, +1 617 492 3869
johnl@iecc.cambridge.ma.us, {ima|spdcc|world}!iecc!johnl
Re-elect Vice President Potatoe-Head !
From: u8800914@cs.uow.edu.au (Mohammad Salim Olime)
Newsgroups: comp.lang.c
Subject: help REAL TIME CLOCK INTERRUPT
Date: 18 Aug 92 04:39:38 GMT
Organization: Dept of Computer Science, Wollongong University, Australia

For simulation of an ATM link between to IBM-PC/AT I need to generate
packets(pay load)  in real time using Turbo C under MS-DOS .
Interrupt 08h ie the clock tick with a frequency of 18.2 Hz is not 
fast enough. In C User Journal Dec 1991  I found an article
by Paul A. Cornelius titled "Using 1KHz Interrupts on AT CLones"
He discusses a method for generating interrupts at a rate of 1KHz
using the Real Time clock interrupt (70h) which can be enabled 
through BIOS INT 15h, function 83h.
Unfortunately the  code he has given are written in Zortech C++
I have quite few problems translating it to TURBO C .
The problems are basically to do with the way Interrupt Service
Routines are written in Turbo C.(Stack is not automatically set
for ISR ).
I would appreciate if someone who came across a Turbo C code for
 such thing, or even knows where I can get help, response to this
 CRY FOR HELP posting either directly or via this  group.
 Thanks in Advance.
From: dave@cs.arizona.edu (Dave Schaumann)
Newsgroups: comp.lang.c
Subject: Re: POWER OF LARGE NUMBERS
Date: 16 Aug 92 05:21:57 GMT
Reply-To: dave@cs.arizona.edu (Dave Schaumann)
Organization: University of Arizona

In article <thompson.713734408@daphne.socsci.umn.edu>, thompson@atlas (T. Scott Thompson) writes:
>u8705957@cs.uow.edu.au (Hitesh Sanghvi) writes:
>
>>	Does any one know how to raise power of possibly 100 digits 
>>to possibly 100 digits. Any algorithm or code will be appriciated.
>
>>Example >(1234367463746464647464...up to 100 digit)**(647254627463048736...up to 100 digit)
>
>The order of magnitude of the solution to this problem is 
>
>              10**(10**102)
>
>which is a ridiculously large number.

Yah.

>Is there any hope of solving this?

Only if you're willing to give up most of the significant digits.
But it's certainly within the bounds of imagination to have a
program that could do something like

  google_t a, b ;

  a = make_google( 10, make_int(100) ) ;
  b = google_mult( a, a ) ;

At this point, the value of `b' could be expressed as

  make_google( 10, make_google( 10, make_int(10) ) ) ;

Of course, using C++ would make certain aspects of this easier...

-- 
You're traveling through another dimension -- a dimension not only of sight and
sound but of mind. A journey into a wonderous land whose boundaries are that of
imagination.  That's a signpost up ahead: your next stop: the Twilight Zone!
From: gregh@alw.nih.gov (Gregory Humphreys)
Newsgroups: comp.lang.c
Subject: Re: POWER OF LARGE NUMBERS
Date: 20 Aug 92 14:01:51 GMT
Organization: National Inst. of Health, DCRT, CSL

In article <1992Aug19.142921.27592@crpmks.uucp>, 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.
|> 
|> -- 
|> Bill Bochnik			| It's hard to be a James Bond in an Abbott
|> Systems Analyst 		|	and Costello world.
|> Ciba-Geigy Corporation		| Signed and sealed, they deliver oblivion.
|> philabs!crpmks!billb		| It's worse than that, he's dead Jim.

There's the simple one from the taylor series for (arctan?):

P I         1   1   1   1   
---  =  1 - - + - - - + - - ...
 4          3   5   7   9    

Don't yell at me if ther's a better way, I know there is.  This converges really slowly, tho.  The best way is to Use Mathematica:



N[Pi,Num_Digits]

-- 
Greg Humphreys    |  "Playing not to win is like sleeping with your 
gregh@alw.nih.gov |  sister - sure, she's a great piece of tail, 
                  |  and she's got a bag full of goodies, but it's 
(301) 402-1817    |  just plain illegal."  -Charlie Sheen, "Hotshots"
From: U56779@uicvm.uic.edu
Newsgroups: comp.lang.c
Subject: spin the wheel
Date: 17 Aug 92 18:26:15 GMT
Organization: University of Illinois at Chicago

Can anybody tell me a code in c to spin the wheel after drawing it.
thanks...
From: lou1347@cucs17.cs.cuhk.hk
Newsgroups: comp.lang.c
Subject: Problem on getting video ram data
Date: 12 Aug 92 09:04:28 GMT
Organization: Dept of Computer Sci, CUHK

In last message says that:

> Leo> I wanna write a program which load the data in video ram
> directly in PC.
> 
> Leo> void release(void)
> Leo> {
> Leo>   unsigned int count=0,vcount,code,inused;
> Leo>   unsigned char far *video;
> Leo>   while(count<usedno)
> Leo>   {
> Leo>     inused=0; video=(char far *)0xb8000000;
> Leo>     for(vcount=0;vcount<2000;vcount++)
> Leo>     {
> Leo>       code=(*video++)+(*video++ & 8)?256:0;
> 
> According to "The C Pocket Reference" by Herbert Schildt,
> Osborne McGraw-Hill, ?: operator's presedence is lower than
> +'s, so code is either 256 or 0.

Thanks, but I still in trouble.  I wrote another test program like that:

#include <stdio.h>
main()
{
char a[]={10,20},*video;
int code;
video=a;
code=(*video++)+((*video++ & 8)?256:0);
printf("%d\n",code);
}

The bracket is added.  I expect the result to be 10.  But It give 276!!
(If I split it into two lines, the result will be 10).

I think the problem is that the operand after '+' do first so that the 
first *video got 20 and second *video got 10 which give the result 276.

But I know that in C,'+' sign will do from left to right.  ( I also write a
program to test it and it is true )  So what is the result?

I am using turbo C 2.0.

Regards
Newsgroups: comp.lang.c
From: alpha@wyvern.twuug.com (Joe Wright)
Subject: Re: Pointer/address reluctance
Organization: Box 68621, Virginia Beach, 23455
X-Newsreader: Tin 1.1 PL4
Date: Fri, 14 Aug 1992 17:32:55 GMT

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"?
: 
: The ANSI C standard displays no such inhibition, e.g. Section 3.4
: line 32 mentions "An address constant is a pointer to ..."
: 
I agree with Peter.  A pointer value is the address of an object.
This 'address' is abstract, not 'actual' necessarily.  In the normal
context of a C program nobody knows or cares how the bits are set
on the cpu's (or mmu's) hardware address bus.  The 'address' in C
context means 'where it is' as opposed to 'what is it'.  I have
no problem using 'address of' and 'pointer to' interchangably in
the value context.  Flames ON!
-- 
Joe Wright  alpha@wyvern.twuug.com    
Newsgroups: comp.lang.c