summaryrefslogtreecommitdiff
path: root/jam-files/engine/modules/regex.c
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2012-10-22 12:07:20 +0100
committerKenneth Heafield <github@kheafield.com>2012-10-22 12:07:20 +0100
commit5f98fe5c4f2a2090eeb9d30c030305a70a8347d1 (patch)
tree9b6002f850e6dea1e3400c6b19bb31a9cdf3067f /jam-files/engine/modules/regex.c
parentcf9994131993b40be62e90e213b1e11e6b550143 (diff)
parent21825a09d97c2e0afd20512f306fb25fed55e529 (diff)
Merge remote branch 'upstream/master'
Conflicts: Jamroot bjam decoder/Jamfile decoder/cdec.cc dpmert/Jamfile jam-files/sanity.jam klm/lm/Jamfile klm/util/Jamfile mira/Jamfile
Diffstat (limited to 'jam-files/engine/modules/regex.c')
-rw-r--r--jam-files/engine/modules/regex.c96
1 files changed, 0 insertions, 96 deletions
diff --git a/jam-files/engine/modules/regex.c b/jam-files/engine/modules/regex.c
deleted file mode 100644
index d048ba1d..00000000
--- a/jam-files/engine/modules/regex.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/* Copyright Vladimir Prus 2003. Distributed under the Boost */
-/* Software License, Version 1.0. (See accompanying */
-/* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */
-
-#include "../native.h"
-#include "../timestamp.h"
-#include "../newstr.h"
-#include "../strings.h"
-#include "../regexp.h"
-#include "../compile.h"
-
-/*
-rule transform ( list * : pattern : indices * )
-{
- indices ?= 1 ;
- local result ;
- for local e in $(list)
- {
- local m = [ MATCH $(pattern) : $(e) ] ;
- if $(m)
- {
- result += $(m[$(indices)]) ;
- }
- }
- return $(result) ;
-}
-*/
-LIST *regex_transform( PARSE *parse, FRAME *frame )
-{
- LIST* l = lol_get( frame->args, 0 );
- LIST* pattern = lol_get( frame->args, 1 );
- LIST* indices_list = lol_get(frame->args, 2);
- int* indices = 0;
- int size;
- int* p;
- LIST* result = 0;
-
- string buf[1];
- string_new(buf);
-
- if (indices_list)
- {
- size = list_length(indices_list);
- indices = (int*)BJAM_MALLOC(size*sizeof(int));
- for(p = indices; indices_list; indices_list = indices_list->next)
- {
- *p++ = atoi(indices_list->string);
- }
- }
- else
- {
- size = 1;
- indices = (int*)BJAM_MALLOC(sizeof(int));
- *indices = 1;
- }
-
- {
- /* Result is cached and intentionally never freed */
- regexp *re = regex_compile( pattern->string );
-
- for(; l; l = l->next)
- {
- if( regexec( re, l->string ) )
- {
- int i = 0;
- for(; i < size; ++i)
- {
- int index = indices[i];
- /* Skip empty submatches. Not sure it's right in all cases,
- but surely is right for the case for which this routine
- is optimized -- header scanning.
- */
- if (re->startp[index] != re->endp[index])
- {
- string_append_range( buf, re->startp[index], re->endp[index] );
- result = list_new( result, newstr( buf->value ) );
- string_truncate( buf, 0 );
- }
- }
- }
- }
- string_free( buf );
- }
-
- BJAM_FREE(indices);
-
- return result;
-}
-
-void init_regex()
-{
- {
- char* args[] = { "list", "*", ":", "pattern", ":", "indices", "*", 0 };
- declare_native_rule("regex", "transform", args, regex_transform, 2);
- }
-}