On Mon, Jan 25, 2016 at 10:41:38PM +, Rainer Weikusat wrote:
[cut]
>
> But the loop in
>
> static char const *get_name(char const *arg0)
> {
> char const *n, *r;
>
> n = r = arg0;
> while (*r) if (*r++ == '/') n = r;
> return n;
> }
>
> is not of this type. It contains an
Peter Olson writes:
>> On January 25, 2016 at 5:54 PM Rainer Weikusat
>> wrote:
>
> [...]
>
>> A related but IMHO more interesting set of questions could be:
>>
>> 1. Should every trivial crap $someone ever implemented since 1978 end up
>>in
KatolaZ writes:
> On Mon, Jan 25, 2016 at 05:44:11PM -0500, Peter Olson wrote:
>
> [cut]
>
>>
>> This also brings up the question of whether you should roll your own
>> get_name or
>> use basename(3) which already does the same thing except in some edge cases.
>> It's
> On January 26, 2016 at 2:30 PM Rainer Weikusat
> wrote:
>
> Peter Olson writes:
> >> On January 25, 2016 at 5:54 PM Rainer Weikusat
> >> wrote:
> >
> > [...]
> >
> >> A related but IMHO more interesting set of
Peter Olson writes:
[...]
>> it (the string would need to be copied, including handling errors in
>
> Living on the edge?
The standardized definition of the function requests that unless one is
happy with the original string being changed.
On Mon, Jan 25, 2016 at 05:44:11PM -0500, Peter Olson wrote:
[cut]
>
> This also brings up the question of whether you should roll your own get_name
> or
> use basename(3) which already does the same thing except in some edge cases.
> It's easier for the student to understand the code if it
> On January 25, 2016 at 5:54 PM Rainer Weikusat
> wrote:
[...]
> A related but IMHO more interesting set of questions could be:
>
> 1. Should every trivial crap $someone ever implemented since 1978 end up
>in general purpose library just because $someone
On Mon, Jan 25, 2016 at 12:23:01PM +, Rainer Weikusat wrote:
> KatolaZ writes:
>
> [...]
>
> > I still don't see the need for an internal buffer to print out a
> > formatted string, to be honest :)
>
> Everything in code can always be implemented in a number of
On Mon, Jan 25, 2016 at 01:47:46PM +0100, Didier Kryn wrote:
> Le 25/01/2016 13:23, Rainer Weikusat a écrit :
> > while (*r) if (*r++ == '/') n = r;
>
> Does it mean
>
> while (*r)
> {
> if (*r == '/')
> {
>n = r;
>r++;
> }
>
Le 25/01/2016 13:23, Rainer Weikusat a écrit :
while (*r) if (*r++ == '/') n = r;
Does it mean
while (*r)
{
if (*r == '/')
{
n = r;
r++;
}
}
or
while (*r)
{
if (*r == '/')
{
r++;
Le 25/01/2016 13:47, Didier Kryn a écrit :
while (*r)
{
if (*r == '/')
{
r++;
n = r;
}
}
It's not even that. A for loop would do it:
for ( ; *r; r++ ) n = r+1;
___
Dng mailing
Didier Kryn:
> Le 25/01/2016 13:23, Rainer Weikusat a écrit :
> > while (*r) if (*r++ == '/') n = r;
>
> Does it mean
>
> while (*r)
>{
> if (*r == '/')
> {
> n = r;
> r++;
> }
>}
>
> or
>
> while (*r)
>
Didier Kryn writes:
> Le 25/01/2016 13:23, Rainer Weikusat a écrit :
>> while (*r) if (*r++ == '/') n = r;
>
> Does it mean
>
> while (*r)
> {
> if (*r == '/')
> {
>n = r;
>r++;
> }
> }
>
> or
>
> while (*r)
Le 25/01/2016 16:08, Rainer Weikusat a écrit :
Didier Kryn writes:
Le 25/01/2016 13:23, Rainer Weikusat a écrit :
while (*r) if (*r++ == '/') n = r;
Does it mean
while (*r)
{
if (*r == '/')
{
n = r;
r++;
Didier Kryn writes:
[...]
>> A multi-line version could look like this:
>>
>> while (c = *r) {
>> ++r;
>> if (c == '/') n = r;
>> }
>>
>
> It might be done with a for loop. eg:
>
> for ( ; *r ; ++r) if(*r=='/') n=r;
> n++;
[...]
> The for loop is the best
Peter Olson writes:
>> On January 25, 2016 at 7:40 AM KatolaZ wrote:
>> On Mon, Jan 25, 2016 at 12:23:01PM +, Rainer Weikusat wrote:
[...]
>> > static char const *get_name(char const *arg0)
>> > {
>> > char const *n, *r;
>> >
>> > n = r =
Le 25/01/2016 23:44, Peter Olson a écrit :
This also brings up the question of whether you should roll your own get_name or
use basename(3) which already does the same thing except in some edge cases.
It's easier for the student to understand the code if it is implemented as
get_name, but the
Le 25/01/2016 19:11, Rainer Weikusat a écrit :
Didier Kryn writes:
[...]
A multi-line version could look like this:
while (c = *r) {
++r;
if (c == '/') n = r;
}
It might be done with a for loop. eg:
for ( ; *r ; ++r) if(*r=='/') n=r;
n++;
Rainer Weikusat writes:
> Didier Kryn writes:
>
> [...]
>
>>> A multi-line version could look like this:
>>>
>>> while (c = *r) {
>>> ++r;
>>> if (c == '/') n = r;
>>> }
>>>
>>
>> It might be done with a for loop. eg:
>>
>> for
> On January 25, 2016 at 7:40 AM KatolaZ wrote:
>
>
> On Mon, Jan 25, 2016 at 12:23:01PM +, Rainer Weikusat wrote:
> > KatolaZ writes:
> >
> > [...]
[...]
> > The program also contains a very nice example of why the post-increment
> >
KatolaZ writes:
[...]
> I still don't see the need for an internal buffer to print out a
> formatted string, to be honest :)
Everything in code can always be implemented in a number of different
ways, hence, whatever the code ends up doing is "not really needed" ---
it
21 matches
Mail list logo