HDTenEightyP/NetNews huggingface dataset:
From: jes@grendel.demon.co.uk (Jim Segrave)
Newsgroups: comp.lang.c
Subject: Re: Strings and integer sizes
Date: 13 Oct 92 00:33:44 GMT
Organization: None
ReplyTo: jes@grendel.demon.co.uk
X-Mailer: cppnews $Revision: 1.18 $


In article <1992Oct12.164905.11901@athena.mit.edu> scs@adam.mit.edu (Steve Summit) writes:
> 
> Finally, in article <1992Oct10.181249.26069@mccc.edu>, Pete Holsberg (pjh@mccc.edu) writes:
> > In article <1992Oct9.173755.18595@athena.mit.edu> scs@adam.mit.edu (Steve Summit) writes:
> >= (It's been mentioned several times during this thread, but
> >= "string" is a weakly-defined concept in C, not a formal part of
> >= the language except by convention, and by the fact that string
> >= literals generate them and many standard library routines expect
> >= them.)
> > 
> > I believe that string is quite well-defined: it's a constant.
> 
> Don't you mean "string literal"?  A string literal is a
> well-defined lexical element (i.e. it exists only in source code
> at compile time); ANSI X3.159 defines it in section 3.1.4 .
> 
> > We're
> > running into semantic problems here. For example, which of the following
> > is an "int", given the declaration "int count;"?
> > 	a. 7
> > 	b. count
> > Both are, because loosely speaking, an int is either an int variable or
> > an int constant. Or perhaps neither is, because the question wasn't
> > specific enough.
> 
> Er, yeah.  (Vaguely worded questions and imprecisely defined
> terms, though rampant in comp.lang.c and indeed all of Usenet,
> are not really "semantic problems," at least as the term
> "semantic problem" is commonly used in comp.lang.c :-) .)
> 
> 					Steve Summit
> 					scs@adam.mit.edu

And, just to confuse an already overlong thread.
For those who said that I zoe[] did not store a string (whatever that
may be) I might point out that *all* the information about the
initialising string is encoded in zoe, since it's length is known at
compile time. It does in some vague sense store the entire string, since
it can be reconstructed. I simply can't be used in some places where a
string literal stored in a unsized or oversized char array could be used
- ie. strcpy and friends.
I merely started this whole mess by reminding people of the relatively
obscure special case of literal initialisers which are just 'big'
enough. Didn't really expect the volume of traffic generated, but if it
caused people to go back and look harder at things, then I can't say I
regret it.
 
> 
--
Jim Segrave (Segrave Software Services)     jes@grendel.demon.co.uk
Newsgroups: comp.lang.c,news.admin.misc,news.admin
From: scs@adam.mit.edu (Steve Summit)
Subject: duplicate articles in comp.lang.c
Followup-To: news.admin.misc
Organization: none, at the moment
Date: Wed, 14 Oct 1992 16:48:25 GMT

I just forged cancel messages for six duplicate articles in
comp.lang.c .  These were evidently sent out by
news-daemon@monly.wlink.nl.wlink.nl, which assigned new
Message-ID's (thus the duplication), rewrote From: lines to
<user>@f1.n100.z60.wlink.nl (so that the original poster was
unlikely to get any replies in response to the duplicate), and
(rather amusingly) recomputed the Date: lines to GMT-0100.
Precise details (e.g. Message-ID's) are available upon request.

There were three more of these for which I was unable to locate
the originals (such that I could not verify and cancel them); I
suspect that there were also other similarly-affected articles in
other newsgroups.

I am sending messages to postmaster@monly.wlink.nl.wlink.nl and
other likely addresses.

Followups to news.admin.misc .

					Steve Summit
					scs@adam.mit.edu
Xref: sparky comp.lang.c:15025 comp.software-eng:3794 comp.sys.mac.programmer:17016
From: markh@csd4.csd.uwm.edu (Mark)
Newsgroups: comp.lang.c,comp.software-eng,comp.sys.mac.programmer
Subject: Re: Productivity of a C programmer ?
Date: 15 Oct 1992 16:21:21 GMT
Organization: Computing Services Division, University of Wisconsin - Milwaukee
NNTP-Posting-Host: 129.89.7.4

In article <mxmora-121092100513@css-mac1.sri.com> mxmora@unix.sri.com (Matthew Xavier Mora) writes:
>In article <BvvIK4.EuJ@news.cso.uiuc.edu>, rolf@geoserv (Rolf Wilson)
>wrote:
>>   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.
>
>They also forget to include the time for testing and debugging. :-)

