aboutsummaryrefslogtreecommitdiff
path: root/tools/re2c/substr.h
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2013-03-28 15:33:02 +0000
committerTorne (Richard Coles) <torne@google.com>2013-03-28 15:33:02 +0000
commitc580f3c787d8ad2dcccceb4438b7572d9713a296 (patch)
treed8f5d6b20552cfe016f9af38440fd9caacf4a188 /tools/re2c/substr.h
parent1fe0cccaa99357259c9ab42ce88626b95856b77c (diff)
parent53137eb420065ea05c21ae0728a67ead80f17e1f (diff)
downloadpatched-yasm-kitkat-mr2.1-release.tar.gz
This commit was generated by merge_to_master.py. Change-Id: I1975b1fce5e96446e4fa27feda7009fe340d4cff
Diffstat (limited to 'tools/re2c/substr.h')
-rw-r--r--tools/re2c/substr.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/tools/re2c/substr.h b/tools/re2c/substr.h
new file mode 100644
index 0000000..0a19b93
--- /dev/null
+++ b/tools/re2c/substr.h
@@ -0,0 +1,89 @@
+#ifndef re2c_substr_h
+#define re2c_substr_h
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "tools/re2c/basics.h"
+
+struct SubStr {
+ char *str;
+ unsigned int len;
+};
+
+typedef struct SubStr SubStr;
+
+int SubStr_eq(const SubStr *, const SubStr *);
+
+static void SubStr_init_u(SubStr*, unsigned char*, unsigned int);
+static SubStr *SubStr_new_u(unsigned char*, unsigned int);
+
+static void SubStr_init(SubStr*, char*, unsigned int);
+static SubStr *SubStr_new(char*, unsigned int);
+
+static void SubStr_copy(SubStr*, const SubStr*);
+static SubStr *SubStr_new_copy(const SubStr*);
+
+void SubStr_out(const SubStr*, FILE *);
+#define SubStr_delete(x) free(x)
+
+typedef struct SubStr Str;
+
+void Str_init(Str*, const SubStr*);
+Str *Str_new(const SubStr*);
+
+void Str_copy(Str*, Str*);
+Str *Str_new_copy(Str*);
+
+Str *Str_new_empty(void);
+void Str_destroy(Str *);
+void Str_delete(Str *);
+
+static void
+SubStr_init_u(SubStr *r, unsigned char *s, unsigned int l)
+{
+ r->str = (char*)s;
+ r->len = l;
+}
+
+static SubStr *
+SubStr_new_u(unsigned char *s, unsigned int l)
+{
+ SubStr *r = malloc(sizeof(SubStr));
+ r->str = (char*)s;
+ r->len = l;
+ return r;
+}
+
+static void
+SubStr_init(SubStr *r, char *s, unsigned int l)
+{
+ r->str = s;
+ r->len = l;
+}
+
+static SubStr *
+SubStr_new(char *s, unsigned int l)
+{
+ SubStr *r = malloc(sizeof(SubStr));
+ r->str = s;
+ r->len = l;
+ return r;
+}
+
+static void
+SubStr_copy(SubStr *r, const SubStr *s)
+{
+ r->str = s->str;
+ r->len = s->len;
+}
+
+static SubStr *
+SubStr_new_copy(const SubStr *s)
+{
+ SubStr *r = malloc(sizeof(SubStr));
+ r->str = s->str;
+ r->len = s->len;
+ return r;
+}
+
+#endif