HDTenEightyP/NetNews huggingface dataset:
From: adams@pdv3.fmr.maschinenbau.th-darmstadt.de (Adams)
Subject: Re: Fortran to C conversion: Why bother?
Date: Wed, 11 Nov 1992 01:24:30 GMT
Organization: TH-Darmstadt

In article <1992Nov9.131601.167@gems.vcu.edu> hleaves@gems.vcu.edu writes:


>   I was wondering why anyone would bother using the f2c (or similar) program to
>   translate fortran code directly into C. All you end up with is C code that
>   exactly mimics the functionality of the original fortran code. Its not as if
>   the translating program rewrites your algorithms to use the parts of C that
>   make C really useful. Its just fortran code expressed in C. What's the point?

Well, dreadful enough, there are just a few reasons:

	1) Some systems are not equipped anymore with Fortran-Compilers,
	but you have to keep the old stuff running.
	You want to have one source for all systems to support, 
	sso you will take "C", as "C" is supported virtual everywhere,
	something FORTRAN always claimed.

	2) Those FORTRAN programs are not worth to be recoded,
	but must yet run for a limited time, on a new system.

	3) You want to integrate old FORTRAN  stuff, like EISPACK, into new
	software, like khoros. Usage of FORTRAN or Fortran forbidds itself,
	as I/O system is record based and part of the language itself.
	
	Fortran does not fit into an event driven
	enviroment (X-Widnows) together with character based I/O (***X).


>   If you're going to write programs in fortran, use a fortran compiler. If you
>   want to use the features of C, learn C and use a C compiler. Using f2c doesnt
>   give you any of the advantages of designing and writing the original program in
   C.

It saves workhours. 

Most of the FORTRAN stuff I know of will never be rewritten (manually)
in "C", as  reimplementations in Maxima(Lisp) and Prolog are
underway [spelling?].

Perhaps "C"-sources will be derived from specification in Maxima.....

perhaps unusual,

best adams




Newsgroups: comp.lang.c
From: pal@regent.e-technik.tu-muenchen.dbp.de (Peter Loibl)
Subject: Re: Macros
Organization: Technical University of Munich, Germany
Date: Fri, 13 Nov 1992 10:14:11 GMT

chuckb@stein.u.washington.edu (Charles Bass) writes:

>I)  avoiding function calls 
>2)  simplifying complex expressions (bit operations are common)
>3)  conditional code for debugging/platform changes
>4)  common loop iterators (someone posted examples a while
>back)

5) generation of new trigonometric functions by using implemented
   tirgonometric functions
6) polynomial functions
7) tools, like: SWAP, MIN, MAX ...

BTW. 3) is the most powerful way of using a macro without 
rewriting code.

Peter Loibl
pal@regent.e-technik.tu-muenchen.de
From: birnbaum@cor5.pica.army.mil (Richard C. Birnbaum (GC-ACCURATE) <birnbaum>)
Newsgroups: comp.lang.c
Subject: Re: Help.  (Unix C)
Date: 5 Nov 92 16:28:18 GMT
Organization: U.S. Army Armament Research Dev. & Eng. Ctr, Dover NJ

Following up my own post with a correction....


I wrote:

|> .. discussion of qsort and comparison function for comparing float members
|> of structures deleted....
|> 
|> instead of the comparison function doing
|> 
|>      if (ptr->item1 == ptr->item 2) return 0;
|>      if (ptr->item1 > ptr->item 2) return 1;
|>      return -1;
|> 
|> you could do simply
|> 
|>      return (ptr->item1 - ptr->item2);
|> 
|> You need not return only the values 0, 1, or -1 - you must return 0,
|> positive number, or negative number.

This works for intgers, not floats (sorry)
Xref: sparky comp.lang.c:16356 comp.software-eng:4238 comp.sys.mac.programmer:18285
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c,comp.software-eng,comp.sys.mac.programmer
Subject: Re: Productivity of a C programmer ?
Date: 11 Nov 92 21:30:30 GMT
Followup-To: comp.lang.c
Organization: negligable

