HDTenEightyP/NetNews huggingface dataset:
From: martin@mwtech.UUCP (Martin Weitzel)
Newsgroups: comp.lang.c,comp.programming
Subject: Re: Processing arguments...Need suggestions
Keywords: data-driven
Date: 12 Oct 92 17:47:40 GMT
Reply-To: martin@mwtech.UUCP (Martin Weitzel)
Organization: MIKROS Systemware, Darmstadt/W-Germany

In article <1992Oct8.163318.12167@athena.mit.edu> scs@adam.mit.edu (Steve Summit) writes:

[details about benefits of using data structures in place of code deleted]

>This lesson (that it's often
>better to embed requirements in data rather than in code) is an
>old one, not as well known as it should be, and one which even
>though I think I know well I'm still finding new ways to apply.

Like Steve I strongly recommend the approach of choosing a program
structure that closely models the problem's specification.  If this
specification is best described in (some) table(s) - fine, use
initialized array(s) of structs and an interpreter (which might seem
a bit complicated the first time you have to write it, but it stays
invariant later when the specification changes).  This first version
will  - at least - be useful as a prototype(*).

Other advantages with this approach is that (with a little more effort)
the table may be initialized when the program starts up, so that it can
satisfy changing requirements (probably not applicable to the originally
posted question).

