Menu ▾ ▴

#2896 strcol() returns something that's not a string

None
closed-fixed
nobody
None
55 minutes ago
2026-10-14
Anonymous
No

If your data has a missing value in the column strcol() is supposed to read, the returned value cannot be used with the "eq" string operator.

Example:

$dat << EOD                                       
1 A B
2 B 
3 A B
4 T H
5 A A
6 A B
EOD
plot $dat us 1 : (strcol(2) eq "A" ? 10 :-10) w lp  # column 2 is fine, no problem

 plot $dat us 1 : (strcol(3) eq "A" ? 10 :-10) w lp  # col 3 has one value missing
         internal error : STRING operator applied to undefined or non-STRING variable

I guess the return is undefined instead of a string with zero lenght (which I was expecting).

I found a workaround, concatenating strcol() to a zero lenght string:
~~~
plot $dat us 1 : ("".strcol(3) eq "A" ? 10 :-10) w lp` # Works
~~~

Discussion

  • Ethan Merritt

    Ethan Merritt - 2026-10-15
    • status: open --> pending-fixed
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2026-10-15

    Now fixed in master and will be included in 6.0.6

     
  • Ethan Merritt

    Ethan Merritt - 7 days ago
    • status: pending-fixed --> open
     
  • Ethan Merritt

    Ethan Merritt - 7 days ago

    Reopening this because the fix introduces another problem. Now strcol(N) on a missing column returns an empty string, but that string is never freed so it's a memory leak, albeit a small one.

     
  • Ethan Merritt

    Ethan Merritt - 10 hours ago
    • status: open --> pending-fixed
     
  • Ethan Merritt

    Ethan Merritt - 10 hours ago

    Reopening this because the fix introduces another problem. Now strcol(N) on a missing column returns an empty string, but that string is never freed so it's a memory leak, albeit a small one.

     
  • Ethan Merritt

    Ethan Merritt - 55 minutes ago
    • Status: pending-fixed --> closed-fixed
     

Log in to post a comment.