Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #149173

Re: C String terminator

From T <T@invalid.invalid>
Newsgroups comp.lang.c
Subject Re: C String terminator
Date 2020-01-15 19:38 -0800
Organization A noiseless patient Spider
Message-ID <qvolrg$ean$1@dont-email.me> (permalink)
References (3 earlier) <87muaoimkt.fsf@nosuchdomain.example.com> <qvnncu$ci0$1@dont-email.me> <87a76ofad3.fsf@bsb.me.uk> <qvohm6$rt5$1@dont-email.me> <87muaodqqn.fsf@bsb.me.uk>

Show all headers | View raw


On 2020-01-15 19:28, Ben Bacarisse wrote:
> T <T@invalid.invalid> writes:
> 
>> On 2020-01-15 17:39, Ben Bacarisse wrote:
>>> T <T@invalid.invalid> writes:
>>>
>>>> On 2020-01-15 10:47, Keith Thompson wrote:
>>>>> T <T@invalid.invalid> writes:
>>>>>> On 2020-01-15 07:11, Jorgen Grahn wrote:
>>>>>>> If I were you, I'd not argue about the definition of words with these
>>>>>>> guys, unless their documentation is misleading.
>>>>>>
>>>>>> Ya, their conversion utility does not include
>>>>>> a nul terminator, so the arguing continues.
>>>>>> Took me forever to figure out where the strange
>>>>>> characters were coming from.
>>>>>
>>>>> Then your best bet is to put together a small example that
>>>>> demonstrates a bug.  Arguing about the definitions of terms in
>>>>> a language that is not the topic of their mailing list might not
>>>>> be productive.  It might be perfectly reasonable for Raku's native
>>>>> call interface to accept arguments that don't point to C strings,
>>>>> or for Raku to use the term "string" to refer to something that
>>>>> isn't a C string.
>>>>>
>>>>
>>>> I EVEN sent the gatekeeper PICTURES!
>>>>
>>>> https://ibb.co/tHy7ZQM
>>>
>>> That would not convince me, and I know you are right about this!  You
>>> need code, not pictures of output.  (Maybe you posted the code, but
>>> didn't see it.)
>>
>> I was trying to show him that if you did not properly
>> terminate your C String, that the Win API call would
>> careen through memory until it found its of nul.
>>
>> I did post the code.  I got my s*** jumped into for flooding
>> the group.  Some of the nice ones told me to take it to
>> GIT.  That is probably a good idea.
>>
>> If you would like to see it, I will post it to vpaste.net.
>> But it is hundred and hundred of lines.  Basically four modules
>> concerning various WinAPI calls I need fro a project.
> 
> I don't need to see it.  Also you can't really support a bug report with
> hundreds of lines of code.
> 
> Your best bet is to submit a patch to the documentation.  Note that all
> the example code needs is and extra ", 0":
> 
>    my $array = CArray[uint8].new($string.encode.list, 0);

Sweet!  I like it!  I am just included it in my paper.

By the way
     my $array = CArray[uint16].new($string.encode.list, 0);
the "0" at the end puts a zero in both bytes of teh last
word, which is perfect.


> and a note to the effect that, in general, character arrays passed to C
> functions taking strings should be null-terminated.
> 
> The example in the documentation is not actually wrong because it is
> possible that the C function knows or can assume the length of the
> usable data.  

You are asking for the C function to go careening.  It
is really bad practice.  Also, the C guys told those
functions that can figure out on the own are not
actually called a string function.  I can try to
find what they called it, just the wrote me a ton stuff.

> It's just a bad example as it's not really general.

JJ's point is that it works in the example, so it is not
an error.  My point is that the documentation should help
the reader understand how to use the thing in practice.
I lost.



Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

C String terminator T <T@invalid.invalid> - 2020-01-14 09:22 -0800
  Re: C String terminator Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-01-14 09:32 -0800
    Re: C String terminator T <T@invalid.invalid> - 2020-01-14 09:43 -0800
      Re: C String terminator Bart <bc@freeuk.com> - 2020-01-14 17:53 +0000
        Re: C String terminator David Brown <david.brown@hesbynett.no> - 2020-01-14 20:17 +0100
          Re: C String terminator Bart <bc@freeuk.com> - 2020-01-14 20:01 +0000
      Re: C String terminator Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-01-14 09:57 -0800
        Re: C String terminator Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-14 11:37 -0800
          Re: C String terminator T <T@invalid.invalid> - 2020-01-15 09:02 -0800
            Re: C String terminator T <T@invalid.invalid> - 2020-01-15 09:38 -0800
              Re: C String terminator T <T@invalid.invalid> - 2020-01-15 09:53 -0800
        Re: C String terminator Manfred <noname@add.invalid> - 2020-01-14 20:48 +0100
    Re: C String terminator chad <cdalten@gmail.com> - 2020-01-15 05:43 -0800
      Re: C String terminator Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-01-15 07:12 -0800
      Re: C String terminator Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-15 15:35 +0000
        Re: C String terminator chad <cdalten@gmail.com> - 2020-01-19 06:20 -0800
    Re: C String terminator Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-15 10:52 -0800
      Re: C String terminator Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-01-15 12:52 -0800
        Re: C String terminator gazelle@shell.xmission.com (Kenny McCormack) - 2020-01-15 20:56 +0000
        Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 02:17 +0000
        Re: C String terminator Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-15 21:54 -0800
          Re: C String terminator fir <profesor.fir@gmail.com> - 2020-01-16 02:07 -0800
            Re: C String terminator Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-01-16 02:45 -0800
              Re: C String terminator Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2020-01-16 08:21 -0700
                Re: C String terminator Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-01-16 08:03 -0800
              Re: C String terminator John Bode <jfbode1029@gmail.com> - 2020-01-16 09:06 -0800
              Re: C String terminator James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-16 11:29 -0800
      Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 02:01 +0000
        Re: C String terminator James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-15 23:02 -0500
        Re: C String terminator David Brown <david.brown@hesbynett.no> - 2020-01-16 11:15 +0100
          Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 13:07 +0000
        Re: C String terminator Manfred <noname@add.invalid> - 2020-01-17 18:43 +0100
          Re: C String terminator Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-01-21 04:00 -0800
          Re: C String terminator James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-21 05:00 -0800
  Re: C String terminator Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2020-01-14 12:36 -0700
    Re: C String terminator Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-14 12:05 -0800
      Re: C String terminator Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2020-01-14 13:54 -0700
        Re: C String terminator James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-14 15:03 -0800
          Re: C String terminator Thiago Adams <thiago.adams@gmail.com> - 2020-01-15 04:55 -0800
            Re: C String terminator Guillaume <message@bottle.org> - 2020-01-15 20:49 +0100
              Re: C String terminator Thiago Adams <thiago.adams@gmail.com> - 2020-01-15 12:55 -0800
        Re: C String terminator Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-14 21:31 -0800
    Re: C String terminator T <T@invalid.invalid> - 2020-01-15 09:28 -0800
      Re: C String terminator T <T@invalid.invalid> - 2020-01-15 09:38 -0800
        Re: C String terminator Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2020-01-15 10:50 -0700
          Re: C String terminator T <T@invalid.invalid> - 2020-01-15 10:17 -0800
        Re: C String terminator T <T@invalid.invalid> - 2020-01-15 09:53 -0800
  Re: C String terminator Richard Damon <Richard@Damon-Family.org> - 2020-01-14 21:43 -0500
  Re: C String terminator "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-01-14 22:52 -0800
    Re: C String terminator "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-01-14 22:54 -0800
  Re: C String terminator Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-15 02:00 -0800
    Re: C String terminator gazelle@shell.xmission.com (Kenny McCormack) - 2020-01-15 10:47 +0000
      Re: C String terminator Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-01-15 03:02 -0800
    Re: C String terminator T <T@invalid.invalid> - 2020-01-15 10:19 -0800
      Re: C String terminator Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-15 11:33 -0800
        Re: C String terminator T <T@invalid.invalid> - 2020-01-15 12:03 -0800
          Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 01:30 +0000
            Re: C String terminator T <T@invalid.invalid> - 2020-01-15 18:17 -0800
              Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 03:44 +0000
                Re: C String terminator T <T@invalid.invalid> - 2020-01-15 20:33 -0800
          Re: C String terminator fir <profesor.fir@gmail.com> - 2020-01-16 02:26 -0800
  Re: C String terminator Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-15 15:11 +0000
    Re: C String terminator T <T@invalid.invalid> - 2020-01-15 09:32 -0800
      Re: C String terminator Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-15 10:47 -0800
        Re: C String terminator T <T@invalid.invalid> - 2020-01-15 10:58 -0800
          Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 01:39 +0000
            Re: C String terminator T <T@invalid.invalid> - 2020-01-15 18:27 -0800
              Re: C String terminator T <T@invalid.invalid> - 2020-01-15 19:03 -0800
              Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 03:28 +0000
                Re: C String terminator T <T@invalid.invalid> - 2020-01-15 19:33 -0800
                Re: C String terminator T <T@invalid.invalid> - 2020-01-15 19:38 -0800
                Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 13:31 +0000
                Re: C String terminator T <T@invalid.invalid> - 2020-01-16 09:09 -0800
                Re: C String terminator Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2020-01-16 10:27 -0700
                Re: C String terminator T <T@invalid.invalid> - 2020-01-16 10:54 -0800
                Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 20:59 +0000
                Re: C String terminator T <T@invalid.invalid> - 2020-01-16 14:11 -0800
                Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 20:17 +0000
                Re: C String terminator T <T@invalid.invalid> - 2020-01-16 14:14 -0800
                Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 23:45 +0000
                Yes, Ben makes house calls (Was: C String terminator) gazelle@shell.xmission.com (Kenny McCormack) - 2020-01-16 23:57 +0000
                Re: C String terminator T <T@invalid.invalid> - 2020-01-17 11:28 -0800
                Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-17 20:46 +0000
                Re: C String terminator T <T@invalid.invalid> - 2020-01-17 12:48 -0800
                Re: C String terminator T <T@invalid.invalid> - 2020-01-17 12:54 -0800
                Re: C String terminator Bart <bc@freeuk.com> - 2020-01-17 21:02 +0000
                Re: C String terminator Bart <bc@freeuk.com> - 2020-01-17 21:21 +0000
                Re: C String terminator T <T@invalid.invalid> - 2020-01-17 13:35 -0800
                Re: C String terminator T <T@invalid.invalid> - 2020-01-17 13:44 -0800
                Re: C String terminator fir <profesor.fir@gmail.com> - 2020-01-17 15:03 -0800
                Re: C String terminator fir <profesor.fir@gmail.com> - 2020-01-17 15:06 -0800
                Re: C String terminator Ike Naar <ike@sdf.lonestar.org> - 2020-01-18 07:30 +0000
                Re: C String terminator Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-01-17 16:06 -0500
                Re: C String terminator Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-01-17 16:23 -0500
                Re: C String terminator T <T@invalid.invalid> - 2020-01-17 13:37 -0800
                Re: C String terminator Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-01-21 04:10 -0800
                Re: C String terminator Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-21 10:41 -0800
                Re: C String terminator Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-01-17 01:55 -0800
                Re: C String terminator Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-17 09:52 -0800
                Re: C String terminator T <T@invalid.invalid> - 2020-01-17 11:29 -0800
                Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 18:21 +0000
                Re: C String terminator T <T@invalid.invalid> - 2020-01-16 10:50 -0800
                Re: C String terminator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 20:50 +0000
                Re: C String terminator T <T@invalid.invalid> - 2020-01-16 14:17 -0800
  Re: C String terminator Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-15 09:59 -0800
  Re: C String terminator T <T@invalid.invalid> - 2020-01-15 10:15 -0800
  Re: C String terminator T <T@invalid.invalid> - 2020-01-18 21:42 -0800
    Re: C String terminator T <T@invalid.invalid> - 2020-01-19 22:13 -0800
  Re: C String terminator Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-21 19:49 +0100
  Re: C String terminator John Bode <jfbode1029@gmail.com> - 2020-01-21 15:33 -0800
    Re: C String terminator Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-21 23:19 -0800
    Re: C String terminator Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-22 08:39 +0100
      Re: C String terminator chad <cdalten@gmail.com> - 2020-01-22 06:59 -0800
        Re: C String terminator Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-22 18:44 +0100

csiph-web