Finally, if you have a table and an interpreter and you recognize that
this solution is too slow (I doubt it will bee too slow in 99% or more of
all cases, but nevertheless), it's often not so difficult to change the
interpreter so that it - according to the table - emits C-Source-Code
which solves the same task faster.  (Possibly this source contains lots
of goto-s but that shouldn't be an issue in machine generated code.)

Further readings I can recommend on that topic are the books by Jon Bentley:

	- Programming Pearls
	- More Programming Pearls

(Though the topic in question is only discussed in some chapters, it's
worthwhile to read the books cover to cover.)

*: I appreciate very much to have a prototype with a simple algorithm which
I can check for "correctness" more or less by (visual) inspection.  If I
later have to code an "improved" version of this program or function,
together with some generator program that produces random test data the
prototype version helps much to test the improved version, simply by
comparing the output of the both.
-- 
Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83
Newsgroups: comp.lang.c
From: msr52148@uxa.cso.uiuc.edu (Shepard)
Subject: Returning an array from a function -> How to?
Organization: University of Illinois at Urbana
Date: Sat, 10 Oct 1992 22:06:50 GMT

I am fairly new to C, and I want to write a function that returns an array. 
I would like to avoid passing in pointer to an empty array and modifying it
that way.  I need one function that generates a table of integers dependent
on an string/array of characters which is passed in as an argument.  I've 
tried every arrangement of pointers and definitions I can think of, but nothing
seems to work.  What I'm aiming for is something like this:

int maketable(char *string)
{
   int table[xxx];
   .
   .
   .
   return (table);
}

main()
{
  int maintable[xxx];

  maintable=maketable("TestString");
}

I'm sure this must be possible somehow, but I've spent the past two days 
messing with pointers to this and that and nothing seems to work.  Any
suggestions?  Thanks in advance!

			Mike Root
			msr52148@uxa.cso.uiuc.edu
Newsgroups: comp.lang.c
From: jutta@opal.cs.tu-berlin.de (Jutta Degener)
Subject: Re: multidimensional arrays as parameters
Organization: Techn. University of Berlin, Germany
Date: Fri, 16 Oct 1992 17:28:35 GMT

hartman@ulogic.UUCP (Richard M. Hartman) writes:
> I generally write a test program that defines and initializes a
> 5by5 array of int then walk an int* through from the start,
> printing the values as I go.  You'll either see all the values
> in row 1, then row 2, etc or all the values in column 1, column 2,
> etc.

If you see all the values in column 1, then the values in column 2,
the next thing you should see is either your vendor or your optician.

   "Elements are stored by rows, so the rightmost subscript,
    or column, varies fastest as elements are accessed in
    storage order." 
						K&R II, P. 112

(I do admit writing such programs, too, but that was because I
could never remember what "row" and what "column" is, especially 
when programming with curses, where it's "LINES" and "COLS" in
the environment, but "rows" and "columns" or "cols" (but never
lines) in the stty(1) interface.)

Jutta
Newsgroups: comp.lang.c,comp.programming
From: rick@opus.alf.dec.com (Rick Silverstein)
Subject: Re: Processing arguments...Need suggestions
Keywords: data-driven
Reply-To: rick@opus.alf.dec.com (Rick Silverstein)
Organization: Digital Equipment Corporation
Date: Thu, 8 Oct 1992 20:28:21 GMT


Thanks Steve.

The idea I ended up using hit me like a brick as I was crawling into bed last 
night.

Each possible argument had its own bit.  As each argument was processed by
getopt(), I'd set the bit.  

I also had a variable per argument (there were 9 of them) which was initialized
to the OR'ing of all the bits which corresponded to the arguments that were
ILLEGAL with this argument.  Then to check for legality, all I had to do was
AND the bits representing the currently set arguments with the bits representing
the illegal arguments.  If the results was not zero, then the combination of
arguments was illegal.

It took about 15 minutes to program and if the rules ever change, the code
is easy to change.

Rick
Newsgroups: comp.lang.c,comp.lang.c++,comp.os.msdos.programmer
From: fjh@cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: [Stack Overflow] How do I find cause using Turbo Debugger?
Organization: Computer Science, University of Melbourne, Australia
Date: Sun, 11 Oct 1992 00:33:56 GMT

ccsmh@gdr.bath.ac.uk (Mark Harding) writes:

>My program recently bombed out with a 'Stack Overflow!' message on the screen.
>I have stopped it doing so by increasing _stklen but I'd really like to
>find the point in my program that caused the overflow in the first place.
>
>Can this be done easily? Any suggestions welcome.

Compile with stack checking on, and start up your program in the debugger.
Examine the assembly for any of your functions; at the very start, there
will be a check to see whether the stack has overflowed or not, and if
so, it jumps to the stack overflow handler. Note the name or address
that it jumps to, and set a break-point there. Run your program, and
when your break-point is triggered, you can examine the call stack
to see which function calls were responsible.
From: mjd@saul.cis.upenn.edu ("[*] Angel of Eggs")
Newsgroups: comp.lang.c
Subject: Re: Productivity of a C programmer ?
Date: 13 Oct 92 17:58:47 GMT
Article-I.D.: saul.MJD.92Oct13135847
Organization: Eaters of Wisdom
In-reply-to: smr@pki-nbg.philips.de's message of 12 Oct 92 12:11:24 GMT

In article <smr.718891884@hitkw14> smr@pki-nbg.philips.de (Stephen Riehm) writes:
   >  Er, interfering management.  Maybe giving them a copy of the Tao of 
   >Programming with the Management section highlighted would help.  |-)

   Would this happen to be in form suitable for posting?? I have heard
   about it before but never actually seen a copy. Anyone care to post??


    _The Tao of Programming_ is COPYRIGHT COPYRIGHT COPYRIGHT 1987 by
Geoffrey James, so please DON'T post.

    It is available from InfoBooks, POB 1018, Santa Monica CA 90406, for
$7.95.
--

                And for to se, and eek for to be seye
Mark-Jason Dominus 	  			    mjd@central.cis.upenn.edu
From: 6500msd@ucsbuxa.ucsb.edu (Michael D'Errico)
Newsgroups: comp.lang.c
Subject: Re: Returning an array from a function -> How to?
Date: 11 Oct 92 21:28:58 GMT

In article <runeh.65.718760603@dhhalden.no> runeh@dhhalden.no (RUNE HALFDAN HOLST HUSEBY) writes:

  ]In article <BvxErG.MCA@news.cso.uiuc.edu> msr52148@uxa.cso.uiuc.edu (Shepard) writes:
  ] ]
  ] ]I am fairly new to C, and I want to write a function that returns an array. 
  ] ]I would like to avoid passing in pointer to an empty array and modifying it
  ] ]that way.  I need one function that generates a table of integers dependent
  ] ]on an string/array of characters which is passed in as an argument.  I've 

  ]Try this:

  ]int maketable(char *string)

