[Info-vax] C str calls
VAXman- at SendSpamHere.ORG
VAXman- at SendSpamHere.ORG
Sun Aug 23 18:58:51 EDT 2015
In article <6953ee43-47db-4dfd-9623-9aabd2d1a96f at googlegroups.com>, mcleanjoh at gmail.com writes:
>On Monday, August 24, 2015 at 4:43:26 AM UTC+10, JF Mezei wrote:
>> C is like a knife.
>>
>> When you don't know about its dangers, you get finger cuts as you handle
>> knife or try to wash it.
>>
>> When you know how to handle the knife, you know how to handle it so that
>> you don't get cut, including how you can slide your fingers on it to
>> wash it and not get cut.
>
>IIRC someone, maybe here, advocated a form of string descriptor for C so that issues of length were easier to deal with - pass the address of the descriptor as an argument rather than the pointer to the string and, separately, the string length.
>
>I'm thinking that the descriptor holding not just maximum length but also current length might be useful, of course with a pointer to the string.
If we're talking about C on VMS, use string descriptors; there's nothing in
C that prohibits it.
#include <descrip.h>
struct dsc$descriptor_d xx = { 0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0 }; // dynamic
struct dsc$descriptor_s yy = { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0 }; // static
Or, use that fugly $DESCRIPTOR() substituter.
--
VAXman- A Bored Certified VMS Kernel Mode Hacker VAXman(at)TMESIS(dot)ORG
I speak to machines with the voice of humanity.
More information about the Info-vax
mailing list