Skip to content

Instantly share code, notes, and snippets.

@LebedevRI
Forked from codingdave/variables.c
Last active February 8, 2017 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LebedevRI/99d6d9753f2f02e5937fbea663307a45 to your computer and use it in GitHub Desktop.
Save LebedevRI/99d6d9753f2f02e5937fbea663307a45 to your computer and use it in GitHub Desktop.
gchar *_string_get_next_variable(gchar *string, gchar *variable, const size_t variable_size)
{
gchar *end = NULL;
gchar *start = g_strstr_len(string, -1, "$(");
if(start)
{
end = g_strstr_len(start, -1, ")");
if(end)
{
*end = '\0';
g_strlcpy(variable, start, variable_size);
// the string in variable is null terminated
end++;
}
}
return end;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment