Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The simple plugin code, presented in the plugin development documentation , contains the following code snippet:
hello-world.c
if (!TSPluginRegister(&info)) { TSError ("[plugin_name] Plugin registration failed."); }
But the header file defines the return code in the following way:
ts/apidef.h
typedef enum { TS_ERROR = -1, TS_SUCCESS = 0 } TSReturnCode;
Apparently, in case of success the return code is 0 and non-zero in case of failure, so the sample code is expected to be
hello-world.c suggested fix for condition
if (TSPluginRegister(&info)) { TSError ("[plugin_name] Plugin registration failed."); }
Also, it seems that on error TSPlugInit function should return immediately, like in the following suggestion:
hello-world.c suggested fix
if (TSPluginRegister(&info)) { TSError ("[plugin_name] Plugin registration failed."); return; }