In article <721104893@sheol.UUCP> throopw@sheol.UUCP (Wayne Throop) writes:
>A bit easier to gather than, say, McCabe or other metrics, but
>still probably quite a bit more useful than line counts are
>
>          # total number of identifiers
>          # total number of unique identifiers
>          # total number of C (or whatever language) keywords
>          # total number of unique C (or whatever language) keywords

Since this was modified from a xref-generator, I might be able to
do something about this (someday :)  You would also have to distinguish
between global identifiers & local.  You might have "i" everywhere, but
that doesn't make it important, and it would probably be local everywhere.

Even more interesting is counting usage of keywords a separate from
lines of code.  You might also wish to count complete statements separated
from lines of code:

	if (cond 1 ||
		((cond2a && cond2b) && !cond2c))
		do_this;
	else
		do_that;


may be five lines of code, but it is one (or three?) statements....

>Therefore, though I don't know how the metrics I suggest really
>correspond to development time, number of requirements, bug density,
>customer satisfaction, and other important matters, I know that for me,
>they *do* tend to correspond to how long it will take me to
>*understand* a given chunk of code.

I think it also helps that you can jump to all the references quickly.
I don't know if just the raw numbers w/o your tag-like file would
be nearly as significant, but it is something to think about.



=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Blasting, bursting, billowing forth with	|
the power of ten billion butterfly sneezes,	|	-Richard Hartman	
Man, with his flaming fire,			|	hartman@uLogic.COM
has conquered the wayword breezes.		|
Newsgroups: comp.lang.c
From: "corey groves" <corey.groves@canrem.com>
Subject: tsr's
Reply-To: "corey groves" <corey.groves@canrem.com>
Organization: Canada Remote Systems
Distribution: comp
Date: 13 Nov 92 11:14:06 EST

Hi,
  I am trying to program a TSR and was wondering if anybody could point
  me towards some good how to's on the subject.  I am running BC++ V3.1.
Thanx
Corey
--
Corey J. Groves       (416)648-3711
56 Enmore Avenue      corey.groves@canrem.com
Ancaster, Ontario     corey.groves@crs.com
Canada L9G 2H3        corey.groves@rose.com
PROFANITY IS THE LANGUAGE PROGRAMMERS KNOW BEST

--
Canada Remote Systems  - Toronto, Ontario
World's Largest PCBOARD System - 416-629-7000/629-7044
From: c60c-2gf@web-2a.berkeley.edu
Newsgroups: comp.lang.c
Subject: getch
Date: 13 Nov 92 02:22:17 GMT
Organization: University of California, Berkeley


At home, I run a version of Turbo C on my IBM.  There is a library function
with a prototype in conio.h called getch (and getche).  Is there an 
equivalent of this function on standard Unix systems.  I'm on a Sun, I 
believe (not a Sparc station though).  This question may be really
obvious, but I am not quite sure how all the specifics with input/output
work on the system (i.e. x-window control etc.) and I can't quite seem
to find getch.  The man page goes on and on abou'curses,' but I am still
pretty lost.  Any help would be appreciated (in email, please).  Thanks

-David Simpson
Newsgroups: comp.lang.c
From: dfuller@portal.hq.videocart.com (Dave Fuller)
Subject: Re: pixels -> GIF
Organization: VideOcart Inc.
X-Newsreader: Tin 1.1 PL3
Date: Tue, 10 Nov 1992 19:38:20 GMT

kv07@IASTATE.EDU (Warren Vonroeschlaub) writes:
: 
:   Or any other graphic image format that is standard.
: 
:   Specifically I am looking for some function that creates a file (or returns
: the numbers you should put in a file) of a graphic image when it is fed the
: image on a pixel-by-pixel basis.  It doesn't matter if it requires a special
: ordering.  (unless the order is completely whacked out, like every other prime
: coordinate or something like that)
: 
:   Into GIF would be best, but PCX or JPG or whatever is okay.
:
 the GIF file format is not that easy. it includes headers for the information
