mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-05 01:00:21 +02:00
* libguile/regex-posix.c: * libguile/regex-posix.h (scm_is_regexp): (scm_to_regexp): (scm_from_regexp): (SCM_REGEXP_P): (SCM_VALIDATE_REGEXP): Move definitions to header.
62 lines
1.5 KiB
C
62 lines
1.5 KiB
C
#ifndef SCM_REGEX_POSIX_H
|
||
#define SCM_REGEX_POSIX_H
|
||
|
||
/* Copyright 1997-1998,2000-2001,2006,2008,2018,2025
|
||
Free Software Foundation, Inc.
|
||
|
||
This file is part of Guile.
|
||
|
||
Guile 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 3 of the License, or
|
||
(at your option) any later version.
|
||
|
||
Guile 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 Guile. If not, see
|
||
<https://www.gnu.org/licenses/>. */
|
||
|
||
|
||
|
||
#include <regex.h>
|
||
|
||
#include <libguile/scm.h>
|
||
|
||
struct scm_regexp
|
||
{
|
||
scm_t_bits tag;
|
||
regex_t regex;
|
||
};
|
||
|
||
static inline int
|
||
scm_is_regexp (SCM x)
|
||
{
|
||
return SCM_HAS_TYP16 (x, scm_tc16_regexp);
|
||
}
|
||
|
||
static inline struct scm_regexp*
|
||
scm_to_regexp (SCM x)
|
||
{
|
||
if (!scm_is_regexp (x))
|
||
abort ();
|
||
return (struct scm_regexp *) SCM_UNPACK_POINTER (x);
|
||
}
|
||
|
||
static inline SCM
|
||
scm_from_regexp (struct scm_regexp *x)
|
||
{
|
||
return SCM_PACK_POINTER (x);
|
||
}
|
||
|
||
#define SCM_REGEXP_P(x) (scm_is_regexp (x))
|
||
#define SCM_VALIDATE_REGEXP(pos, a) \
|
||
SCM_MAKE_VALIDATE_MSG (pos, a, REGEXP_P, "regexp")
|
||
|
||
SCM_INTERNAL void scm_i_finalize_regexp (struct scm_thread*, SCM);
|
||
SCM_INTERNAL void scm_init_regex_posix (void);
|
||
|
||
#endif /* SCM_REGEX_POSIX_H */
|