Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: fusl/src/regex/tre.h

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: fusl/src/regex/tre.h
diff --git a/fusl/src/regex/tre.h b/fusl/src/regex/tre.h
index 67cb9a84fb9b8c78e71e93642b533834963434d4..6859d869524031c0d8f0825ab72eac3077b7639f 100644
--- a/fusl/src/regex/tre.h
+++ b/fusl/src/regex/tre.h
@@ -33,7 +33,7 @@
#include <wchar.h>
#include <wctype.h>
-#undef TRE_MBSTATE
+#undef TRE_MBSTATE
#define NDEBUG
@@ -42,9 +42,11 @@ typedef int reg_errcode_t;
typedef wchar_t tre_char_t;
-#define DPRINT(msg) do { } while(0)
+#define DPRINT(msg) \
+ do { \
+ } while (0)
-#define elementsof(x) ( sizeof(x) / sizeof(x[0]) )
+#define elementsof(x) (sizeof(x) / sizeof(x[0]))
#define tre_mbrtowc(pwc, s, n, ps) (mbtowc((pwc), (s), (n)))
@@ -67,19 +69,19 @@ typedef wint_t tre_cint_t;
#define tre_tolower towlower
#define tre_toupper towupper
-#define tre_strlen wcslen
+#define tre_strlen wcslen
/* Use system provided iswctype() and wctype(). */
typedef wctype_t tre_ctype_t;
#define tre_isctype iswctype
-#define tre_ctype wctype
+#define tre_ctype wctype
/* Returns number of bytes to add to (char *)ptr to make it
properly aligned for the type. */
-#define ALIGN(ptr, type) \
- ((((long)ptr) % sizeof(type)) \
- ? (sizeof(type) - (((long)ptr) % sizeof(type))) \
- : 0)
+#define ALIGN(ptr, type) \
+ ((((long)ptr) % sizeof(type)) \
+ ? (sizeof(type) - (((long)ptr) % sizeof(type))) \
+ : 0)
#undef MAX
#undef MIN
@@ -95,11 +97,11 @@ struct tnfa_transition {
tre_cint_t code_min;
tre_cint_t code_max;
/* Pointer to the destination state. */
- tre_tnfa_transition_t *state;
+ tre_tnfa_transition_t* state;
/* ID number of the destination state. */
int state_id;
/* -1 terminated array of tags (or NULL). */
- int *tags;
+ int* tags;
/* Assertion bitmap. */
int assertions;
/* Assertion parameters. */
@@ -110,27 +112,23 @@ struct tnfa_transition {
int backref;
} u;
/* Negative character class assertions. */
- tre_ctype_t *neg_classes;
+ tre_ctype_t* neg_classes;
};
-
/* Assertions. */
-#define ASSERT_AT_BOL 1 /* Beginning of line. */
-#define ASSERT_AT_EOL 2 /* End of line. */
-#define ASSERT_CHAR_CLASS 4 /* Character class in `class'. */
-#define ASSERT_CHAR_CLASS_NEG 8 /* Character classes in `neg_classes'. */
-#define ASSERT_AT_BOW 16 /* Beginning of word. */
-#define ASSERT_AT_EOW 32 /* End of word. */
-#define ASSERT_AT_WB 64 /* Word boundary. */
-#define ASSERT_AT_WB_NEG 128 /* Not a word boundary. */
-#define ASSERT_BACKREF 256 /* A back reference in `backref'. */
-#define ASSERT_LAST 256
+#define ASSERT_AT_BOL 1 /* Beginning of line. */
+#define ASSERT_AT_EOL 2 /* End of line. */
+#define ASSERT_CHAR_CLASS 4 /* Character class in `class'. */
+#define ASSERT_CHAR_CLASS_NEG 8 /* Character classes in `neg_classes'. */
+#define ASSERT_AT_BOW 16 /* Beginning of word. */
+#define ASSERT_AT_EOW 32 /* End of word. */
+#define ASSERT_AT_WB 64 /* Word boundary. */
+#define ASSERT_AT_WB_NEG 128 /* Not a word boundary. */
+#define ASSERT_BACKREF 256 /* A back reference in `backref'. */
+#define ASSERT_LAST 256
/* Tag directions. */
-typedef enum {
- TRE_TAG_MINIMIZE = 0,
- TRE_TAG_MAXIMIZE = 1
-} tre_tag_direction_t;
+typedef enum { TRE_TAG_MINIMIZE = 0, TRE_TAG_MAXIMIZE = 1 } tre_tag_direction_t;
/* Instructions to compute submatch register values from tag values
after a successful match. */
@@ -140,26 +138,25 @@ struct tre_submatch_data {
/* Tag that gives the value for rm_eo (submatch end offset). */
int eo_tag;
/* List of submatches this submatch is contained in. */
- int *parents;
+ int* parents;
};
typedef struct tre_submatch_data tre_submatch_data_t;
-
/* TNFA definition. */
typedef struct tnfa tre_tnfa_t;
struct tnfa {
- tre_tnfa_transition_t *transitions;
+ tre_tnfa_transition_t* transitions;
unsigned int num_transitions;
- tre_tnfa_transition_t *initial;
- tre_tnfa_transition_t *final;
- tre_submatch_data_t *submatch_data;
- char *firstpos_chars;
+ tre_tnfa_transition_t* initial;
+ tre_tnfa_transition_t* final;
+ tre_submatch_data_t* submatch_data;
+ char* firstpos_chars;
int first_char;
unsigned int num_submatches;
- tre_tag_direction_t *tag_directions;
- int *minimal_tags;
+ tre_tag_direction_t* tag_directions;
+ int* minimal_tags;
int num_tags;
int num_minimals;
int end_tag;
@@ -174,29 +171,32 @@ struct tnfa {
#define TRE_MEM_BLOCK_SIZE 1024
typedef struct tre_list {
- void *data;
- struct tre_list *next;
+ void* data;
+ struct tre_list* next;
} tre_list_t;
typedef struct tre_mem_struct {
- tre_list_t *blocks;
- tre_list_t *current;
- char *ptr;
+ tre_list_t* blocks;
+ tre_list_t* current;
+ char* ptr;
size_t n;
int failed;
- void **provided;
-} *tre_mem_t;
+ void** provided;
+} * tre_mem_t;
-#define tre_mem_new_impl __tre_mem_new_impl
+#define tre_mem_new_impl __tre_mem_new_impl
#define tre_mem_alloc_impl __tre_mem_alloc_impl
-#define tre_mem_destroy __tre_mem_destroy
+#define tre_mem_destroy __tre_mem_destroy
-tre_mem_t tre_mem_new_impl(int provided, void *provided_block);
-void *tre_mem_alloc_impl(tre_mem_t mem, int provided, void *provided_block,
- int zero, size_t size);
+tre_mem_t tre_mem_new_impl(int provided, void* provided_block);
+void* tre_mem_alloc_impl(tre_mem_t mem,
+ int provided,
+ void* provided_block,
+ int zero,
+ size_t size);
/* Returns a new memory allocator or NULL if out of memory. */
-#define tre_mem_new() tre_mem_new_impl(0, NULL)
+#define tre_mem_new() tre_mem_new_impl(0, NULL)
/* Allocates a block of `size' bytes from `mem'. Returns a pointer to the
allocated block or NULL if an underlying malloc() failed. */
@@ -214,13 +214,12 @@ void *tre_mem_alloc_impl(tre_mem_t mem, int provided, void *provided_block,
#define tre_mem_newa() \
tre_mem_new_impl(1, alloca(sizeof(struct tre_mem_struct)))
-#define tre_mem_alloca(mem, size) \
- ((mem)->n >= (size) \
- ? tre_mem_alloc_impl((mem), 1, NULL, 0, (size)) \
- : tre_mem_alloc_impl((mem), 1, alloca(TRE_MEM_BLOCK_SIZE), 0, (size)))
+#define tre_mem_alloca(mem, size) \
+ ((mem)->n >= (size) \
+ ? tre_mem_alloc_impl((mem), 1, NULL, 0, (size)) \
+ : tre_mem_alloc_impl((mem), 1, alloca(TRE_MEM_BLOCK_SIZE), 0, (size)))
#endif /* TRE_USE_ALLOCA */
-
/* Frees the memory allocator and all memory allocated with it. */
void tre_mem_destroy(tre_mem_t mem);
@@ -228,4 +227,3 @@ void tre_mem_destroy(tre_mem_t mem);
#define xcalloc calloc
#define xfree free
#define xrealloc realloc
-

Powered by Google App Engine
This is Rietveld 408576698