mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into devel
This commit is contained in:
commit
04fbad730a
|
@ -6,22 +6,6 @@
|
|||
|
||||
include(ExternalProject)
|
||||
|
||||
################################################################################
|
||||
## GETOPT
|
||||
################################################################################
|
||||
|
||||
if (WINDOWS)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/getopt)
|
||||
endif ()
|
||||
|
||||
################################################################################
|
||||
## REGEX
|
||||
################################################################################
|
||||
|
||||
if (WINDOWS)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/regex)
|
||||
endif ()
|
||||
|
||||
################################################################################
|
||||
## EV
|
||||
################################################################################
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
# -*- mode: CMAKE; -*-
|
||||
|
||||
## -----------------------------------------------------------------------------
|
||||
## --SECTION-- COMMON DEFINES
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
|
||||
################################################################################
|
||||
### @brief getopt library
|
||||
################################################################################
|
||||
|
||||
project(getopt)
|
||||
|
||||
set(LIB_GETOPT getopt)
|
||||
|
||||
## -----------------------------------------------------------------------------
|
||||
## --SECTION-- LIBRARIES
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
################################################################################
|
||||
### @brief LIB_GETOPT
|
||||
################################################################################
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR})
|
||||
|
||||
add_library(
|
||||
${LIB_GETOPT}
|
||||
STATIC
|
||||
mygetopt.c
|
||||
)
|
||||
|
||||
set(GETOPT_INCLUDE_DIR
|
||||
${PROJECT_SOURCE_DIR}
|
||||
CACHE INTERNAL
|
||||
"${PROJECT_NAME}: Include Directories"
|
||||
)
|
|
@ -1,43 +0,0 @@
|
|||
OUT=../out/$(VS)-getopt-
|
||||
|
||||
.PHONY: all all_bits all_config install install_bits clean
|
||||
|
||||
all:
|
||||
$(MAKE) all_bits BITS=32 TARGET="$(TARGET)"
|
||||
$(MAKE) all_bits BITS=64 TARGET="$(TARGET) Win64"
|
||||
|
||||
all_bits:
|
||||
rm -rf Build$(BITS)
|
||||
mkdir Build$(BITS)
|
||||
|
||||
$(MAKE) all_config CONFIG=RelWithDebInfo BITS=$(BITS) TARGET="$(TARGET)"
|
||||
$(MAKE) all_config CONFIG=Debug BITS=$(BITS) TARGET="$(TARGET)"
|
||||
|
||||
all_config:
|
||||
@echo "--------------------------------------------------------------------------------"
|
||||
@echo "Build: $(CONFIG) for $(BITS) bits"
|
||||
@echo "--------------------------------------------------------------------------------"
|
||||
@echo
|
||||
|
||||
cd Build$(BITS) && cmake -G "$(TARGET)" ..
|
||||
cd Build$(BITS) && cmake --build . --config $(CONFIG)
|
||||
|
||||
install:
|
||||
$(MAKE) install_bits BITS=32
|
||||
$(MAKE) install_bits BITS=64
|
||||
|
||||
install_bits:
|
||||
rm -rf "$(OUT)$(BITS)"
|
||||
|
||||
mkdir "$(OUT)$(BITS)"
|
||||
mkdir "$(OUT)$(BITS)/lib"
|
||||
mkdir "$(OUT)$(BITS)/include"
|
||||
|
||||
cp -a Build$(BITS)/RelWithDebInfo "$(OUT)$(BITS)/lib"
|
||||
cp -a Build$(BITS)/getopt.dir/RelWithDebInfo/*.pdb "$(OUT)$(BITS)/lib/RelWithDebInfo/getopt.pdb"
|
||||
cp -a Build$(BITS)/Debug "$(OUT)$(BITS)/lib"
|
||||
|
||||
cp *.h "$(OUT)$(BITS)/include"
|
||||
|
||||
clean:
|
||||
rm -rf Build32 Build64
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* getopt.h - cpp wrapper for my_getopt to make it look like getopt.
|
||||
* Copyright 1997, 2000, 2001, 2002, Benjamin Sittler
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MY_WRAPPER_GETOPT_H_INCLUDED
|
||||
#define MY_WRAPPER_GETOPT_H_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "mygetopt.h"
|
||||
|
||||
#undef getopt
|
||||
#define getopt my_getopt
|
||||
#undef getopt_long
|
||||
#define getopt_long my_getopt_long
|
||||
#undef getopt_long_only
|
||||
#define getopt_long_only my_getopt_long_only
|
||||
#undef _getopt_internal
|
||||
#define _getopt_internal _my_getopt_internal
|
||||
#undef opterr
|
||||
#define opterr my_opterr
|
||||
#undef optind
|
||||
#define optind my_optind
|
||||
#undef optopt
|
||||
#define optopt my_optopt
|
||||
#undef optarg
|
||||
#define optarg my_optarg
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MY_WRAPPER_GETOPT_H_INCLUDED */
|
|
@ -1,284 +0,0 @@
|
|||
/*
|
||||
* my_getopt.c - my re-implementation of getopt.
|
||||
* Copyright 1997, 2000, 2001, 2002, 2006, Benjamin Sittler
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "mygetopt.h"
|
||||
|
||||
int my_optind=1, my_opterr=1, my_optopt=0;
|
||||
char *my_optarg=0;
|
||||
|
||||
/* reset argument parser to start-up values */
|
||||
int my_getopt_reset(void)
|
||||
{
|
||||
my_optind = 1;
|
||||
my_opterr = 1;
|
||||
my_optopt = 0;
|
||||
my_optarg = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* this is the plain old UNIX getopt, with GNU-style extensions. */
|
||||
/* if you're porting some piece of UNIX software, this is all you need. */
|
||||
/* this supports GNU-style permution and optional arguments */
|
||||
|
||||
int my_getopt(int argc, char * argv[], const char *opts)
|
||||
{
|
||||
static int charind=0;
|
||||
const char *s;
|
||||
char mode, colon_mode;
|
||||
int off = 0, opt = -1;
|
||||
|
||||
if(getenv("POSIXLY_CORRECT")) colon_mode = mode = '+';
|
||||
else {
|
||||
if((colon_mode = *opts) == ':') off ++;
|
||||
if(((mode = opts[off]) == '+') || (mode == '-')) {
|
||||
off++;
|
||||
if((colon_mode != ':') && ((colon_mode = opts[off]) == ':'))
|
||||
off ++;
|
||||
}
|
||||
}
|
||||
my_optarg = 0;
|
||||
if(charind) {
|
||||
my_optopt = argv[my_optind][charind];
|
||||
for(s=opts+off; *s; s++) if(my_optopt == *s) {
|
||||
charind++;
|
||||
if((*(++s) == ':') || ((my_optopt == 'W') && (*s == ';'))) {
|
||||
if(argv[my_optind][charind]) {
|
||||
my_optarg = &(argv[my_optind++][charind]);
|
||||
charind = 0;
|
||||
} else if(*(++s) != ':') {
|
||||
charind = 0;
|
||||
if(++my_optind >= argc) {
|
||||
if(my_opterr) fprintf(stderr,
|
||||
"%s: option requires an argument -- %c\n",
|
||||
argv[0], my_optopt);
|
||||
opt = (colon_mode == ':') ? ':' : '?';
|
||||
goto my_getopt_ok;
|
||||
}
|
||||
my_optarg = argv[my_optind++];
|
||||
}
|
||||
}
|
||||
opt = my_optopt;
|
||||
goto my_getopt_ok;
|
||||
}
|
||||
if(my_opterr) fprintf(stderr,
|
||||
"%s: illegal option -- %c\n",
|
||||
argv[0], my_optopt);
|
||||
opt = '?';
|
||||
if(argv[my_optind][++charind] == '\0') {
|
||||
my_optind++;
|
||||
charind = 0;
|
||||
}
|
||||
my_getopt_ok:
|
||||
if(charind && ! argv[my_optind][charind]) {
|
||||
my_optind++;
|
||||
charind = 0;
|
||||
}
|
||||
} else if((my_optind >= argc) ||
|
||||
((argv[my_optind][0] == '-') &&
|
||||
(argv[my_optind][1] == '-') &&
|
||||
(argv[my_optind][2] == '\0'))) {
|
||||
my_optind++;
|
||||
opt = -1;
|
||||
} else if((argv[my_optind][0] != '-') ||
|
||||
(argv[my_optind][1] == '\0')) {
|
||||
char *tmp;
|
||||
int i, j, k;
|
||||
|
||||
if(mode == '+') opt = -1;
|
||||
else if(mode == '-') {
|
||||
my_optarg = argv[my_optind++];
|
||||
charind = 0;
|
||||
opt = 1;
|
||||
} else {
|
||||
for(i=j=my_optind; i<argc; i++) if((argv[i][0] == '-') &&
|
||||
(argv[i][1] != '\0')) {
|
||||
my_optind=i;
|
||||
opt=my_getopt(argc, argv, opts);
|
||||
while(i > j) {
|
||||
tmp=argv[--i];
|
||||
for(k=i; k+1<my_optind; k++) argv[k]=argv[k+1];
|
||||
argv[--my_optind]=tmp;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(i == argc) opt = -1;
|
||||
}
|
||||
} else {
|
||||
charind++;
|
||||
opt = my_getopt(argc, argv, opts);
|
||||
}
|
||||
if (my_optind > argc) my_optind = argc;
|
||||
return opt;
|
||||
}
|
||||
|
||||
/* this is the extended getopt_long{,_only}, with some GNU-like
|
||||
* extensions. Implements _getopt_internal in case any programs
|
||||
* expecting GNU libc getopt call it.
|
||||
*/
|
||||
|
||||
int _my_getopt_internal(int argc, char * argv[], const char *shortopts,
|
||||
const struct option *longopts, int *longind,
|
||||
int long_only)
|
||||
{
|
||||
char mode, colon_mode = *shortopts;
|
||||
int shortoff = 0, opt = -1;
|
||||
|
||||
if(getenv("POSIXLY_CORRECT")) colon_mode = mode = '+';
|
||||
else {
|
||||
if((colon_mode = *shortopts) == ':') shortoff ++;
|
||||
if(((mode = shortopts[shortoff]) == '+') || (mode == '-')) {
|
||||
shortoff++;
|
||||
if((colon_mode != ':') && ((colon_mode = shortopts[shortoff]) == ':'))
|
||||
shortoff ++;
|
||||
}
|
||||
}
|
||||
my_optarg = 0;
|
||||
if((my_optind >= argc) ||
|
||||
((argv[my_optind][0] == '-') &&
|
||||
(argv[my_optind][1] == '-') &&
|
||||
(argv[my_optind][2] == '\0'))) {
|
||||
my_optind++;
|
||||
opt = -1;
|
||||
} else if((argv[my_optind][0] != '-') ||
|
||||
(argv[my_optind][1] == '\0')) {
|
||||
char *tmp;
|
||||
int i, j, k;
|
||||
|
||||
opt = -1;
|
||||
if(mode == '+') return -1;
|
||||
else if(mode == '-') {
|
||||
my_optarg = argv[my_optind++];
|
||||
return 1;
|
||||
}
|
||||
for(i=j=my_optind; i<argc; i++) if((argv[i][0] == '-') &&
|
||||
(argv[i][1] != '\0')) {
|
||||
my_optind=i;
|
||||
opt=_my_getopt_internal(argc, argv, shortopts,
|
||||
longopts, longind,
|
||||
long_only);
|
||||
while(i > j) {
|
||||
tmp=argv[--i];
|
||||
for(k=i; k+1<my_optind; k++)
|
||||
argv[k]=argv[k+1];
|
||||
argv[--my_optind]=tmp;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if((!long_only) && (argv[my_optind][1] != '-'))
|
||||
opt = my_getopt(argc, argv, shortopts);
|
||||
else {
|
||||
int charind, offset;
|
||||
int found = 0, ind, hits = 0;
|
||||
|
||||
if(((my_optopt = argv[my_optind][1]) != '-') && ! argv[my_optind][2]) {
|
||||
int c;
|
||||
|
||||
ind = shortoff;
|
||||
while((c = shortopts[ind++])) {
|
||||
if(((shortopts[ind] == ':') ||
|
||||
((c == 'W') && (shortopts[ind] == ';'))) &&
|
||||
(shortopts[++ind] == ':'))
|
||||
ind ++;
|
||||
if(my_optopt == c) return my_getopt(argc, argv, shortopts);
|
||||
}
|
||||
}
|
||||
offset = 2 - (argv[my_optind][1] != '-');
|
||||
for(charind = offset;
|
||||
(argv[my_optind][charind] != '\0') &&
|
||||
(argv[my_optind][charind] != '=');
|
||||
charind++);
|
||||
for(ind = 0; longopts[ind].name && !hits; ind++)
|
||||
if((strlen(longopts[ind].name) == (size_t) (charind - offset)) &&
|
||||
(strncmp(longopts[ind].name,
|
||||
argv[my_optind] + offset, charind - offset) == 0))
|
||||
found = ind, hits++;
|
||||
if(!hits) for(ind = 0; longopts[ind].name; ind++)
|
||||
if(strncmp(longopts[ind].name,
|
||||
argv[my_optind] + offset, charind - offset) == 0)
|
||||
found = ind, hits++;
|
||||
if(hits == 1) {
|
||||
opt = 0;
|
||||
|
||||
if(argv[my_optind][charind] == '=') {
|
||||
if(longopts[found].has_arg == 0) {
|
||||
opt = '?';
|
||||
if(my_opterr) fprintf(stderr,
|
||||
"%s: option `--%s' doesn't allow an argument\n",
|
||||
argv[0], longopts[found].name);
|
||||
} else {
|
||||
my_optarg = argv[my_optind] + ++charind;
|
||||
charind = 0;
|
||||
}
|
||||
} else if(longopts[found].has_arg == 1) {
|
||||
if(++my_optind >= argc) {
|
||||
opt = (colon_mode == ':') ? ':' : '?';
|
||||
if(my_opterr) fprintf(stderr,
|
||||
"%s: option `--%s' requires an argument\n",
|
||||
argv[0], longopts[found].name);
|
||||
} else my_optarg = argv[my_optind];
|
||||
}
|
||||
if(!opt) {
|
||||
if (longind) *longind = found;
|
||||
if(!longopts[found].flag) opt = longopts[found].val;
|
||||
else *(longopts[found].flag) = longopts[found].val;
|
||||
}
|
||||
my_optind++;
|
||||
} else if(!hits) {
|
||||
if(offset == 1) opt = my_getopt(argc, argv, shortopts);
|
||||
else {
|
||||
opt = '?';
|
||||
if(my_opterr) fprintf(stderr,
|
||||
"%s: unrecognized option `%s'\n",
|
||||
argv[0], argv[my_optind++]);
|
||||
else {
|
||||
my_optind++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
opt = '?';
|
||||
if(my_opterr) fprintf(stderr,
|
||||
"%s: option `%s' is ambiguous\n",
|
||||
argv[0], argv[my_optind++]);
|
||||
}
|
||||
}
|
||||
if (my_optind > argc) my_optind = argc;
|
||||
return opt;
|
||||
}
|
||||
|
||||
int my_getopt_long(int argc, char * argv[], const char *shortopts,
|
||||
const struct option *longopts, int *longind)
|
||||
{
|
||||
return _my_getopt_internal(argc, argv, shortopts, longopts, longind, 0);
|
||||
}
|
||||
|
||||
int my_getopt_long_only(int argc, char * argv[], const char *shortopts,
|
||||
const struct option *longopts, int *longind)
|
||||
{
|
||||
return _my_getopt_internal(argc, argv, shortopts, longopts, longind, 1);
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* my_getopt.h - interface to my re-implementation of getopt.
|
||||
* Copyright 1997, 2000, 2001, 2002, 2006, Benjamin Sittler
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MY_GETOPT_H_INCLUDED
|
||||
#define MY_GETOPT_H_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* reset argument parser to start-up values */
|
||||
extern int my_getopt_reset(void);
|
||||
|
||||
/* UNIX-style short-argument parser */
|
||||
extern int my_getopt(int argc, char * argv[], const char *opts);
|
||||
|
||||
extern int my_optind, my_opterr, my_optopt;
|
||||
extern char *my_optarg;
|
||||
|
||||
struct option {
|
||||
const char *name;
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* human-readable values for has_arg */
|
||||
#undef no_argument
|
||||
#define no_argument 0
|
||||
#undef required_argument
|
||||
#define required_argument 1
|
||||
#undef optional_argument
|
||||
#define optional_argument 2
|
||||
|
||||
/* GNU-style long-argument parsers */
|
||||
extern int my_getopt_long(int argc, char * argv[], const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
|
||||
extern int my_getopt_long_only(int argc, char * argv[], const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
|
||||
extern int _my_getopt_internal(int argc, char * argv[], const char *shortopts,
|
||||
const struct option *longopts, int *longind,
|
||||
int long_only);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MY_GETOPT_H_INCLUDED */
|
|
@ -1,43 +0,0 @@
|
|||
# -*- mode: CMAKE; -*-
|
||||
|
||||
## -----------------------------------------------------------------------------
|
||||
## --SECTION-- COMMON DEFINES
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE string "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
||||
endif ()
|
||||
|
||||
################################################################################
|
||||
### @brief regex library
|
||||
################################################################################
|
||||
|
||||
project(regex)
|
||||
|
||||
set(LIB_REGEX regex)
|
||||
|
||||
## -----------------------------------------------------------------------------
|
||||
## --SECTION-- LIBRARIES
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
################################################################################
|
||||
### @brief LIB_REGEX
|
||||
################################################################################
|
||||
|
||||
include_directories(.)
|
||||
|
||||
add_definitions("-DREGEX_STATIC=1")
|
||||
|
||||
add_library(
|
||||
${LIB_REGEX}
|
||||
STATIC
|
||||
regex.c
|
||||
)
|
||||
|
||||
set(REGEX_INCLUDE_DIR
|
||||
${PROJECT_SOURCE_DIR}
|
||||
CACHE INTERNAL
|
||||
"${PROJECT_NAME}: Include Directories"
|
||||
)
|
|
@ -1,42 +0,0 @@
|
|||
OUT=../out/$(VS)-regex-
|
||||
|
||||
.PHONY: all all_bits all_config install install_bits clean
|
||||
|
||||
all:
|
||||
$(MAKE) all_bits BITS=32
|
||||
$(MAKE) all_bits BITS=64 TARGET="$(TARGET) Win64"
|
||||
|
||||
all_bits:
|
||||
rm -rf Build$(BITS)
|
||||
mkdir Build$(BITS)
|
||||
|
||||
$(MAKE) all_config CONFIG=RelWithDebInfo BITS=$(BITS) TARGET="$(TARGET)"
|
||||
$(MAKE) all_config CONFIG=Debug BITS=$(BITS) TARGET="$(TARGET)"
|
||||
|
||||
all_config:
|
||||
@echo "--------------------------------------------------------------------------------"
|
||||
@echo "Build: $(CONFIG) for $(BITS) bits"
|
||||
@echo "--------------------------------------------------------------------------------"
|
||||
@echo
|
||||
|
||||
cd Build$(BITS) && cmake -G "$(TARGET)" ..
|
||||
cd Build$(BITS) && cmake --build . --config $(CONFIG)
|
||||
|
||||
install:
|
||||
$(MAKE) install_bits BITS=32
|
||||
$(MAKE) install_bits BITS=64
|
||||
|
||||
install_bits:
|
||||
rm -rf "$(OUT)$(BITS)"
|
||||
|
||||
mkdir "$(OUT)$(BITS)"
|
||||
mkdir "$(OUT)$(BITS)/lib"
|
||||
mkdir "$(OUT)$(BITS)/include"
|
||||
|
||||
cp -a Build$(BITS)/RelWithDebInfo "$(OUT)$(BITS)/lib"
|
||||
cp -a Build$(BITS)/Debug "$(OUT)$(BITS)/lib"
|
||||
|
||||
cp regex.h "$(OUT)$(BITS)/include"
|
||||
|
||||
clean:
|
||||
rm -rf Build32 Build64
|
|
@ -1,26 +0,0 @@
|
|||
/* Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifndef _RE_COMP_H
|
||||
#define _RE_COMP_H 1
|
||||
|
||||
/* This is only a wrapper around the <regex.h> file. XPG4.2 mentions
|
||||
this name. */
|
||||
#include <regex.h>
|
||||
|
||||
#endif /* re_comp.h */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,77 +0,0 @@
|
|||
/* Extended regular expression matching and search library.
|
||||
Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* Make sure noone compiles this code with a C++ compiler. */
|
||||
#ifdef __cplusplus
|
||||
# error "This is C code, use a C compiler"
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
/* We have to keep the namespace clean. */
|
||||
# define regfree(preg) __regfree (preg)
|
||||
# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
|
||||
# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
|
||||
# define regerror(errcode, preg, errbuf, errbuf_size) \
|
||||
__regerror(errcode, preg, errbuf, errbuf_size)
|
||||
# define re_set_registers(bu, re, nu, st, en) \
|
||||
__re_set_registers (bu, re, nu, st, en)
|
||||
# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
|
||||
__re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
|
||||
# define re_match(bufp, string, size, pos, regs) \
|
||||
__re_match (bufp, string, size, pos, regs)
|
||||
# define re_search(bufp, string, size, startpos, range, regs) \
|
||||
__re_search (bufp, string, size, startpos, range, regs)
|
||||
# define re_compile_pattern(pattern, length, bufp) \
|
||||
__re_compile_pattern (pattern, length, bufp)
|
||||
# define re_set_syntax(syntax) __re_set_syntax (syntax)
|
||||
# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
|
||||
__re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
|
||||
# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
|
||||
|
||||
# include "../locale/localeinfo.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define alloca _alloca
|
||||
|
||||
/* On some systems, limits.h sets RE_DUP_MAX to a lower value than
|
||||
GNU regex allows. Include it before <regex.h>, which correctly
|
||||
#undefs RE_DUP_MAX and sets it to the right value. */
|
||||
#include <limits.h>
|
||||
|
||||
#include <regex.h>
|
||||
#include "regex_internal.h"
|
||||
|
||||
#include "regex_internal.c"
|
||||
#include "regcomp.c"
|
||||
#include "regexec.c"
|
||||
|
||||
/* Binary backward compatibility. */
|
||||
#if _LIBC
|
||||
# include <shlib-compat.h>
|
||||
# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
|
||||
link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
|
||||
int re_max_failures = 2000;
|
||||
# endif
|
||||
#endif
|
|
@ -1,580 +0,0 @@
|
|||
/* Definitions for data structures and routines for the regular
|
||||
expression library.
|
||||
Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifndef _REGEX_H
|
||||
#define _REGEX_H 1
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef __GNUC__
|
||||
# define __DLL_IMPORT__ __declspec(dllimport)
|
||||
# define __DLL_EXPORT__ __declspec(dllexport)
|
||||
#else
|
||||
# define __DLL_IMPORT__ __attribute__((dllimport)) extern
|
||||
# define __DLL_EXPORT__ __attribute__((dllexport)) extern
|
||||
#endif
|
||||
|
||||
#if (defined __WIN32__) || (defined _WIN32)
|
||||
# ifdef BUILD_REGEX_DLL
|
||||
# define REGEX_DLL_IMPEXP __DLL_EXPORT__
|
||||
# elif defined(REGEX_STATIC)
|
||||
# define REGEX_DLL_IMPEXP
|
||||
# elif defined (USE_REGEX_DLL)
|
||||
# define REGEX_DLL_IMPEXP __DLL_IMPORT__
|
||||
# elif defined (USE_REGEX_STATIC)
|
||||
# define REGEX_DLL_IMPEXP extern
|
||||
# else /* assume USE_REGEX_DLL */
|
||||
# define REGEX_DLL_IMPEXP __DLL_IMPORT__
|
||||
# endif
|
||||
#else /* __WIN32__ */
|
||||
# define REGEX_DLL_IMPEXP
|
||||
#endif
|
||||
|
||||
/* Allow the use in C++ code. */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The following two types have to be signed and unsigned integer type
|
||||
wide enough to hold a value of a pointer. For most ANSI compilers
|
||||
ptrdiff_t and size_t should be likely OK. Still size of these two
|
||||
types is 2 for Microsoft C. Ugh... */
|
||||
typedef long int s_reg_t;
|
||||
typedef unsigned long int active_reg_t;
|
||||
|
||||
/* The following bits are used to determine the regexp syntax we
|
||||
recognize. The set/not-set meanings are chosen so that Emacs syntax
|
||||
remains the value 0. The bits are given in alphabetical order, and
|
||||
the definitions shifted by one from the previous bit; thus, when we
|
||||
add or remove a bit, only one other definition need change. */
|
||||
typedef unsigned long int reg_syntax_t;
|
||||
|
||||
/* If this bit is not set, then \ inside a bracket expression is literal.
|
||||
If set, then such a \ quotes the following character. */
|
||||
#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
|
||||
|
||||
/* If this bit is not set, then + and ? are operators, and \+ and \? are
|
||||
literals.
|
||||
If set, then \+ and \? are operators and + and ? are literals. */
|
||||
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
|
||||
|
||||
/* If this bit is set, then character classes are supported. They are:
|
||||
[:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
|
||||
[:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
|
||||
If not set, then character classes are not supported. */
|
||||
#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
|
||||
|
||||
/* If this bit is set, then ^ and $ are always anchors (outside bracket
|
||||
expressions, of course).
|
||||
If this bit is not set, then it depends:
|
||||
^ is an anchor if it is at the beginning of a regular
|
||||
expression or after an open-group or an alternation operator;
|
||||
$ is an anchor if it is at the end of a regular expression, or
|
||||
before a close-group or an alternation operator.
|
||||
|
||||
This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
|
||||
POSIX draft 11.2 says that * etc. in leading positions is undefined.
|
||||
We already implemented a previous draft which made those constructs
|
||||
invalid, though, so we haven't changed the code back. */
|
||||
#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
|
||||
|
||||
/* If this bit is set, then special characters are always special
|
||||
regardless of where they are in the pattern.
|
||||
If this bit is not set, then special characters are special only in
|
||||
some contexts; otherwise they are ordinary. Specifically,
|
||||
* + ? and intervals are only special when not after the beginning,
|
||||
open-group, or alternation operator. */
|
||||
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
|
||||
|
||||
/* If this bit is set, then *, +, ?, and { cannot be first in an re or
|
||||
immediately after an alternation or begin-group operator. */
|
||||
#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
|
||||
|
||||
/* If this bit is set, then . matches newline.
|
||||
If not set, then it doesn't. */
|
||||
#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
|
||||
|
||||
/* If this bit is set, then . doesn't match NUL.
|
||||
If not set, then it does. */
|
||||
#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
|
||||
|
||||
/* If this bit is set, nonmatching lists [^...] do not match newline.
|
||||
If not set, they do. */
|
||||
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
|
||||
|
||||
/* If this bit is set, either \{...\} or {...} defines an
|
||||
interval, depending on RE_NO_BK_BRACES.
|
||||
If not set, \{, \}, {, and } are literals. */
|
||||
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
|
||||
|
||||
/* If this bit is set, +, ? and | aren't recognized as operators.
|
||||
If not set, they are. */
|
||||
#define RE_LIMITED_OPS (RE_INTERVALS << 1)
|
||||
|
||||
/* If this bit is set, newline is an alternation operator.
|
||||
If not set, newline is literal. */
|
||||
#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
|
||||
|
||||
/* If this bit is set, then `{...}' defines an interval, and \{ and \}
|
||||
are literals.
|
||||
If not set, then `\{...\}' defines an interval. */
|
||||
#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
|
||||
|
||||
/* If this bit is set, (...) defines a group, and \( and \) are literals.
|
||||
If not set, \(...\) defines a group, and ( and ) are literals. */
|
||||
#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
|
||||
|
||||
/* If this bit is set, then \<digit> matches <digit>.
|
||||
If not set, then \<digit> is a back-reference. */
|
||||
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
|
||||
|
||||
/* If this bit is set, then | is an alternation operator, and \| is literal.
|
||||
If not set, then \| is an alternation operator, and | is literal. */
|
||||
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
|
||||
|
||||
/* If this bit is set, then an ending range point collating higher
|
||||
than the starting range point, as in [z-a], is invalid.
|
||||
If not set, then when ending range point collates higher than the
|
||||
starting range point, the range is ignored. */
|
||||
#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
|
||||
|
||||
/* If this bit is set, then an unmatched ) is ordinary.
|
||||
If not set, then an unmatched ) is invalid. */
|
||||
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
|
||||
|
||||
/* If this bit is set, succeed as soon as we match the whole pattern,
|
||||
without further backtracking. */
|
||||
#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
|
||||
|
||||
/* If this bit is set, do not process the GNU regex operators.
|
||||
If not set, then the GNU regex operators are recognized. */
|
||||
#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
|
||||
|
||||
/* If this bit is set, turn on internal regex debugging.
|
||||
If not set, and debugging was on, turn it off.
|
||||
This only works if regex.c is compiled -DDEBUG.
|
||||
We define this bit always, so that all that's needed to turn on
|
||||
debugging is to recompile regex.c; the calling code can always have
|
||||
this bit set, and it won't affect anything in the normal case. */
|
||||
#define RE_DEBUG (RE_NO_GNU_OPS << 1)
|
||||
|
||||
/* If this bit is set, a syntactically invalid interval is treated as
|
||||
a string of ordinary characters. For example, the ERE 'a{1' is
|
||||
treated as 'a\{1'. */
|
||||
#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
|
||||
|
||||
/* If this bit is set, then ignore case when matching.
|
||||
If not set, then case is significant. */
|
||||
#define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
|
||||
|
||||
/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only
|
||||
for ^, because it is difficult to scan the regex backwards to find
|
||||
whether ^ should be special. */
|
||||
#define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
|
||||
|
||||
/* If this bit is set, then \{ cannot be first in an bre or
|
||||
immediately after an alternation or begin-group operator. */
|
||||
#define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
|
||||
|
||||
/* If this bit is set, then no_sub will be set to 1 during
|
||||
re_compile_pattern. */
|
||||
#define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1)
|
||||
|
||||
/* This global variable defines the particular regexp syntax to use (for
|
||||
some interfaces). When a regexp is compiled, the syntax used is
|
||||
stored in the pattern buffer, so changing this does not affect
|
||||
already-compiled regexps. */
|
||||
REGEX_DLL_IMPEXP reg_syntax_t re_syntax_options;
|
||||
|
||||
/* Define combinations of the above bits for the standard possibilities.
|
||||
(The [[[ comments delimit what gets put into the Texinfo file, so
|
||||
don't delete them!) */
|
||||
/* [[[begin syntaxes]]] */
|
||||
#define RE_SYNTAX_EMACS 0
|
||||
|
||||
#define RE_SYNTAX_AWK \
|
||||
(RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
|
||||
| RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
|
||||
| RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
|
||||
|
||||
#define RE_SYNTAX_GNU_AWK \
|
||||
((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
|
||||
& ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS \
|
||||
| RE_CONTEXT_INVALID_OPS ))
|
||||
|
||||
#define RE_SYNTAX_POSIX_AWK \
|
||||
(RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
|
||||
| RE_INTERVALS | RE_NO_GNU_OPS)
|
||||
|
||||
#define RE_SYNTAX_GREP \
|
||||
(RE_BK_PLUS_QM | RE_CHAR_CLASSES \
|
||||
| RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
|
||||
| RE_NEWLINE_ALT)
|
||||
|
||||
#define RE_SYNTAX_EGREP \
|
||||
(RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
|
||||
| RE_NEWLINE_ALT | RE_NO_BK_PARENS \
|
||||
| RE_NO_BK_VBAR)
|
||||
|
||||
#define RE_SYNTAX_POSIX_EGREP \
|
||||
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \
|
||||
| RE_INVALID_INTERVAL_ORD)
|
||||
|
||||
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
|
||||
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
|
||||
|
||||
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
|
||||
|
||||
/* Syntax bits common to both basic and extended POSIX regex syntax. */
|
||||
#define _RE_SYNTAX_POSIX_COMMON \
|
||||
(RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
|
||||
| RE_INTERVALS | RE_NO_EMPTY_RANGES)
|
||||
|
||||
#define RE_SYNTAX_POSIX_BASIC \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP)
|
||||
|
||||
/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
|
||||
RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
|
||||
isn't minimal, since other operators, such as \`, aren't disabled. */
|
||||
#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
|
||||
|
||||
#define RE_SYNTAX_POSIX_EXTENDED \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_VBAR \
|
||||
| RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
|
||||
|
||||
/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
|
||||
removed and RE_NO_BK_REFS is added. */
|
||||
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
|
||||
| RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
|
||||
/* [[[end syntaxes]]] */
|
||||
|
||||
/* Maximum number of duplicates an interval can allow. Some systems
|
||||
(erroneously) define this in other header files, but we want our
|
||||
value, so remove any previous define. */
|
||||
#ifdef RE_DUP_MAX
|
||||
# undef RE_DUP_MAX
|
||||
#endif
|
||||
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
|
||||
#define RE_DUP_MAX (0x7fff)
|
||||
|
||||
|
||||
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
|
||||
|
||||
/* If this bit is set, then use extended regular expression syntax.
|
||||
If not set, then use basic regular expression syntax. */
|
||||
#define REG_EXTENDED 1
|
||||
|
||||
/* If this bit is set, then ignore case when matching.
|
||||
If not set, then case is significant. */
|
||||
#define REG_ICASE (REG_EXTENDED << 1)
|
||||
|
||||
/* If this bit is set, then anchors do not match at newline
|
||||
characters in the string.
|
||||
If not set, then anchors do match at newlines. */
|
||||
#define REG_NEWLINE (REG_ICASE << 1)
|
||||
|
||||
/* If this bit is set, then report only success or fail in regexec.
|
||||
If not set, then returns differ between not matching and errors. */
|
||||
#define REG_NOSUB (REG_NEWLINE << 1)
|
||||
|
||||
|
||||
/* POSIX `eflags' bits (i.e., information for regexec). */
|
||||
|
||||
/* If this bit is set, then the beginning-of-line operator doesn't match
|
||||
the beginning of the string (presumably because it's not the
|
||||
beginning of a line).
|
||||
If not set, then the beginning-of-line operator does match the
|
||||
beginning of the string. */
|
||||
#define REG_NOTBOL 1
|
||||
|
||||
/* Like REG_NOTBOL, except for the end-of-line. */
|
||||
#define REG_NOTEOL (1 << 1)
|
||||
|
||||
/* Use PMATCH[0] to delimit the start and end of the search in the
|
||||
buffer. */
|
||||
#define REG_STARTEND (1 << 2)
|
||||
|
||||
|
||||
/* If any error codes are removed, changed, or added, update the
|
||||
`re_error_msg' table in regex.c. */
|
||||
typedef enum
|
||||
{
|
||||
#ifdef _XOPEN_SOURCE
|
||||
REG_ENOSYS = -1, /* This will never happen for this implementation. */
|
||||
#endif
|
||||
|
||||
REG_NOERROR = 0, /* Success. */
|
||||
REG_NOMATCH, /* Didn't find a match (for regexec). */
|
||||
|
||||
/* POSIX regcomp return error codes. (In the order listed in the
|
||||
standard.) */
|
||||
REG_BADPAT, /* Invalid pattern. */
|
||||
REG_ECOLLATE, /* Inalid collating element. */
|
||||
REG_ECTYPE, /* Invalid character class name. */
|
||||
REG_EESCAPE, /* Trailing backslash. */
|
||||
REG_ESUBREG, /* Invalid back reference. */
|
||||
REG_EBRACK, /* Unmatched left bracket. */
|
||||
REG_EPAREN, /* Parenthesis imbalance. */
|
||||
REG_EBRACE, /* Unmatched \{. */
|
||||
REG_BADBR, /* Invalid contents of \{\}. */
|
||||
REG_ERANGE, /* Invalid range end. */
|
||||
REG_ESPACE, /* Ran out of memory. */
|
||||
REG_BADRPT, /* No preceding re for repetition op. */
|
||||
|
||||
/* Error codes we've added. */
|
||||
REG_EEND, /* Premature end. */
|
||||
REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
|
||||
REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
|
||||
} reg_errcode_t;
|
||||
|
||||
/* This data structure represents a compiled pattern. Before calling
|
||||
the pattern compiler, the fields `buffer', `allocated', `fastmap',
|
||||
`translate', and `no_sub' can be set. After the pattern has been
|
||||
compiled, the `re_nsub' field is available. All other fields are
|
||||
private to the regex routines. */
|
||||
|
||||
#ifndef RE_TRANSLATE_TYPE
|
||||
# define RE_TRANSLATE_TYPE unsigned char *
|
||||
#endif
|
||||
|
||||
struct re_pattern_buffer
|
||||
{
|
||||
/* Space that holds the compiled pattern. It is declared as
|
||||
`unsigned char *' because its elements are sometimes used as
|
||||
array indexes. */
|
||||
unsigned char *buffer;
|
||||
|
||||
/* Number of bytes to which `buffer' points. */
|
||||
unsigned long int allocated;
|
||||
|
||||
/* Number of bytes actually used in `buffer'. */
|
||||
unsigned long int used;
|
||||
|
||||
/* Syntax setting with which the pattern was compiled. */
|
||||
reg_syntax_t syntax;
|
||||
|
||||
/* Pointer to a fastmap, if any, otherwise zero. re_search uses the
|
||||
fastmap, if there is one, to skip over impossible starting points
|
||||
for matches. */
|
||||
char *fastmap;
|
||||
|
||||
/* Either a translate table to apply to all characters before
|
||||
comparing them, or zero for no translation. The translation is
|
||||
applied to a pattern when it is compiled and to a string when it
|
||||
is matched. */
|
||||
RE_TRANSLATE_TYPE translate;
|
||||
|
||||
/* Number of subexpressions found by the compiler. */
|
||||
size_t re_nsub;
|
||||
|
||||
/* Zero if this pattern cannot match the empty string, one else.
|
||||
Well, in truth it's used only in `re_search_2', to see whether or
|
||||
not we should use the fastmap, so we don't set this absolutely
|
||||
perfectly; see `re_compile_fastmap' (the `duplicate' case). */
|
||||
unsigned can_be_null : 1;
|
||||
|
||||
/* If REGS_UNALLOCATED, allocate space in the `regs' structure
|
||||
for `max (RE_NREGS, re_nsub + 1)' groups.
|
||||
If REGS_REALLOCATE, reallocate space if necessary.
|
||||
If REGS_FIXED, use what's there. */
|
||||
#define REGS_UNALLOCATED 0
|
||||
#define REGS_REALLOCATE 1
|
||||
#define REGS_FIXED 2
|
||||
unsigned regs_allocated : 2;
|
||||
|
||||
/* Set to zero when `regex_compile' compiles a pattern; set to one
|
||||
by `re_compile_fastmap' if it updates the fastmap. */
|
||||
unsigned fastmap_accurate : 1;
|
||||
|
||||
/* If set, `re_match_2' does not return information about
|
||||
subexpressions. */
|
||||
unsigned no_sub : 1;
|
||||
|
||||
/* If set, a beginning-of-line anchor doesn't match at the beginning
|
||||
of the string. */
|
||||
unsigned not_bol : 1;
|
||||
|
||||
/* Similarly for an end-of-line anchor. */
|
||||
unsigned not_eol : 1;
|
||||
|
||||
/* If true, an anchor at a newline matches. */
|
||||
unsigned newline_anchor : 1;
|
||||
};
|
||||
|
||||
typedef struct re_pattern_buffer regex_t;
|
||||
|
||||
/* Type for byte offsets within the string. POSIX mandates this. */
|
||||
typedef int regoff_t;
|
||||
|
||||
|
||||
/* This is the structure we store register match data in. See
|
||||
regex.texinfo for a full description of what registers match. */
|
||||
struct re_registers
|
||||
{
|
||||
unsigned num_regs;
|
||||
regoff_t *start;
|
||||
regoff_t *end;
|
||||
};
|
||||
|
||||
|
||||
/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
|
||||
`re_match_2' returns information about at least this many registers
|
||||
the first time a `regs' structure is passed. */
|
||||
#ifndef RE_NREGS
|
||||
# define RE_NREGS 30
|
||||
#endif
|
||||
|
||||
|
||||
/* POSIX specification for registers. Aside from the different names than
|
||||
`re_registers', POSIX uses an array of structures, instead of a
|
||||
structure of arrays. */
|
||||
typedef struct
|
||||
{
|
||||
regoff_t rm_so; /* Byte offset from string's start to substring's start. */
|
||||
regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
|
||||
} regmatch_t;
|
||||
|
||||
/* Declarations for routines. */
|
||||
|
||||
/* Sets the current default syntax to SYNTAX, and return the old syntax.
|
||||
You can also simply assign to the `re_syntax_options' variable. */
|
||||
REGEX_DLL_IMPEXP reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
|
||||
|
||||
/* Compile the regular expression PATTERN, with length LENGTH
|
||||
and syntax given by the global `re_syntax_options', into the buffer
|
||||
BUFFER. Return NULL if successful, and an error string if not. */
|
||||
REGEX_DLL_IMPEXP const char *re_compile_pattern (const char *__pattern, size_t __length,
|
||||
struct re_pattern_buffer *__buffer);
|
||||
|
||||
|
||||
/* Compile a fastmap for the compiled pattern in BUFFER; used to
|
||||
accelerate searches. Return 0 if successful and -2 if was an
|
||||
internal error. */
|
||||
REGEX_DLL_IMPEXP int re_compile_fastmap (struct re_pattern_buffer *__buffer);
|
||||
|
||||
|
||||
/* Search in the string STRING (with length LENGTH) for the pattern
|
||||
compiled into BUFFER. Start searching at position START, for RANGE
|
||||
characters. Return the starting position of the match, -1 for no
|
||||
match, or -2 for an internal error. Also return register
|
||||
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
|
||||
REGEX_DLL_IMPEXP int re_search (struct re_pattern_buffer *__buffer, const char *__string,
|
||||
int __length, int __start, int __range,
|
||||
struct re_registers *__regs);
|
||||
|
||||
|
||||
/* Like `re_search', but search in the concatenation of STRING1 and
|
||||
STRING2. Also, stop searching at index START + STOP. */
|
||||
REGEX_DLL_IMPEXP int re_search_2 (struct re_pattern_buffer *__buffer,
|
||||
const char *__string1, int __length1,
|
||||
const char *__string2, int __length2, int __start,
|
||||
int __range, struct re_registers *__regs, int __stop);
|
||||
|
||||
|
||||
/* Like `re_search', but return how many characters in STRING the regexp
|
||||
in BUFFER matched, starting at position START. */
|
||||
REGEX_DLL_IMPEXP int re_match (struct re_pattern_buffer *__buffer, const char *__string,
|
||||
int __length, int __start, struct re_registers *__regs);
|
||||
|
||||
|
||||
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
|
||||
REGEX_DLL_IMPEXP int re_match_2 (struct re_pattern_buffer *__buffer,
|
||||
const char *__string1, int __length1,
|
||||
const char *__string2, int __length2, int __start,
|
||||
struct re_registers *__regs, int __stop);
|
||||
|
||||
|
||||
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
|
||||
ENDS. Subsequent matches using BUFFER and REGS will use this memory
|
||||
for recording register information. STARTS and ENDS must be
|
||||
allocated with malloc, and must each be at least `NUM_REGS * sizeof
|
||||
(regoff_t)' bytes long.
|
||||
|
||||
If NUM_REGS == 0, then subsequent matches should allocate their own
|
||||
register data.
|
||||
|
||||
Unless this function is called, the first search or match using
|
||||
PATTERN_BUFFER will allocate its own register data, without
|
||||
freeing the old data. */
|
||||
REGEX_DLL_IMPEXP void re_set_registers (struct re_pattern_buffer *__buffer,
|
||||
struct re_registers *__regs,
|
||||
unsigned int __num_regs,
|
||||
regoff_t *__starts, regoff_t *__ends);
|
||||
|
||||
#if defined _REGEX_RE_COMP || defined _LIBC
|
||||
# ifndef _CRAY
|
||||
/* 4.2 bsd compatibility. */
|
||||
REGEX_DLL_IMPEXP char *re_comp (const char *);
|
||||
REGEX_DLL_IMPEXP int re_exec (const char *);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* GCC 2.95 and later have "__restrict"; C99 compilers have
|
||||
"restrict", and "configure" may have defined "restrict". */
|
||||
#ifndef __restrict
|
||||
# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
|
||||
# if defined restrict || 199901L <= __STDC_VERSION__
|
||||
# define __restrict restrict
|
||||
# else
|
||||
# define __restrict
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
/* gcc 3.1 and up support the [restrict] syntax. */
|
||||
#ifndef __restrict_arr
|
||||
# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \
|
||||
&& !defined __GNUG__
|
||||
# define __restrict_arr __restrict
|
||||
# else
|
||||
# define __restrict_arr
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* POSIX compatibility. */
|
||||
REGEX_DLL_IMPEXP int regcomp (regex_t *__restrict __preg,
|
||||
const char *__restrict __pattern,
|
||||
int __cflags);
|
||||
|
||||
REGEX_DLL_IMPEXP int regexec (const regex_t *__restrict __preg,
|
||||
const char *__restrict __string, size_t __nmatch,
|
||||
regmatch_t __pmatch[__restrict_arr],
|
||||
int __eflags);
|
||||
|
||||
REGEX_DLL_IMPEXP size_t regerror (int __errcode, const regex_t *__restrict __preg,
|
||||
char *__restrict __errbuf, size_t __errbuf_size);
|
||||
|
||||
REGEX_DLL_IMPEXP void regfree (regex_t *__preg);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
||||
#endif /* regex.h */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,769 +0,0 @@
|
|||
/* Extended regular expression matching and search library.
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifndef _REGEX_INTERNAL_H
|
||||
#define _REGEX_INTERNAL_H 1
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC
|
||||
# include <langinfo.h>
|
||||
#endif
|
||||
#if defined HAVE_LOCALE_H || defined _LIBC
|
||||
# include <locale.h>
|
||||
#endif
|
||||
#if defined HAVE_WCHAR_H || defined _LIBC
|
||||
# include <wchar.h>
|
||||
#endif /* HAVE_WCHAR_H || _LIBC */
|
||||
#if defined HAVE_WCTYPE_H || defined _LIBC
|
||||
# include <wctype.h>
|
||||
#endif /* HAVE_WCTYPE_H || _LIBC */
|
||||
#if defined HAVE_STDBOOL_H || defined _LIBC
|
||||
# include <stdbool.h>
|
||||
#endif /* HAVE_STDBOOL_H || _LIBC */
|
||||
#if defined HAVE_STDINT_H || defined _LIBC
|
||||
# include <stdint.h>
|
||||
#endif /* HAVE_STDINT_H || _LIBC */
|
||||
#if defined _LIBC
|
||||
# include <bits/libc-lock.h>
|
||||
#else
|
||||
# define __libc_lock_define(CLASS,NAME)
|
||||
# define __libc_lock_init(NAME) do { } while (0)
|
||||
# define __libc_lock_lock(NAME) do { } while (0)
|
||||
# define __libc_lock_unlock(NAME) do { } while (0)
|
||||
#endif
|
||||
|
||||
/* In case that the system doesn't have isblank(). */
|
||||
#if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank
|
||||
# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
|
||||
# define _RE_DEFINE_LOCALE_FUNCTIONS 1
|
||||
# include <locale/localeinfo.h>
|
||||
# include <locale/elem-hash.h>
|
||||
# include <locale/coll-lookup.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This is for other GNU distributions with internationalized messages. */
|
||||
#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
|
||||
# include <libintl.h>
|
||||
# ifdef _LIBC
|
||||
# undef gettext
|
||||
# define gettext(msgid) \
|
||||
INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES)
|
||||
# endif
|
||||
#else
|
||||
# define gettext(msgid) (msgid)
|
||||
#endif
|
||||
|
||||
#ifndef gettext_noop
|
||||
/* This define is so xgettext can find the internationalizable
|
||||
strings. */
|
||||
# define gettext_noop(String) String
|
||||
#endif
|
||||
|
||||
/* For loser systems without the definition. */
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_WCRTOMB && HAVE_MBRTOWC && HAVE_WCSCOLL) || _LIBC
|
||||
# define RE_ENABLE_I18N
|
||||
#endif
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
# define BE(expr, val) __builtin_expect (expr, val)
|
||||
#else
|
||||
# define BE(expr, val) (expr)
|
||||
# define inline
|
||||
#endif
|
||||
|
||||
/* Number of single byte character. */
|
||||
#define SBC_MAX 256
|
||||
|
||||
#define COLL_ELEM_LEN_MAX 8
|
||||
|
||||
/* The character which represents newline. */
|
||||
#define NEWLINE_CHAR '\n'
|
||||
#define WIDE_NEWLINE_CHAR L'\n'
|
||||
|
||||
/* Rename to standard API for using out of glibc. */
|
||||
#ifndef _LIBC
|
||||
# define __wctype wctype
|
||||
# define __iswctype iswctype
|
||||
# define __btowc btowc
|
||||
# define __mempcpy mempcpy
|
||||
# define __wcrtomb wcrtomb
|
||||
# define __regfree regfree
|
||||
# define attribute_hidden
|
||||
#endif /* not _LIBC */
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define __attribute(arg) __attribute__ (arg)
|
||||
#else
|
||||
# define __attribute(arg)
|
||||
#endif
|
||||
|
||||
extern const char __re_error_msgid[] attribute_hidden;
|
||||
extern const size_t __re_error_msgid_idx[] attribute_hidden;
|
||||
|
||||
/* An integer used to represent a set of bits. It must be unsigned,
|
||||
and must be at least as wide as unsigned int. */
|
||||
typedef unsigned long int bitset_word_t;
|
||||
/* All bits set in a bitset_word_t. */
|
||||
#define BITSET_WORD_MAX ULONG_MAX
|
||||
/* Number of bits in a bitset_word_t. */
|
||||
#define BITSET_WORD_BITS (sizeof (bitset_word_t) * CHAR_BIT)
|
||||
/* Number of bitset_word_t in a bit_set. */
|
||||
#define BITSET_WORDS (SBC_MAX / BITSET_WORD_BITS)
|
||||
typedef bitset_word_t bitset_t[BITSET_WORDS];
|
||||
typedef bitset_word_t *re_bitset_ptr_t;
|
||||
typedef const bitset_word_t *re_const_bitset_ptr_t;
|
||||
|
||||
#define bitset_set(set,i) \
|
||||
(set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS)
|
||||
#define bitset_clear(set,i) \
|
||||
(set[i / BITSET_WORD_BITS] &= ~((bitset_word_t) 1 << i % BITSET_WORD_BITS))
|
||||
#define bitset_contain(set,i) \
|
||||
(set[i / BITSET_WORD_BITS] & ((bitset_word_t) 1 << i % BITSET_WORD_BITS))
|
||||
#define bitset_empty(set) memset (set, '\0', sizeof (bitset_t))
|
||||
#define bitset_set_all(set) memset (set, '\xff', sizeof (bitset_t))
|
||||
#define bitset_copy(dest,src) memcpy (dest, src, sizeof (bitset_t))
|
||||
|
||||
#define PREV_WORD_CONSTRAINT 0x0001
|
||||
#define PREV_NOTWORD_CONSTRAINT 0x0002
|
||||
#define NEXT_WORD_CONSTRAINT 0x0004
|
||||
#define NEXT_NOTWORD_CONSTRAINT 0x0008
|
||||
#define PREV_NEWLINE_CONSTRAINT 0x0010
|
||||
#define NEXT_NEWLINE_CONSTRAINT 0x0020
|
||||
#define PREV_BEGBUF_CONSTRAINT 0x0040
|
||||
#define NEXT_ENDBUF_CONSTRAINT 0x0080
|
||||
#define WORD_DELIM_CONSTRAINT 0x0100
|
||||
#define NOT_WORD_DELIM_CONSTRAINT 0x0200
|
||||
|
||||
typedef enum
|
||||
{
|
||||
INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
|
||||
WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
|
||||
WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
|
||||
INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
|
||||
LINE_FIRST = PREV_NEWLINE_CONSTRAINT,
|
||||
LINE_LAST = NEXT_NEWLINE_CONSTRAINT,
|
||||
BUF_FIRST = PREV_BEGBUF_CONSTRAINT,
|
||||
BUF_LAST = NEXT_ENDBUF_CONSTRAINT,
|
||||
WORD_DELIM = WORD_DELIM_CONSTRAINT,
|
||||
NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT
|
||||
} re_context_type;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int alloc;
|
||||
int nelem;
|
||||
int *elems;
|
||||
} re_node_set;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NON_TYPE = 0,
|
||||
|
||||
/* Node type, These are used by token, node, tree. */
|
||||
CHARACTER = 1,
|
||||
END_OF_RE = 2,
|
||||
SIMPLE_BRACKET = 3,
|
||||
OP_BACK_REF = 4,
|
||||
OP_PERIOD = 5,
|
||||
#ifdef RE_ENABLE_I18N
|
||||
COMPLEX_BRACKET = 6,
|
||||
OP_UTF8_PERIOD = 7,
|
||||
#endif /* RE_ENABLE_I18N */
|
||||
|
||||
/* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used
|
||||
when the debugger shows values of this enum type. */
|
||||
#define EPSILON_BIT 8
|
||||
OP_OPEN_SUBEXP = EPSILON_BIT | 0,
|
||||
OP_CLOSE_SUBEXP = EPSILON_BIT | 1,
|
||||
OP_ALT = EPSILON_BIT | 2,
|
||||
OP_DUP_ASTERISK = EPSILON_BIT | 3,
|
||||
ANCHOR = EPSILON_BIT | 4,
|
||||
|
||||
/* Tree type, these are used only by tree. */
|
||||
CONCAT = 16,
|
||||
SUBEXP = 17,
|
||||
|
||||
/* Token type, these are used only by token. */
|
||||
OP_DUP_PLUS = 18,
|
||||
OP_DUP_QUESTION,
|
||||
OP_OPEN_BRACKET,
|
||||
OP_CLOSE_BRACKET,
|
||||
OP_CHARSET_RANGE,
|
||||
OP_OPEN_DUP_NUM,
|
||||
OP_CLOSE_DUP_NUM,
|
||||
OP_NON_MATCH_LIST,
|
||||
OP_OPEN_COLL_ELEM,
|
||||
OP_CLOSE_COLL_ELEM,
|
||||
OP_OPEN_EQUIV_CLASS,
|
||||
OP_CLOSE_EQUIV_CLASS,
|
||||
OP_OPEN_CHAR_CLASS,
|
||||
OP_CLOSE_CHAR_CLASS,
|
||||
OP_WORD,
|
||||
OP_NOTWORD,
|
||||
OP_SPACE,
|
||||
OP_NOTSPACE,
|
||||
BACK_SLASH
|
||||
|
||||
} re_token_type_t;
|
||||
|
||||
#ifdef RE_ENABLE_I18N
|
||||
typedef struct
|
||||
{
|
||||
/* Multibyte characters. */
|
||||
wchar_t *mbchars;
|
||||
|
||||
/* Collating symbols. */
|
||||
# ifdef _LIBC
|
||||
int32_t *coll_syms;
|
||||
# endif
|
||||
|
||||
/* Equivalence classes. */
|
||||
# ifdef _LIBC
|
||||
int32_t *equiv_classes;
|
||||
# endif
|
||||
|
||||
/* Range expressions. */
|
||||
# ifdef _LIBC
|
||||
uint32_t *range_starts;
|
||||
uint32_t *range_ends;
|
||||
# else /* not _LIBC */
|
||||
wchar_t *range_starts;
|
||||
wchar_t *range_ends;
|
||||
# endif /* not _LIBC */
|
||||
|
||||
/* Character classes. */
|
||||
wctype_t *char_classes;
|
||||
|
||||
/* If this character set is the non-matching list. */
|
||||
unsigned int non_match : 1;
|
||||
|
||||
/* # of multibyte characters. */
|
||||
int nmbchars;
|
||||
|
||||
/* # of collating symbols. */
|
||||
int ncoll_syms;
|
||||
|
||||
/* # of equivalence classes. */
|
||||
int nequiv_classes;
|
||||
|
||||
/* # of range expressions. */
|
||||
int nranges;
|
||||
|
||||
/* # of character classes. */
|
||||
int nchar_classes;
|
||||
} re_charset_t;
|
||||
#endif /* RE_ENABLE_I18N */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{
|
||||
unsigned char c; /* for CHARACTER */
|
||||
re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */
|
||||
#ifdef RE_ENABLE_I18N
|
||||
re_charset_t *mbcset; /* for COMPLEX_BRACKET */
|
||||
#endif /* RE_ENABLE_I18N */
|
||||
int idx; /* for BACK_REF */
|
||||
re_context_type ctx_type; /* for ANCHOR */
|
||||
} opr;
|
||||
#if __GNUC__ >= 2
|
||||
re_token_type_t type : 8;
|
||||
#else
|
||||
re_token_type_t type;
|
||||
#endif
|
||||
unsigned int constraint : 10; /* context constraint */
|
||||
unsigned int duplicated : 1;
|
||||
unsigned int opt_subexp : 1;
|
||||
#ifdef RE_ENABLE_I18N
|
||||
unsigned int accept_mb : 1;
|
||||
/* These 2 bits can be moved into the union if needed (e.g. if running out
|
||||
of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */
|
||||
unsigned int mb_partial : 1;
|
||||
#endif
|
||||
unsigned int word_char : 1;
|
||||
} re_token_t;
|
||||
|
||||
#define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT)
|
||||
|
||||
struct re_string_t
|
||||
{
|
||||
/* Indicate the raw buffer which is the original string passed as an
|
||||
argument of regexec(), re_search(), etc.. */
|
||||
const unsigned char *raw_mbs;
|
||||
/* Store the multibyte string. In case of "case insensitive mode" like
|
||||
REG_ICASE, upper cases of the string are stored, otherwise MBS points
|
||||
the same address that RAW_MBS points. */
|
||||
unsigned char *mbs;
|
||||
#ifdef RE_ENABLE_I18N
|
||||
/* Store the wide character string which is corresponding to MBS. */
|
||||
wint_t *wcs;
|
||||
int *offsets;
|
||||
mbstate_t cur_state;
|
||||
#endif
|
||||
/* Index in RAW_MBS. Each character mbs[i] corresponds to
|
||||
raw_mbs[raw_mbs_idx + i]. */
|
||||
int raw_mbs_idx;
|
||||
/* The length of the valid characters in the buffers. */
|
||||
int valid_len;
|
||||
/* The corresponding number of bytes in raw_mbs array. */
|
||||
int valid_raw_len;
|
||||
/* The length of the buffers MBS and WCS. */
|
||||
int bufs_len;
|
||||
/* The index in MBS, which is updated by re_string_fetch_byte. */
|
||||
int cur_idx;
|
||||
/* length of RAW_MBS array. */
|
||||
int raw_len;
|
||||
/* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */
|
||||
int len;
|
||||
/* End of the buffer may be shorter than its length in the cases such
|
||||
as re_match_2, re_search_2. Then, we use STOP for end of the buffer
|
||||
instead of LEN. */
|
||||
int raw_stop;
|
||||
/* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */
|
||||
int stop;
|
||||
|
||||
/* The context of mbs[0]. We store the context independently, since
|
||||
the context of mbs[0] may be different from raw_mbs[0], which is
|
||||
the beginning of the input string. */
|
||||
unsigned int tip_context;
|
||||
/* The translation passed as a part of an argument of re_compile_pattern. */
|
||||
RE_TRANSLATE_TYPE trans;
|
||||
/* Copy of re_dfa_t's word_char. */
|
||||
re_const_bitset_ptr_t word_char;
|
||||
/* 1 if REG_ICASE. */
|
||||
unsigned char icase;
|
||||
unsigned char is_utf8;
|
||||
unsigned char map_notascii;
|
||||
unsigned char mbs_allocated;
|
||||
unsigned char offsets_needed;
|
||||
unsigned char newline_anchor;
|
||||
unsigned char word_ops_used;
|
||||
int mb_cur_max;
|
||||
};
|
||||
typedef struct re_string_t re_string_t;
|
||||
|
||||
|
||||
struct re_dfa_t;
|
||||
typedef struct re_dfa_t re_dfa_t;
|
||||
|
||||
#ifndef _LIBC
|
||||
# ifdef __i386__
|
||||
# define internal_function __attribute ((regparm (3), stdcall))
|
||||
# else
|
||||
# define internal_function
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef NOT_IN_libc
|
||||
static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
|
||||
int new_buf_len)
|
||||
internal_function;
|
||||
# ifdef RE_ENABLE_I18N
|
||||
static void build_wcs_buffer (re_string_t *pstr) internal_function;
|
||||
static int build_wcs_upper_buffer (re_string_t *pstr) internal_function;
|
||||
# endif /* RE_ENABLE_I18N */
|
||||
static void build_upper_buffer (re_string_t *pstr) internal_function;
|
||||
static void re_string_translate_buffer (re_string_t *pstr) internal_function;
|
||||
static unsigned int re_string_context_at (const re_string_t *input, int idx,
|
||||
int eflags)
|
||||
internal_function __attribute ((pure));
|
||||
#endif
|
||||
#define re_string_peek_byte(pstr, offset) \
|
||||
((pstr)->mbs[(pstr)->cur_idx + offset])
|
||||
#define re_string_fetch_byte(pstr) \
|
||||
((pstr)->mbs[(pstr)->cur_idx++])
|
||||
#define re_string_first_byte(pstr, idx) \
|
||||
((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF)
|
||||
#define re_string_is_single_byte_char(pstr, idx) \
|
||||
((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \
|
||||
|| (pstr)->wcs[(idx) + 1] != WEOF))
|
||||
#define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx)
|
||||
#define re_string_cur_idx(pstr) ((pstr)->cur_idx)
|
||||
#define re_string_get_buffer(pstr) ((pstr)->mbs)
|
||||
#define re_string_length(pstr) ((pstr)->len)
|
||||
#define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx])
|
||||
#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
|
||||
#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
|
||||
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
#ifndef _LIBC
|
||||
# if HAVE_ALLOCA
|
||||
/* The OS usually guarantees only one guard page at the bottom of the stack,
|
||||
and a page size can be as small as 4096 bytes. So we cannot safely
|
||||
allocate anything larger than 4096 bytes. Also care for the possibility
|
||||
of a few compiler-allocated temporary stack slots. */
|
||||
# define __libc_use_alloca(n) ((n) < 4032)
|
||||
# else
|
||||
/* alloca is implemented with malloc, so just use malloc. */
|
||||
# define __libc_use_alloca(n) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
|
||||
#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t)))
|
||||
#define re_free(p) free (p)
|
||||
|
||||
struct bin_tree_t
|
||||
{
|
||||
struct bin_tree_t *parent;
|
||||
struct bin_tree_t *left;
|
||||
struct bin_tree_t *right;
|
||||
struct bin_tree_t *first;
|
||||
struct bin_tree_t *next;
|
||||
|
||||
re_token_t token;
|
||||
|
||||
/* `node_idx' is the index in dfa->nodes, if `type' == 0.
|
||||
Otherwise `type' indicate the type of this node. */
|
||||
int node_idx;
|
||||
};
|
||||
typedef struct bin_tree_t bin_tree_t;
|
||||
|
||||
#define BIN_TREE_STORAGE_SIZE \
|
||||
((1024 - sizeof (void *)) / sizeof (bin_tree_t))
|
||||
|
||||
struct bin_tree_storage_t
|
||||
{
|
||||
struct bin_tree_storage_t *next;
|
||||
bin_tree_t data[BIN_TREE_STORAGE_SIZE];
|
||||
};
|
||||
typedef struct bin_tree_storage_t bin_tree_storage_t;
|
||||
|
||||
#define CONTEXT_WORD 1
|
||||
#define CONTEXT_NEWLINE (CONTEXT_WORD << 1)
|
||||
#define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1)
|
||||
#define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1)
|
||||
|
||||
#define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD)
|
||||
#define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE)
|
||||
#define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF)
|
||||
#define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF)
|
||||
#define IS_ORDINARY_CONTEXT(c) ((c) == 0)
|
||||
|
||||
#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_')
|
||||
#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR)
|
||||
#define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_')
|
||||
#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR)
|
||||
|
||||
#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \
|
||||
((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
|
||||
|| ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
|
||||
|| ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\
|
||||
|| ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context)))
|
||||
|
||||
#define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \
|
||||
((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
|
||||
|| (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
|
||||
|| (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \
|
||||
|| (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context)))
|
||||
|
||||
struct re_dfastate_t
|
||||
{
|
||||
unsigned int hash;
|
||||
re_node_set nodes;
|
||||
re_node_set non_eps_nodes;
|
||||
re_node_set inveclosure;
|
||||
re_node_set *entrance_nodes;
|
||||
struct re_dfastate_t **trtable, **word_trtable;
|
||||
unsigned int context : 4;
|
||||
unsigned int halt : 1;
|
||||
/* If this state can accept `multi byte'.
|
||||
Note that we refer to multibyte characters, and multi character
|
||||
collating elements as `multi byte'. */
|
||||
unsigned int accept_mb : 1;
|
||||
/* If this state has backreference node(s). */
|
||||
unsigned int has_backref : 1;
|
||||
unsigned int has_constraint : 1;
|
||||
};
|
||||
typedef struct re_dfastate_t re_dfastate_t;
|
||||
|
||||
struct re_state_table_entry
|
||||
{
|
||||
int num;
|
||||
int alloc;
|
||||
re_dfastate_t **array;
|
||||
};
|
||||
|
||||
/* Array type used in re_sub_match_last_t and re_sub_match_top_t. */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int next_idx;
|
||||
int alloc;
|
||||
re_dfastate_t **array;
|
||||
} state_array_t;
|
||||
|
||||
/* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int node;
|
||||
int str_idx; /* The position NODE match at. */
|
||||
state_array_t path;
|
||||
} re_sub_match_last_t;
|
||||
|
||||
/* Store information about the node NODE whose type is OP_OPEN_SUBEXP.
|
||||
And information about the node, whose type is OP_CLOSE_SUBEXP,
|
||||
corresponding to NODE is stored in LASTS. */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int str_idx;
|
||||
int node;
|
||||
state_array_t *path;
|
||||
int alasts; /* Allocation size of LASTS. */
|
||||
int nlasts; /* The number of LASTS. */
|
||||
re_sub_match_last_t **lasts;
|
||||
} re_sub_match_top_t;
|
||||
|
||||
struct re_backref_cache_entry
|
||||
{
|
||||
int node;
|
||||
int str_idx;
|
||||
int subexp_from;
|
||||
int subexp_to;
|
||||
char more;
|
||||
char unused;
|
||||
unsigned short int eps_reachable_subexps_map;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* The string object corresponding to the input string. */
|
||||
re_string_t input;
|
||||
#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
|
||||
const re_dfa_t *const dfa;
|
||||
#else
|
||||
const re_dfa_t *dfa;
|
||||
#endif
|
||||
/* EFLAGS of the argument of regexec. */
|
||||
int eflags;
|
||||
/* Where the matching ends. */
|
||||
int match_last;
|
||||
int last_node;
|
||||
/* The state log used by the matcher. */
|
||||
re_dfastate_t **state_log;
|
||||
int state_log_top;
|
||||
/* Back reference cache. */
|
||||
int nbkref_ents;
|
||||
int abkref_ents;
|
||||
struct re_backref_cache_entry *bkref_ents;
|
||||
int max_mb_elem_len;
|
||||
int nsub_tops;
|
||||
int asub_tops;
|
||||
re_sub_match_top_t **sub_tops;
|
||||
} re_match_context_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
re_dfastate_t **sifted_states;
|
||||
re_dfastate_t **limited_states;
|
||||
int last_node;
|
||||
int last_str_idx;
|
||||
re_node_set limits;
|
||||
} re_sift_context_t;
|
||||
|
||||
struct re_fail_stack_ent_t
|
||||
{
|
||||
int idx;
|
||||
int node;
|
||||
regmatch_t *regs;
|
||||
re_node_set eps_via_nodes;
|
||||
};
|
||||
|
||||
struct re_fail_stack_t
|
||||
{
|
||||
int num;
|
||||
int alloc;
|
||||
struct re_fail_stack_ent_t *stack;
|
||||
};
|
||||
|
||||
struct re_dfa_t
|
||||
{
|
||||
re_token_t *nodes;
|
||||
size_t nodes_alloc;
|
||||
size_t nodes_len;
|
||||
int *nexts;
|
||||
int *org_indices;
|
||||
re_node_set *edests;
|
||||
re_node_set *eclosures;
|
||||
re_node_set *inveclosures;
|
||||
struct re_state_table_entry *state_table;
|
||||
re_dfastate_t *init_state;
|
||||
re_dfastate_t *init_state_word;
|
||||
re_dfastate_t *init_state_nl;
|
||||
re_dfastate_t *init_state_begbuf;
|
||||
bin_tree_t *str_tree;
|
||||
bin_tree_storage_t *str_tree_storage;
|
||||
re_bitset_ptr_t sb_char;
|
||||
int str_tree_storage_idx;
|
||||
|
||||
/* number of subexpressions `re_nsub' is in regex_t. */
|
||||
unsigned int state_hash_mask;
|
||||
int init_node;
|
||||
int nbackref; /* The number of backreference in this dfa. */
|
||||
|
||||
/* Bitmap expressing which backreference is used. */
|
||||
bitset_word_t used_bkref_map;
|
||||
bitset_word_t completed_bkref_map;
|
||||
|
||||
unsigned int has_plural_match : 1;
|
||||
/* If this dfa has "multibyte node", which is a backreference or
|
||||
a node which can accept multibyte character or multi character
|
||||
collating element. */
|
||||
unsigned int has_mb_node : 1;
|
||||
unsigned int is_utf8 : 1;
|
||||
unsigned int map_notascii : 1;
|
||||
unsigned int word_ops_used : 1;
|
||||
int mb_cur_max;
|
||||
bitset_t word_char;
|
||||
reg_syntax_t syntax;
|
||||
int *subexp_map;
|
||||
#ifdef DEBUG
|
||||
char* re_str;
|
||||
#endif
|
||||
__libc_lock_define (, lock)
|
||||
};
|
||||
|
||||
#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
|
||||
#define re_node_set_remove(set,id) \
|
||||
(re_node_set_remove_at (set, re_node_set_contains (set, id) - 1))
|
||||
#define re_node_set_empty(p) ((p)->nelem = 0)
|
||||
#define re_node_set_free(set) re_free ((set)->elems)
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SB_CHAR,
|
||||
MB_CHAR,
|
||||
EQUIV_CLASS,
|
||||
COLL_SYM,
|
||||
CHAR_CLASS
|
||||
} bracket_elem_type;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bracket_elem_type type;
|
||||
union
|
||||
{
|
||||
unsigned char ch;
|
||||
unsigned char *name;
|
||||
wchar_t wch;
|
||||
} opr;
|
||||
} bracket_elem_t;
|
||||
|
||||
|
||||
/* Inline functions for bitset operation. */
|
||||
static inline void
|
||||
bitset_not (bitset_t set)
|
||||
{
|
||||
int bitset_i;
|
||||
for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
|
||||
set[bitset_i] = ~set[bitset_i];
|
||||
}
|
||||
|
||||
static inline void
|
||||
bitset_merge (bitset_t dest, const bitset_t src)
|
||||
{
|
||||
int bitset_i;
|
||||
for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
|
||||
dest[bitset_i] |= src[bitset_i];
|
||||
}
|
||||
|
||||
static inline void
|
||||
bitset_mask (bitset_t dest, const bitset_t src)
|
||||
{
|
||||
int bitset_i;
|
||||
for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
|
||||
dest[bitset_i] &= src[bitset_i];
|
||||
}
|
||||
|
||||
#ifdef RE_ENABLE_I18N
|
||||
/* Inline functions for re_string. */
|
||||
static inline int
|
||||
internal_function __attribute ((pure))
|
||||
re_string_char_size_at (const re_string_t *pstr, int idx)
|
||||
{
|
||||
int byte_idx;
|
||||
if (pstr->mb_cur_max == 1)
|
||||
return 1;
|
||||
for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx)
|
||||
if (pstr->wcs[idx + byte_idx] != WEOF)
|
||||
break;
|
||||
return byte_idx;
|
||||
}
|
||||
|
||||
static inline wint_t
|
||||
internal_function __attribute ((pure))
|
||||
re_string_wchar_at (const re_string_t *pstr, int idx)
|
||||
{
|
||||
if (pstr->mb_cur_max == 1)
|
||||
return (wint_t) pstr->mbs[idx];
|
||||
return (wint_t) pstr->wcs[idx];
|
||||
}
|
||||
|
||||
# ifndef NOT_IN_libc
|
||||
static int
|
||||
internal_function __attribute ((pure))
|
||||
re_string_elem_size_at (const re_string_t *pstr, int idx)
|
||||
{
|
||||
# ifdef _LIBC
|
||||
const unsigned char *p, *extra;
|
||||
const int32_t *table, *indirect;
|
||||
int32_t tmp;
|
||||
# include <locale/weight.h>
|
||||
uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
|
||||
|
||||
if (nrules != 0)
|
||||
{
|
||||
table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
|
||||
extra = (const unsigned char *)
|
||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
|
||||
indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
|
||||
_NL_COLLATE_INDIRECTMB);
|
||||
p = pstr->mbs + idx;
|
||||
tmp = findidx (&p);
|
||||
return p - pstr->mbs - idx;
|
||||
}
|
||||
else
|
||||
# endif /* _LIBC */
|
||||
return 1;
|
||||
}
|
||||
# endif
|
||||
#endif /* RE_ENABLE_I18N */
|
||||
|
||||
#endif /* _REGEX_INTERNAL_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -214,13 +214,12 @@ if (MSVC)
|
|||
configure_file("Installation/Windows/vcproj.user/arangod.vcxproj.user" ${CMAKE_BINARY_DIR})
|
||||
add_definitions("-D_CRT_SECURE_NO_WARNINGS=1")
|
||||
add_definitions("-DFD_SETSIZE=2048")
|
||||
add_definitions("-DUSE_REGEX_STATIC=1")
|
||||
add_definitions("-DU_STATIC_IMPLEMENTATION=1")
|
||||
|
||||
set(MSVC_LIBS crypt32.lib;WINMM.LIB;Ws2_32.lib;getopt;regex)
|
||||
set(MSVC_LIBS crypt32.lib;WINMM.LIB;Ws2_32.lib)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE /SAFESEH:NO /MACHINE:x64 /ignore:4099 /ignore:1021 ${BASE_LD_FLAGS}"
|
||||
"${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE /SAFESEH:NO /MACHINE:x64 /ignore:4099 ${BASE_LD_FLAGS}"
|
||||
)
|
||||
else ()
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
|
@ -600,22 +599,6 @@ foreach (LINK_DIR ${LINK_DIRECTORIES})
|
|||
link_directories("${LINK_DIR}")
|
||||
endforeach()
|
||||
|
||||
################################################################################
|
||||
## GETOPT
|
||||
################################################################################
|
||||
|
||||
if (WINDOWS)
|
||||
include_directories(${GETOPT_INCLUDE_DIR})
|
||||
endif ()
|
||||
|
||||
################################################################################
|
||||
## REGEX
|
||||
################################################################################
|
||||
|
||||
if (WINDOWS)
|
||||
include_directories(${REGEX_INCLUDE_DIR})
|
||||
endif ()
|
||||
|
||||
################################################################################
|
||||
## BOOST
|
||||
################################################################################
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Kaveh Vahedipour
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CONSENSUS_AGENCY_COMMON_H
|
||||
#define ARANGODB_CONSENSUS_AGENCY_COMMON_H
|
||||
#ifndef ARANGOD_CONSENSUS_AGENCY_COMMON_H
|
||||
#define ARANGOD_CONSENSUS_AGENCY_COMMON_H 1
|
||||
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Logger/Logger.h"
|
||||
|
@ -31,9 +31,6 @@
|
|||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace arangodb {
|
||||
|
|
|
@ -21,16 +21,16 @@
|
|||
/// @author Kaveh Vahedipour
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CONSENSUS_AGENT_H
|
||||
#define ARANGODB_CONSENSUS_AGENT_H
|
||||
#ifndef ARANGOD_CONSENSUS_AGENT_H
|
||||
#define ARANGOD_CONSENSUS_AGENT_H 1
|
||||
|
||||
#include "AgencyCommon.h"
|
||||
#include "AgentConfiguration.h"
|
||||
#include "AgentCallback.h"
|
||||
#include "Constituent.h"
|
||||
#include "Supervision.h"
|
||||
#include "State.h"
|
||||
#include "Store.h"
|
||||
#include "Agency/AgencyCommon.h"
|
||||
#include "Agency/AgentConfiguration.h"
|
||||
#include "Agency/AgentCallback.h"
|
||||
#include "Agency/Constituent.h"
|
||||
#include "Agency/Supervision.h"
|
||||
#include "Agency/State.h"
|
||||
#include "Agency/Store.h"
|
||||
|
||||
struct TRI_server_t;
|
||||
struct TRI_vocbase_t;
|
||||
|
@ -41,7 +41,7 @@ class Agent : public arangodb::Thread {
|
|||
|
||||
public:
|
||||
/// @brief Construct with program options
|
||||
Agent(config_t const&);
|
||||
explicit Agent(config_t const&);
|
||||
|
||||
/// @brief Clean up
|
||||
~Agent();
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
/// @author Kaveh Vahedipour
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CONSENSUS_AGENT_CALLBACK_H
|
||||
#define ARANGODB_CONSENSUS_AGENT_CALLBACK_H
|
||||
#ifndef ARANGOD_CONSENSUS_AGENT_CALLBACK_H
|
||||
#define ARANGOD_CONSENSUS_AGENT_CALLBACK_H 1
|
||||
|
||||
#include "Agency/AgencyCommon.h"
|
||||
#include "Cluster/ClusterComm.h"
|
||||
#include "AgencyCommon.h"
|
||||
|
||||
namespace arangodb {
|
||||
namespace consensus {
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Kaveh Vahedipour
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CONSENSUS_AGENT_CONFIGURATION_H
|
||||
#define ARANGODB_CONSENSUS_AGENT_CONFIGURATION_H
|
||||
#ifndef ARANGOD_CONSENSUS_AGENT_CONFIGURATION_H
|
||||
#define ARANGOD_CONSENSUS_AGENT_CONFIGURATION_H 1
|
||||
|
||||
namespace arangodb {
|
||||
namespace consensus {
|
||||
|
|
|
@ -70,6 +70,8 @@ void Constituent::configure(Agent* agent) {
|
|||
// Default ctor
|
||||
Constituent::Constituent()
|
||||
: Thread("Constituent"),
|
||||
_vocbase(nullptr),
|
||||
_queryRegistry(nullptr),
|
||||
_term(0),
|
||||
_leaderID((std::numeric_limits<uint32_t>::max)()),
|
||||
_id(0),
|
||||
|
|
|
@ -21,11 +21,9 @@
|
|||
/// @author Kaveh Vahedipour
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CONSENSUS_CONSTITUENT_H
|
||||
#define ARANGODB_CONSENSUS_CONSTITUENT_H
|
||||
#ifndef ARANGOD_CONSENSUS_CONSTITUENT_H
|
||||
#define ARANGOD_CONSENSUS_CONSTITUENT_H 1
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <random>
|
||||
|
||||
#include "AgencyCommon.h"
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Kaveh Vahedipour
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CONSENSUS_NODE_H
|
||||
#define ARANGODB_CONSENSUS_NODE_H
|
||||
#ifndef ARANGOD_CONSENSUS_NODE_H
|
||||
#define ARANGOD_CONSENSUS_NODE_H 1
|
||||
|
||||
#include "AgencyCommon.h"
|
||||
|
||||
|
|
|
@ -21,13 +21,12 @@
|
|||
/// @author Andreas Streichardt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CONSENSUS_NOTIFIER_COMMON_H
|
||||
#define ARANGODB_CONSENSUS_NOTIFIER_COMMON_H
|
||||
#ifndef ARANGOD_CONSENSUS_NOTIFIER_COMMON_H
|
||||
#define ARANGOD_CONSENSUS_NOTIFIER_COMMON_H 1
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/ConditionVariable.h"
|
||||
#include "Basics/Thread.h"
|
||||
|
||||
|
|
|
@ -21,11 +21,12 @@
|
|||
/// @author Andreas Streichardt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __ARANGODB_CONSENSUS_NOTIFY_CALLBACK__
|
||||
#define __ARANGODB_CONSENSUS_NOTIFY_CALLBACK__
|
||||
#ifndef ARANGOD_CONSENSUS_NOTIFY_CALLBACK_H
|
||||
#define ARANGOD_CONSENSUS_NOTIFY_CALLBACK_H 1
|
||||
|
||||
#include "Agency/AgencyCommon.h"
|
||||
#include "Cluster/ClusterComm.h"
|
||||
#include "AgencyCommon.h"
|
||||
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
namespace arangodb {
|
||||
|
@ -35,7 +36,7 @@ class NotifyCallback : public arangodb::ClusterCommCallback {
|
|||
|
||||
public:
|
||||
|
||||
NotifyCallback(std::function<void(bool)>);
|
||||
explicit NotifyCallback(std::function<void(bool)>);
|
||||
|
||||
virtual bool operator()(arangodb::ClusterCommResult*) override final;
|
||||
|
||||
|
|
|
@ -21,14 +21,14 @@
|
|||
/// @author Kaveh Vahedipour
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CONSENSUS_STATE_H
|
||||
#define ARANGODB_CONSENSUS_STATE_H
|
||||
|
||||
#ifndef ARANGOD_CONSENSUS_STATE_H
|
||||
#define ARANGOD_CONSENSUS_STATE_H 1
|
||||
|
||||
#include "AgencyCommon.h"
|
||||
|
||||
#include <Basics/Thread.h>
|
||||
#include <Cluster/ClusterComm.h>
|
||||
#include "Basics/Thread.h"
|
||||
#include "Cluster/ClusterComm.h"
|
||||
|
||||
#include <velocypack/vpack.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
|
|
@ -21,18 +21,14 @@
|
|||
/// @author Kaveh Vahedipour
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CONSENSUS_STORE_H
|
||||
#define ARANGODB_CONSENSUS_STORE_H
|
||||
#ifndef ARANGOD_CONSENSUS_STORE_H
|
||||
#define ARANGOD_CONSENSUS_STORE_H 1
|
||||
|
||||
#include "Node.h"
|
||||
|
||||
//#include <velocypack/Buffer.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
namespace arangodb {
|
||||
namespace consensus {
|
||||
|
||||
|
||||
class Agent;
|
||||
|
||||
/// @brief Key value tree
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Kaveh Vahedipour
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CONSENSUS_STORE_CALLBACK_H
|
||||
#define ARANGODB_CONSENSUS_STORE_CALLBACK_H
|
||||
#ifndef ARANGOD_CONSENSUS_STORE_CALLBACK_H
|
||||
#define ARANGOD_CONSENSUS_STORE_CALLBACK_H 1
|
||||
|
||||
#include "Cluster/ClusterComm.h"
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Kaveh Vahedipour
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CONSENSUS_SUPERVISION_H
|
||||
#define ARANGODB_CONSENSUS_SUPERVISION_H
|
||||
#ifndef ARANGOD_CONSENSUS_SUPERVISION_H
|
||||
#define ARANGOD_CONSENSUS_SUPERVISION_H 1
|
||||
|
||||
#include "Basics/Thread.h"
|
||||
#include "Basics/ConditionVariable.h"
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Max Neunhoeffer
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_AQL_ENUMERATE_COLLECTION_BLOCK_H
|
||||
#define ARANGODB_AQL_ENuMERATE_COLLECTION_BLOCK_H 1
|
||||
#ifndef ARANGOD_AQL_ENUMERATE_COLLECTION_BLOCK_H
|
||||
#define ARANGOD_AQL_ENUMERATE_COLLECTION_BLOCK_H 1
|
||||
|
||||
#include "Aql/ExecutionBlock.h"
|
||||
#include "Aql/ExecutionNode.h"
|
||||
|
|
|
@ -21,26 +21,31 @@
|
|||
/// @author Andreas Streichardt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "AgencyCallback.h"
|
||||
#include "Basics/MutexLocker.h"
|
||||
#include "Basics/ConditionLocker.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <velocypack/Exception.h>
|
||||
#include <velocypack/Parser.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include "Basics/MutexLocker.h"
|
||||
|
||||
#include "AgencyCallback.h"
|
||||
|
||||
using namespace arangodb;
|
||||
|
||||
AgencyCallback::AgencyCallback(AgencyComm& agency,
|
||||
std::string const& key,
|
||||
std::function<bool(VPackSlice const&)> const& cb,
|
||||
bool needsValue)
|
||||
bool needsValue,
|
||||
bool needsInitialValue)
|
||||
: key(key),
|
||||
_useCv(false),
|
||||
_agency(agency),
|
||||
_cb(cb),
|
||||
_needsValue(needsValue) {
|
||||
|
||||
if (_needsValue) {
|
||||
if (_needsValue && needsInitialValue) {
|
||||
refetchAndUpdate();
|
||||
}
|
||||
}
|
||||
|
@ -63,22 +68,42 @@ void AgencyCallback::refetchAndUpdate() {
|
|||
return;
|
||||
}
|
||||
|
||||
std::map<std::string, AgencyCommResultEntry>::const_iterator it =
|
||||
result._values.begin();
|
||||
// mop: we need to find out if it is a directory :S
|
||||
// because we lost this information while parsing
|
||||
std::shared_ptr<VPackBuilder> bodyBuilder =
|
||||
VPackParser::fromJson(result.body().c_str());
|
||||
|
||||
if (it == result._values.end()) {
|
||||
std::shared_ptr<VPackBuilder> newData = std::make_shared<VPackBuilder>();
|
||||
newData->add(VPackSlice::noneSlice());
|
||||
checkValue(newData);
|
||||
} else {
|
||||
checkValue(it->second._vpack);
|
||||
VPackSlice slice = bodyBuilder->slice();
|
||||
if (!slice.isObject() || !slice.hasKey("node")) {
|
||||
LOG(ERR) << "Invalid structure " << result.body();
|
||||
return;
|
||||
}
|
||||
|
||||
VPackSlice node = slice.get("node");
|
||||
if (!slice.isObject()) {
|
||||
LOG(ERR) << "Node is not an object";
|
||||
return;
|
||||
}
|
||||
|
||||
bool isDir = node.hasKey("dir");
|
||||
|
||||
std::shared_ptr<VPackBuilder> newData = std::make_shared<VPackBuilder>();
|
||||
if (isDir) {
|
||||
VPackObjectBuilder builder(newData.get());
|
||||
for (auto& it: result._values) {
|
||||
newData->add(it.first, it.second._vpack->slice());
|
||||
}
|
||||
} else if (result._values.size() == 0) {
|
||||
newData->add(VPackSlice::noneSlice());
|
||||
} else {
|
||||
newData->add(result._values.begin()->second._vpack->slice());
|
||||
}
|
||||
checkValue(newData);
|
||||
}
|
||||
|
||||
void AgencyCallback::checkValue(std::shared_ptr<VPackBuilder> newData) {
|
||||
if (!_lastData || !_lastData->slice().equals(newData->slice())) {
|
||||
LOG(DEBUG) << "Got new value " << newData->slice().typeName();
|
||||
LOG(DEBUG) << "Got new value " << newData->toJson();
|
||||
LOG(DEBUG) << "Got new value " << newData->slice().typeName() << " " << newData->toJson();
|
||||
if (execute(newData)) {
|
||||
_lastData = newData;
|
||||
} else {
|
||||
|
@ -89,22 +114,65 @@ void AgencyCallback::checkValue(std::shared_ptr<VPackBuilder> newData) {
|
|||
|
||||
bool AgencyCallback::executeEmpty() {
|
||||
LOG(DEBUG) << "Executing (empty)";
|
||||
MUTEX_LOCKER(locker, _lock);
|
||||
return _cb(VPackSlice::noneSlice());
|
||||
bool result;
|
||||
{
|
||||
MUTEX_LOCKER(locker, _lock);
|
||||
result = _cb(VPackSlice::noneSlice());
|
||||
}
|
||||
|
||||
if (_useCv) {
|
||||
CONDITION_LOCKER(locker, _cv);
|
||||
_cv.signal();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AgencyCallback::execute(std::shared_ptr<VPackBuilder> newData) {
|
||||
LOG(DEBUG) << "Executing";
|
||||
MUTEX_LOCKER(locker, _lock);
|
||||
return _cb(newData->slice());
|
||||
bool result;
|
||||
{
|
||||
MUTEX_LOCKER(locker, _lock);
|
||||
result = _cb(newData->slice());
|
||||
}
|
||||
|
||||
if (_useCv) {
|
||||
CONDITION_LOCKER(locker, _cv);
|
||||
_cv.signal();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void AgencyCallback::waitWithFailover(double timeout) {
|
||||
// mop: todo thread safe? check with max
|
||||
std::shared_ptr<VPackBuilder> beginData = _lastData;
|
||||
VPackSlice compareSlice;
|
||||
if (_lastData) {
|
||||
compareSlice = _lastData->slice();
|
||||
} else {
|
||||
compareSlice = VPackSlice::noneSlice();
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(timeout * 1000)));
|
||||
|
||||
if (!_lastData || _lastData->slice().equals(beginData->slice())) {
|
||||
if (!_lastData || _lastData->slice().equals(compareSlice)) {
|
||||
LOG(DEBUG) << "Waiting done and nothing happended. Refetching to be sure";
|
||||
// mop: watches have not triggered during our sleep...recheck to be sure
|
||||
refetchAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void AgencyCallback::waitForExecution(double maxTimeout) {
|
||||
VPackSlice compareSlice;
|
||||
if (_lastData) {
|
||||
compareSlice = _lastData->slice();
|
||||
} else {
|
||||
compareSlice = VPackSlice::noneSlice();
|
||||
}
|
||||
|
||||
_useCv = true;
|
||||
CONDITION_LOCKER(locker, _cv);
|
||||
locker.wait(maxTimeout * 1000000);
|
||||
_useCv = false;
|
||||
|
||||
if (!_lastData || _lastData->slice().equals(compareSlice)) {
|
||||
LOG(DEBUG) << "Waiting done and nothing happended. Refetching to be sure";
|
||||
// mop: watches have not triggered during our sleep...recheck to be sure
|
||||
refetchAndUpdate();
|
||||
|
|
|
@ -21,16 +21,18 @@
|
|||
/// @author Andreas Streichardt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//XXX #warning MOP nope, include guards
|
||||
#pragma once
|
||||
#ifndef ARANGODB_CLUSTER_AGENCYCALLBACK_H
|
||||
#define ARANGODB_CLUSTER_AGENCYCALLBACK_H
|
||||
|
||||
#include "Basics/ConditionVariable.h"
|
||||
#include "Basics/Mutex.h"
|
||||
|
||||
//XXX #warning MOP order, Common.h
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include "Cluster/AgencyComm.h"
|
||||
#include <velocypack/Builder.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
#include "Basics/Mutex.h"
|
||||
|
||||
#include "Cluster/AgencyComm.h"
|
||||
|
||||
namespace arangodb {
|
||||
|
||||
|
@ -40,7 +42,8 @@ public:
|
|||
/// @brief ctor
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
AgencyCallback(AgencyComm&, std::string const&,
|
||||
std::function<bool(VPackSlice const&)> const&, bool needsValue);
|
||||
std::function<bool(VPackSlice const&)> const&, bool needsValue,
|
||||
bool needsInitialValue = false);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief wait a specified timeout. execute cb if watch didn't fire
|
||||
|
@ -50,10 +53,14 @@ public:
|
|||
std::string const key;
|
||||
|
||||
void refetchAndUpdate();
|
||||
void waitForExecution(double);
|
||||
|
||||
|
||||
private:
|
||||
arangodb::Mutex _lock;
|
||||
arangodb::basics::ConditionVariable _cv;
|
||||
bool _useCv;
|
||||
|
||||
AgencyComm& _agency;
|
||||
std::function<bool(VPackSlice const&)> const _cb;
|
||||
std::shared_ptr<VPackBuilder> _lastData;
|
||||
|
@ -68,3 +75,5 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,6 +23,14 @@
|
|||
|
||||
#include "AgencyCallbackRegistry.h"
|
||||
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/ReadLocker.h"
|
||||
#include "Basics/WriteLocker.h"
|
||||
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Endpoint/Endpoint.h"
|
||||
#include "Random/RandomGenerator.h"
|
||||
|
||||
#include <ctime>
|
||||
//XXX #warning MOP why? use ConditionVariable
|
||||
#include <condition_variable>
|
||||
|
@ -32,13 +40,6 @@
|
|||
#include <velocypack/Slice.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/ReadLocker.h"
|
||||
#include "Basics/WriteLocker.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Endpoint/Endpoint.h"
|
||||
#include "Random/RandomGenerator.h"
|
||||
|
||||
using namespace arangodb;
|
||||
|
||||
AgencyCallbackRegistry::AgencyCallbackRegistry(std::string const& callbackBasePath)
|
||||
|
|
|
@ -110,7 +110,7 @@ AgencyPrecondition::AgencyPrecondition(std::string const& key, Type t, bool e)
|
|||
|
||||
AgencyPrecondition::AgencyPrecondition(std::string const& key, Type t,
|
||||
VPackSlice s)
|
||||
: key(AgencyComm::prefix() + key), type(t), value(s) {
|
||||
: key(AgencyComm::prefix() + key), type(t), empty(false), value(s) {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1251,6 +1251,47 @@ int ClusterInfo::createCollectionCoordinator(std::string const& databaseName,
|
|||
if (ac.exists("Plan/Collections/" + databaseName + "/" + collectionID)) {
|
||||
return setErrormsg(TRI_ERROR_CLUSTER_COLLECTION_ID_EXISTS, errorMsg);
|
||||
}
|
||||
|
||||
int dbServerResult = -1;
|
||||
|
||||
std::function<bool(VPackSlice const& result)> dbServerChanged = [&](VPackSlice const& result) {
|
||||
if (result.isObject() && result.length() == (size_t) numberOfShards) {
|
||||
std::string tmpMsg = "";
|
||||
bool tmpHaveError = false;
|
||||
|
||||
for (auto const& p: VPackObjectIterator(result)) {
|
||||
if (arangodb::basics::VelocyPackHelper::getBooleanValue(
|
||||
p.value, "error", false)) {
|
||||
tmpHaveError = true;
|
||||
tmpMsg += " shardID:" + p.key.copyString() + ":";
|
||||
tmpMsg += arangodb::basics::VelocyPackHelper::getStringValue(
|
||||
p.value, "errorMessage", "");
|
||||
if (p.value.hasKey("errorNum")) {
|
||||
VPackSlice const errorNum = p.value.get("errorNum");
|
||||
if (errorNum.isNumber()) {
|
||||
tmpMsg += " (errNum=";
|
||||
tmpMsg += basics::StringUtils::itoa(
|
||||
errorNum.getNumericValue<uint32_t>());
|
||||
tmpMsg += ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
loadCurrentCollections();
|
||||
if (tmpHaveError) {
|
||||
errorMsg = "Error in creation of collection:" + tmpMsg;
|
||||
dbServerResult = TRI_ERROR_CLUSTER_COULD_NOT_CREATE_COLLECTION;
|
||||
return true;
|
||||
}
|
||||
dbServerResult = setErrormsg(TRI_ERROR_NO_ERROR, errorMsg);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
auto agencyCallback = std::make_shared<AgencyCallback>(
|
||||
ac, "Current/Collections/" + databaseName + "/" + collectionID, dbServerChanged, true, false);
|
||||
_agencyCallbackRegistry->registerCallback(agencyCallback);
|
||||
|
||||
VPackBuilder builder;
|
||||
builder.add(VPackValue(json.toJson()));
|
||||
|
@ -1284,43 +1325,15 @@ int ClusterInfo::createCollectionCoordinator(std::string const& databaseName,
|
|||
std::string const where =
|
||||
"Current/Collections/" + databaseName + "/" + collectionID;
|
||||
while (TRI_microtime() <= endTime) {
|
||||
res.clear();
|
||||
res = ac.getValues(where, true);
|
||||
agencyCallback->waitForExecution(interval);
|
||||
|
||||
if (res.successful() && res.parse(where + "/", false)) {
|
||||
if (res._values.size() == (size_t)numberOfShards) {
|
||||
std::string tmpMsg = "";
|
||||
bool tmpHaveError = false;
|
||||
for (auto const& p : res._values) {
|
||||
VPackSlice const slice = p.second._vpack->slice();
|
||||
if (arangodb::basics::VelocyPackHelper::getBooleanValue(
|
||||
slice, "error", false)) {
|
||||
tmpHaveError = true;
|
||||
tmpMsg += " shardID:" + p.first + ":";
|
||||
tmpMsg += arangodb::basics::VelocyPackHelper::getStringValue(
|
||||
slice, "errorMessage", "");
|
||||
if (slice.hasKey("errorNum")) {
|
||||
VPackSlice const errorNum = slice.get("errorNum");
|
||||
if (errorNum.isNumber()) {
|
||||
tmpMsg += " (errNum=";
|
||||
tmpMsg += basics::StringUtils::itoa(
|
||||
errorNum.getNumericValue<uint32_t>());
|
||||
tmpMsg += ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
loadCurrentCollections();
|
||||
if (tmpHaveError) {
|
||||
errorMsg = "Error in creation of collection:" + tmpMsg;
|
||||
return TRI_ERROR_CLUSTER_COULD_NOT_CREATE_COLLECTION;
|
||||
}
|
||||
return setErrormsg(TRI_ERROR_NO_ERROR, errorMsg);
|
||||
}
|
||||
if (dbServerResult >= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
res.clear();
|
||||
_agencyCallbackRegistry->awaitNextChange("Current/Version", interval);
|
||||
}
|
||||
_agencyCallbackRegistry->unregisterCallback(agencyCallback);
|
||||
if (dbServerResult >= 0) {
|
||||
return dbServerResult;
|
||||
}
|
||||
|
||||
// LOG(ERR) << "GOT TIMEOUT. NUMBEROFSHARDS: " << numberOfShards;
|
||||
|
@ -1343,7 +1356,41 @@ int ClusterInfo::dropCollectionCoordinator(std::string const& databaseName,
|
|||
double const realTimeout = getTimeout(timeout);
|
||||
double const endTime = TRI_microtime() + realTimeout;
|
||||
double const interval = getPollInterval();
|
||||
|
||||
int dbServerResult = -1;
|
||||
std::function<bool(VPackSlice const& result)> dbServerChanged = [&](VPackSlice const& result) {
|
||||
if (result.isObject() && result.length() == 0) {
|
||||
// ...remove the entire directory for the collection
|
||||
AgencyCommLocker locker("Current", "WRITE");
|
||||
if (locker.successful()) {
|
||||
AgencyCommResult res;
|
||||
res = ac.removeValues(
|
||||
"Current/Collections/" + databaseName + "/" + collectionID, true);
|
||||
if (res.successful()) {
|
||||
dbServerResult = setErrormsg(TRI_ERROR_NO_ERROR, errorMsg);
|
||||
return true;
|
||||
}
|
||||
dbServerResult = setErrormsg(
|
||||
TRI_ERROR_CLUSTER_COULD_NOT_REMOVE_COLLECTION_IN_CURRENT,
|
||||
errorMsg);
|
||||
return true;
|
||||
}
|
||||
loadCurrentCollections();
|
||||
dbServerResult = setErrormsg(TRI_ERROR_NO_ERROR, errorMsg);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
// monitor the entry for the collection
|
||||
std::string const where =
|
||||
"Current/Collections/" + databaseName + "/" + collectionID;
|
||||
|
||||
auto agencyCallback = std::make_shared<AgencyCallback>(
|
||||
ac, where, dbServerChanged, true, false);
|
||||
_agencyCallbackRegistry->registerCallback(agencyCallback);
|
||||
|
||||
{
|
||||
AgencyCommLocker locker("Plan", "WRITE");
|
||||
|
||||
|
@ -1369,40 +1416,14 @@ int ClusterInfo::dropCollectionCoordinator(std::string const& databaseName,
|
|||
// Update our own cache:
|
||||
loadPlannedCollections();
|
||||
|
||||
// monitor the entry for the collection
|
||||
std::string const where =
|
||||
"Current/Collections/" + databaseName + "/" + collectionID;
|
||||
while (TRI_microtime() <= endTime) {
|
||||
res.clear();
|
||||
res = ac.getValues(where, true);
|
||||
if (!res.successful()) {
|
||||
// It seems the collection is already gone, do not wait further
|
||||
errorMsg = "Collection already gone.";
|
||||
return setErrormsg(TRI_ERROR_NO_ERROR, errorMsg);
|
||||
agencyCallback->waitForExecution(interval);
|
||||
if (dbServerResult >= 0) {
|
||||
break;
|
||||
}
|
||||
if (res.successful() && res.parse(where + "/", false)) {
|
||||
// if there are no more active shards for the collection...
|
||||
if (res._values.size() == 0) {
|
||||
// ...remove the entire directory for the collection
|
||||
AgencyCommLocker locker("Current", "WRITE");
|
||||
if (locker.successful()) {
|
||||
res.clear();
|
||||
res = ac.removeValues(
|
||||
"Current/Collections/" + databaseName + "/" + collectionID, true);
|
||||
if (res.successful()) {
|
||||
return setErrormsg(TRI_ERROR_NO_ERROR, errorMsg);
|
||||
}
|
||||
return setErrormsg(
|
||||
TRI_ERROR_CLUSTER_COULD_NOT_REMOVE_COLLECTION_IN_CURRENT,
|
||||
errorMsg);
|
||||
}
|
||||
loadCurrentCollections();
|
||||
return setErrormsg(TRI_ERROR_NO_ERROR, errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
res.clear();
|
||||
_agencyCallbackRegistry->awaitNextChange("Current/Version", interval);
|
||||
}
|
||||
if (dbServerResult >= 0) {
|
||||
return dbServerResult;
|
||||
}
|
||||
return setErrormsg(TRI_ERROR_CLUSTER_TIMEOUT, errorMsg);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class Dispatcher;
|
|||
|
||||
class RestShardHandler : public RestBaseHandler {
|
||||
public:
|
||||
RestShardHandler(HttpRequest* request);
|
||||
explicit RestShardHandler(HttpRequest* request);
|
||||
|
||||
public:
|
||||
bool isDirect() const override;
|
||||
|
|
|
@ -39,7 +39,7 @@ class ServerJob : public arangodb::rest::Job {
|
|||
ServerJob& operator=(ServerJob const&) = delete;
|
||||
|
||||
public:
|
||||
ServerJob(HeartbeatThread* heartbeat);
|
||||
explicit ServerJob(HeartbeatThread* heartbeat);
|
||||
~ServerJob();
|
||||
|
||||
public:
|
||||
|
|
|
@ -106,7 +106,7 @@ void DispatcherFeature::prepare() {
|
|||
ApplicationServer::lookupFeature("V8Dealer"));
|
||||
|
||||
if (dealer != nullptr) {
|
||||
dealer->defineDouble("DISPATCHER_THREADS", _nrStandardThreads);
|
||||
dealer->defineDouble("DISPATCHER_THREADS", static_cast<double>(_nrStandardThreads));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ void DispatcherFeature::buildStandardQueue() {
|
|||
LOG_TOPIC(DEBUG, Logger::STARTUP) << "setting up a standard queue with "
|
||||
<< _nrStandardThreads << " threads";
|
||||
|
||||
_dispatcher->addStandardQueue(_nrStandardThreads, _queueSize);
|
||||
_dispatcher->addStandardQueue(static_cast<size_t>(_nrStandardThreads), static_cast<size_t>(_queueSize));
|
||||
}
|
||||
|
||||
void DispatcherFeature::buildAqlQueue() {
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace arangodb {
|
|||
|
||||
class RestQueryHandler : public RestVocbaseBaseHandler {
|
||||
public:
|
||||
RestQueryHandler(HttpRequest*);
|
||||
explicit RestQueryHandler(HttpRequest*);
|
||||
|
||||
public:
|
||||
bool isDirect() const override;
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace arangodb {
|
|||
|
||||
class RestShutdownHandler : public RestBaseHandler {
|
||||
public:
|
||||
RestShutdownHandler(HttpRequest*);
|
||||
explicit RestShutdownHandler(HttpRequest*);
|
||||
|
||||
public:
|
||||
bool isDirect() const override;
|
||||
|
|
|
@ -36,6 +36,7 @@ AffinityFeature::AffinityFeature(
|
|||
application_features::ApplicationServer* server)
|
||||
: ApplicationFeature(server, "Affinity"),
|
||||
_threadAffinity(0),
|
||||
_n(0),
|
||||
_nd(0),
|
||||
_ns(0) {
|
||||
startsAfter("Logger");
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "ApplicationFeatures/ApplicationServer.h"
|
||||
#include "Logger/LogAppender.h"
|
||||
#include "ProgramOptions/ProgramOptions.h"
|
||||
#include "ProgramOptions/Section.h"
|
||||
|
@ -67,9 +68,8 @@ void SchedulerFeature::collectOptions(
|
|||
"number of threads for I/O scheduler",
|
||||
new UInt64Parameter(&_nrSchedulerThreads));
|
||||
|
||||
std::unordered_set<uint64_t> backends = {0, 1, 2, 3, 4};
|
||||
|
||||
#ifndef _WIN32
|
||||
std::unordered_set<uint64_t> backends = {0, 1, 2, 3, 4};
|
||||
options->addHiddenOption(
|
||||
"--scheduler.backend", "1: select, 2: poll, 4: epoll",
|
||||
new DiscreteValuesParameter<UInt64Parameter>(&_backend, backends));
|
||||
|
@ -209,8 +209,8 @@ bool CtrlHandler(DWORD eventType) {
|
|||
if (!seen) {
|
||||
LOG(INFO) << "" << shutdownMessage << ", beginning shut down sequence";
|
||||
|
||||
if (SchedulerFeature::SCHEDULER != nullptr) {
|
||||
SchedulerFeature::SCHEDULER->server()->beginShutdown();
|
||||
if (application_features::ApplicationServer::server != nullptr) {
|
||||
application_features::ApplicationServer::server->beginShutdown();
|
||||
}
|
||||
|
||||
seen = true;
|
||||
|
|
|
@ -690,7 +690,7 @@ void V8DealerFeature::applyContextUpdates() {
|
|||
}
|
||||
|
||||
V8Context* context =
|
||||
V8DealerFeature::DEALER->enterContext(vocbase, true, i);
|
||||
V8DealerFeature::DEALER->enterContext(vocbase, true, static_cast<ssize_t>(i));
|
||||
|
||||
if (context == nullptr) {
|
||||
LOG(FATAL) << "could not updated V8 context #" << i;
|
||||
|
@ -975,7 +975,7 @@ void V8DealerFeature::initializeContext(size_t i) {
|
|||
|
||||
void V8DealerFeature::loadJavascriptFiles(TRI_vocbase_t* vocbase,
|
||||
std::string const& file, size_t i) {
|
||||
V8Context* context = V8DealerFeature::DEALER->enterContext(vocbase, true, i);
|
||||
V8Context* context = V8DealerFeature::DEALER->enterContext(vocbase, true, static_cast<ssize_t>(i));
|
||||
|
||||
if (context == nullptr) {
|
||||
LOG(FATAL) << "could not load JavaScript files in context #" << i;
|
||||
|
|
|
@ -2130,6 +2130,7 @@ TRI_vocbase_operationmode_e TRI_GetOperationModeServer() { return Mode; }
|
|||
|
||||
TRI_server_t::TRI_server_t()
|
||||
: _databasesLists(new DatabasesLists()),
|
||||
_databaseManagerStarted(false),
|
||||
_indexPool(nullptr),
|
||||
_queryRegistry(nullptr),
|
||||
_basePath(nullptr),
|
||||
|
@ -2137,6 +2138,7 @@ TRI_server_t::TRI_server_t()
|
|||
_lockFilename(nullptr),
|
||||
_serverIdFilename(nullptr),
|
||||
_disableReplicationAppliers(false),
|
||||
_disableCompactor(false),
|
||||
_iterateMarkersOnOpen(false),
|
||||
_hasCreatedSystemDatabase(false),
|
||||
_initialized(false) {}
|
||||
|
|
|
@ -138,6 +138,20 @@ void V8ShellFeature::start() {
|
|||
|
||||
void V8ShellFeature::stop() {
|
||||
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::stop";
|
||||
|
||||
{
|
||||
v8::Locker locker{_isolate};
|
||||
|
||||
v8::Isolate::Scope isolate_scope(_isolate);
|
||||
v8::HandleScope handle_scope(_isolate);
|
||||
|
||||
v8::Local<v8::Context> context =
|
||||
v8::Local<v8::Context>::New(_isolate, _context);
|
||||
|
||||
v8::Context::Scope context_scope{context};
|
||||
|
||||
TRI_RunGarbageCollectionV8(_isolate, 2500.0);
|
||||
}
|
||||
|
||||
{
|
||||
v8::Locker locker{_isolate};
|
||||
|
|
|
@ -3520,10 +3520,11 @@ testFuncs.upgrade = function(options) {
|
|||
let args = makeArgsArangod(options, appDir);
|
||||
args["server.endpoint"] = "tcp://127.0.0.1:" + port;
|
||||
args["database.directory"] = fs.join(tmpDataDir, "data");
|
||||
args["database.upgrade"] = true;
|
||||
|
||||
fs.makeDirectoryRecursive(fs.join(tmpDataDir, "data"));
|
||||
|
||||
const argv = toArgv(args).concat(["--database.upgrade"]);
|
||||
const argv = toArgv(args);
|
||||
|
||||
result.upgrade.first = executeAndWait(ARANGOD_BIN, argv, options, "upgrade");
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ Endpoint::Endpoint(DomainType domainType, EndpointType type,
|
|||
|
||||
std::string Endpoint::uriForm (std::string const& endpoint) {
|
||||
static std::string illegal;
|
||||
std::string unified = unifiedForm(endpoint);
|
||||
|
||||
if (StringUtils::isPrefix(endpoint, "http+tcp://")) {
|
||||
return "http://" + endpoint.substr(11);
|
||||
|
|
|
@ -737,6 +737,7 @@ V8Buffer::V8Buffer(v8::Isolate* isolate, v8::Handle<v8::Object> wrapper,
|
|||
// used in base member initializer
|
||||
// list
|
||||
_length(0),
|
||||
_data(nullptr),
|
||||
_callback(nullptr) {
|
||||
replace(isolate, NULL, length, NULL, NULL);
|
||||
}
|
||||
|
@ -778,6 +779,8 @@ void V8Buffer::replace(v8::Isolate* isolate, char* data, size_t length,
|
|||
delete[] _data;
|
||||
isolate->AdjustAmountOfExternalAllocatedMemory(
|
||||
-static_cast<intptr_t>(sizeof(V8Buffer) + _length));
|
||||
} else {
|
||||
delete[] _data;
|
||||
}
|
||||
|
||||
_length = length;
|
||||
|
|
Loading…
Reference in New Issue