in the rest of the file. (compression mode, color mapping patterns, total
length of image, graphic x & y sizes, etc . .) these parts MAY be written
out first, then gone back and rewritten after an fseek, but it's not very
reliable. any algorithm would probably assume it had the entire image
available, then try to compress it, then write out ALL of the information
about the file at once. you could go ahead and write out a default file
header, not compress the stuff, and then accumulate all of the pixels into
respective bytes. The process may be easier with the others, i don't know
anything about them. But i do know the GIF creation won't be that easy
using the method you are talking about.
 
Dave Fuller
dfuller@portal.hq.videocart.com
 

Newsgroups: comp.lang.c
From: rbassadi@cs1.uct.ac.za (R BASSADIEN)
Subject: Zapping TSR's
Organization: Computer Science Department, University of Cape Town
Date: Mon, 9 Nov 1992 11:10:01 GMT

HELP!!!!

I know how to:
Program a working TSR.

I need to know how to:
Enable my TSR to unload itself (command line or other).
Allow my TSR to detect that it has already been loaded.

I use:
Borland Turbo C. v2.0
I use the KEEP command (prototype in DOS.H) to get my program to go TSR.

Please help. Thanks.

PS. Post you reply to this newsgroup since there might do others who would 
    like to know this. (If possible).

 Aceman, alias Doc, alias Blank magic.
From: roder@cco.caltech.edu (Brenda J. Roder)
Newsgroups: comp.lang.c
Subject: Re: Rounding floats to integers
Date: 10 Nov 1992 17:40:27 GMT
Organization: California Institute of Technology, Pasadena
NNTP-Posting-Host: sandman.caltech.edu

eli@csd4.csd.uwm.edu (Elihu Lubkin) writes:

>From: IA8@psuvm.psu.edu (Alan R. Heyd)

[How to round floats?]
>>What I do now is add 0.5 to the float before it is converted to
>>an integer, for example:
>>
>>          int i;
>>                                 /* Using Turbo C on and IBM PC: */
>>          i = 6.0 / 0.3;         /*   i = 19                     */
>>          i = 6.0 / 0.3 + 0.5;   /*   i = 20 as expected         */
>>

>      But if i = -6.0 / 0.3 + 0.5 then i = -19 so you also have to
>watch out for the sign.
>                          Thelma Lubkin

Yes, so use floor (in math library) instead of depending on the truncation.
i.e.

	i = floor(-6.0 / 0.3 + 0.5);  /* i = -20 as expected */
this equation will work for both signs (since it does an explicit truncation
in a defined direction).



-- 
-- Brenda (roder@cobalt.caltech.edu)
Thought before action, if there's time.
    _The Edge_  Dick Francis
From: rwyoung@csugrad.cs.vt.edu (Robert Young)
Newsgroups: comp.lang.c
Subject: C compiler
Keywords: compiler
Date: 13 Nov 92 01:48:44 GMT
Organization: Virginia Tech Computer Science Dept, Blacksburg, VA


 Could anyone tell me where I could find a simple c compiler?  I have
