Steve Litt writes:
> Rainer Weikusat wrote:
>
>> Can the effect of the following C function
>>
>> static void print_start(char const *name, char const *what)
>> {
[...]
>> }
>>
>> be considered obvious or should it rather get an
Am Montag, 25. Januar 2016 schrieb Rainer Weikusat:
> "Dr. Nikolaus Klepp" writes:
>
> [...]
>
> > What about making the source smaller and not the executable?
> >
> > static void print_start(char const *name, char const *what) {
> > if (name[0])
Le 24/01/2016 19:14, KatolaZ a écrit :
Soo, the above is nearly the same as
>
> char buf[total];
> p = buf;
>
>Why then use alloca()?
>
Maybe because
char buf[total];
works only in ANSI C11. I still don't see the need for an internal
buffer to print out a formatted string, to be
On Mon, Jan 25, 2016 at 09:27:15AM +0100, Didier Kryn wrote:
[cut]
>
> The following works in plain old C:
>
> #include
> #include
> static void print_start(char const *name, char const *what)
> {
> unsigned name_len, what_len, total;
>
> name_len = strlen(name);
>
Le 25/01/2016 11:34, KatolaZ a écrit :
I would say that having embedded subprograms in a function is not the
best thing one can do in C
Every block is a subprogram. The block in a do loop, the
conditional block in an if or while statement. The subprogram blocks are
everywhere in C;
Am Montag, 25. Januar 2016 schrieb KatolaZ:
> On Mon, Jan 25, 2016 at 09:27:15AM +0100, Didier Kryn wrote:
>
> [cut]
>
> >
> > The following works in plain old C:
> >
> > #include
> > #include
> > static void print_start(char const *name, char const *what)
> > {
> > unsigned
On Mon, Jan 25, 2016 at 12:18:09PM +0100, Dr. Nikolaus Klepp wrote:
[cut]
>
> What about making the source smaller and not the executable?
>
> static void print_start(char const *name, char const *what) {
> if (name[0]) fprintf("%c%s",name[0]&~0x20, name+1);
> fprintf(stderr, " %s:
Didier Kryn writes:
> Le 24/01/2016 19:14, KatolaZ a écrit :
>>> Soo, the above is nearly the same as
>>> >
>>> > char buf[total];
>>> > p = buf;
>>> >
>>> >Why then use alloca()?
>>> >
>> Maybe because
>> char buf[total];
>>
>> works only in ANSI C11. I still don't see
"Dr. Nikolaus Klepp" writes:
[...]
> What about making the source smaller and not the executable?
>
> static void print_start(char const *name, char const *what) {
> if (name[0]) fprintf("%c%s",name[0]&~0x20, name+1);
> fprintf(stderr, " %s: ",what);
> }
Are you
Peter Olson writes:
>> On January 23, 2016 at 1:36 PM Rainer Weikusat
>> wrote:
>>
>> Peter Olson writes:
>> 5>> On January 22, 2016 at 4:34 PM Rainer Weikusat
>> wrote:
>>
>> [...]
>>
>> >>
Didier Kryn writes:
> Le 23/01/2016 19:28, Rainer Weikusat a écrit :
>> Didier Kryn writes:
>>> Le 23/01/2016 12:16, Didier Kryn a écrit :
I'm curious of the reason why you specify
static void print_start(char const *name, char const *what)
[...]
k...@aspodata.se writes:
> Katola2:
> ...
>> void another_print_start(char *name, char *what){
>>
>> char c[3] = " :";
>>
>> c[2] = name[0] & ~0x20;
>>
>> write(2, c+2, 1);
>> write(2, name+1, strlen(name) -1);
>> write(2, c, 2);
>> write(2, what, strlen(what));
>>
>> }
>
> Why not just
Reiner Weikusat:
> Peter Olson writes:
>
> >> On January 23, 2016 at 1:36 PM Rainer Weikusat
> >> wrote:
> >>
> >> Peter Olson writes:
> >> 5>> On January 22, 2016 at 4:34 PM Rainer Weikusat
> >>
Rainer Weikusat:
> k...@aspodata.se writes:
> > Katola2:
> > ...
> >> void another_print_start(char *name, char *what){
> >>
> >> char c[3] = " :";
> >>
> >> c[2] = name[0] & ~0x20;
> >>
> >> write(2, c+2, 1);
> >> write(2, name+1, strlen(name) -1);
> >> write(2, c, 2);
> >> write(2,
On Sun, Jan 24, 2016 at 05:25:47PM +0100, k...@aspodata.se wrote:
[cut]
> ...
> > In this respect, there's no difference between alloca and static stack
> > allocations.
> ...
>
> Soo, the above is nearly the same as
>
> char buf[total];
> p = buf;
>
> Why then use alloca()?
>
Maybe
"Dr. Nikolaus Klepp" writes:
> Am Freitag, 22. Januar 2016 schrieb Rainer Weikusat:
[...]
>> name_len = strlen(name);
>> what_len = strlen(what);
>> total = name_len + what_len + 3;
>>
>> p = buf = alloca(total);
>> memcpy(p, name, name_len);
>> p
k...@aspodata.se writes:
> Reiner Weikusat:
>> Peter Olson writes:
>>
>> >> On January 23, 2016 at 1:36 PM Rainer Weikusat
>> >> wrote:
>> >>
>> >> Peter Olson writes:
>> >> 5>> On January 22, 2016 at 4:34 PM Rainer Weikusat
>>
k...@aspodata.se writes:
> Reiner Weikusat:
>> Peter Olson writes:
>>
>> >> On January 23, 2016 at 1:36 PM Rainer Weikusat
>> >> wrote:
>> >>
>> >> Peter Olson writes:
>> >> 5>> On January 22, 2016 at 4:34 PM Rainer Weikusat
>>
k...@aspodata.se writes:
> Rainer Weikusat:
>> k...@aspodata.se writes:
>> > Katola2:
>> > ...
>> >> void another_print_start(char *name, char *what){
>> >>
>> >> char c[3] = " :";
>> >>
>> >> c[2] = name[0] & ~0x20;
>> >>
>> >> write(2, c+2, 1);
>> >> write(2, name+1, strlen(name) -1);
>>
On Sat, Jan 23, 2016 at 02:10:46AM -0500, Peter Olson wrote:
[cut]
>
> I'm unhappy for two reasons:
>
> the failure mode of alloca is SIGSEGV or some other malfunction and there is
> no way to test for it
>
> the *buf &= ~0x20; breaks for UTF8 strings.
>
> Nevermind that the function
Le 22/01/2016 22:34, Rainer Weikusat a écrit :
Can the effect of the following C function
static void print_start(char const *name, char const *what)
{
char *buf, *p;
unsigned name_len, what_len, total;
name_len = strlen(name);
what_len = strlen(what);
total = name_len
Le 23/01/2016 14:48, Hendrik Boom a écrit :
I've always said the C syntax for declarators was confusing.
Even those who understand it read it wrong!
(Yes, In understand the logic behind it. It is still confusing.)
I fully agree: it's confusing.
Actually, in a single statement one can
On Fri, 22 Jan 2016 21:34:28 +
Rainer Weikusat wrote:
> Can the effect of the following C function
>
> static void print_start(char const *name, char const *what)
> {
> char *buf, *p;
> unsigned name_len, what_len, total;
>
> name_len =
On Sat, Jan 23, 2016 at 11:45:30AM -0500, Steve Litt wrote:
> On Fri, 22 Jan 2016 21:34:28 +
> Rainer Weikusat wrote:
>
> > Can the effect of the following C function
> >
> > static void print_start(char const *name, char const *what)
> > {
> > char *buf,
Didier Kryn writes:
> Le 23/01/2016 12:16, Didier Kryn a écrit :
>>
>> I'm curious of the reason why you specify
>>static void print_start(char const *name, char const *what)
>>
>> This means the pointers to the arrays of characters are constant
>> (not the
On Sat, Jan 23, 2016 at 06:59:10PM +0100, Didier Kryn wrote:
[cut]
>
> The syntax used by Rainer is usefull when declaring in the same
> statement constant and non-constant characters, which I, personnaly,
> try to avoid because it is confusing. Confusing statements simply
> boost the
On Sat, Jan 23, 2016 at 06:36:46PM +, Rainer Weikusat wrote:
> Peter Olson writes:
> 5>> On January 22, 2016 at 4:34 PM Rainer Weikusat
> wrote:
>
> [...]
>
> >> p = buf = alloca(total);
>
> [...]
>
> > the failure mode of alloca is
On Sat, Jan 23, 2016 at 04:45:05PM +0100, Didier Kryn wrote:
> Le 23/01/2016 12:16, Didier Kryn a écrit :
> >
> >I'm curious of the reason why you specify
> > static void print_start(char const *name, char const *what)
> >
> >This means the pointers to the arrays of characters are
>
Le 23/01/2016 12:16, Didier Kryn a écrit :
I'm curious of the reason why you specify
static void print_start(char const *name, char const *what)
This means the pointers to the arrays of characters are constant
(not the characters). The effect of this cannot be to protect the
Katola2:
...
> void another_print_start(char *name, char *what){
>
> char c[3] = " :";
>
> c[2] = name[0] & ~0x20;
>
> write(2, c+2, 1);
> write(2, name+1, strlen(name) -1);
> write(2, c, 2);
> write(2, what, strlen(what));
>
> }
Why not just use writev(2) and write it one system call ?
Peter Olson writes:
5>> On January 22, 2016 at 4:34 PM Rainer Weikusat
wrote:
[...]
>> p = buf = alloca(total);
[...]
> the failure mode of alloca is SIGSEGV or some other malfunction and
> there is no way to test for it
It's supposed
> On January 23, 2016 at 1:36 PM Rainer Weikusat
> wrote:
>
> Peter Olson writes:
> 5>> On January 22, 2016 at 4:34 PM Rainer Weikusat
> wrote:
>
> [...]
>
> >> p = buf = alloca(total);
>
> [...]
>
> >
Le 23/01/2016 19:28, Rainer Weikusat a écrit :
Didier Kryn writes:
Le 23/01/2016 12:16, Didier Kryn a écrit :
I'm curious of the reason why you specify
static void print_start(char const *name, char const *what)
This means the pointers to the arrays of characters
Can the effect of the following C function
static void print_start(char const *name, char const *what)
{
char *buf, *p;
unsigned name_len, what_len, total;
name_len = strlen(name);
what_len = strlen(what);
total = name_len + what_len + 3;
p = buf = alloca(total);
On Fri, Jan 22, 2016 at 09:34:28PM +, Rainer Weikusat wrote:
> Can the effect of the following C function
>
> static void print_start(char const *name, char const *what)
> {
[cut]
> be considered obvious or should it rather get an explanation?
>
katolaZ said:
Well, it will depend on
Am Freitag, 22. Januar 2016 schrieb Rainer Weikusat:
> Can the effect of the following C function
>
> static void print_start(char const *name, char const *what)
> {
> char *buf, *p;
> unsigned name_len, what_len, total;
>
> name_len = strlen(name);
> what_len = strlen(what);
>
> On January 22, 2016 at 4:34 PM Rainer Weikusat
> wrote:
>
> Can the effect of the following C function
>
> static void print_start(char const *name, char const *what)
> {
> char *buf, *p;
> unsigned name_len, what_len, total;
>
> name_len =
On Fri, Jan 22, 2016 at 09:34:28PM +, Rainer Weikusat wrote:
> Can the effect of the following C function
>
> static void print_start(char const *name, char const *what)
> {
> char *buf, *p;
> unsigned name_len, what_len, total;
>
> name_len = strlen(name);
> what_len =
38 matches
Mail list logo