From experience, debugging is about 5% of the total time, because of the
process undergone in prior stages (incremental development strategy, correct
programming, and formal verification)

Testing is nil, since that's part of coding (in an incremental development
strategy).

Experience generates these numbers:

                       75% thinking through the design
                        5% coding
                        5% debugging
                       15% documentation
Newsgroups: comp.lang.c
From: ins314l@aurora.cc.monash.edu.au (Justin Keene)
Subject: Bar-Code routines
Organization: Monash University
X-Newsreader: TIN [version 1.1 PL6]
Date: Mon, 12 Oct 1992 15:02:47 GMT

	I've seen this posted several times before, but I am suddenly in
need of routines to generate bar-codes on an IBM pc. I'm not sure of the
format I need, but it covers numbers and letters. 

	Or, if you could refer me to any books that would contain the info I
need to do it myself.

Please e-mail directly to me

Thanks
	Justin Keene

: ins314l@aurora.cc.monash.edu.au 
:  glitch@yoyo.cc.monash.edu.au 
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.pascal,sci.math.num-analysi
From: regeorge@magnus.acs.ohio-state.edu (Robert E George)
Subject: RE: Numerical Analysis on a PC-languages?
Organization: The Ohio State University
Date: Tue, 13 Oct 1992 18:21:05 GMT

We want to write numerical analysis programs (mainly integrations) on a
486DX 33 MHz pc. There are several options as far as languages:

     (1) Turbo Pascal 5.5 (what we currently use)
     (2) Microsoft FORTRAN
     (3) Microfsoft FORTRAN for Windows
(Many others as well, of course, but these are those we feel comfortable with.)
     (4) Microsoft C (not comfortable with, willing to learn if dramatically
                      superior to (1)-(2)-(3)  )
Any suggestions on which is best?  (Execution speed??)

Please email suggestions.

Thanks in advance!

Robert George
(speaking only for myself)
Newsgroups: comp.lang.c,comp.software-eng,comp.sys.mac.programmer
From: rich@grayhawk.rent.com (Richard R. Harms)
Subject: Re: Productivity of a C programmer ?
Date: Sat, 10 Oct 1992 06:42:24 GMT
Organization: Grayhawk - Des Moines Public Access Unix - 515/277-6753

In article <1992Oct8.184718.12802@midway.uchicago.edu> cjh1@midway.uchicago.edu writes:
>Hello, world.
>
>Could any one show me the light on
>"Average productivity of a C programmer in today's industry in terms of
>number of lines of source code produced per day."
>
>What I need is the number (lines/day), the conditions and the assumptions
>under which the number is derived, and the reliable source of this model.
>
>I need this information to estimate the cost of a new project and to convince
>people whether it is worth of the effort or not.

A lines of code per day estimate is about the most useless thing you can ask
for - I learned that very well, after getting some sample code once from a
scanner manufacturer, the auther of it actually assigned each character into
a string on a separate line of code and did other things too horrible to 
mention... but I'm willing to bet that he/she was paid per line of code
written.

I can't see where you could ever reliably estimate anything on the Mac this
way, since there's going to be some time spent looking up toolbox calls, etc.
which will all effect how long it'll take - something straight-forward using
little toolbox won't take long, and will get a high line count per day, whereas
something requiring a lot more toolbox digging will be significantly lower...