Borlands, C and C++, but am looking for a very easy and simple compiler
that I can use up at college.  I'm forced to use an old crapper 80886
(don't laugh!) to program on the IBM.  This computer is so ancient that it
cannot load any of my other compilers.  Please help!

Rob
"We're getting a bit short on heros..."
Newsgroups: comp.lang.c
From: yngvar@imr.no (Yngvar Foelling)
Subject: Re: The %lf format specifier.
Organization: Institute of Marine Research.
Date: Mon, 9 Nov 92 17:52:43 GMT

In article <1992Nov6.201125.8252@klaava.Helsinki.FI>, wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:
|> yngvar@imr.no (Yngvar Foelling) writes:
|> >My question is: Is the %lf specifier really illegal in printf?  
|> 
|> It is definitely non-standard.
|> 
|> >In that case, why _does_ the standard define specifiers like %hd for
|> >short, when short is always expanded to int?
|> 
|> What happens is that the short value is promoted to an int before the
|> function is called, but the function converts it back before printing it
|> out.  This has implications for at least the u, o, X, and x formats,
|> where the value is actually converted to an unsigned.  For example, if
|> you pass -(short)1 as the argument (which is an OK thing to do), the
|> function gets -1 (a signed int) and convertes it to an unsigned short. 
|> If it couldn't convert it to short, but had to use int, and if ints are
|> longer than shorts, the value printed out would be different. 
|> 
|> Try this on a machine with ints that are larger than shorts:
|> 
|> 	printf("%x\n", -1);
|> 	printf("%hx\n", -1);
|> 
|> For example, on a two's complement machine with 16-bit shorts and 32-bit
|> longs, the output is:
|> 
|> 	ffffffff
|> 	ffff
|> 
|> If there were no %hx, it wouldn't be possible to obtain the latter
|> output.
|> 
|> I have no idea why %hd exists, though, unless it is because of
|> orthogonality.
|> 
|> --
|> Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
|>    MS-DOS, you can't live with it, you can live without it.

It seems to me that you're passing signed int's while telling printf to expect
unsigned.  While that works in a two's complement environment (the only type
that I've used) I suspect that it will give different results elsewhere.

However, I've realized that there is a clear need for %hu, %hx and %ho.  The
programmer can't be expected to know if sizeof (short) < sizeof (int) or not.
So he can't know if unsigned short is expanded to int or unsigned int, to
decide whether to use %d or %u/x/o.

Frankly, I was more or less certain that %lf was non-standard.  I was just mad
at Borland for using it in example code with their compilers.

I'm also a bit puzzled as to why the ANSI commitee has included so much
redundancy in both the printf and scanf formats (e.g. printf has both %d and %i,
while scanf has %e, %f and %g) that seems to exist only to make them more
similar, while leaving this little detail out.

-- 
Yngvar Flling (yngvar@imr.no)
Institute of Marine Research
Bergen
Norway
From: svrobins@bra.isnet.inmos.co.uk (Paul Robins)
Newsgroups: comp.lang.c
Subject: Re: fputs question.
Date: 5 Nov 92 14:02:08 GMT
Organization: Inmos Ltd

In article <1d9e4mINN8hn@rodan.UU.NET>, 
smm@uunet.uu.net (Steve Mansfield) writes:
> I'm working on a program, and for some reason this little chunk of code:
> 
> receive_link()
> {
>    int i;
>    FILE *outstuff;
>    char segment[30];
> 
>    outstuff = fopen("o","w");
>    while(read(linkpipe[0],segment,30) != 0)
>       fputs(segment,outstuff);
>    close(outstuff);
     ^^^^
try fclose(outstuff);

>    close(linkpipe);
> }
> doesn't seem to want to write to file "o".  When I replace the fputs line
> 

fclose() flushes any unwritten data for the stream before closing. close()
may not do that. I think this varies between machines/implementations of
the standard libs, but using fclose() is the safe way to ensure any buffered
data is written.

Paul Robins.
_______________________________________________________________________
email: svrobins@isnet.inmos.co.uk | 
phone: (UK) 0633 810121           |     gave up the .sigs years ago
fax  : (UK) 0633 810820           |
-----------------------------------------------------------------------
From: torek@horse.ee.lbl.gov (Chris Torek)
Newsgroups: comp.lang.c
Subject: Re: Hows this for odd
Date: 11 Nov 1992 12:23:47 GMT
Organization: Lawrence Berkeley Laboratory, Berkeley
Reply-To: torek@horse.ee.lbl.gov (Chris Torek)
NNTP-Posting-Host: 128.3.112.15

(I was hoping to stay out of this mess, but...)

I *can* think of one good use for

	i == 0 ? TRUE : FALSE

(instead of just `i == 0', or, for the terse among us, `!i').  In this
one situation, however, I would probably spell `TRUE' and `FALSE'
differently.

The situation I have in mind is a C-language implementation of some
other (non-C) language, where the other language *has* a boolean type
with specific values for `true' and `false'.  For instance, a Pascal
system written in C might use something like:

	i == 0 ? V_TRUE : V_FALSE

to get the value nodes (which presumably would have some kind of
aggregate type, or be an index into a table) for the `true' and `false'
values.  These would be different nodes from, e.g., the integer
constant `0' and the untyped pointer `nil' (which might be V_0 and
V_NIL respectively).

The situation is not always clear-cut, and blanket statements like
`a definition for TRUE is always bad' are bound to be false sometimes.

(For the most part, though, I do think `i == 0 ? TRUE : FALSE' is at
best suspicious.)
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov
Newsgroups: comp.lang.c
From: misar@rbg.informatik.th-darmstadt.de (walter misar)
Subject: Re: Please help me with my #include mess-up.
Date: Thu, 12 Nov 1992 10:01:50 GMT
Organization: TU Darmstadt

