145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#ifndef re2c_substr_h 245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define re2c_substr_h 345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include <stdio.h> 545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include <stdlib.h> 645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include "tools/re2c/basics.h" 745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstruct SubStr { 945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org char *str; 1045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org unsigned int len; 1145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org}; 1245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgtypedef struct SubStr SubStr; 1445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgint SubStr_eq(const SubStr *, const SubStr *); 1645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void SubStr_init_u(SubStr*, unsigned char*, unsigned int); 1845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic SubStr *SubStr_new_u(unsigned char*, unsigned int); 1945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void SubStr_init(SubStr*, char*, unsigned int); 2145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic SubStr *SubStr_new(char*, unsigned int); 2245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void SubStr_copy(SubStr*, const SubStr*); 2445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic SubStr *SubStr_new_copy(const SubStr*); 2545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgvoid SubStr_out(const SubStr*, FILE *); 2745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define SubStr_delete(x) free(x) 2845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgtypedef struct SubStr Str; 3045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgvoid Str_init(Str*, const SubStr*); 3245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgStr *Str_new(const SubStr*); 3345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgvoid Str_copy(Str*, Str*); 3545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgStr *Str_new_copy(Str*); 3645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgStr *Str_new_empty(void); 3845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgvoid Str_destroy(Str *); 3945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgvoid Str_delete(Str *); 4045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 4145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void 4245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgSubStr_init_u(SubStr *r, unsigned char *s, unsigned int l) 4345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 4445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org r->str = (char*)s; 4545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org r->len = l; 4645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 4745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 4845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic SubStr * 4945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgSubStr_new_u(unsigned char *s, unsigned int l) 5045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 5145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org SubStr *r = malloc(sizeof(SubStr)); 5245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org r->str = (char*)s; 5345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org r->len = l; 5445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return r; 5545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 5645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 5745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void 5845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgSubStr_init(SubStr *r, char *s, unsigned int l) 5945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 6045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org r->str = s; 6145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org r->len = l; 6245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 6345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 6445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic SubStr * 6545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgSubStr_new(char *s, unsigned int l) 6645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 6745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org SubStr *r = malloc(sizeof(SubStr)); 6845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org r->str = s; 6945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org r->len = l; 7045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return r; 7145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 7245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 7345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic void 7445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgSubStr_copy(SubStr *r, const SubStr *s) 7545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 7645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org r->str = s->str; 7745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org r->len = s->len; 7845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 7945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 8045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstatic SubStr * 8145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgSubStr_new_copy(const SubStr *s) 8245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org{ 8345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org SubStr *r = malloc(sizeof(SubStr)); 8445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org r->str = s->str; 8545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org r->len = s->len; 8645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return r; 8745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 8845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 8945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#endif 90