Austin Group Bug Tracker
2014-09-19 17:37:23 UTC
The following issue has been SUBMITTED.
======================================================================
http://austingroupbugs.net/view.php?id=878
======================================================================
Reported By: safinaskar
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 878
Category: System Interfaces
Type: Enhancement Request
Severity: Editorial
Priority: normal
Status: New
Name: Askar Safin
Organization:
User Reference:
Section: strtok, strtok_r
Page Number: strtok, strtok_r
Line Number: strtok, strtok_r
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-19 17:37 UTC
Last Modified: 2014-09-19 17:37 UTC
======================================================================
Summary: Is empty s2/sep allowed? What is the meaning of
"lasts"?
Description:
1. First of all, very minor issue. Argument names for "strtok" and
"strtok_r" are different. First uses s1 and s2, second - s and sep with
same meaning. This, for example, complicates writing such bug reports.
2. Second, the page doesn't say whatever empty string s2/sep is allowed.
Please, document this. I think that empty string s2/sep should be allowed
and strtok(_r) (if s2/sep is empty) should return remaining string. So,
this provides easy way to get the remaining string and to continue parsing
it using other tools.
I tested Debian GNU/Linux Wheezy 7.6.0, FreeBSD 10.0, OpenBSD 5.5, NetBSD
6.1.4, Oracle Solaris 11.2, Debian GNU/Hurd 2013-03-18 and all this systems
support empty s2/sep this way.
(Also I still have this systems, so if you want, I can perform some another
test on them)
(But this system list is, of course, very incomplete. It doesn't include
Cygwin and MinGW, it doesn't include very popular MacOS X and it doesn't
include HP-UX and AIX)
This means that the systems already support this behavior and some apps may
already depend on this.
So, please allow empty s2/sep and write something like this: "empty s2/sep
provides way to get remaining string".
I will assume in the remaining part of my bug report that you agree with my
point :)
3. Third, the page doesn't say what is the meaning of "lasts". But the page
names this argument as "lasts", and this implicitly implies that *lasts is
remaining string. So, please do one of the following:
A. Rename "lasts" to some other name, for example, "internal_data" or
something like that. Explicitly say that this "internal_data" is
implementation detail and the application should not depend on it. Say
something like that: "The only allowed use of "internal_data" is to pass it
to the next strtok_r call. If an application want to get the remaining
string, it should do "strtok_r(0, "", internal_data)"" (as I said I assume
that you will allow empty s2/sep).
B. Explicitly say that "lasts" is the remaining string.
I prefer B. I perform another test on that bunch of systems and on them
"lasts" is remaining string. So, please do B, because, again, getting
remaining string is so useful, because it is already supported in systems,
and because some apps may depend on this behavior.
Unfortunately, there is differences in "last" meaning. For example,
consider the following code:
char s[] = "a";
char *lasts;
strtok_r(s, "-", &lasts);
On GNU/Linux and GNU/Hurd "lasts" will be empty string. But on that three
BSD systems and on Solaris this is null pointer. So, please, document and
allow all such differences.
4. Fourth, I want to put some notes again. So, de-facto strtok_r currently
supports two ways of getting remaining string on real systems. It is lasts
and it is empty s2/sep. Getting remaining string is useful feature, so in
any case please allow at least one of this two methods. If you disallow
both methods, then I think apps continue to use one of them. Also, some
apps may depend on one of them and some on another, so the best is to allow
both methods.
Desired Action:
Do something (and I hate "Desired Action" field in your bug tracker)
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2014-09-19 17:37 safinaskar New Issue
2014-09-19 17:37 safinaskar Name => Askar Safin
2014-09-19 17:37 safinaskar Section => strtok, strtok_r
2014-09-19 17:37 safinaskar Page Number => strtok, strtok_r
2014-09-19 17:37 safinaskar Line Number => strtok, strtok_r
======================================================================
======================================================================
http://austingroupbugs.net/view.php?id=878
======================================================================
Reported By: safinaskar
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 878
Category: System Interfaces
Type: Enhancement Request
Severity: Editorial
Priority: normal
Status: New
Name: Askar Safin
Organization:
User Reference:
Section: strtok, strtok_r
Page Number: strtok, strtok_r
Line Number: strtok, strtok_r
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-09-19 17:37 UTC
Last Modified: 2014-09-19 17:37 UTC
======================================================================
Summary: Is empty s2/sep allowed? What is the meaning of
"lasts"?
Description:
1. First of all, very minor issue. Argument names for "strtok" and
"strtok_r" are different. First uses s1 and s2, second - s and sep with
same meaning. This, for example, complicates writing such bug reports.
2. Second, the page doesn't say whatever empty string s2/sep is allowed.
Please, document this. I think that empty string s2/sep should be allowed
and strtok(_r) (if s2/sep is empty) should return remaining string. So,
this provides easy way to get the remaining string and to continue parsing
it using other tools.
I tested Debian GNU/Linux Wheezy 7.6.0, FreeBSD 10.0, OpenBSD 5.5, NetBSD
6.1.4, Oracle Solaris 11.2, Debian GNU/Hurd 2013-03-18 and all this systems
support empty s2/sep this way.
(Also I still have this systems, so if you want, I can perform some another
test on them)
(But this system list is, of course, very incomplete. It doesn't include
Cygwin and MinGW, it doesn't include very popular MacOS X and it doesn't
include HP-UX and AIX)
This means that the systems already support this behavior and some apps may
already depend on this.
So, please allow empty s2/sep and write something like this: "empty s2/sep
provides way to get remaining string".
I will assume in the remaining part of my bug report that you agree with my
point :)
3. Third, the page doesn't say what is the meaning of "lasts". But the page
names this argument as "lasts", and this implicitly implies that *lasts is
remaining string. So, please do one of the following:
A. Rename "lasts" to some other name, for example, "internal_data" or
something like that. Explicitly say that this "internal_data" is
implementation detail and the application should not depend on it. Say
something like that: "The only allowed use of "internal_data" is to pass it
to the next strtok_r call. If an application want to get the remaining
string, it should do "strtok_r(0, "", internal_data)"" (as I said I assume
that you will allow empty s2/sep).
B. Explicitly say that "lasts" is the remaining string.
I prefer B. I perform another test on that bunch of systems and on them
"lasts" is remaining string. So, please do B, because, again, getting
remaining string is so useful, because it is already supported in systems,
and because some apps may depend on this behavior.
Unfortunately, there is differences in "last" meaning. For example,
consider the following code:
char s[] = "a";
char *lasts;
strtok_r(s, "-", &lasts);
On GNU/Linux and GNU/Hurd "lasts" will be empty string. But on that three
BSD systems and on Solaris this is null pointer. So, please, document and
allow all such differences.
4. Fourth, I want to put some notes again. So, de-facto strtok_r currently
supports two ways of getting remaining string on real systems. It is lasts
and it is empty s2/sep. Getting remaining string is useful feature, so in
any case please allow at least one of this two methods. If you disallow
both methods, then I think apps continue to use one of them. Also, some
apps may depend on one of them and some on another, so the best is to allow
both methods.
Desired Action:
Do something (and I hate "Desired Action" field in your bug tracker)
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2014-09-19 17:37 safinaskar New Issue
2014-09-19 17:37 safinaskar Name => Askar Safin
2014-09-19 17:37 safinaskar Section => strtok, strtok_r
2014-09-19 17:37 safinaskar Page Number => strtok, strtok_r
2014-09-19 17:37 safinaskar Line Number => strtok, strtok_r
======================================================================