In article <1992Nov11.172840.5540@news.ysu.edu>, ae007@yfn.ysu.edu (Daniel Newcombe) writes:
> 
> Well here is my problem:  I have these modules:
>   MOSTYPES.H - defines several types I am using in this
>     project, such as boolean, and a few structs and typedefs
> QUEUE.H - the header file for my queue class which has a few
>    inline things in it.
>    This has to include mostypes.h because it needs boolean.
> QUEUE.CPP - the rest of the code for the queues.  It includes
>   queue.h
> MAINMOD.CPP - my main module.  It includes QUEUE.H and MOSTYPES.H.
> When I compile I get a whole mess of errors saying that all sorts
> of things in MOSTYPES.H are redefined.  There are a lot more        
> modules that are going to have to use mostypes.h before it's   
> all over with.
> 
> My question - how do I get this to compile, while still keeping
> the code portable and re-usable???

Hm, first of all, an ANSI-compiler shouldn't complain with an error if you
re#define a macro with the SAME definition (different white-space doesn't count)
, but the inlines sure will cause trouble. The easiest way looks like this:
#ifndef MOSTYPES_H
#define MOSTYPES_H
... /* defines, typedefs, prototypings .... */
#endif

This way the headers definitions will be visible only the first time.

-- 
Walter Misar
misar@rbhp56.rbg.informatik.th-darmstadt.de
Newsgroups: comp.lang.c
From: blume@tyrolia.Princeton.EDU (Matthias Blume)
Subject: Re: Hows this for odd
Reply-To: blume@tyrolia.Princeton.EDU (Matthias Blume)
Organization: Dept. of Computer Science, Princeton University
Date: Tue, 10 Nov 1992 17:24:09 GMT

In article <BxGq4z.8oA@portal.hq.videocart.com>,
dfuller@portal.hq.videocart.com (Dave Fuller) writes:
|> bena@yoyo.cc.monash.edu.au (Ben Aveling) writes:
|> : 
|> : Hi all,
|> : 
|> : Just recently I saw the following fragment of code, and I thought
I'd share
|> : it with you all.  (This is real code, part of a real program people will
|> : pay money for.)
|> : 
|> : 	... ,(i==0)?TRUE:FALSE,...
|> : 
|> : Am I going mad, or is this slightly redundant ?
|> : 
|> : 	:-/  Ben
|> 
|> Not at all. Depends on what TRUE & FALSE are, and what they mean to the
|> calling function. possible that TRUE is defined as -1, FALSE as -2. 
                     ^^^^^^^^    -- I hope, you're not serious!
|> 0 does not always mean TRUE. actually i prefer to always give a TRUE
and FALSE
|> definition and return them from all functions. this way code is more
|> readable and checking return values (func() == 0) vs (func() == TRUE)
|> is much easier this way.
|> 
|> Dave Fuller
|> dfuller@portal.hq.videocart.com
|> 

This doesn't sound very reasonable!  Using 0 as FALSE in C is not a convention,
0 *is* C's FALSE.  All language constructs like `if', `while', `for', `||' and
`&&' behave according to this.  Defining anything like
# define FALSE 0
is like defining
# define THREE 3
Defining anything other than that, as in
# define FALSE -1
is even dangerous (consider `while (!FALSE) ...'), and it resembles nonsense
like
# define THREE 2

It is bad practice to define special values for TRUE and FALSE.
Of course, if those Pascal-people are to read your programs, than they might
be in trouble... :-)

-Matthias
Newsgroups: comp.lang.c
From: d0np@io.sun.csd.unb.ca (Godzilla)
Subject: Re: void pointer to a struct?
Organization: University of New Brunswick
Date: Wed, 11 Nov 1992 00:35:09 GMT



