Declare do_str() function before the implementation

This ensures that GCC does not discard the do_str implementation in
some cases eg when compiling tests with debug enabled:
  make RUN_TESTS=1 DEBUG=1
Merge pull request #844 from chrisdearman/do_str

Declare do_str() function before the implementation