dtrace-utils icon indicating copy to clipboard operation
dtrace-utils copied to clipboard

Inconsistent behaviour between trace(strtok(...)) and s = strtok(...); trace(s)

Open kvanhees opened this issue 4 years ago • 0 comments

Consider the following:

dtrace -n BEGIN'{ x = "a|b|c|"; trace(x); trace(strtok(x, "|")); trace(strtok(NULL, "|")); trace(strtok(NULL, "|")); trace(strtok(NULL, "|")); exit(0); }' dtrace: description 'BEGIN' matched 1 probe dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address (0x0) in action #1

vs

dtrace -n BEGIN'{ x = "a|b|c|"; trace(x); trace(strtok(x, "|")); trace(strtok(NULL, "|")); trace(strtok(NULL, "|")); s = strtok(NULL, "|"); trace(s); exit(0); }' dtrace: description 'BEGIN' matched 1 probe CPU ID FUNCTION:NAME 9 1 :BEGIN a|b|c| a b c

In the second case, s is output as the empty string while the first example would indicate that the result of the strtok is NULL.

kvanhees avatar Dec 03 '21 20:12 kvanhees