+++ /dev/null
-/**********************************************************************\r
- regtrav.c - Oniguruma (regular expression library)\r
-**********************************************************************/\r
-/*-\r
- * Copyright (c) 2002-2004 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- * SUCH DAMAGE.\r
- */\r
-\r
-#include "regint.h"\r
-\r
-#ifdef USE_CAPTURE_HISTORY\r
-\r
-static int\r
-capture_tree_traverse(OnigCaptureTreeNode* node, int at,\r
- int(*callback_func)(int,int,int,int,int,void*),\r
- int level, void* arg)\r
-{\r
- int r, i;\r
-\r
- if (node == (OnigCaptureTreeNode* )0)\r
- return 0;\r
-\r
- if ((at & ONIG_TRAVERSE_CALLBACK_AT_FIRST) != 0) {\r
- r = (*callback_func)(node->group, node->beg, node->end,\r
- level, ONIG_TRAVERSE_CALLBACK_AT_FIRST, arg);\r
- if (r != 0) return r;\r
- }\r
-\r
- for (i = 0; i < node->num_childs; i++) {\r
- r = capture_tree_traverse(node->childs[i], at,\r
- callback_func, level + 1, arg);\r
- if (r != 0) return r;\r
- }\r
-\r
- if ((at & ONIG_TRAVERSE_CALLBACK_AT_LAST) != 0) {\r
- r = (*callback_func)(node->group, node->beg, node->end,\r
- level, ONIG_TRAVERSE_CALLBACK_AT_LAST, arg);\r
- if (r != 0) return r;\r
- }\r
-\r
- return 0;\r
-}\r
-#endif /* USE_CAPTURE_HISTORY */\r
-\r
-extern int\r
-onig_capture_tree_traverse(OnigRegion* region, int at,\r
- int(*callback_func)(int,int,int,int,int,void*), void* arg)\r
-{\r
-#ifdef USE_CAPTURE_HISTORY\r
- return capture_tree_traverse(region->history_root, at,\r
- callback_func, 0, arg);\r
-#else\r
- return ONIG_NO_SUPPORT_CONFIG;\r
-#endif\r
-}\r