🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.internals
Article #2590

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

#2590
From: Gary Bisaga x4219
Date: Fri, 28 Jun 1991 17:52
34 lines
2858 bytes
In article <3529@unisoft.UUCP> greywolf@unisoft.UUCP (The Grey Wolf) writes:
>/* <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.  ...
>
>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,
                                                     ^^^ System call? (I know,
                                                     picky picky)
>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!*
Why even bother EVER referring to the start of the string?  Why not
always use pointers to the end of strings to refer to them?  The length
would be stored at that location, and the [] operator would be changed
accordingly.  Or better yet, change the C compilers so that a (char *)
is actually a 64-bit pointer that holds BOTH the start and end of the
string!  The drawback, of course, is that most string handling routines
would need to use unions or be written in assembly language to handle
strings, or the compiler would need to be further modified to recognize
as builtins functions like strlen, but this seems a small price to pay
for the increased functionality.

In spite of this, I do agree that returning the start of the string is
useless.  It would be much more useful instead to return a pointer to
the start of the global shared-segment pointer table, unless you have
an inverted page table machine, in which case it wouldn't return anything.
Technical Details
Message-ID: <1991Jun28.175244.29906@europa.asd.contel.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!spool.mu.edu!olivea!uunet!europa.asd.contel.com!neptune!gary
References: <426@n4hgf.Mt-Park.GA.US> <2883@mccuts.uts.mcc.ac.uk> <3529@unisoft.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!spool.mu.edu!olivea!uunet!europa.asd.contel.com!neptune!gary
From: gary@neptune.uucp (Gary Bisaga  x4219)
Newsgroups: comp.unix.internals
Subject: Re: (Too) Much Ado About Nothing (Re(ally): Strings?)
Keywords: X11 silliness
Message-ID: <1991Jun28.175244.29906@europa.asd.contel.com>
Date: 28 Jun 91 17:52:44 GMT
Article-I.D.: europa.1991Jun28.175244.29906
References: <426@n4hgf.Mt-Park.GA.US> <2883@mccuts.uts.mcc.ac.uk> <3529@unisoft.UUCP>
Sender: news@europa.asd.contel.com (News)
Reply-To: gary@ctc.contel.com (Gary Bisaga  x4219)
Organization: Contel Technology Center
Lines: 34
Nntp-Posting-Host: neptune.ctc.contel.com