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 44 of 61 Topic 1118 of 1217
Post > Topic >>

Re: NUL to terminate strings; was reinventing ASCII?

by Eric Sosman <Eric.Sosman@[EMAIL PROTECTED] > Mar 13, 2008 at 05:37 PM

CBFalconer wrote:
> Eric Sosman wrote:
>> Rod Pemberton wrote:
>>
>>> A string can be an contiguous sequence of char - even with a
>>> length prefix. Whether it's C compliant is a separate issue. 
>>> The header containing the length just needs to be placed prior
>>> to the address representing the start of the string.
>>      "Prior to," but at what distance?
>>
>>         char *string = "Vogon poetry";
>>         assert (strlen(string) == 12);
>>         assert (strlen(string+6) == ???);
> 
> I don't see any point.  What is wrong with:
> 
>           assert (strlen(string + 6) == 6);

     Pemberton's proposal (as I understood it, anyhow) was to
store a string's length just before its first character, in
much the say some malloc() implementations store metadata
just before an allocated block:

	[12] V o g o n   p o e t r y
	     ^
	     The decayed `string' points here

strlen() would swizzle its argument to locate and fetch the 12
without hunting for a (non-existent) sentinel character.  And
my point was that

	[12] V o g o n   p o e t r y
	                 ^
	                 `string+6' points here

.... would cause strlen() to mis-swizzle its argument and
pick up some kind of garbage length.

-- 
Eric.Sosman@[EMAIL PROTECTED]

 




 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 Fri Jul 25 18:14:50 CDT 2008.