From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NOvCt-0007hL-HP for mharc-grub-devel@gnu.org; Sun, 27 Dec 2009 10:38:59 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NOvCq-0007gq-Ia for grub-devel@gnu.org; Sun, 27 Dec 2009 10:38:56 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NOvCn-0007fv-1U for grub-devel@gnu.org; Sun, 27 Dec 2009 10:38:56 -0500 Received: from [199.232.76.173] (port=43121 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NOvCm-0007fs-Pq for grub-devel@gnu.org; Sun, 27 Dec 2009 10:38:52 -0500 Received: from mail-bw0-f215.google.com ([209.85.218.215]:59728) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NOvCm-0002w0-72 for grub-devel@gnu.org; Sun, 27 Dec 2009 10:38:52 -0500 Received: by bwz7 with SMTP id 7so6854584bwz.26 for ; Sun, 27 Dec 2009 07:38:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:x-enigmail-version:content-type; bh=VMdJKdTm7sPLWVHHzdcUaDlXAFSCp2vTM9kb5YvWPPc=; b=MttIr2uNhgQMoYPEKJtBNi0iVI5HhYQaFTXlJX05fSIp2IjipeElge9CkZbnr1Dc8a dyTGIwjzrgX2n3R27vPyE4jkr3ghgA+fwyBLc/RWxHLOpNTlZ4meraay/efIwksRnyg2 dWNeSrfA4J3a6Ec/N95IpGf4MR9ry0hb7t0PM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type; b=YHBA3IcZseSDhgyY+bovSx/BpEg+tVxxfwy21UO1OxJ19ZJwt+cFiLO/BKe+N/+dYO cF+mBLYCW6DFLaX7gm/jqfRDjtlA0jrytRwc+JVWRsurm8MI8JTDsPexUe92Q2lDtb6Z XxZSi9QBp3+eOKWZlY0wpLAWC9VHOzLQ07I2U= Received: by 10.204.14.82 with SMTP id f18mr8932695bka.204.1261928331176; Sun, 27 Dec 2009 07:38:51 -0800 (PST) Received: from debian.bg45.phnet (132-131.203-62.cust.bluewin.ch [62.203.131.132]) by mx.google.com with ESMTPS id 16sm3135627bwz.7.2009.12.27.07.38.50 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 27 Dec 2009 07:38:50 -0800 (PST) Message-ID: <4B377F7D.5050206@gmail.com> Date: Sun, 27 Dec 2009 16:38:37 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109) MIME-Version: 1.0 To: The development of GRUB 2 X-Enigmail-Version: 0.95.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig9E3D439CF4574D5C28539400" X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [PATCH] Regexp matching in grub X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Dec 2009 15:38:56 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig9E3D439CF4574D5C28539400 Content-Type: multipart/mixed; boundary="------------020607070009050506070507" This is a multi-part message in MIME format. --------------020607070009050506070507 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello, I imported regexp from gnulib into grub. Available from people/phcoder/regexp. Following changes required: common.rmk Add: pkglib_MODULES +=3D regexp.mod regexp_mod_SOURCES =3D gnulib/regex.c commands/regexp.c regexp_mod_CFLAGS =3D $(COMMON_CFLAGS) -Wno-sign-compare -Wno-unused regexp_mod_LDFLAGS =3D $(COMMON_LDFLAGS) commands/regexp.c New file (attached) gnulib/regcomp.c, gnulib/regex_internal.c, gnulib/regexec.c: Copied verbatim from gnulib. gnulib/regex.c: New file (attached). Based on file from gnulib, heavily modified gnulib/regex_internal.h. Copied from gnulib following modification needed= : --- /home/phcoder/repos/gnulib/lib/regex_internal.h 2009-11-19 14:02:55.406619037 +0100 +++ gnulib/regex_internal.h 2009-12-27 14:28:10.504789886 +0100 @@ -21,33 +21,6 @@ #ifndef _REGEX_INTERNAL_H #define _REGEX_INTERNAL_H 1 =20 -#include -#include -#include -#include -#include -#include - -#ifdef _LIBC -# include -#else -# include "localcharset.h" -#endif -#if defined HAVE_LOCALE_H || defined _LIBC -# include -#endif - -#include -#include -#include -#if defined _LIBC -# include -#else -# 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 isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK)) # define isblank(ch) ((ch) =3D=3D ' ' || (ch) =3D=3D '\t') include/grub/gnulib-wrap.h: New file include/grub/regex.h: Copied from gnulib. Following modification: --- /home/phcoder/repos/gnulib/lib/regex.h 2009-11-19 14:02:55.402619158 +0100 +++ include/grub/regex.h 2009-12-27 14:20:37.356524246 +0100 @@ -21,7 +21,7 @@ #ifndef _REGEX_H #define _REGEX_H 1 =20 -#include +#include =20 /* Allow the use in C++ code. */ #ifdef __cplusplus --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------020607070009050506070507 Content-Type: text/x-csrc; name="regexp.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="regexp.c" /* regexp.c -- The regexp command. */ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 2005,2007 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GRUB 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GRUB. If not, see . */ #include #include #include #include #include static grub_err_t grub_cmd_regexp (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) { int argn =3D 0; int matches =3D 0; regex_t regex; int ret; grub_size_t s; char *comperr; grub_err_t err; if (argc !=3D 2) return grub_error (GRUB_ERR_BAD_ARGUMENT, "2 arguments expected"); ret =3D regcomp (®ex, args[0], RE_SYNTAX_GNU_AWK); if (ret) goto fail; ret =3D regexec (®ex, args[1], 0, 0, 0); if (!ret) { regfree (®ex); return GRUB_ERR_NONE; } fail: s =3D regerror (ret, ®ex, 0, 0); comperr =3D grub_malloc (s); if (!comperr) { regfree (®ex); return grub_errno; } regerror (ret, ®ex, comperr, s); err =3D grub_error (GRUB_ERR_TEST_FAILURE, "%s", comperr); regfree (®ex); grub_free (comperr); return err; } static grub_command_t cmd; =0C GRUB_MOD_INIT(regexp) { cmd =3D grub_register_command ("regexp", grub_cmd_regexp, "REGEXP STRING", "Test if REGEXP matches STRING."); } GRUB_MOD_FINI(regexp) { grub_unregister_command (cmd); } --------------020607070009050506070507 Content-Type: text/x-csrc; name="regex.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="regex.c" /* Extended regular expression matching and search library. Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License alon= g with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "regex_internal.h" #include "regex_internal.c" #include "regcomp.c" #include "regexec.c" --------------020607070009050506070507 Content-Type: text/x-chdr; name="gnulib-wrap.h" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="gnulib-wrap.h" /* * GRUB -- GRand Unified Bootloader * Copyright (C) 2009 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GRUB 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GRUB. If not, see . */ #ifndef GRUB_GNULIB_WRAP_H #define GRUB_GNULIB_WRAP_H 1 #include #include typedef grub_size_t size_t; typedef int bool; static const bool true =3D 1; static const bool false =3D 0; #define assert(x) assert_real(__FILE__, __LINE__, x) static inline void assert_real (const char *file, int line, int cond) { if (!cond) grub_fatal ("Assertion failed at %s:%d\n", file, line); } static inline char * locale_charset (void) { return "UTF-8"; } #define MB_CUR_MAX 6 static inline void * realloc (void *ptr, grub_size_t size) { return grub_realloc (ptr, size); } static inline int toupper (int c) { return grub_toupper (c); } static inline int=20 isspace (int c) { return grub_isspace (c); } static inline int=20 isdigit (int c) { return grub_isdigit (c); } static inline int islower (int c) { return (c >=3D 'a' && c <=3D 'z'); } static inline int isupper (int c) { return (c >=3D 'A' && c <=3D 'Z'); } static inline int isxdigit (int c) { return (c >=3D 'a' && c <=3D 'f') || (c >=3D 'A' && c <=3D 'F') || (c >=3D '0' && c <=3D '9'); } static inline int=20 isprint (int c) { return grub_isprint (c); } static inline int=20 iscntrl (int c) { return !grub_isprint (c); } static inline int=20 isgraph (int c) { return grub_isprint (c) && !grub_isspace (c); } static inline int isalnum (int c) { return grub_isalpha (c) || grub_isdigit (c); } static inline int=20 ispunct (int c) { return grub_isprint (c) && !grub_isspace (c) && !isalnum (c); } static inline int=20 isalpha (int c) { return grub_isalpha (c); } static inline int tolower (int c) { return grub_tolower (c); } static inline grub_size_t strlen (const char *s) { return grub_strlen (s); } static inline int=20 strcmp (const char *s1, const char *s2) { return grub_strcmp (s1, s2); } static inline void abort (void) { grub_abort (); } static inline void=20 free (void *ptr) { grub_free (ptr); } static inline void * malloc (grub_size_t size) { return grub_malloc (size); } static inline void * calloc (grub_size_t size, grub_size_t nelem) { return grub_zalloc (size * nelem); } #define ULONG_MAX GRUB_ULONG_MAX #define UCHAR_MAX 0xff /* UCS-4. */ typedef grub_uint32_t wchar_t; #undef __libc_lock_init #define __libc_lock_init(x) #undef __libc_lock_lock #define __libc_lock_lock(x) #undef __libc_lock_unlock #define __libc_lock_unlock(x) #endif --------------020607070009050506070507-- --------------enig9E3D439CF4574D5C28539400 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iF4EAREKAAYFAks3f4kACgkQNak7dOguQgmomQEArp9OCGyKZz62QdHgkvp8j9dY kTdwNZuULw+kbNLMfMIBAKH1jE8oaRPuJuFD8bhWnDQd5PSjtVSWy2zeaghXvHid =nU5w -----END PGP SIGNATURE----- --------------enig9E3D439CF4574D5C28539400--