OSDN Git Service

Fix no pic
[uclinux-h8/uClinux-dist.git] / user / tinytcl / regex_compat.c
1 /*
2  * regex_compat.c
3  *
4  *
5  * Copyright (c) 2004 Snapgear
6  *
7  * See the file "license.terms" for information on usage and redistribution
8  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9  *
10  */
11 #include <features.h>
12
13 #ifdef __UC_LIBC__
14 #include <stdio.h>
15 #define REGEX_COMPAT_IMPL
16 #include "regex_compat.h"
17
18 int compat_regcomp(regex_t *preg, const char *regex, int cflags)
19 {
20         preg->preg = regcomp((char *)regex);
21         return(preg->preg == 0);
22 }
23
24 int compat_regexec(const  regex_t  *preg,  const  char *string, size_t nmatch, regmatch_t pmatch[], int eflags)
25 {
26         if (regexec(preg->preg, (char *)string) == 1) {
27                 int i;
28                 for (i = 0; i < NSUBEXP && i < nmatch; i++) {
29                         if (preg->preg->startp[i]) {
30                                 pmatch[i].rm_so = preg->preg->startp[i] - string;
31                         }
32                         else {
33                                 pmatch[i].rm_so = -1;
34                         }
35                         if (preg->preg->endp[i]) {
36                                 pmatch[i].rm_eo = preg->preg->endp[i] - string;
37                         }
38                         else {
39                                 pmatch[i].rm_eo = -1;
40                         }
41                 }
42                 return(0);
43         }
44         /* No match */
45         return(1);
46 }
47
48 size_t compat_regerror(int errcode, const regex_t *preg, char *errbuf,  size_t errbuf_size)
49 {
50         return snprintf(errbuf, errbuf_size, "regex_compat() error %d", errcode);
51 }
52
53 void compat_regfree(regex_t *preg)
54 {
55 }
56 #endif