diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-23 18:01:06 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-23 18:01:06 +0100 |
commit | c7a85982b468d326d05eeaa21669e019803942a6 (patch) | |
tree | c6b25e1a52402e107ff46b962a8c7332b2cb7f34 | |
parent | dfbffadbb973469a22d4cd05694edd73ebf5fca1 (diff) | |
download | eo_tokenizer-c7a85982b468d326d05eeaa21669e019803942a6.zip eo_tokenizer-c7a85982b468d326d05eeaa21669e019803942a6.tar.gz |
add _eo_tokenizer_token_get()
-rw-r--r-- | eo_tokenizer.rl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/eo_tokenizer.rl b/eo_tokenizer.rl index 8a1f57a..8b2118d 100644 --- a/eo_tokenizer.rl +++ b/eo_tokenizer.rl @@ -14,6 +14,19 @@ _eo_tokenizer_abort(Eo_Tokenizer *toknz, } #define ABORT(toknz, msg) _eo_tokenizer_abort(toknz, __FILE__, __FUNCTION__, __LINE__, msg); +static const char* +_eo_tokenizer_token_get(Eo_Tokenizer *toknz, char *p) +{ + if (toknz->saved.tok == NULL) ABORT(toknz, "toknz->saved.tok is NULL"); + int l = (p - toknz->saved.tok); + char d[BUFSIZE]; + memcpy(d, toknz->saved.tok, l); + d[l] = '\0'; + toknz->saved.tok = NULL; + ERR("token : >%s<", d); + return eina_stringshare_add(d); +} + %%{ machine common; |