-rh

-- 
Richard R. Harms            Internet: r-harms@grayhawk.rent.com 
1217 24th, Suite 49             UUCP: {...}!{rutgers!bobsbox}!grayhawk!rich
Des Moines, Iowa 50311       AOnline: Grayhawk             AppleLink: D2656 
Unix / Macintosh Programmer      Fax: 515/884-2736       Unix: 515/277-6753
From: ajay@hadar.cs.Buffalo.EDU (Ajay Shekhawat)
Newsgroups: comp.lang.c
Subject: Help with source code formatters
Date: 16 Oct 92 03:40:24 GMT
Reply-To: ajay@cs.Buffalo.EDU (Ajay Shekhawat)
Distribution: na
Organization: University at Buffalo, Dept. of Computer Science
Originator: ajay@hadar.cs.buffalo.edu
Posting-Software: pnews (version 1.4)


Question: Which source code formatter folds long lines?
In a recent post, people recommend gnudent (GNU indent). I've tried it,
as well as indent. Both of them don't fold source lines, even when used 
with the -l option. Am I missing something? 
Long statements like

extern int foo_bar, bar_foo_blah, blechh, very_long_variable_name, some_other_variable, barf;

                     make editing difficult, and pretty-printers won't 
handle them. 

Any help will be appreciated.

Thanks, 
	Ajay

ajay@cs.Buffalo.EDU
From: slahiri@jade.tufts.edu (Sandip Lahiri)
Newsgroups: comp.lang.c
Subject: Scanf and pointer problem, HEELP!!
Date: 13 Oct 92 21:28:55 GMT
Organization: Tufts University - Medford, MA
Originator: slahiri@jade.tufts.edu

I don't know whether this is a faq, but scanf is screwing me left and
right (sorry for the language folks, but i am pretty frustated at this
point). My program does a seg fault if i say this,

char *nodename;

scanf("%s",nodename);

I got around the problem by initializing nodename to "", so that
now i have,

char *nodename = "";

scanf("%s", nodename);

this thing is working. But i always thought that initialization is
not necessary for a scanf variable. Am i wrong ?

And then here's come the pointer stuff, which is leaving
me completely baffled,

I have a char pointer in a function, which i am calling from main(),