This should be
int *maketable(char *string)

  ]{
  ]  int *table;
  ]
  ]  /* you need the create space on the global heap */
  ]  table = (int *) malloc(size_of_array * sizeof(int));
  ]  if(table == NULL)
  ]  {
  ]  /* an error has occured */
  ]    return ERROR
  ]  }
  ]  .
  ]  .
  ]  .
  ]  return table;
  ]}
Newsgroups: comp.lang.c,comp.compilers,comp.unix.i386,comp.windows.x
From: cs__sjh@selway.umt.edu
Subject: ANSI C Compiler, Debugger, X testing for Interactive UNIX 3.0?
Reply-To: cs__sjh@selway.umt.edu
Organization: University of Montana
Date: Tue, 13 Oct 1992 01:11:50 GMT
Keywords: C, question, comment

Hi, We're developing Motif programs on 386 machines running Interactive
UNIX 3.0 and MetroLink's X11R4 and R5.  We have been using the K&R
compiler that was supplied with Interactive UNIX for the past two years.
However, the project is very big and really getting out of hand and we
decided to that we need to convert to ANSI C for better type and error
checking.  Does anyone know of any good ANSI C compiler for Interactive
UNIX with a good C debugger that works under Motif/X Windows ?  I heard
that Centerline ( formerly Saber ) C is a good product. Do they make one
for Interactive UNIX ?  

We also need a good testing program that enables us to write some kind of
script or some kind of event recording program that helps us test our
Motif programs repetitively.  I've tried XTrap and it seems to work OK,
but are there better ones available for the X/Motif environment ?

Thanks.

