misc.c (133385) | misc.c (200420) |
---|---|
1/*- 2 * Copyright (c) 1992 Diomidis Spinellis. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Diomidis Spinellis of Imperial College, University of London. 8 * --- 18 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1992 Diomidis Spinellis. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Diomidis Spinellis of Imperial College, University of London. 8 * --- 18 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/usr.bin/sed/misc.c 133385 2004-08-09 15:29:41Z dds $"); | 35__FBSDID("$FreeBSD: head/usr.bin/sed/misc.c 200420 2009-12-11 23:35:38Z delphij $"); |
36 37#ifndef lint 38static const char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93"; 39#endif 40 41#include <sys/types.h> 42 43#include <err.h> | 36 37#ifndef lint 38static const char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93"; 39#endif 40 41#include <sys/types.h> 42 43#include <err.h> |
44#include <limits.h> | |
45#include <regex.h> | 44#include <regex.h> |
46#include <stdio.h> | |
47#include <stdlib.h> | 45#include <stdlib.h> |
48#include <string.h> | |
49 | 46 |
50#include "defs.h" 51#include "extern.h" 52 | |
53/* 54 * Return a string for a regular expression error passed. This is overkill, 55 * because of the silly semantics of regerror (we can never know the size of 56 * the buffer). 57 */ 58char * 59strregerror(int errcode, regex_t *preg) 60{ 61 static char *oe; 62 size_t s; 63 64 if (oe != NULL) 65 free(oe); 66 s = regerror(errcode, preg, NULL, 0); 67 if ((oe = malloc(s)) == NULL) 68 err(1, "malloc"); 69 (void)regerror(errcode, preg, oe, s); 70 return (oe); 71} | 47/* 48 * Return a string for a regular expression error passed. This is overkill, 49 * because of the silly semantics of regerror (we can never know the size of 50 * the buffer). 51 */ 52char * 53strregerror(int errcode, regex_t *preg) 54{ 55 static char *oe; 56 size_t s; 57 58 if (oe != NULL) 59 free(oe); 60 s = regerror(errcode, preg, NULL, 0); 61 if ((oe = malloc(s)) == NULL) 62 err(1, "malloc"); 63 (void)regerror(errcode, preg, oe, s); 64 return (oe); 65} |