File: repl.h

package info (click to toggle)
mawk 1.3.4.20260302-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,244 kB
  • sloc: ansic: 19,997; sh: 4,627; yacc: 1,182; awk: 903; makefile: 301
file content (61 lines) | stat: -rw-r--r-- 1,396 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/********************************************
repl.h
copyright 2009-2023,2024, Thomas E. Dickey
copyright 1991,1993, Michael D. Brennan

This is a source file for mawk, an implementation of
the AWK programming language.

Mawk is distributed without warranty under the terms of
the GNU General Public License, version 2, 1991.
********************************************/

/*
 * $MawkId: repl.h,v 1.14 2024/09/05 17:24:56 tom Exp $
 */

/* repl.h */

#ifndef  REPL_H
#define  REPL_H

#include <types.h>

typedef struct _re_data
#ifdef Visible_RE_DATA
{
    PTR compiled;		/* must be first... */
    int anchored;		/* use to limit recursion in gsub */
    int is_empty;		/* check if pattern is empty */
}
#endif
RE_DATA;

typedef struct _re_node
#ifdef Visible_RE_NODE
{
    RE_DATA re;			/* keep this first, for re_destroy() */
    STRING *sval;
    struct _re_node *link;
}
#endif
RE_NODE;

/*
 * re_compile returns a RE_DATA*, but mawk handles it as a PTR thereafter.
 */
#define isAnchored(ptr) (((RE_DATA *)(ptr))->anchored)
#define isEmpty_RE(ptr) (((RE_DATA *)(ptr))->is_empty)
#define cast_to_re(ptr) (((RE_DATA *)(ptr))->compiled)

RE_NODE *re_compile(STRING *);
STRING *re_uncompile(PTR);

CELL *repl_compile(STRING *);
const STRING *repl_uncompile(CELL *);
void re_destroy(PTR);
void repl_destroy(CELL *);
CELL *replv_cpy(CELL *, CELL *);
CELL *replv_to_repl(CELL *, STRING *);

#endif