diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2025-06-30 11:15:47 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2025-06-30 11:15:47 -0400 |
commit | a94d4a90c063c1b148f4725938cdfb45f906e964 (patch) | |
tree | 5dfc65de9bc76504a14fcde88dd42aa063413e80 | |
parent | 43e828aca9e3eed2bf8a58cef8d8224d65586957 (diff) | |
download | stasis-a94d4a90c063c1b148f4725938cdfb45f906e964.tar.gz |
Update to_short_version() documentation
-rw-r--r-- | src/lib/core/include/str.h | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/lib/core/include/str.h b/src/lib/core/include/str.h index bb96db0..be497ed 100644 --- a/src/lib/core/include/str.h +++ b/src/lib/core/include/str.h @@ -293,18 +293,27 @@ int isdigit_s(const char *s); char *tolower_s(char *s); /** - * Return a copy of the input string with "." characters removed + * Reduce a version string to the major[minor] format used by Python * - * ~~~{.c} - * char *version = strdup("1.2.3"); - * char *version_short = to_short_version(str); - * // version_short is "123" - * free(version_short); + * @code{.c} + * #include <stdio.h> + * #include "str.h" * - * ~~~ + * int main(int argc, char *argv[]) { + * char python_version[] = "3.13.3" + * char *python_short_version = to_short_version(python_version); // "313" + * if (!python_short_version) { + * perror("unable to allocate memory for shortened python version"); + * return 1; + * } + * free(python_short_version); + * return 0; + * } + * @endcode * - * @param s input string - * @return pointer to new string + * @param s python version string + * @return the shortened version string + * @return NULL on error */ char *to_short_version(const char *s); |