]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regtrav.c
MdeModulePkg: Delete useless case code
[mirror_edk2.git] / MdeModulePkg / Universal / RegularExpressionDxe / Oniguruma / regtrav.c
CommitLineData
14b0e578
CS
1/**********************************************************************\r
2 regtrav.c - Oniguruma (regular expression library)\r
3**********************************************************************/\r
4/*-\r
5 * Copyright (c) 2002-2004 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>\r
6 * All rights reserved.\r
7 *\r
8 * Redistribution and use in source and binary forms, with or without\r
9 * modification, are permitted provided that the following conditions\r
10 * are met:\r
11 * 1. Redistributions of source code must retain the above copyright\r
12 * notice, this list of conditions and the following disclaimer.\r
13 * 2. Redistributions in binary form must reproduce the above copyright\r
14 * notice, this list of conditions and the following disclaimer in the\r
15 * documentation and/or other materials provided with the distribution.\r
16 *\r
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\r
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
27 * SUCH DAMAGE.\r
28 */\r
29\r
30#include "regint.h"\r
31\r
32#ifdef USE_CAPTURE_HISTORY\r
33\r
34static int\r
35capture_tree_traverse(OnigCaptureTreeNode* node, int at,\r
36 int(*callback_func)(int,int,int,int,int,void*),\r
37 int level, void* arg)\r
38{\r
39 int r, i;\r
40\r
41 if (node == (OnigCaptureTreeNode* )0)\r
42 return 0;\r
43\r
44 if ((at & ONIG_TRAVERSE_CALLBACK_AT_FIRST) != 0) {\r
45 r = (*callback_func)(node->group, node->beg, node->end,\r
46 level, ONIG_TRAVERSE_CALLBACK_AT_FIRST, arg);\r
47 if (r != 0) return r;\r
48 }\r
49\r
50 for (i = 0; i < node->num_childs; i++) {\r
51 r = capture_tree_traverse(node->childs[i], at,\r
52 callback_func, level + 1, arg);\r
53 if (r != 0) return r;\r
54 }\r
55\r
56 if ((at & ONIG_TRAVERSE_CALLBACK_AT_LAST) != 0) {\r
57 r = (*callback_func)(node->group, node->beg, node->end,\r
58 level, ONIG_TRAVERSE_CALLBACK_AT_LAST, arg);\r
59 if (r != 0) return r;\r
60 }\r
61\r
62 return 0;\r
63}\r
64#endif /* USE_CAPTURE_HISTORY */\r
65\r
66extern int\r
67onig_capture_tree_traverse(OnigRegion* region, int at,\r
68 int(*callback_func)(int,int,int,int,int,void*), void* arg)\r
69{\r
70#ifdef USE_CAPTURE_HISTORY\r
71 return capture_tree_traverse(region->history_root, at,\r
72 callback_func, 0, arg);\r
73#else\r
74 return ONIG_NO_SUPPORT_CONFIG;\r
75#endif\r
76}\r