Jeffrey.
[Nearly everyone I know uses GCC and GDB, the latter often through various
spiffy X front ends.  You can't beat the price.  Centerline is great, but
I haven't seen it for SysV/386.  For Motif testing, I'd recommend the
widget-based platform-independent testing tools from Segue Software in
Newton MA (617-969-3771) though since I'm a founder of and major investor
in Segue, I'm hardly unbiased.  -John]
-- 
Send compilers articles to compilers@iecc.cambridge.ma.us or
{ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
Newsgroups: comp.lang.c
From: paubert@piaf3.cern.ch (Pierre Aubert)
Subject: gif && X-window
Keywords: gif,X11
Organization: CERN, European Research Center for High Energy Physics
Date: Fri, 9 Oct 1992 16:48:25 GMT

Hello,

I'm looking for a small code who
        1/ take a GIF file
        2/ return an X Drawable ( window , pixmap , ximage ? ) and a colormap 

Could someone help me ?

Merci beaucoup ...

-- 
                                                                 
                                                                 
     A++
                           Pierre                                     
   +--------------------------+--------------------------+  
   |  I'd rather be juggling  |  paubert@dxcern.cern.ch  |
   +--------------------------+--------------------------+	
Newsgroups: comp.lang.c
From: thssrsf@iitmax.iit.edu (Russ Fuja)
Subject: Too much global data -- Borland C++ 3.1
Keywords: Borland,64K
Organization: Illinois Institute of Technology / Academic Computing Center
Date: Tue, 13 Oct 92 15:39:48 GMT

I am having a problem with Borland C++ 3.1 which I, now 
somewhat desparately, turn to the net for assistance.

The problem is this -- I am getting the error "Too much global
data in file" while compiling a file of C code (not C++).  The
manual says "The sum of the global data declarations exceeds
64K".  Alright, so I went into the file and stuck a _far keyword
on all my statically declared structures and recompiled -- same
error.  I compiled with the Zortech C++ compiler with no problem, 
that is, the problem seems to lie in the way Borland compiles my
program, not that I am using more than 64K (at least by my estimate).

Because this file is produced through a compilation from another file,
I am lothe to do the simple fixes of going through it and eliminating 
redundant allocations and breaking the file up into multiple files.

I am using the large memory model.  I have to because this is a Windows
program.  I have tried the -Ff=<size> options with no success.

The question, then, is what is Borland doing?  Is it ignoring my _far
keywords and putting my statically allocated structure arrays in the 
DGROUP anyway (and just leaving me a pointer in my _far segment, like it
so stupidly does with literal strings?).  Or, is it having some other
problem which it reports as a global data overrun?  Or, am I just not
understanding how this compilation is supposed to work?

Anyway, any pointers or issues touching the above would be greatly
appreciated.  Please e-mail to the address below (fuja@athens.eid.anl.gov)
and I will repost (if requested) to the net.

BTW, is there any way to make Borland put the values of literal strings
in some other segment than the _DATA segment?

Thanks in advance,

Russ

*****************************************************************
Russell Fuja
Argonne National Laboratory
(708) 252-4070
fuja@athens.eid.anl.gov
*****************************************************************



Newsgroups: comp.lang.c
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: Checkpointable malloc library?
Organization: Computer Science, University of Melbourne, Australia
Date: Tue, 13 Oct 1992 15:54:04 GMT

richk@grebyn.com (Richard Krehbiel) writes:

>Here's what I'd like to be able to do:
>
>main() {
>
>    for(;;)                    /* Part of a long-running program */
>    {
>        chkpt = malloc_chkpt();   /* Save current state of dynamic memory */
>        if(setjmp(jmp_b))         /* setup for exception exit */
>        {
>            /* Something in work_process() threw an exception. */
>            malloc_restart(chkpt);  /* discard any allocations made
>                                       following the checkpoint */
>            continue;
>        }
>        work_process();            /* Work */
>
>        malloc_forget(chkpt);    /* Forget the checkpoint; anything
>                                   still allocated is needed. */
>    }
>}
>
>Has anyone ever seen something like this?  Thanks.

I haven't seen any such thing, and I doubt that you will find it.

What you *could* use, however, is a garbage collector.
There is a garbage collector available via anonymous ftp in
parcftp.xerox.com:~ftp/pub/gc.tar.Z.

If the garbage collector honours explicit deallocation with free(), then
your main program might look something like this:

main() {
    init_garbage_collector();

    /*
     *  you don't want to do garbage collection except when explicitly specified
     */
    disable_automatic_garbage_collection();

    for(;;)                    /* Part of a long-running program */
    {
        if(setjmp(jmp_b))         /* setup for exception exit */
        {
            /* Something in work_process() threw an exception. */
	    collect_garbage();	/* explicitly invoke garbage collector
				   to reclaim any unreferenced memory */
            continue;
        }
        work_process();            /* Work */
    }
}
-- 
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!
From: mhughes@comtch.spk.wa.us (Mark Hughes)
Newsgroups: comp.lang.c
Subject: Re: Productivity of a C programmer ?
Date: 10 Oct 92 21:41:07 GMT
Organization: Waffle BBS at CompuTech Spokane, Washington


  This is a composite reply...
From: d88-jwa@alv.nada.kth.se (Jon Wtte)
> I'm sure you lost a zero there.
 
  No, most programmers can come pretty close to the actual amount of time 
a project will take, assuming no spec changes, interfering management, or 
hurricanes...  The 20% is just to be safe (and to deal with hurricanes).
 
From: rolf@geoserv (Rolf Wilson)
>   And then double it. Most programmers are pretty good at estimating
> their programming time, but don't seem to realize that they may only
> get half of their day to program in.
 
  Er, interfering management.  Maybe giving them a copy of the Tao of 
Programming with the Management section highlighted would help.  |-)
 
From: sbill@informix.com (Bill Stackhouse)
> SLOC does tend to be constant because it is measured across the
> total development life cycle (requirments, design, code, test).

  ROTFL!  (might I suggest you re-read the Mythical Man-Month?)
 
 - Mark Hughes (Caves of Steel 509-624-2078)  mhughes@comtch.spk.wa.us
Newsgroups: comp.lang.c
From: kaleb@thyme.jpl.nasa.gov (Kaleb Keithley)
Subject: Re: lint
Organization: Jet Propulsion Laboratory, Pasadena, CA
Date: Wed, 7 Oct 92 16:54:12 GMT

In article <herman.718468501@phage> herman@nosc.mil (John W. Herman) writes:
>
>Why doesn't the FSF have a lint that works with GCC??

Whatever for?  'gcc -c -Wall -pedantic -traditional' does a much better job
on K&R1 C than most lints do.  And if you substitute -traditional with
-ansi, it works on Standard (K&R2 a.k.a. ANSI) C too.

-- 

Kaleb Keithley                          kaleb@thyme.jpl.nasa.gov

Not authorized, in any way, shape, or form, to speak for anyone.
Newsgroups: comp.lang.c
From: saud@seas.gwu.edu
Subject: Currency formated numbers
Originator: saud@seas.gwu.edu
Organization: George Washington University
Distribution: usa
Date: Wed, 14 Oct 1992 23:13:43 GMT


I was asked if its possible in C to print a number using currency notation
	
	For example:
		$1,000,987,98.00
Thanks


Wanes



P.S. I know the dollar sign is not a big deal.
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.c
Subject: Re: Life, stderr, and everything (was Re: malloc() as a user...)
Date: 14 Oct 92 11:16:18 GMT
Organization: Comp Sci, RMIT, Melbourne, Australia

In article <9228722.5429@mulga.cs.mu.OZ.AU>, fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
> If malloc fails, it may return an indication of the reason for failure
> in errno, and if so then you use should use perror() to give that information
> to the user.

There has never been anything in the UNIX documentation to say that malloc()
sets errno to any particular value.  There is nothing in the SVID to
require it.  There is nothing in the ANSI C standard.  (We ordered a copy
of POSIX.1 over a year ago.  We haven't got it yet.  So I don't know whether
1003.1 says anything more about malloc(), but the last draft I saw didn't.)

It is _only_ safe to use perror() for library functions which are
_documented_ as setting errno.  In particular, the pundits in comp.std.c
have ruled that this is a valid implementation of malloc():

	void *malloc(size_t size) { return NULL; }

Some UNIX manual pages _do_ state that malloc() calls sbrk(), but they
do _not_ say that it assigns the same meanings to errno as sbrk().  I
have been advised by UNIX wizards not to trust errno after malloc().
(In fact I _have_ seen what purported to be the listing of one vendor's
implementation of malloc() and it _did_ do other system calls.  There
were other aspects of it that made me wonder how they stayed in business,
but that's another story.)

In summary, DO NOT CALL perror UNLESS the library function in question
is DOCUMENTED as defining errno, or unless you are happy with garbage.
Newsgroups: comp.lang.c
From: rehak@breeze.rap.ucar.edu (Nancy Rehak)
Subject: Re: Strings and integer sizes
Organization: NCAR / RAP
Date: Wed, 7 Oct 1992 16:10:05 GMT

In article <1992Oct7.134613.8936@ncar.ucar.edu> rehak@breeze.rap.ucar.edu (Nancy Rehak) writes:
>In article <718167097snx@grendel.demon.co.uk> jes@grendel.demon.co.uk (Jim Segrave) writes:
>>
>>In article <9227705.8771@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
>>
>>> 
>>> >Multiple choice question:
>>> >
>>> >A string is stored
>>> >	a. in an array of characters
>>> >	b. in an array of characters terminated with 0
>>> >	c. in an array of characters terminated with '\0'
>>> 
>>> Well, the answer is:
>>> 	d. all of the above
>>
>>What about:
>>
>>char zoe[3] = "123";
>>
>>neither b. nor c. applies here.
>> 
>> 
>>--
>>Jim Segrave (Segrave Software Services)     jes@grendel.demon.co.uk
>>
>
>
>Actually, b. and c. both apply here as the string "123" is actually "123\0" and
>the \0 is stored in the byte following the end of the array zoe.  Big problem!
>
>If you said:
>
>char zoe[3];
>
>zoe[0] = '1';
>zoe[1] = '2';
>zoe[2] = '3';
>
>then you would not have the trailing \0, but I would contend that you don't have
>a string -- you have an array of characters.
>
>Nancy Rehak


As two others (Dave Eisen and Barry ??? - sorry, I didn't keep your names
because I expected the mistake to have already been corrected by another
poster) have informed me, my post was wrong.  According to ANSI standard,
the original initialization acts exactly as my "correction."  I was making
assumptions that I shouldn't have made.

I'm very sorry for the errors in my post.  I hope that this post will
serve to correct any other programmers that made the same mistake as I did.
My greatest apologies go to Jim Segrave, whom I was "correcting."

Nancy Rehak
From: williford@lub001.lamar.edu
Newsgroups: comp.lang.c
Subject: Need Decimal to Binary converter....
Date: 15 Oct 92 14:26:03 GMT
Article-I.D.: lub001.1992Oct14.212603.1656
Organization: Lamar University - Beaumont

I am in desperate need of a simple piece of code to input a binary like:
10011000
and convert it into its decimal equivalent.  Then be able to convert it back to
binary.  If there is a function to do this I could not find it.

Please e-mail the results.....

T.I.A.  (Thanks In Advance)

*****************************************************************************
Rhett Williford
Systems Operator
ACM President-Lamar University, Beaumont, TX  USA
Internet: williford@lub001.lamar.edu
*****************************************************************************
From: conniff@mailhost.aa.cad.slb.com (Steven D. Conniff)
Newsgroups: comp.lang.c
Subject: ### Question about setitimer ####
Date: 7 Oct 92 19:12:50 GMT
Distribution: usa
Organization: Schlumberger CAD/CAM at Ann Arbor, MI


I am having some difficulties with using setitimer.  Here is my program:

The below program block forever on the pause statement.  It seems that
the timer never starts.  Does anyone know what I'm doing wrong!?!?!

Curious,
Steve

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <stdio.h>
#include <sys/time.h>

main(int argc, char *argv[])
{
    struct itimerval value;
    struct itimerval ovalue;

    if (argc < 2)  {
       printf("Usage: usleep <usecs>\n");
       exit(0);
    }

    value.it_interval.tv_sec = 0;
    value.it_interval.tv_usec = atol(argv[1]);

    setitimer(ITIMER_REAL, &value, &ovalue);
    pause();

    printf("Out of pause.\n");

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Steve Conniff                             conniff@ann-arbor.cad.slb.com
Applicon Schlumberger                     conniff@aaaca1.sinet.slb.com 
Ann Arbor, Michigan (USA)                 AAACA1::CONNIFF (SINet)  
Newsgroups: comp.lang.objective-c
From: subiaagb@w350zrz.zrz.tu-berlin.de (Andre Pareis)
Subject: Looking for a library
Reply-To: pareis@cs.tu-berlin.de
Organization: Dept. of CS, Techn. University Berlin
Date: Wed, 14 Oct 1992 13:48:29 GMT


Hi,

this may be a FAQ, but is important to me:

Where can I get a PD library for objective-c?
I have a compiler, but nothing to use with it.


-- 
				 -----------------------------------------------
				| Andr'e Pareis,				|
				| e-mail:    pareis@cs.tu-berlin.de		|
				|	     subiaagb@w350zrz.zrz.tu-berlin.de	|
				| NeXT-mail: subiaagb@w271zrz.zrz.tu-berlin.de  |
				 -----------------------------------------------
Newsgroups: comp.lang.objective-c