🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.internals
Article #2546

Re: (Too) Much Ado About Nothing (Re(ally): Strings?)

#2546
From: The Grey Wolf
Date: Wed, 19 Jun 1991 00:16
41 lines
2384 bytes
/* <2883@mccuts.uts.mcc.ac.uk> by zzassgl@uts.mcc.ac.uk (Geoff Lane)
 * 
 * Arrrrrhhhhhhhhh......... NO NO NO.  What you REALLY should do is
 * prefix all strings with an expicit length.  Look at the
 * advantages - no more scanning down the bytes looking for the end - no
 * more having to rewrite all the string handling routines because your
 * particular project *must* have strings with embedded null bytes - no
 * more forgetting about that final invisible byte and overwriting something
 * vital.
 *

Lessee, now...as I understand/perceive this one (I know we're not
looking for a debate here), given that most of the string routines
return a pointer to the beginning of the string which you've just
passed it, prefixing with an explicit length might not be a
terrible idea......nahhhhh.

I *do*, however, find it annoying that when you call something
like getwd(), gets()/fgets(), str[n]cpy(), str[n]cat(), et al.
they all return pointers to the *start* of the string, which you
just passed.  Why couldn't they return a pointer to the *end* of
the string so that you don't have to go through all the bleeding
overhead to find out yourself?  Sure, it's just one system call,
but sometimes strcpy/strcat occur in tight loops, with the need to
know where the end of the string is (bad example, since strcat()
appends by default).  This necessitates a strlen() call, or an
inline for(;;) loop to calculate it.  *I ALREADY KNOW WHERE THE
START OF MY STRING IS!  USING THAT AS A RETURN VALUE IS USELESS!*

*ARGH!*

 * By the way, is this a 5 minute argument or a 10 minute argument?

regain_composure();

I told you once...

 * -- 
 * Geoff. Lane.                                  Janet: zzassgl@uk.ac.mcc.cms
 * UTS Sys Admin, Manchester Computing Centre, Oxford Rd, Manchester, M13 9PL
 */
Technical Details
Message-ID: <3529@unisoft.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!unisoft!greywolf
References: <315@titccy.cc.titech.ac.jp> <1991Jun10.061602.25336@kithrup.COM> <426@n4hgf.Mt-Park.GA.US> <2883@mccuts.uts.mcc.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!unisoft!greywolf
From: greywolf@unisoft.UUCP (The Grey Wolf)
Newsgroups: comp.unix.internals
Subject: Re: (Too) Much Ado About Nothing (Re(ally): Strings?)
Keywords: X11 silliness
Message-ID: <3529@unisoft.UUCP>
Date: 19 Jun 91 00:16:17 GMT
References: <315@titccy.cc.titech.ac.jp> <1991Jun10.061602.25336@kithrup.COM> <426@n4hgf.Mt-Park.GA.US> <2883@mccuts.uts.mcc.ac.uk>
Reply-To: greywolf@unisoft.UUCP (The Grey Wolf)
Organization: Foo Bar and Grill
Lines: 41