char *get_ filename()
{
  char *file_name = "";
  
  printf("Enter file name: );
  scanf("%s", file_name);
  return file_name;
}

After this I am calling another function, from main() as before,

int get_node(fptr)
FILE *fptr;
{
 char *nodename, *list = "";

 printf("Enter nodename: );
 scanf("%s", nodename);
 
 printf("Enter list of nodes: );
 /* I am using gets to read in the lines from here */
}

The odd part is that the pointer nodename is pointing towards the  
pointer file_name, so that if i print out the value of nodename 
**BEFORE** printf("Enter nodename:"); it prints out the value pointed
by file_name!!! How come ? Also, note that the scanf thing for nodename
works even if i have not initialized it, but gives a seg fault for
*list. Why ? Any pointers, help will be most gratefully accepted. 
Thanx in advance folks,

Sandip
From: richw@sol.camb.inmet.com (Richard Wagner)
Newsgroups: comp.lang.c
Subject: Re: Fast way of counting number of bits =1 in an int.
Keywords: bit operations
Date: 12 Oct 92 17:01:11 GMT
Organization: Intermetrics, Inc.

In article <92Oct10.031840.26015@acs.ucalgary.ca> puri@enel.ucalgary.ca (Ruchir Puri) writes:
>>  Hi there!
>>  	I was wondering if software pundits out there know of 
>>  a better way of counting the number of bits=1 in an integer variable.
>>  The regular way is mask, shift, mask, shift,......
>>  
>>  But it is slow and requires 32 shift and & operations. 
>>  Can anybody suugest a better solution.
>>  
>>  I am interested in finding the difference between the number of
>>  bits that are 1 in two variables. 
>>  
>>  I will appreciate any pointers to an effecient way...
>>  
>>  Thanks a lot for your time...
>>  
>>  --Ruchir


Here's a method which I (unfortunately) can't take original credit for, but
I've at least been given the blessing to pass it on:

            unsigned int
        count_one_bits (i)
        unsigned int i;
        {
            unsigned int result;

            result = 0;
            while (i != 0) {
                i &= i - 1;
                result += 1;
            }
            return result;
        }

Here's why this works:

Let "bit position 1" refer to the position of the right-most, least-significant
bit in the binary representation of "i"; "bit position 2" to the second least-
significant bit, etc.

Any non-0 number, "i", can be viewed as a series of bits with 0-bits in bit
positions 1 through N (with N >= 0), a 1-bit in bit position (N+1), and some
combination of 0- and 1-bits in positions (N+2) and higher.  For example, 68
in binary is:

        1000100

In this case, N = 2.  As we'll soon see, it helps to add a space to this
representation to isolate the right (N+1) bits:

        1000 100

Subtracting 1 from "i" changes that bit pattern by making all N 0-bits become
1-bits, and by making the 1-bit at position (N+1) turn into a 0:

        1000 100
           |
           V
        1000 011

Notice that the bits to the left of the space didn't change and that the
bits to the right of the space were all inverted.  Thus, the next "&" (and)
operation has the effect of leaving what's to the left of the space unchanged,
and of making what's to the right of the space all 0's:

        1000 100
           |
           | Subtract 1
           V
        1000 011
           |
           | "&" together
           V
        1000 000

As long as "i" is non-0, the net effect of subtracting 1 and "and"-ing is to
eliminate exactly one 1-bit from the starting bit pattern.  Thus, if you count
the number of times this can be done before you reach a 0 value for "i",
you've effectively counted the number of 1's in "i".

--

Rich Wagner
Intermetrics, Inc.
From: rkummer@phillip.edu.au
Newsgroups: comp.lang.c
Subject: reading in Joystick value
Date: 7 Oct 92 22:36:33 GMT
Organization: RMIT (Bundoora Campus)

Hi there,
	I'm having a little trouble reading in joystick information with
my Turbo C++ program. I am currently using a little bit of inline assembly
code to read in the information using interrupt 15, but the best I can do is 
read about 40 samples per second. I am using a fairly fast machine (25MHz 386)
so this shouldn't be a problem. I want to read in information much faster than
this (e.g. more than 100 sanples per second). Can anyone help?

Ross Kummer
RMIT Bundoora
Internet Address RKUMMER@PHILLIP.EDU.AU
From: jliukkon@klaava.Helsinki.FI (Juha-Matti Liukkonen)
Newsgroups: comp.lang.c
Subject: Re: Problem with TC 2.0
Date: 16 Oct 92 22:59:11 GMT
Organization: University of Helsinki

In <1992Oct16.020725.22065@coe.montana.edu> icsg0131@cs.montana.edu (Jeff) writes:

>In article <1992Oct16.003104.11323@qualcomm.com> gbrand@qualcom.qualcomm.com (Graham Brand) writes:
>>   _main not found in module C0S

>Make sure you have a main() function and take out the NONAME.C from the
>Primary file option on the Compile menu.  You can do this from TCINST but
>if you've already installed it you need to do it from the TC IDE.        

Or compile your stuff with the command line compiler tcc. I've grown to
like emacs & make & tcc more than the IDE. They work. I've stumbled to
this "undeclared _main" too many a time. It seems that always when I
have more than four files in my project the IDE begins to mess up...

The only problem is that you can't debug the thingy with IDE either if
you compile with tcc. But then we should write code that needs no
debugging, shouldn't we? :)

-- 
               Juha Liukkonen, aka jliukkon@cc.helsinki.fi
       University of Helsinki, Dept. of Paranormal Investigations
           "Trust me, I know what I'm doing." - Sledge Hammer
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: Strings and integer sizes
Date: 7 Oct 92 17:29:58 GMT
Organization: AND Software BV Rotterdam

[ someone asked about how strings are stored and ... ]

In article <718167097snx@grendel.demon.co.uk>, jes@grendel.demon.co.uk
(Jim Segrave) writes:
 
| What about:
| 
| char zoe[3] = "123";
| 
| neither b. nor c. applies here.

|In article <1992Oct7.140844.816@newross.Princeton.EDU> blume@tyrolia.Princeton.EDU (Matthias Blume) replies:

|Right, but this is *not* a string at all!  It's a character array together
|with an initializer, which *looks* like a string.

In article <1992Oct7.161704.5930@hubcap.clemson.edu> mjs@hubcap.clemson.edu (M. J. Saltzman) replies to that:

|Furthermore, it is an erroneous initializer, since it is longer than 
|its target array.

Sorry, I have to disagree. In C, a string is no more and no less than
a _conceptual_ data type, there is no `string' type available in C.
There is a world wide agreement in the C programming world that a
string must be represented by a sequence of non-zero-value bytes
(zero or more of them) and terminated by a '\0' byte. 

The standard mentions a string as: ANSI-C 7.1.1 Definitions of terms:

`A string is contiguous sequence of characters terminated by and
including the first null character.'

The most convenient way to store a string is a character array. The 
initializer: char zoe[3] = "123"; does, therefore, _not_ store a 
conceptual string in the array `zoe', but it _is_ a valid initializer. 
Have a look at ANSI-C 3.5.7 Initialization:

`An array of character type may be initialized by a character string
literal, optionally enclosed in braces. Successive characters of the
character string literal (including the terminating null character
if there is room or if the array is of unknown size) initialize the
elements of the array.'

So, I agree that a sequence of bytes '1', '2', '3', without a terminating
zero-valued byte does _not_ conform to the conceptual string type, but 
I disagree that char zoe[3] = "123"; would be an erroneous initializer.

kind regards,

Jos aka jos@and.nl
From: roy@mchip00.med.nyu.edu (Roy Smith)
Newsgroups: comp.lang.c
Subject: question about duplicate declarations
Date: 13 Oct 92 21:17:53 GMT
Organization: New York University, School of Medicine

Let's say you write this:

foo (int x)
{
	int x;

	...
}

What should you expect a compiler to do?  In my case, the second "int x" was
a mistake; it shouldn't have been there at all.  Apparantly, though, the
compiler treated it as if it was simply a declaration of a new x inside a
local block.  Is that the reasonable thing to do?  Should it have issued
some sort of warning about duplicate declarations?
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Newsgroups: comp.lang.c
Subject: Re: Strings and integer sizes
Date: 9 Oct 92 07:57:10 GMT
Organization: University of Helsinki

hartman@ulogic.UUCP (Richard M. Hartman) writes:
>I have this in a central include file as:
>	strncpyz(d,s,n) { strcpy(d,s,n); d[n] = '\0'; }

Is n the size of the destination or the maximum length of the target
string, i.e. destination size - 1 ?  If the former, then the last
assignment should be d[n-1]='\0', of course.

I think that usual C convention would be to specify the destination size
(since then you can use sizeof if that is convenient for you), not
maximum string length.  Examples include strncpy, mem*, and fgets.

>I think there's a memcpyz() to go w/ memcpy(), but I'm not sure....

Seems curious, since the mem* functions shouldn't care about null
characters.

By the way, if you follow strict ANSI rules, your function names (if
they are of external linkage) are not quite valid, since names with
external linkage and beginning with mem and a a lowercase letter, or str
and a lowercase letter are reserved, i.e. should not be used by the
programmer, only the C library implementor.  (If you are implementing a
library, the issue is fuzzier.)

--
Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
Newsgroups: comp.lang.c
From: capntaz@dudemar.b24a.ingr.com (heath g goebel)
Subject: Help: Variable-length Argument Lists
Reply-To: capntaz@dudemar.b24a.ingr.com
Organization: Intergraph Corp. Huntsville, AL
Date: Thu, 15 Oct 1992 14:24:12 GMT


I am trying to write a wrapper around a routine that accepts a variable-
length argument list, but I'm having trouble passing on the variable
arguments.

Given:
-----

int UMSGetByNum( char msgBuff[], int msgNum, char *msgFmt, ... )
	where *msgFmt is the C format specification for the variables being
        substituted.  0 if variables are not being substituted.


I tried to no avail:
-------------------

/*********************************H H H H H*********************************/
int AecStMsg_GetByNum( char msgBuff[], int msgNum, *msgFmt, ...)
/***************************************************************************

Purpose:  This routine is a wrapper around UMSGetByNum.

/*********************************H H H H H*********************************/

{
  int sts;
  va_list ap;   /* points to the unamed args, if any */

  if (msgFmt == NULL)
    {
      sts = UMSGetByNum( msgBuff, msgNum, msgFmt );
    }
  else
    {
      va_start( ap, msgFmt );   /* make ap point to the 1st unnamed arg */
      sts = UMSGetByNum( msgBuff, msgNum, msgFmt, ap );
      va_end( ap );   /* clean up */
    }

  return sts;
}

Any suggestions?  e-mail prefered.  Thank you.
Xref: sparky comp.lang.c:14683 comp.compilers:1716 comp.lang.c++:14714
From: tell@cs.unc.edu (Stephen Tell)
Newsgroups: comp.lang.c,comp.compilers,comp.lang.c++
Subject: A better lex for recursive and parallel use?
Summary: Want lexical analyzer class for use with sockets
Keywords: C++, lex, question, comment
Date: 7 Oct 92 20:29:06 GMT
Article-I.D.: comp.92-10-031
Reply-To: tell@cs.unc.edu (Stephen Tell)
Organization: The University of North Carolina at Chapel Hill

I am in need of a lexical analyzer generator with some particular
features, and thought I would ask the net before starting to hack on code.

Background: Currently I am using flex with G++ in a large project.  The
same flex tokenizer is reused many times on different files as a program
runs.  Sometimes it reads from an ordinary disk file, other times from a
TCP socket in an interactive fashion.  Presently only one lexer is used,
and only on one file at a time, but this may need to change.

What I would like is a version of flex or some other lexical-analyzer
generator with the following features:

The output is a class, for example "class Scanner".  Among the class'
methods are things like yylex() and yyrestart().  I should be able to
create multiple objects of this class that operate independently:
	Scanner *a = new Scanner( ... );
	Scanner *b = new Scanner( ... );
	/* now I can intermix calls a->yylex() and b->yylex() */

I should be able to create multiple such classes for lexing different
types of files and use them in the same program.

The scanner should be able to be made nonblocking.  By this I mean using a
file set up for nonblocking I/O, and the scanner itself is nonblocking.
If there are no characters available, the yylex() method should return a
value indicating "no token available".  Then, when select(2) or a SIGIO
signal indicates that there are characters available from the file, I can
try calling yylex() again.

Anyone heard of anything like this?  If not, any suggestions on how to
approach the hacking of flex or some other lexical analyzer generator?

Thanks for any information,
Steve

-- 
Steve Tell       tell@cs.unc.edu H: 919 968 1792  | #5L Estes Park apts
UNC Chapel Hill Computer Science W: 919 962 1845  | Carrboro NC 27510
[Flex plugs its tables into a fixed scanner skeleton.  I wouldn't think it'd
be terribly hard to modify the skeleton to create a C++ class.  Making the
scanner non-blocking is harder, since the state machine currently only
expects to stop between tokens, but for your needs it has to be able to stop
in mid-token if it runs out of input. -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,comp.lang.c++,comp.os.msdos.programmer