In article <1992Nov10.220944.1810@news.ysu.edu>, ae007@yfn.ysu.edu (Daniel Newcombe) writes:
|> 
|> Hi, I have a struct te { int i; char c}
|> In the main part of the program I have the variable r declared
|> as type te.  I also have j as type char.  I then have
|> void *o   in there.  At first I have o point to j and do
|> a printf("%c",*(char *)o) and this works.  How would I use
|> o to point to r, and be able to print the c field?
|> Thanks...
|>  -Dan

o = (void *)&r;
printf( "%c", ((struct te *)o)->c );
              ^              ^
not sure, if you need the outer brackets, but this should work.

|> -- 
|>     -Dan Newcombe
|> Internet Address:  STDN@VM.MARIST.EDU
|> Youngstown Freenet: ae007@yfn.ysu.edu
|> GOAL: To put the world on 3.5" diskettes...  :)


					enjoy
							Mike
d0np@jupiter.sun.csd.unb.ca
d0np@unb.ca
Newsgroups: comp.lang.c
From: msb@sq.sq.com (Mark Brader)
Subject: Re: How to use 'return' in c?
Organization: SoftQuad Inc., Toronto, Canada
Date: Thu, 5 Nov 92 05:49:34 GMT

> After several people wrote me on the use of EXIT_SUCCESS and
> EXIT_FAILURE  and their inability to locate those files on their
> systems I checked K&R 2ndEd for the definitive answer...
> 
> " void exit(int status)
> ... How status is returned to the environment is
> implementation-dependent, but zero is taken as successful
> termination.  The values EXIT_SUCCESS and EXIT_FAILURE may also
> be used."                                              ^^^
> 
> Because the word *may* is used I must assume that you either get
> it or you don't depending on your compiler/OS. ...

No.  What's going on here is that K&R2 is about ANSI C (a.k.a. ISO C,
or standard C), but the standard is a relatively new thing (less than
3 years) and there are still lots of older compilers around.

An ANSI C implementation *must* provide EXIT_SUCCESS and EXIT_FAILURE
in the header <stdlib.h>, and you *may* use them to specify your status.
Alternatively you may use 0, which is also specified as indicating
success, or some other number, whose meaning will be specific to your
implementation.

Older implementations generally did *not* provide EXIT_SUCCESS, EXIT_-
FAILURE, or for that matter, <stdlib.h>.  On UNIX and I believe most
other environments, 0 was specified as success and anything else
indicated failure.  However, not all environments conformed to this;
on VMS, for instance, success and failure were indicated by *odd* and
*even* status returns, with specific values encoding specific types
of success or failure.

For portability to ANSI C and to older systems using the UNIX convention,
the following is one possibility:

	#if __STDC__
	#include <stdlib.h>
	#endif

	#ifndef EXIT_FAILURE
	#define	EXIT_FAILURE 1
	#endif

	#ifndef EXIT_SUCCESS
	#define	EXIT_SUCCESS 0
	#endif

Then use EXIT_SUCCESS or EXIT_FAILURE.
-- 
Mark Brader		  "In the rough, roguish, early days, when men were
SoftQuad Inc., Toronto	   men, women were women, and pointers were ints,
utzoo!sq!msb		   Real C Programmers wouldn't even bother to invent
msb@sq.com		   tags for structs ..."	-- Steve Summit

This article is in the public domain.
Newsgroups: comp.lang.c
From: tma@encore.com (Thanh Ma)
Subject: Re: Oject Oriented C libraries
Organization: Encore Computer Corporation
Date: Thu, 12 Nov 1992 16:23:12 GMT

slahiri@jade.tufts.edu (Count Dracula) writes:

>In article <7885@charon.cwi.nl> kwakkel@cwi.nl (Fred Kwakkel) writes:
>>Hai,
>>
>>I'm looking for some object oriented C likr libraries (not C++!).
>>I want to do set manipulation with arbitrary data structures,
>>symbol table manipulation and more of these these 'low-level' 
>>abstract data types. If you know an ftp site where I can find these libraries
>>(pure C, not compiled), please mail them to me.

>Hey, hey to me too, please .

>-Sandip

And me too, please.

Thanh
Newsgroups: comp.lang.c