Skip to content

gvpr index function produces wrong results

Steps to reproduce

save the following as indexBug.gvpr

BEGIN{

  int i;
  string s1, s2, s3;

  s2="123456789012";

  i=index(s2,"0");
  print("index: ", i, "  should be 9");
  i=index(s2,"4");
  print("index: ", i, "  should be 3");
  i=index(s2,"P");
  print("index: ", i, "  should be -1");
}
echo |gvpr -f indexBug.gvpr
index: -9  should be 9
index: -3  should be 3
index: -1  should be -1

Expected Behaviour

See above, only legal negative number is -1

Actual Behaviour

See above

OS Version

Linux

lsb_release -a
No LSB modules are available.
Distributor ID: Linuxmint
Description:    Linux Mint 20.1
Release:        20.1
Codename:       ulyssa

Graphviz Version

dot - graphviz version 3.0.1~dev.20220310.0251 (20220310.0251)