MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / getnext

Function getnext

lua/sp.c:5973–6014  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5971} sparg_t;
5972
5973static const char *getnext(const char *in, char **a, char **b, void *buf,
5974 int bufsz)
5975{
5976 *a = NULL;
5977 ptrdiff_t len;
5978 const char *start;
5979
5980 /* QUOTED ARG */
5981 if (*in == '"' || *in == '\'') {
5982 start = in++;
5983 char qt = *start;
5984 while (*in && *in != qt)
5985 ++in;
5986 if (*in != qt) return NULL;
5987 ++in;
5988 goto out;
5989 }
5990
5991 /* UNQUOTED ARG */
5992 start = in;
5993 while (*in && *in != ')' && *in != ',' && !isspace(*in))
5994 ++in;
5995
5996out:
5997 len = in - start;
5998 if (len == 0) return NULL;
5999 if (len + 1 < bufsz)
6000 *a = buf;
6001 else
6002 *a = malloc(len + 1);
6003 memcpy(*a, start, len);
6004 (*a)[len] = '\0';
6005 *b = *a + len;
6006
6007 /* move pointer to next arg */
6008 while (isspace(*in))
6009 ++in;
6010 if (*in == ',') ++in;
6011 while (isspace(*in))
6012 ++in;
6013 return in;
6014}
6015
6016static inline int ascii2num(int a)
6017{

Callers 1

getargFunction · 0.85

Calls 1

mallocFunction · 0.85

Tested by

no test coverage detected