Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Languages Misc > Re: NUL to term...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 59 of 61 Topic 1118 of 1217
Post > Topic >>

Re: NUL to terminate strings

by CBFalconer <cbfalconer@[EMAIL PROTECTED] > Mar 10, 2008 at 05:35 PM

Morris Dovey wrote:
> James Harris wrote:
> 
>> I suppose the bit missing from what I said above is that the C
>> concept of a string being an array (of char) allows nowhere for
>> a length prefix. If it is an array of char then all elements
>> should be of type char. I suppose the libraries could just
>> ignore this requirement (could they?) but then would have to
>> agree on how many bytes made up the length and in what order
>> they existed. Hmm....
> 
> The Stratus C compiler provides both BCPL and C strings. IIRC,
> the length component of the BCPL-PL/I style string is a 16-bit
> unsigned value.
> 
> It does require additional library functions (as well as the
> expected conversions back and forth) - and is comparable to
> using both imperial and metric systems in a machine design
> (IMHO, _not_ a great idea).
> 
> I felt that the existing C string implementation was easier to
> work with, but that may just have been a matter of being more
> used to it.

In general, the objections to C string format are due to:

  1.  The lack of an immediately available length.
  2.  Vulnerability to overwriting past storage end.

1. is greatly mitigated by the fact that strings are usually short,
and thus it is a trivial effort to extract the length, with usually
highly optimized code in strlen().

2. is the real bug-a-boo.  Use of carefully crafted routines, such
as strlcpy and strlcat will virtually eliminate those problems. 
Unfortunately, those routines are not present in standard C
libraries.

-- 
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: <http://cbfalconer.home.att.net>
            Try the download section.



-- 
Posted via a free Usenet account from http://www.teranews.com
 




 61 Posts in Topic:
reinventing ASCII?
wildhalcyon <wild.halc  2008-03-03 05:56:01 
Re: reinventing ASCII?
"cr88192" <c  2008-03-04 05:35:03 
Re: reinventing ASCII?
"Rod Pemberton"  2008-03-03 15:13:13 
Re: reinventing ASCII?
Jacko <jackokring@[EMA  2008-03-03 12:58:14 
Re: reinventing ASCII?
torbenm@[EMAIL PROTECTED]  2008-03-04 10:19:06 
Re: reinventing ASCII?
Eliot Miranda <eliotm@  2008-03-04 13:18:31 
Re: reinventing ASCII?
"Charlie Gordon"  2008-03-05 03:58:24 
Re: reinventing ASCII?
ram@[EMAIL PROTECTED] (S  2008-03-05 03:26:51 
Re: reinventing ASCII?
torbenm@[EMAIL PROTECTED]  2008-03-05 10:31:40 
Re: reinventing ASCII?
Edward Feustel <efeust  2008-03-05 06:32:23 
Re: reinventing ASCII?
James Harris <james.ha  2008-03-05 15:05:37 
Re: reinventing ASCII?
torbenm@[EMAIL PROTECTED]  2008-03-06 11:34:33 
Re: NUL to terminate strings; was reinventing ASCII?
James Harris <james.ha  2008-03-08 07:16:34 
Re: NUL to terminate strings; was reinventing ASCII?
Eric Sosman <esosman@[  2008-03-08 10:48:58 
Re: NUL to terminate strings; was reinventing ASCII?
"Rod Pemberton"  2008-03-08 19:29:00 
Re: NUL to terminate strings; was reinventing ASCII?
Ulrich Eckhardt <dooms  2008-03-09 09:18:15 
Re: NUL to terminate strings; was reinventing ASCII?
torbenm@[EMAIL PROTECTED]  2008-03-11 11:04:42 
Re: NUL to terminate strings; was reinventing ASCII?
santosh <santosh.k83@[  2008-03-11 16:26:16 
Re: NUL to terminate strings; was reinventing ASCII?
richard@[EMAIL PROTECTED]  2008-03-11 11:10:37 
Re: NUL to terminate strings; was reinventing ASCII?
torbenm@[EMAIL PROTECTED]  2008-03-12 09:43:18 
Re: NUL to terminate strings; was reinventing ASCII?
santosh <santosh.k83@[  2008-03-12 14:25:04 
Re: NUL to terminate strings; was reinventing ASCII?
"Wilhelm B. Kloke&qu  2008-03-12 09:18:23 
Re: NUL to terminate strings; was reinventing ASCII?
Marco van de Voort <ma  2008-03-12 11:08:21 
Re: NUL to terminate strings; was reinventing ASCII?
"Wilhelm B. Kloke&qu  2008-03-12 12:33:14 
Re: NUL to terminate strings; was reinventing ASCII?
Marco van de Voort <ma  2008-03-12 14:11:25 
Re: NUL to terminate strings; was reinventing ASCII?
Chris Dollin <chris.do  2008-03-12 13:33:42 
Re: NUL to terminate strings; was reinventing ASCII?
"Wilhelm B. Kloke&qu  2008-03-12 15:34:40 
Re: NUL to terminate strings; was reinventing ASCII?
"Default User"   2008-03-12 18:22:45 
Re: NUL to terminate strings; was reinventing ASCII?
"Default User"   2008-03-12 18:22:45 
Re: NUL to terminate strings; was reinventing ASCII?
"Default User"   2008-03-11 21:26:05 
Re: NUL to terminate strings; was reinventing ASCII?
Micah Cowan <micah@[EM  2008-03-11 15:14:10 
Re: NUL to terminate strings; was reinventing ASCII?
richard@[EMAIL PROTECTED]  2008-03-11 22:27:14 
Re: NUL to terminate strings; was reinventing ASCII?
Morris Dovey <mrdovey@  2008-03-08 09:45:05 
Re: NUL to terminate strings; was reinventing ASCII?
Ben Bacarisse <ben.use  2008-03-08 17:22:36 
Re: NUL to terminate strings; was reinventing ASCII?
billg999@[EMAIL PROTECTED  2008-03-08 18:27:46 
Re: NUL to terminate strings; was reinventing ASCII?
James Harris <james.ha  2008-03-09 17:16:03 
Re: NUL to terminate strings; was reinventing ASCII?
richard@[EMAIL PROTECTED]  2008-03-10 01:08:23 
Re: NUL to terminate strings; was reinventing ASCII?
Ben Bacarisse <ben.use  2008-03-10 12:13:19 
Re: NUL to terminate strings; was reinventing ASCII?
James Harris <james.ha  2008-03-10 08:45:25 
Re: NUL to terminate strings; was reinventing ASCII?
"Rod Pemberton"  2008-03-10 19:26:16 
Re: NUL to terminate strings; was reinventing ASCII?
Eric Sosman <esosman@[  2008-03-10 21:03:06 
Re: NUL to terminate strings; was reinventing ASCII?
Marco van de Voort <ma  2008-03-11 11:06:14 
Re: NUL to terminate strings; was reinventing ASCII?
CBFalconer <cbfalconer  2008-03-11 15:22:58 
Re: NUL to terminate strings; was reinventing ASCII?
Eric Sosman <Eric.Sosm  2008-03-13 17:37:20 
Re: NUL to terminate strings; was reinventing ASCII?
rlb@[EMAIL PROTECTED] (R  2008-03-14 09:32:54 
Re: NUL to terminate strings; was reinventing ASCII?
Eric Sosman <esosman@[  2008-03-14 09:21:41 
Re: NUL to terminate strings; was reinventing ASCII?
"Rod Pemberton"  2008-03-14 17:48:27 
Re: NUL to terminate strings; was reinventing ASCII?
Morris Dovey <mrdovey@  2008-03-10 10:35:21 
Re: NUL to terminate strings; was reinventing ASCII?
"Rod Pemberton"  2008-03-10 19:09:27 
Re: NUL to terminate strings; was reinventing ASCII?
Eric Sosman <esosman@[  2008-03-10 21:00:14 
Re: NUL to terminate strings; was reinventing ASCII?
Marco van de Voort <ma  2008-03-11 11:04:46 
Re: NUL to terminate strings; was reinventing ASCII?
billg999@[EMAIL PROTECTED  2008-03-11 12:04:26 
Re: NUL to terminate strings; was reinventing ASCII?
billg999@[EMAIL PROTECTED  2008-03-11 12:07:36 
Re: NUL to terminate strings; was reinventing ASCII?
Neilist <lattoralee@[E  2008-03-11 14:28:23 
Re: NUL to terminate strings; was reinventing ASCII?
richard@[EMAIL PROTECTED]  2008-03-11 22:22:36 
Re: NUL to terminate strings; was reinventing ASCII?
Richard <devr_@[EMAIL   2008-03-11 23:23:21 
Re: NUL to terminate strings; was reinventing ASCII?
Jacko <jackokring@[EMA  2008-03-12 11:49:33 
Re: NUL to terminate strings; was reinventing ASCII?
Micah Cowan <micah@[EM  2008-03-12 19:01:00 
Re: NUL to terminate strings
CBFalconer <cbfalconer  2008-03-10 17:35:16 
Re: NUL to terminate strings
rlb@[EMAIL PROTECTED] (R  2008-03-14 09:28:38 
Re: NUL to terminate strings; was reinventing ASCII?
BruceMcF <agila61@[EMA  2008-04-12 18:27:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 5:27:04 CDT 2008.