mg

port of mg editor (openbsd to linux)
Log | Files | Refs | README

commit 81e066932e7233ddc14c91a9f63b144989031ceb
parent 76fb7b42d3085d9270992e8770c255ea52c063ea
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Mon, 24 Nov 2014 23:02:12 +0100

improve Makefile, merge util.h

Diffstat:
Makefile | 3++-
config.mk | 4++--
def.h | 2+-
libopenbsd/util.h | 12------------
libutil/util.h | 74--------------------------------------------------------------------------
util.h | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 95 insertions(+), 90 deletions(-)

diff --git a/Makefile b/Makefile @@ -12,7 +12,8 @@ HDR =\ macro.h\ pathnames.h\ sysdef.h\ - ttydef.h + ttydef.h\ + util.h LIBUTIL = libutil.a LIBUTILSRC =\ diff --git a/config.mk b/config.mk @@ -17,6 +17,6 @@ RANLIB = ranlib CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 CFLAGS = -Os -std=c99 -Wall -pedantic \ - -DDEFFILEMODE=0666 -D__dead="" -I. -Iinclude -Ilibutil \ + -DDEFFILEMODE=0666 -D__dead="" -I. -Iinclude \ -DFKEYS -DREGEX -DXKEYS -LDFLAGS = -s -static -lcurses -Llibopenbsd -lopenbsd -Llibutil -lutil +LDFLAGS = -s -static -lcurses -L. -lopenbsd -lutil diff --git a/def.h b/def.h @@ -13,7 +13,7 @@ #include "sysdef.h" /* Order is critical. */ #include "ttydef.h" #include "chrdef.h" -#include "libopenbsd/util.h" +#include "util.h" typedef int (*PF)(int, int); /* generally useful type */ diff --git a/libopenbsd/util.h b/libopenbsd/util.h @@ -1,11 +0,0 @@ -/* some libc's like musl don't support REG_STARTEND (yet) and - * glibc has some differences compared to OpenBSD */ -#ifndef REG_STARTEND -#define REG_STARTEND 0 -#endif - -void * reallocarray(void *, size_t, size_t); -size_t strlcat(char *, const char *, size_t); -size_t strlcpy(char *, const char *, size_t); -long long strtonum(const char *, long long, long long, const char **); -uint32_t arc4random(void);- \ No newline at end of file diff --git a/libutil/util.h b/libutil/util.h @@ -1,74 +0,0 @@ -/* $OpenBSD: util.h,v 1.34 2013/06/03 21:07:02 tedu Exp $ */ -/* $NetBSD: util.h,v 1.2 1996/05/16 07:00:22 thorpej Exp $ */ - -/*- - * Copyright (c) 1995 - * The Regents of the University of California. All rights reserved. - * Portions Copyright (c) 1996, Jason Downs. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _UTIL_H_ -#define _UTIL_H_ - -#include <sys/types.h> - -/* - * fparseln() specific operation flags. - */ -#define FPARSELN_UNESCESC 0x01 -#define FPARSELN_UNESCCONT 0x02 -#define FPARSELN_UNESCCOMM 0x04 -#define FPARSELN_UNESCREST 0x08 -#define FPARSELN_UNESCALL 0x0f - -/* - * opendev() specific operation flags. - */ -#define OPENDEV_PART 0x01 /* Try to open the raw partition. */ -#define OPENDEV_BLCK 0x04 /* Open block, not character device. */ - -/* - * uucplock(3) specific flags. - */ -#define UU_LOCK_INUSE (1) -#define UU_LOCK_OK (0) -#define UU_LOCK_OPEN_ERR (-1) -#define UU_LOCK_READ_ERR (-2) -#define UU_LOCK_CREAT_ERR (-3) -#define UU_LOCK_WRITE_ERR (-4) -#define UU_LOCK_LINK_ERR (-5) -#define UU_LOCK_TRY_ERR (-6) -#define UU_LOCK_OWNER_ERR (-7) - -/* - * fmt_scaled(3) specific flags. - */ -#define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */ - -char *fparseln(FILE *, size_t *, size_t *, const char[3], int); - -#endif /* !_UTIL_H_ */ diff --git a/util.h b/util.h @@ -0,0 +1,90 @@ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +#include <sys/types.h> +#include <stdio.h> + +/* libopenbsd util.h */ + +/* some libc's like musl don't support REG_STARTEND (yet) and + * glibc has some differences compared to OpenBSD */ +#ifndef REG_STARTEND +#define REG_STARTEND 0 +#endif + +void * reallocarray(void *, size_t, size_t); +size_t strlcat(char *, const char *, size_t); +size_t strlcpy(char *, const char *, size_t); +long long strtonum(const char *, long long, long long, const char **); +uint32_t arc4random(void);/* $OpenBSD: util.h,v 1.34 2013/06/03 21:07:02 tedu Exp $ */ + +/* from libutil util.h */ + +/* $NetBSD: util.h,v 1.2 1996/05/16 07:00:22 thorpej Exp $ */ + +/*- + * Copyright (c) 1995 + * The Regents of the University of California. All rights reserved. + * Portions Copyright (c) 1996, Jason Downs. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * fparseln() specific operation flags. + */ +#define FPARSELN_UNESCESC 0x01 +#define FPARSELN_UNESCCONT 0x02 +#define FPARSELN_UNESCCOMM 0x04 +#define FPARSELN_UNESCREST 0x08 +#define FPARSELN_UNESCALL 0x0f + +/* + * opendev() specific operation flags. + */ +#define OPENDEV_PART 0x01 /* Try to open the raw partition. */ +#define OPENDEV_BLCK 0x04 /* Open block, not character device. */ + +/* + * uucplock(3) specific flags. + */ +#define UU_LOCK_INUSE (1) +#define UU_LOCK_OK (0) +#define UU_LOCK_OPEN_ERR (-1) +#define UU_LOCK_READ_ERR (-2) +#define UU_LOCK_CREAT_ERR (-3) +#define UU_LOCK_WRITE_ERR (-4) +#define UU_LOCK_LINK_ERR (-5) +#define UU_LOCK_TRY_ERR (-6) +#define UU_LOCK_OWNER_ERR (-7) + +/* + * fmt_scaled(3) specific flags. + */ +#define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */ + +char *fparseln(FILE *, size_t *, size_t *, const char[3], int); + +#endif /* !_UTIL_H_ */