Merge ^/head r317971 through r318379.

This commit is contained in:
Dimitry Andric 2017-05-16 19:54:47 +00:00
commit 209be20560
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/clang500-import/; revision=318381
347 changed files with 6084 additions and 2201 deletions

View File

@ -302,6 +302,11 @@ CLEANDIR= clean cleandepend
CLEANDIR= cleandir
.endif
.if defined(WORLDFAST)
NO_CLEAN= t
NO_OBJ= t
.endif
.if ${MK_META_MODE} == "yes"
# If filemon is used then we can rely on the build being incremental-safe.
# The .meta files will also track the build command and rebuild should
@ -310,6 +315,13 @@ CLEANDIR= cleandir
NO_CLEAN= t
.endif
.endif
.if defined(NO_OBJ) || ${MK_AUTO_OBJ} == "yes"
NO_OBJ= t
NO_KERNELOBJ= t
.endif
.if !defined(NO_OBJ)
_obj= obj
.endif
LOCAL_TOOL_DIRS?=
PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
@ -824,13 +836,22 @@ everything: .PHONY
${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
WMAKE_TGTS=
.if !defined(WORLDFAST)
WMAKE_TGTS+= _worldtmp _legacy
.if empty(SUBDIR_OVERRIDE)
WMAKE_TGTS+= _bootstrap-tools
.endif
WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
WMAKE_TGTS+= _cleanobj
.if !defined(NO_OBJ)
WMAKE_TGTS+= _obj
.endif
WMAKE_TGTS+= _build-tools _cross-tools
WMAKE_TGTS+= _compiler-metadata
WMAKE_TGTS+= _includes _libraries
WMAKE_TGTS+= _includes
.endif
.if !defined(NO_LIBS)
WMAKE_TGTS+= _libraries
.endif
WMAKE_TGTS+= everything
.if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
WMAKE_TGTS+= build${libcompat}
@ -1610,7 +1631,7 @@ legacy: .PHONY
.for _tool in tools/build ${_elftoolchain_libs}
${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
cd ${.CURDIR}/${_tool}; \
${MAKE} DIRPRFX=${_tool}/ obj; \
if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
@ -1766,7 +1787,7 @@ bootstrap-tools: .PHONY
${_bt}-${_tool}: .PHONY .MAKE
${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
cd ${.CURDIR}/${_tool}; \
${MAKE} DIRPRFX=${_tool}/ obj; \
if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
${MAKE} DIRPRFX=${_tool}/ all; \
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
@ -1805,7 +1826,7 @@ _rescue=rescue/rescue
build-tools_${_tool}: .PHONY
${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
cd ${.CURDIR}/${_tool}; \
${MAKE} DIRPRFX=${_tool}/ obj; \
if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
${MAKE} DIRPRFX=${_tool}/ build-tools
build-tools: build-tools_${_tool}
.endfor
@ -1814,7 +1835,7 @@ build-tools: build-tools_${_tool}
build-tools_${_tool}: .PHONY
${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
cd ${.CURDIR}/${_tool}; \
${MAKE} DIRPRFX=${_tool}/ obj; \
if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
${MAKE} DIRPRFX=${_tool}/ all
build-tools: build-tools_${_tool}
.endfor
@ -1899,7 +1920,7 @@ cross-tools: .MAKE .PHONY
${_usb_tools}
${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
cd ${.CURDIR}/${_tool}; \
${MAKE} DIRPRFX=${_tool}/ obj; \
if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
${MAKE} DIRPRFX=${_tool}/ all; \
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
.endfor
@ -1931,7 +1952,7 @@ native-xtools: .PHONY
mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
cd ${.CURDIR}/${_gperf}; \
${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
if [ -z "${NO_OBJ}" ]; then ${NXBMAKE} DIRPRFX=${_gperf}/ obj; fi; \
${NXBMAKE} DIRPRFX=${_gperf}/ all; \
${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
.endif
@ -2007,7 +2028,7 @@ native-xtools: .PHONY
usr.sbin/chown
${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
cd ${.CURDIR}/${_tool}; \
${NXBMAKE} DIRPRFX=${_tool}/ obj; \
if [ -z "${NO_OBJ}" ]; then ${NXBMAKE} DIRPRFX=${_tool}/ obj; fi; \
${NXBMAKE} DIRPRFX=${_tool}/ all; \
${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
.endfor
@ -2269,7 +2290,7 @@ ${_lib}__PL: .PHONY .MAKE
.if exists(${.CURDIR}/${_lib})
${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
cd ${.CURDIR}/${_lib}; \
${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
if [ -z "${NO_OBJ}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
DIRPRFX=${_lib}/ all; \
${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
@ -2282,7 +2303,7 @@ ${_lib}__L: .PHONY .MAKE
.if exists(${.CURDIR}/${_lib})
${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
cd ${.CURDIR}/${_lib}; \
${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
if [ -z "${NO_OBJ}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
.endif
@ -2609,7 +2630,7 @@ _xb-bootstrap-tools: .PHONY
${_yacc}
${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
cd ${.CURDIR}/${_tool}; \
${CDMAKE} DIRPRFX=${_tool}/ obj; \
if [ -z "${NO_OBJ}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
${CDMAKE} DIRPRFX=${_tool}/ all; \
${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
.endfor
@ -2628,7 +2649,7 @@ _xb-cross-tools: .PHONY
${_gcc}
${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
cd ${.CURDIR}/${_tool}; \
${CDMAKE} DIRPRFX=${_tool}/ obj; \
if [ -z "${NO_OBJ}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
${CDMAKE} DIRPRFX=${_tool}/ all
.endfor

View File

@ -163,7 +163,7 @@ build${libcompat}: .PHONY
.endif
mkdir -p ${WORLDTMP}
ln -sf ${.CURDIR}/sys ${WORLDTMP}
.for _t in obj includes
.for _t in ${_obj} includes
.for _dir in ${_LC_INCDIRS}
${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \
DIRPRFX=${_dir}/ ${_t}
@ -180,7 +180,7 @@ build${libcompat}: .PHONY
${_+_}cd ${.CURDIR}; \
${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
.if ${libcompat} == "32"
.for _t in obj all
.for _t in ${_obj} all
${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \
-DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \

2
README
View File

@ -81,4 +81,4 @@ usr.sbin System administration commands.
For information on synchronizing your source tree with one or more of
the FreeBSD Project's development branches, please see:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/synching.html
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/updating-src.html

View File

@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcapsicum \
lib/libcompiler_rt \

View File

@ -440,8 +440,15 @@ expari(const char *p, struct nodelist **restrict argbackq, int flag,
fmtstr(expdest, DIGITS(result), ARITH_FORMAT_STR, result);
adj = strlen(expdest);
STADJUST(adj, expdest);
if (!quoted)
reprocess(expdest - adj - stackblock(), flag, VSNORMAL, 0, dst);
/*
* If this is quoted, a '-' must not indicate a range in [...].
* If this is not quoted, splitting may occur.
*/
if (quoted ?
result < 0 && begoff > 1 && flag & (EXP_GLOB | EXP_CASE) :
flag & EXP_SPLIT)
reprocess(expdest - adj - stackblock(), flag, VSNORMAL, quoted,
dst);
return p;
}

View File

@ -40,6 +40,8 @@ ${PACKAGE}FILES+= case17.0
${PACKAGE}FILES+= case18.0
${PACKAGE}FILES+= case19.0
${PACKAGE}FILES+= case20.0
${PACKAGE}FILES+= case21.0
${PACKAGE}FILES+= case22.0
${PACKAGE}FILES+= cd1.0
${PACKAGE}FILES+= cd2.0
${PACKAGE}FILES+= cd3.0

View File

@ -0,0 +1,10 @@
# $FreeBSD$
case 5 in
[0$((-9))]) ;;
*) echo bad1 ;;
esac
case - in
[0$((-9))]) echo bad2 ;;
esac

View File

@ -0,0 +1,10 @@
# $FreeBSD$
case 5 in
[0"$((-9))"]) echo bad1 ;;
esac
case - in
[0"$((-9))"]) ;;
*) echo bad2 ;;
esac

View File

@ -26,6 +26,9 @@
#include "atf-c/detail/process.h"
#include <sys/types.h>
#ifdef __FreeBSD__
#include <sys/sysctl.h>
#endif
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
@ -667,6 +670,14 @@ ATF_TC_BODY(status_coredump, tc)
atf_tc_skip("Cannot unlimit the core file size; check limits "
"manually");
#ifdef __FreeBSD__
int coredump_enabled;
size_t ce_len = sizeof(coredump_enabled);
if (sysctlbyname("kern.coredump", &coredump_enabled, &ce_len, NULL,
0) == 0 && !coredump_enabled)
atf_tc_skip("Coredumps disabled");
#endif
const int rawstatus = fork_and_wait_child(child_sigquit);
atf_process_status_t s;
RE(atf_process_status_init(&s, rawstatus));

View File

@ -5211,12 +5211,6 @@ parse_neon_mov (char **str, int *which_operand)
inst.operands[i].present = 1;
}
}
else if (parse_qfloat_immediate (&ptr, &inst.operands[i].imm) == SUCCESS)
/* Case 2: VMOV<c><q>.<dt> <Qd>, #<float-imm>
Case 3: VMOV<c><q>.<dt> <Dd>, #<float-imm>
Case 10: VMOV.F32 <Sd>, #<imm>
Case 11: VMOV.F64 <Dd>, #<imm> */
inst.operands[i].immisfloat = 1;
else if ((val = arm_typed_reg_parse (&ptr, REG_TYPE_NSDQ, &rtype,
&optype)) != FAIL)
{
@ -5253,9 +5247,15 @@ parse_neon_mov (char **str, int *which_operand)
inst.operands[i].reg = val;
inst.operands[i].isreg = 1;
inst.operands[i++].present = 1;
inst.operands[i].present = 1;
}
}
else if (parse_qfloat_immediate (&ptr, &inst.operands[i].imm) == SUCCESS)
/* Case 2: VMOV<c><q>.<dt> <Qd>, #<float-imm>
Case 3: VMOV<c><q>.<dt> <Dd>, #<float-imm>
Case 10: VMOV.F32 <Sd>, #<imm>
Case 11: VMOV.F64 <Dd>, #<imm> */
inst.operands[i].immisfloat = 1;
else if (parse_big_immediate (&ptr, i) == SUCCESS)
/* Case 2: VMOV<c><q>.<dt> <Qd>, #<imm>
Case 3: VMOV<c><q>.<dt> <Dd>, #<imm> */
@ -5337,7 +5337,7 @@ parse_neon_mov (char **str, int *which_operand)
inst.operands[i].isvec = 1;
inst.operands[i].issingle = 1;
inst.operands[i].vectype = optype;
inst.operands[i++].present = 1;
inst.operands[i].present = 1;
}
}
else

View File

@ -1,3 +1,29 @@
2017-05-10 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (_MAKE_VERSION): 20170510
Merge with NetBSD make, pick up
o main.c: Main_SetObjdir: ensure buf2 is in scope
2017-05-08 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (_MAKE_VERSION): 20170505
see mk/ChangeLog
2017-05-05 Simon J. Gerraty <sjg@bad.crufty.net>
* parse.c: not everyone has stdint.h
2017-05-01 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (_MAKE_VERSION): 20170501
see mk/ChangeLog
2017-04-21 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (_MAKE_VERSION): 20170421
Merge with NetBSD make, pick up
o str.c: Str_Match: fix closure tests for [^] and add unit-test.
2017-04-20 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (_MAKE_VERSION): 20170420

View File

@ -1,7 +1,7 @@
# $Id: Makefile,v 1.88 2017/04/20 14:51:14 sjg Exp $
# $Id: Makefile,v 1.92 2017/05/10 22:29:04 sjg Exp $
# Base version on src date
_MAKE_VERSION= 20170420
_MAKE_VERSION= 20170510
PROG= bmake

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $ */
/* $NetBSD: main.c,v 1.265 2017/05/10 22:26:14 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.265 2017/05/10 22:26:14 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $");
__RCSID("$NetBSD: main.c,v 1.265 2017/05/10 22:26:14 sjg Exp $");
#endif
#endif /* not lint */
#endif
@ -751,6 +751,7 @@ Main_SetObjdir(const char *fmt, ...)
struct stat sb;
char *path;
char buf[MAXPATHLEN + 1];
char buf2[MAXPATHLEN + 1];
Boolean rc = FALSE;
va_list ap;
@ -759,8 +760,6 @@ Main_SetObjdir(const char *fmt, ...)
va_end(ap);
if (path[0] != '/') {
char buf2[MAXPATHLEN + 1];
snprintf(buf2, MAXPATHLEN, "%s/%s", curdir, path);
path = buf2;
}

View File

@ -1,3 +1,37 @@
2017-05-08 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20170505
* meta2deps.py: fix botched indenation.
2017-05-05 Simon J. Gerraty <sjg@bad.crufty.net>
* sys/*.mk: Remove setting of MAKE it is unnecessary and
in many cases wrong (basname rather than full path)
* scripts.mk (SCRIPTSGROUPS): make this more like files.mk and inc.mk
* init.mk: define realbuild to simplify logic in {lib,prog}.mk etc
2017-05-01 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20170501
* doc.mk: fix typo in DOC_INSTALL_OWN
* inc.mk: handle INCGROUPS similar to freebsd
* files.mk: add something for files too
* add staging logic to lib.mk prog.mk etc.
2017-04-24 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20170424
* dirdeps.mk: set NO_DIRDEPS when bootstrapping.
also target of bootstrap-this when sed is needed should be ${_want:T}
2017-04-18 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20170418

View File

@ -9,6 +9,7 @@ cython.mk
dep.mk
doc.mk
dpadd.mk
files.mk
final.mk
host-target.mk
host.libnames.mk

View File

@ -1,4 +1,4 @@
# $Id: dirdeps.mk,v 1.87 2017/03/07 01:49:03 sjg Exp $
# $Id: dirdeps.mk,v 1.88 2017/04/24 20:34:59 sjg Exp $
# Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved.
@ -137,6 +137,14 @@
# built for.
#
.if !target(bootstrap) && (make(bootstrap) || \
make(bootstrap-this) || \
make(bootstrap-recurse) || \
make(bootstrap-empty))
# disable most of below
.MAKE.LEVEL = 1
.endif
# touch this at your peril
_DIRDEP_USE_LEVEL?= 0
.if ${.MAKE.LEVEL} == ${_DIRDEP_USE_LEVEL}
@ -757,7 +765,7 @@ bootstrap-this: .NOTMAIN
@echo Bootstrapping ${RELDIR}/${_want:T} from ${_src:T}; \
echo You need to build ${RELDIR} to correctly populate it.
.if ${_src:T} != ${.MAKE.DEPENDFILE_PREFIX:T}
(cd ${.CURDIR} && sed ${.MAKE.DEPENDFILE_BOOTSTRAP_SED} ${_src} > ${_want})
(cd ${.CURDIR} && sed ${.MAKE.DEPENDFILE_BOOTSTRAP_SED} ${_src} > ${_want:T})
.else
cp ${.CURDIR}/${_src:T} ${_want}
.endif

View File

@ -1,4 +1,4 @@
# $Id: doc.mk,v 1.5 2015/09/08 06:15:31 sjg Exp $
# $Id: doc.mk,v 1.6 2017/05/01 21:24:10 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@ -59,7 +59,7 @@ spell: ${SRCS}
.include <own.mk>
.if !empty(DOCOWN)
DOC_INSTALL_OWN?= -o ${DOCOWN} -g ${DOGGRP}
DOC_INSTALL_OWN?= -o ${DOCOWN} -g ${DOCGRP}
.endif
.endif

83
contrib/bmake/mk/files.mk Normal file
View File

@ -0,0 +1,83 @@
# $Id: files.mk,v 1.6 2017/05/07 02:21:02 sjg Exp $
#
# @(#) Copyright (c) 2017, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
.include <init.mk>
FILES_INSTALL_OWN ?= -o ${SHAREOWN} -g ${SHAREGRP}
FILESMODE ?= ${SHAREMODE}
FILES_COPY ?= -C
FILESGROUPS ?= FILES
FILESGROUPS := ${FILESGROUPS:O:u}
.if !target(buildfiles)
.for group in ${FILESGROUPS}
buildfiles: ${${group}}
.endfor
.endif
buildfiles:
realbuild: buildfiles
# there is no default FILESDIR so
# ignore group if ${group}DIR is not defined
.for group in ${FILESGROUPS}
.if !empty(${group}) && defined(${group}DIR)
.if ${group} != "FILES"
${group}_INSTALL_OWN ?= ${FILES_INSTALL_OWN}
.endif
# incase we are staging
STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
.for file in ${${group}:O:u}
${group}_INSTALL_OWN.${file:T} ?= ${${group}_INSTALL_OWN}
${group}DIR.${file:T} ?= ${${group}DIR}
file_mkdir_list += ${${group}DIR.${file:T}}
.if defined(${group}NAME.${file:T})
STAGE_AS_SETS += ${group}
STAGE_AS_${file} = ${${group}NAME.${file:T}}
stage_as.${group}: ${file}
installfiles: installfiles.${group}.${file:T}
installfiles.${group}.${file:T}: ${file} file_mkdirs
${INSTALL} ${FILES_COPY} ${${group}_INSTALL_OWN.${file:T}} \
-m ${FILESMODE} ${.ALLSRC:Nfile_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${file:T}}
.else
STAGE_SETS += ${group}
stage_files.${group}: ${file}
installfiles.${group}: ${file}
installfiles: installfiles.${group}
.endif
.endfor # file
installfiles.${group}: file_mkdirs
${INSTALL} ${FILES_COPY} ${${group}_INSTALL_OWN} -m ${FILESMODE} \
${.ALLSRC:Nfile_mkdirs:O:u} ${DESTDIR}${${group}DIR}
.endif # !empty
.endfor # group
file_mkdirs:
@for d in ${file_mkdir_list:O:u}; do \
test -d ${DESTDIR}$$d || \
${INSTALL} -d ${FILES_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
done
beforeinstall:
installfiles:
realinstall: installfiles
.ORDER: beforeinstall installfiles

View File

@ -1,4 +1,4 @@
# $Id: final.mk,v 1.6 2016/04/05 15:58:37 sjg Exp $
# $Id: final.mk,v 1.8 2017/05/07 20:30:08 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@ -6,9 +6,17 @@ __${.PARSEFILE}__:
# provide a hook for folk who want to do scary stuff
.-include <${.CURDIR:H}/Makefile-final.inc>
.if !empty(STAGE)
.if ${MK_STAGING} == "yes"
.include <meta.stage.mk>
.elif !empty(STAGE)
.-include <stage.mk>
.endif
.-include <local.final.mk>
.if empty(_SKIP_BUILD)
install: realinstall
.endif
realinstall:
.endif

View File

@ -1,4 +1,4 @@
# $Id: inc.mk,v 1.3 2011/03/11 05:23:05 sjg Exp $
# $Id: inc.mk,v 1.7 2017/05/06 17:29:45 sjg Exp $
#
# @(#) Copyright (c) 2008, Simon J. Gerraty
#
@ -15,8 +15,6 @@
.include <init.mk>
includes: ${INCS}
.if !empty(LIBOWN)
INC_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
.endif
@ -24,12 +22,68 @@ INCMODE ?= 444
INC_COPY ?= -C
INCSDIR ?= ${INCDIR}
realinstall: incinstall
STAGE_INCSDIR?= ${STAGE_OBJTOP}${INCSDIR}
# accommodate folk used to freebsd
INCGROUPS ?= ${INCSGROUPS:UINCS}
INCGROUPS := ${INCGROUPS:O:u}
.if !target(buildincludes)
.for group in ${INCGROUPS}
buildincludes: ${${group}}
.endfor
.endif
buildincludes:
includes: buildincludes
.if !target(incinstall)
incinstall:
.if !empty(INCS)
[ -d ${DESTDIR}${INCSDIR} ] || \
${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}${INCSDIR}
${INSTALL} ${INC_COPY} ${INC_INSTALL_OWN} -m ${INCMODE} ${INCS} ${DESTDIR}${INCSDIR}
.for group in ${INCGROUPS}
.if !empty(${group})
.if ${group} != "INC"
${group}_INSTALL_OWN ?= ${INC_INSTALL_OWN}
${group}DIR ?= ${INCDIR}
.endif
# incase we are staging
STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
.for header in ${${group}:O:u}
${group}_INSTALL_OWN.${header:T} ?= ${${group}_INSTALL_OWN}
${group}DIR.${header:T} ?= ${${group}DIR}
inc_mkdir_list += ${${group}DIR.${header:T}}
.if defined(${group}NAME.${header:T})
STAGE_AS_SETS += ${group}
STAGE_AS_${header} = ${${group}NAME.${header:T}}
stage_as.${group}: ${header}
incinstall: incinstall.${group}.${header:T}
incinstall.${group}.${header:T}: ${header} inc_mkdirs
${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN.${header:T}} -m ${INCMODE} ${.ALLSRC:Ninc_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${header:T}}
.else
STAGE_SETS += ${group}
stage_files.${group}: ${header}
incinstall.${group}: ${header}
incinstall: incinstall.${group}
.endif
.endfor # header
incinstall.${group}: inc_mkdirs
${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN} -m ${INCMODE} \
${.ALLSRC:Ninc_mkdirs:O:u} ${DESTDIR}${${group}DIR}
.endif # !empty
.endfor # group
inc_mkdirs:
@for d in ${inc_mkdir_list:O:u}; do \
test -d ${DESTDIR}$$d || \
${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
done
.endif # !target(incinstall)
beforeinstall:
realinstall: incinstall
.ORDER: beforeinstall incinstall

View File

@ -1,4 +1,4 @@
# $Id: init.mk,v 1.12 2016/04/05 15:58:37 sjg Exp $
# $Id: init.mk,v 1.15 2017/05/07 20:27:54 sjg Exp $
#
# @(#) Copyright (c) 2002, Simon J. Gerraty
#
@ -50,8 +50,20 @@ PROFFLAGS?= -DGPROF -DPROF
_SKIP_BUILD = not building at level 0
.endif
.if !empty(_SKIP_BUILD)
.if !defined(.PARSEDIR)
# no-op is the best we can do if not bmake.
.WAIT:
.endif
# define this once for consistency
.if empty(_SKIP_BUILD)
# beforebuild is a hook for things that must be done early
all: beforebuild .WAIT realbuild
.else
all: .PHONY
.warning ${_SKIP_BUILD}
.endif
beforebuild:
realbuild:
.endif

View File

@ -55,7 +55,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
# $Id: install-mk,v 1.141 2017/04/18 23:53:18 sjg Exp $
# $Id: install-mk,v 1.145 2017/05/09 04:05:32 sjg Exp $
#
# @(#) Copyright (c) 1994 Simon J. Gerraty
#
@ -70,7 +70,7 @@
# sjg@crufty.net
#
MK_VERSION=20170418
MK_VERSION=20170505
OWNER=
GROUP=
MODE=444
@ -176,7 +176,7 @@ $SKIP_MKFILES Do chmod $BINMODE $mk_scripts
[ "$OWNER" ] && $SKIP_MKFILES Do chown $OWNER $mk_files $sys_mk_files
# if this is a BSD system the bsd.*.mk should exist and be used.
if [ -z "$SKIP_BSD_MK" ]; then
for f in dep doc init lib links man nls obj own prog subdir
for f in dep doc files inc init lib links man nls obj own prog subdir
do
b=bsd.$f.mk
[ -s $b ] || Do ln -s $f.mk $b

View File

@ -1,4 +1,4 @@
# $Id: lib.mk,v 1.55 2016/09/23 23:04:51 sjg Exp $
# $Id: lib.mk,v 1.61 2017/05/06 17:30:09 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@ -37,7 +37,7 @@ PICO?= .pico
CFLAGS+= ${COPTS}
# Derrived from NetBSD-1.6
# Originally derrived from NetBSD-1.6
# Set PICFLAGS to cc flags for producing position-independent code,
# if not already set. Includes -DPIC, if required.
@ -375,15 +375,14 @@ _LIBS+=llib-l${LIB}.ln
.include <dpadd.mk>
.endif
.if empty(LIB)
_LIBS=
.endif
.if !defined(_SKIP_BUILD)
all: prebuild .WAIT ${_LIBS}
# a hook for things that must be done early
prebuild:
.if !defined(.PARSEDIR)
# no-op is the best we can do if not bmake.
.WAIT:
.endif
realbuild: ${_LIBS}
.endif
all: _SUBDIRUSE
.for s in ${SRCS:N*.h:M*/*}
@ -509,7 +508,7 @@ LIB_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
.include <links.mk>
.if !target(realinstall)
.if !target(realinstall) && !empty(LIB)
realinstall: libinstall
.endif
.if !target(libinstall)
@ -552,13 +551,19 @@ libinstall:
.endif
.endif
.if ${MK_MAN} != "no"
install: maninstall _SUBDIRUSE
maninstall: afterinstall
.endif
afterinstall: realinstall
libinstall: beforeinstall
realinstall: beforeinstall
.endif
.if defined(FILES) || defined(FILESGROUPS)
.include <files.mk>
.endif
.if ${MK_MAN} != "no"
.include <man.mk>
.endif
@ -591,5 +596,10 @@ realinstall: beforeinstall
.endfor
@touch ${.TARGET}
.if !empty(LIB)
STAGE_LIBDIR?= ${STAGE_OBJTOP}${LIBDIR}
stage_libs: ${_LIBS}
.endif
.include <final.mk>
.endif

View File

@ -37,7 +37,7 @@
"""
RCSid:
$Id: meta2deps.py,v 1.25 2017/04/03 21:04:09 sjg Exp $
$Id: meta2deps.py,v 1.26 2017/05/09 04:04:16 sjg Exp $
Copyright (c) 2011-2013, Juniper Networks, Inc.
All rights reserved.
@ -142,7 +142,7 @@ def sort_unique(list, cmp=None, key=None, reverse=False):
for e in list:
if e == le:
continue
le = e
le = e
nl.append(e)
return nl
@ -534,7 +534,7 @@ def parse_path(self, path, cwd, op=None, w=[]):
# to the src dir, we may need to add dependencies for each
rdir = dir
dir = abspath(dir, cwd, self.last_dir, self.debug, self.debug_out)
rdir = os.path.realpath(dir)
rdir = os.path.realpath(dir)
if rdir == dir:
rdir = None
# now put path back together

View File

@ -1,4 +1,4 @@
# $Id: own.mk,v 1.32 2016/05/18 20:54:29 sjg Exp $
# $Id: own.mk,v 1.35 2017/05/03 18:09:44 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@ -117,6 +117,7 @@ OPTIONS_DEFAULT_DEPENDENT+= \
PICINSTALL/LINKLIB \
PICLIB/PIC \
PROFILE/LINKLIB \
STAGING_PROG/STAGING \
.include <options.mk>
@ -128,7 +129,7 @@ _uid!= id -u
USERGRP!= id -g
.export USERGRP
.endif
.for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE
.for x in BIN CONF DOC INC INFO FILES KMOD LIB MAN NLS SHARE
$xOWN= ${USER}
$xGRP= ${USERGRP}
$x_INSTALL_OWN=
@ -145,6 +146,9 @@ BINMODE?= 555
NONBINMODE?= 444
DIRMODE?= 755
INCLUDEDIR?= ${prefix}/include
INCDIR?= ${INCLUDEDIR}
# Define MANZ to have the man pages compressed (gzip)
#MANZ= 1
@ -184,6 +188,10 @@ KMODGRP?= ${BINGRP}
KMODOWN?= ${BINOWN}
KMODMODE?= ${NONBINMODE}
SHAREGRP?= ${BINGRP}
SHAREOWN?= ${BINOWN}
SHAREMODE?= ${NONBINMODE}
COPY?= -c
STRIP_FLAG?= -s
@ -244,4 +252,19 @@ MK_MAN= no
MK_NLS= no
.endif
# :U incase not using our sys.mk
.if ${MK_META_MODE:Uno} == "yes"
# should all be set by sys.mk if not default
TARGET_SPEC_VARS ?= MACHINE
.if ${TARGET_SPEC_VARS:[#]} > 1
TARGET_SPEC_VARS_REV := ${TARGET_SPEC_VARS:[-1..1]}
.else
TARGET_SPEC_VARS_REV = ${TARGET_SPEC_VARS}
.endif
.if ${MK_STAGING} == "yes"
STAGE_ROOT?= ${OBJROOT}/stage
STAGE_OBJTOP?= ${STAGE_ROOT}/${TARGET_SPEC_VARS_REV:ts/}
.endif
.endif
.endif

View File

@ -1,4 +1,4 @@
# $Id: prog.mk,v 1.28 2017/02/14 21:26:13 sjg Exp $
# $Id: prog.mk,v 1.32 2017/05/06 17:30:09 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@ -75,6 +75,8 @@ ${CXX_SUFFIXES:%=%.o}:
.if defined(PROG)
BINDIR ?= ${prefix}/bin
SRCS?= ${PROG}.c
.for s in ${SRCS:N*.h:N*.sh:M*/*}
${.o .po .lo:L:@o@${s:T:R}$o@}: $s
@ -126,8 +128,9 @@ MAN= ${PROG}.1
.endif # defined(PROG)
.if !defined(_SKIP_BUILD)
all: ${PROG}
realbuild: ${PROG}
.endif
all: _SUBDIRUSE
.if !target(clean)
@ -208,6 +211,10 @@ lint: ${LOBJS}
.NOPATH: ${OBJS}
.endif
.if defined(FILES) || defined(FILESGROUPS)
.include <files.mk>
.endif
.if ${MK_MAN} != "no"
.include <man.mk>
.endif
@ -219,6 +226,20 @@ lint: ${LOBJS}
.include <obj.mk>
.include <dep.mk>
.include <subdir.mk>
.if !empty(PROG) && ${MK_STAGING_PROG} == "yes"
STAGE_BINDIR ?= ${STAGE_OBJTOP}${BINDIR}
STAGE_DIR.prog ?= ${STAGE_BINDIR}
.if ${PROG_NAME:U${PROG}} != ${PROG}
STAGE_AS_SETS += prog
STAGE_AS_${PROG} = ${PROG_NAME}
stage_as.prog: ${PROG}
.else
STAGE_SETS += prog
stage_files.prog: ${PROG}
.endif
.endif
.include <final.mk>
.endif

View File

@ -1,52 +1,91 @@
# $Id: scripts.mk,v 1.2 2006/11/09 01:55:18 sjg Exp $
# $Id: scripts.mk,v 1.3 2017/05/06 17:29:45 sjg Exp $
#
# @(#) Copyright (c) 2006, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
.include <init.mk>
.if defined(SCRIPTS)
SCRIPTSGROUPS ?= SCRIPTS
SCRIPTSGROUPS := ${SCRIPTSGROUPS:O:u}
all: ${SCRIPTS}
.PHONY: scriptsinstall
install: scriptsinstall
.if !target(scriptsinstall)
SCRIPTSDIR?= ${BINDIR}
SCRIPTSOWN?= ${BINOWN}
SCRIPTSGRP?= ${BINGRP}
SCRIPTSMODE?= ${BINMODE}
SCRIPTS_INSTALL_OWN?= -o ${SCRIPTSOWN} -g ${SCRIPTSGRP}
SCRIPTS_COPY ?= -C
# how we get script name from src
SCRIPTSNAME_MOD?=T:R
script_targets= ${SCRIPTS:@s@${DESTDIR}${SCRIPTSDIR_$s:U${SCRIPTSDIR}}/${SCRIPTSNAME_$s:U${s:${SCRIPTSNAME_MOD}}}@}
scriptsinstall:: ${script_targets}
.PRECIOUS: ${script_targets}
.if !defined(UPDATE)
.PHONY: ${script_targets}
.endif
INSTALL_FLAGS?= ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} \
-o ${OWN_${.TARGET:T}:U${SCRIPTSOWN}} \
-g ${GRP_${.TARGET:T}:U${SCRIPTSGRP}} \
-m ${MODE_${.TARGET:T}:U${SCRIPTSMODE}}
__SCRIPTINSTALL_USE: .USE
${INSTALL} ${INSTALL_FLAGS_${.TARGET:T}:U${INSTALL_FLAGS}} \
${.ALLSRC} ${.TARGET}
.for s in ${SCRIPTS}
.if !defined(BUILD) && !make(all) && !make(${s})
${DESTDIR}${SCRIPTSDIR_$s:U${SCRIPTSDIR}}/${SCRIPTSNAME_$s:U${s:${SCRIPTSNAME_MOD}}}: .MADE
.endif
${DESTDIR}${SCRIPTSDIR_$s:U${SCRIPTSDIR}}/${SCRIPTSNAME_$s:U${s:${SCRIPTSNAME_MOD}}}: ${s} __SCRIPTINSTALL_USE
.if !target(buildfiles)
.for group in ${SCRIPTSGROUPS}
buildfiles: ${${group}}
.endfor
.endif
buildfiles:
realbuild: buildfiles
.for group in ${SCRIPTSGROUPS}
.if !empty(${group}) && defined(${group}DIR)
.if ${group} != "SCRIPTS"
${group}_INSTALL_OWN ?= ${SCRIPTS_INSTALL_OWN}
.endif
# incase we are staging
STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
.for script in ${${group}:O:u}
${group}_INSTALL_OWN.${script:T} ?= ${${group}_INSTALL_OWN}
${group}DIR.${script:T} ?= ${${group}DIR_${script:T}:U${${group}DIR}}
script_mkdir_list += ${${group}DIR.${script:T}}
${group}NAME.${script} ?= ${${group}NAME_${script:T}:U${script:${SCRIPTSNAME_MOD}}}
.if ${${group}NAME.${script}:T} != ${script:T}
STAGE_AS_SETS += ${group}
STAGE_AS_${script} = ${${group}NAME.${script:T}}
stage_as.${group}: ${script}
installscripts: installscripts.${group}.${script:T}
installscripts.${group}.${script:T}: ${script} script_mkdirs
${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN.${script:T}} \
-m ${SCRIPTSMODE} ${.ALLSRC:Nscript_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${script:T}}
.else
STAGE_SETS += ${group}
stage_files.${group}: ${script}
installscripts.${group}: ${script}
installscripts: installscripts.${group}
.endif
.if !target(scriptsinstall)
scriptsinstall::
.endif
.endfor # script
installscripts.${group}: script_mkdirs
${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN} -m ${SCRIPTSMODE} \
${.ALLSRC:Nscript_mkdirs:O:u} ${DESTDIR}${${group}DIR}
.endif # !empty
.endfor # group
script_mkdirs:
@for d in ${script_mkdir_list:O:u}; do \
test -d ${DESTDIR}$$d || \
${INSTALL} -d ${SCRIPTS_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
done
beforeinstall:
installscripts:
realinstall: installscripts
.ORDER: beforeinstall installscripts

View File

@ -67,8 +67,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
MAKE= bmake
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c

View File

@ -84,8 +84,6 @@ LINTFLAGS?= -chapbx
LORDER?= lorder
MAKE?= bmake
NM?= nm
PC?= pc

View File

@ -1,4 +1,4 @@
# $Id: Generic.mk,v 1.12 2016/03/22 20:45:14 sjg Exp $
# $Id: Generic.mk,v 1.13 2017/05/05 18:02:16 sjg Exp $
#
# some reasonable defaults
@ -80,8 +80,6 @@ LDFLAGS?=
LINT?= lint
LINTFLAGS?= -chapbxzF
MAKE?= ${.MAKE}
NM?= nm
PC?= pc

View File

@ -1,4 +1,4 @@
# $Id: HP-UX.mk,v 1.10 2016/03/22 20:45:14 sjg Exp $
# $Id: HP-UX.mk,v 1.11 2017/05/05 18:02:16 sjg Exp $
# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
# @(#)sys.mk 5.11 (Berkeley) 3/13/91
@ -101,8 +101,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
MAKE= bmake
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c

View File

@ -70,8 +70,6 @@ LINTFLAGS?= -chapbxzF
LORDER?= lorder
MAKE?= make
NM?= nm
PC?= pc

View File

@ -1,4 +1,4 @@
# $Id: Linux.mk,v 1.8 2016/03/22 20:45:14 sjg Exp $
# $Id: Linux.mk,v 1.9 2017/05/05 18:02:16 sjg Exp $
# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
# @(#)sys.mk 5.11 (Berkeley) 3/13/91
@ -70,8 +70,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
MAKE= bmake
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c

View File

@ -105,8 +105,6 @@ LINTFLAGS?= -chapbxzF
LORDER?= lorder
MAKE?= make
NM?= nm
PC?= pc

View File

@ -1,4 +1,4 @@
# $Id: OSF1.mk,v 1.7 2016/03/22 20:45:15 sjg Exp $
# $Id: OSF1.mk,v 1.8 2017/05/05 18:02:16 sjg Exp $
# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
# @(#)sys.mk 5.11 (Berkeley) 3/13/91
@ -77,8 +77,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
MAKE= bmake
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c

View File

@ -80,8 +80,6 @@ LINTFLAGS?= -chapbxzF
LORDER?= lorder
MAKE?= make
NM?= nm
PC?= pc

View File

@ -1,4 +1,4 @@
# $Id: SunOS.mk,v 1.7 2016/03/22 20:45:15 sjg Exp $
# $Id: SunOS.mk,v 1.8 2017/05/05 18:02:17 sjg Exp $
.if ${.PARSEFILE} == "sys.mk"
.include <host-target.mk>
@ -98,8 +98,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
MAKE= bmake
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c

View File

@ -1,4 +1,4 @@
# $Id: UnixWare.mk,v 1.2 2016/03/22 20:45:15 sjg Exp $
# $Id: UnixWare.mk,v 1.3 2017/05/05 18:02:17 sjg Exp $
# based on "Id: SunOS.5.sys.mk,v 1.6 2003/09/30 16:42:23 sjg Exp "
# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
# @(#)sys.mk 5.11 (Berkeley) 3/13/91
@ -114,8 +114,6 @@ LINTFLAGS?= -pF
LORDER?= lorder
MAKE?= bmake
NM?= nm
PC?= pc # XXX: UDK probably does not have pc

View File

@ -130,7 +130,6 @@ __RCSID("$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $");
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include "make.h"
#include "hash.h"
@ -139,6 +138,10 @@ __RCSID("$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $");
#include "buf.h"
#include "pathnames.h"
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_MMAP
#include <sys/mman.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: str.c,v 1.37 2017/04/11 17:30:13 sjg Exp $ */
/* $NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: str.c,v 1.37 2017/04/11 17:30:13 sjg Exp $";
static char rcsid[] = "$NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90";
#else
__RCSID("$NetBSD: str.c,v 1.37 2017/04/11 17:30:13 sjg Exp $");
__RCSID("$NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $");
#endif
#endif /* not lint */
#endif

View File

@ -81,3 +81,11 @@ GCC_3.5 {
# GNU-specific entry point.
__gnu_unwind_frame
}
%exclude {
_Unwind_Backtrace
}
GCC_4.3.0 {
_Unwind_Backtrace
}

View File

@ -133,4 +133,22 @@ UNWIND_WRAPPER _Unwind_Resume_or_Rethrow 1
UNWIND_WRAPPER _Unwind_ForcedUnwind 3
UNWIND_WRAPPER _Unwind_Backtrace 2
/*
* Originally, we incorrectly export _Unwind_Backtrace symbol
* with GCC_3.3 version, but real GCC libgcc export it as GCC_4.3.0.
* To maintain backward compatibility, export it with both versions where
* GCC_4.3.0 is default one.
*
* The workaround is complicated by next two issues:
* - old GNU ld cannot handle two (or more) symbol versions
* targeting same function.
* - the .weakref crashes clang 4.0
*/
.globl SYM(_Unwind_Backtrace33)
TYPE(_Unwind_Backtrace33)
SYM(_Unwind_Backtrace33):
b _Unwind_Backtrace
.symver SYM(_Unwind_Backtrace33),_Unwind_Backtrace@GCC_3.3
#endif /* ndef __symbian__ */

View File

@ -275,7 +275,7 @@ GCC_4.2.0 {
_Unwind_GetIPInfo
}
%inherit GCC_4.3 GCC_4.2.0
%inherit GCC_4.3.0 GCC_4.2.0
GCC_4.3.0 {
# byte swapping routines
__bswapsi2

View File

@ -10,7 +10,7 @@ ipf_perror(err, string)
if (err == 0)
fprintf(stderr, "%s\n", string);
else
fprintf(stderr, "%s %s\n", string, ipf_strerror(err));
fprintf(stderr, "%s: %s\n", string, ipf_strerror(err));
}
int

View File

@ -59,7 +59,7 @@ printhash_live(hp, fd, name, opts, fields)
printed++;
}
if (last == 0)
ipferror(fd, "walking hash nodes:");
ipferror(fd, "walking hash nodes");
if (printed == 0)
putchar(';');

View File

@ -35,18 +35,47 @@ printhashnode(iph, ipep, copyfunc, opts, fields)
}
printf("\n");
} else if ((opts & OPT_DEBUG) != 0) {
PRINTF("\t%d\tAddress: %s", hv,
inet_ntoa(ipe.ipe_addr.in4));
printmask(ipe.ipe_family, (u_32_t *)&ipe.ipe_mask.in4_addr);
PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref,
ipe.ipe_group);
#ifdef AF_INET6
if (ipe.ipe_family == AF_INET6) {
char buf[INET6_ADDRSTRLEN + 1];
const char *str;
buf[0] = '\0';
str = inet_ntop(AF_INET6, &ipe.ipe_addr.in6,
buf, sizeof(buf) - 1);
if (str == NULL)
str = "???";
PRINTF("\t%d\tAddress: %s", hv, str);
printmask(ipe.ipe_family, (u_32_t *)&ipe.ipe_mask.in4_addr);
PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref,
ipe.ipe_group);
#ifdef USE_QUAD_T
PRINTF("\tHits: %"PRIu64"\tBytes: %"PRIu64"\n",
ipe.ipe_hits, ipe.ipe_bytes);
PRINTF("\tHits: %"PRIu64"\tBytes: %"PRIu64"\n",
ipe.ipe_hits, ipe.ipe_bytes);
#else
PRINTF("\tHits: %lu\tBytes: %lu\n",
ipe.ipe_hits, ipe.ipe_bytes);
#endif
PRINTF("\tHits: %lu\tBytes: %lu\n",
ipe.ipe_hits, ipe.ipe_bytes);
#endif /* USE_QUAD_T */
} else if (ipe.ipe_family == AF_INET) {
#else
if (ipe.ipe_family == AF_INET) {
#endif /* AF_INET6 */
PRINTF("\t%d\tAddress: %s", hv,
inet_ntoa(ipe.ipe_addr.in4));
printmask(ipe.ipe_family, (u_32_t *)&ipe.ipe_mask.in4_addr);
PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref,
ipe.ipe_group);
#ifdef USE_QUAD_T
PRINTF("\tHits: %"PRIu64"\tBytes: %"PRIu64"\n",
ipe.ipe_hits, ipe.ipe_bytes);
#else
PRINTF("\tHits: %lu\tBytes: %lu\n",
ipe.ipe_hits, ipe.ipe_bytes);
#endif /* USE_QUAD_T */
} else {
PRINTF("\tAddress: family: %d\n",
ipe.ipe_family);
}
} else {
putchar(' ');
printip(ipe.ipe_family, (u_32_t *)&ipe.ipe_addr.in4_addr);

View File

@ -33,8 +33,30 @@ printpoolnode(np, opts, fields)
printmask(np->ipn_addr.adf_family,
(u_32_t *)&np->ipn_mask.adf_addr);
} else {
PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
inet_ntoa(np->ipn_addr.adf_addr.in4));
#ifdef AF_INET6
if (np->ipn_addr.adf_family == AF_INET6) {
char buf[INET6_ADDRSTRLEN + 1];
const char *str;
buf[0] = '\0';
str = inet_ntop(AF_INET6, &np->ipn_addr.adf_addr.in6,
buf, sizeof(buf) - 1);
if (str == NULL)
str = "???";
PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
str);
} else if (np->ipn_addr.adf_family == AF_INET) {
#else
if (np->ipn_addr.adf_family == AF_INET) {
#endif
PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
inet_ntoa(np->ipn_addr.adf_addr.in4));
} else {
PRINTF("\tAddress: family: %d\n",
np->ipn_addr.adf_family);
#ifdef AF_INET6
}
#endif
printmask(np->ipn_addr.adf_family,
(u_32_t *)&np->ipn_mask.adf_addr);
#ifdef USE_QUAD_T

View File

@ -1030,45 +1030,80 @@ int
setnodeaddr(int type, int role, void *ptr, char *arg)
{
struct in_addr mask;
sa_family_t family;
char *s;
s = strchr(arg, '/');
if (s == NULL)
mask.s_addr = 0xffffffff;
else if (strchr(s, '.') == NULL) {
if (ntomask(AF_INET, atoi(s + 1), &mask.s_addr) != 0)
return -1;
if (strchr(arg, ':') == NULL) {
family = AF_INET;
s = strchr(arg, '/');
if (s == NULL)
mask.s_addr = 0xffffffff;
else if (strchr(s, '.') == NULL) {
if (ntomask(AF_INET, atoi(s + 1), &mask.s_addr) != 0)
return -1;
} else {
mask.s_addr = inet_addr(s + 1);
}
if (s != NULL)
*s = '\0';
} else {
mask.s_addr = inet_addr(s + 1);
family = AF_INET6;
/* XXX for now we use mask for IPv6 prefix length */
/* XXX mask should be a union with prefix */
/* XXX Currently address handling is sloppy. */
if ((s = strchr(arg, '/')) == NULL)
mask.s_addr = 128;
else
mask.s_addr = atoi(s + 1);
}
if (s != NULL)
*s = '\0';
if (type == IPLT_POOL) {
ip_pool_node_t *node = ptr;
node->ipn_addr.adf_family = family;
#ifdef USE_INET6
if (node->ipn_addr.adf_family == AF_INET)
if (node->ipn_addr.adf_family == AF_INET) {
#endif
node->ipn_addr.adf_len = offsetof(addrfamily_t,
adf_addr) +
sizeof(struct in_addr);
node->ipn_addr.adf_addr.in4.s_addr = inet_addr(arg);
#ifdef USE_INET6
else
} else {
node->ipn_addr.adf_len = offsetof(addrfamily_t,
adf_addr) +
sizeof(struct in6_addr);
inet_pton(AF_INET6, arg,
&node->ipn_addr.adf_addr.in6.s6_addr);
}
#endif
node->ipn_addr.adf_addr.in4.s_addr = inet_addr(arg);
node->ipn_mask.adf_len = node->ipn_addr.adf_len;
node->ipn_mask.adf_addr.in4.s_addr = mask.s_addr;
} else if (type == IPLT_HASH) {
iphtent_t *node = ptr;
node->ipe_addr.in4.s_addr = inet_addr(arg);
node->ipe_mask.in4.s_addr = mask.s_addr;
node->ipe_family = AF_INET;
node->ipe_unit = role;
node->ipe_family = family;
node->ipe_unit = role;
#ifdef USE_INET6
if (node->ipe_family == AF_INET) {
#endif
node->ipe_addr.in4.s_addr = inet_addr(arg);
node->ipe_mask.in4.s_addr = mask.s_addr;
#ifdef USE_INET6
} else {
inet_pton(AF_INET6, arg,
&node->ipe_addr.in6.__u6_addr.__u6_addr32);
node->ipe_mask.in6.__u6_addr.__u6_addr32[0] =
mask.s_addr;
node->ipe_mask.in6.__u6_addr.__u6_addr32[1] =
node->ipe_mask.in6.__u6_addr.__u6_addr32[2] =
node->ipe_mask.in6.__u6_addr.__u6_addr32[3] = 0;
}
#endif
}
return 0;

View File

@ -74,8 +74,8 @@ DEFINE_TEST(test_option_lz4)
free(p);
return;
}
free(p);
failure("--lz4 option is broken: %s", p);
free(p);
assertEqualInt(r, 0);
return;
}

View File

@ -12,7 +12,7 @@
#
AC_PREREQ(2.2)
AC_INIT([libxo], [0.6.3], [phil@juniper.net])
AC_INIT([libxo], [0.7.2], [phil@juniper.net])
AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability])
# Support silent build rules. Requires at least automake-1.11.
@ -20,7 +20,6 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_PROG_CC
AM_PROG_AR
AC_PROG_INSTALL
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_LN_S
@ -135,6 +134,21 @@ if test "$GETTEXT_ENABLE" != "no"; then
AC_MSG_RESULT([$HAVE_GETTEXT])
fi
if test "$HAVE_GETTEXT" != "yes"; then
GETTEXT_PREFIX=/usr/local
AC_MSG_CHECKING([gettext in ${GETTEXT_PREFIX}])
_save_cflags="$CFLAGS"
CFLAGS="$CFLAGS -I${GETTEXT_PREFIX}/include -L${GETTEXT_PREFIX}/lib -Werror -lintl"
AC_LINK_IFELSE([AC_LANG_SOURCE([[#include <libintl.h>]
[int main() {char *cp = dgettext(NULL, "xx"); return 0; }]])],
[HAVE_GETTEXT=yes],
[HAVE_GETTEXT=no])
CFLAGS="$_save_cflags"
AC_MSG_RESULT([$HAVE_GETTEXT])
fi
fi
if test "$HAVE_GETTEXT" = "yes"; then
@ -278,6 +292,13 @@ AC_ARG_ENABLE([debug],
AC_MSG_RESULT([$LIBXO_DEBUG])
AM_CONDITIONAL([LIBXO_DEBUG], [test "$LIBXO_DEBUG" != "no"])
AC_MSG_CHECKING([whether to use int return codes])
AC_ARG_ENABLE([int-return-codes],
[ --enable-int-return-codes Use int return codes (instead of ssize_t)],
[USE_INT_RETURN_CODES=yes; AC_DEFINE([USE_INT_RETURN_CODES], [1], [Use int return codes])],
[USE_INT_RETURN_CODES=no])
AC_MSG_RESULT([$USE_INT_RETURN_CODES])
AC_MSG_CHECKING([whether to build with text-only rendering])
AC_ARG_ENABLE([text-only],
[ --enable-text-only Turn on text-only rendering],

View File

@ -61,9 +61,9 @@ xolint.txt: ${top_srcdir}/xolint/xolint.pl
CLEANFILES = \
xolint.txt \
${INPUT}.xml \
${INPUT}.txt \
${INPUT}.fxml \
${INPUT}.html
${OUTPUT}.txt \
${OUTPUT}.html
else
doc docs:
@${ECHO} "The 'oxtradoc' tool is not installed; see libslax.org"

File diff suppressed because it is too large Load Diff

View File

@ -1070,7 +1070,7 @@ libxo will convert these arguments as needed to either UTF-8 (for XML,
JSON, and HTML styles) or locale-based strings for display in text
style.
xo_emit("Alll strings are utf-8 content {:tag/%ls}",
xo_emit("All strings are utf-8 content {:tag/%ls}",
L"except for wide strings");
"%S" is equivalent to "%ls".
@ -1464,6 +1464,8 @@ styles, flags, or features:
|-------------+-------------------------------------------------------|
| color | Enable colors/effects for display styles (TEXT, HTML) |
| dtrt | Enable "Do The Right Thing" mode |
| flush | Flush after every libxo function call |
| flush-line | Flush after every line (line-buffered) |
| html | Emit HTML output |
| indent=xx | Set the indentation level |
| info | Add info attributes (HTML) |
@ -1479,7 +1481,7 @@ styles, flags, or features:
| pretty | Emit pretty-printed output |
| retain | Force retaining formatting information |
| text | Emit TEXT output |
| underscores | Replace XML-friendly "-"s with JSON friendly "_"s e |
| underscores | Replace XML-friendly "-"s with JSON friendly "_"s |
| units | Add the 'units' (XML) or 'data-units (HTML) attribute |
| warn | Emit warnings when libxo detects bad calls |
| warn-xml | Emit warnings in XML |
@ -1489,6 +1491,29 @@ styles, flags, or features:
The brief options are detailed in ^LIBXO_OPTIONS^.
Most of these option are simple and direct, but some require
additional details:
- "flush-line" performs line buffering, even when the output is not
directed to a TTY device.
- "info" generates additional data for HTML, encoded in attributes
using names that state with "data-".
- "keys" adds a "key" attribute for XML output to indicate that a leaf
is an identifier for the list member.
- "no-humanize"avoids "humanizing" numeric output (see
humanize_number(3) for details).
- "no-locale" instructs libxo to avoid translating output to the
current locale.
- "no-retain" disables the ability of libxo to internally retain
"compiled" information about formatting strings.
- "underscores" can be used with JSON output to change XML-friendly
names with dashes into JSON-friendly name with underscores.
- "warn" allows libxo to emit warnings on stderr when application code
make incorrect calls.
- "warn-xml" causes those warnings to be placed in XML inside the
output.
* The libxo API
This section gives details about the functions in libxo, how to call
@ -1577,6 +1602,16 @@ To use the default handle, pass a NULL handle:
xo_set_style(NULL, XO_STYLE_XML);
*** xo_get_style
To find the current style, use the xo_get_style() function:
xo_style_t xo_get_style(xo_handle_t *xop);
To use the default handle, pass a NULL handle:
style = xo_get_style(NULL);
**** Output Styles (XO_STYLE_*) @styles@
The libxo functions accept a set of output styles:
@ -2883,9 +2918,9 @@ which include the following:
Compiler warnings are a very good thing, but recent compiler version
have added some very pedantic checks. While every attempt is made to
keep libxo code warning-free, warnings are now optional. If you are
doing development work on libxo, it is required that you use
--enable-warnings to keep the code warning free, but most users need
not use this option.
doing development work on libxo, it is required that you
use --enable-warnings to keep the code warning free, but most users
need not use this option.
libxo provides the --enable-text-only option to reduce the footprint
of the library for smaller installations. XML, JSON, and HTML

View File

@ -72,7 +72,10 @@ man3_files = \
man5_files = \
xo_format.5
man_MANS = ${man3_files} ${man5_files}
man7_files = \
xo_options.7
man_MANS = ${man3_files} ${man5_files} ${man7_files}
EXTRA_DIST = \
${man_MANS}
@ -87,3 +90,5 @@ install-data-hook:
cat ../libxo/add.man >> ${DESTDIR}${man3dir}/$$file ; done
for file in ${man5_files}; do \
cat ../libxo/add.man >> ${DESTDIR}${man5dir}/$$file ; done
for file in ${man7_files}; do \
cat ../libxo/add.man >> ${DESTDIR}${man7dir}/$$file ; done

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <stdarg.h>
#include <limits.h>
#include <stdlib.h>
#include <errno.h>
@ -39,7 +40,10 @@
* coward's path, we'll turn it on inside a #if that allows
* others to turn it off where needed. Not ideal, but functional.
*/
#if !defined(NO_PRINTFLIKE) && !defined(__linux__)
#if !defined(NO_PRINTFLIKE)
#if defined(__linux) && !defined(__printflike)
#define __printflike(_x, _y) __attribute__((__format__ (__printf__, _x, _y)))
#endif
#define PRINTFLIKE(_x, _y) __printflike(_x, _y)
#else
#define PRINTFLIKE(_x, _y)
@ -115,7 +119,18 @@ typedef struct xo_info_s {
struct xo_handle_s; /* Opaque structure forward */
typedef struct xo_handle_s xo_handle_t; /* Handle for XO output */
typedef int (*xo_write_func_t)(void *, const char *);
/*
* Early versions of the API used "int" instead of "size_t" for buffer
* sizes. We want to fix this but allow for backwards compatibility
* where needed.
*/
#ifdef USE_INT_RETURN_CODES
typedef int xo_ssize_t; /* Buffer size */
#else /* USE_INT_RETURN_CODES */
typedef ssize_t xo_ssize_t; /* Buffer size */
#endif /* USE_INT_RETURN_CODES */
typedef xo_ssize_t (*xo_write_func_t)(void *, const char *);
typedef void (*xo_close_func_t)(void *);
typedef int (*xo_flush_func_t)(void *);
typedef void *(*xo_realloc_func_t)(void *, size_t);
@ -126,7 +141,7 @@ typedef void (*xo_free_func_t)(void *);
* of the xo handle. The caller should return the number of bytes _needed_
* to fit the data, even if this exceeds 'len'.
*/
typedef int (*xo_formatter_t)(xo_handle_t *, char *, int,
typedef xo_ssize_t (*xo_formatter_t)(xo_handle_t *, char *, xo_ssize_t,
const char *, va_list);
typedef void (*xo_checkpointer_t)(xo_handle_t *, va_list, int);
@ -182,23 +197,23 @@ xo_set_formatter (xo_handle_t *xop, xo_formatter_t func, xo_checkpointer_t);
void
xo_set_depth (xo_handle_t *xop, int depth);
int
xo_ssize_t
xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap);
int
xo_ssize_t
xo_emit_h (xo_handle_t *xop, const char *fmt, ...);
int
xo_ssize_t
xo_emit (const char *fmt, ...);
int
xo_ssize_t
xo_emit_hvf (xo_handle_t *xop, xo_emit_flags_t flags,
const char *fmt, va_list vap);
int
xo_ssize_t
xo_emit_hf (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...);
int
xo_ssize_t
xo_emit_f (xo_emit_flags_t flags, const char *fmt, ...);
PRINTFLIKE(2, 0)
@ -260,97 +275,97 @@ xo_emit_fp (xo_emit_flags_t flags, const char *fmt, ...)
return rc;
}
int
xo_ssize_t
xo_open_container_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_container (const char *name);
int
xo_ssize_t
xo_open_container_hd (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_container_d (const char *name);
int
xo_ssize_t
xo_close_container_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_close_container (const char *name);
int
xo_ssize_t
xo_close_container_hd (xo_handle_t *xop);
int
xo_ssize_t
xo_close_container_d (void);
int
xo_ssize_t
xo_open_list_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_list (const char *name);
int
xo_ssize_t
xo_open_list_hd (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_list_d (const char *name);
int
xo_ssize_t
xo_close_list_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_close_list (const char *name);
int
xo_ssize_t
xo_close_list_hd (xo_handle_t *xop);
int
xo_ssize_t
xo_close_list_d (void);
int
xo_ssize_t
xo_open_instance_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_instance (const char *name);
int
xo_ssize_t
xo_open_instance_hd (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_instance_d (const char *name);
int
xo_ssize_t
xo_close_instance_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_close_instance (const char *name);
int
xo_ssize_t
xo_close_instance_hd (xo_handle_t *xop);
int
xo_ssize_t
xo_close_instance_d (void);
int
xo_ssize_t
xo_open_marker_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_marker (const char *name);
int
xo_ssize_t
xo_close_marker_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_close_marker (const char *name);
int
xo_ssize_t
xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...);
int
xo_ssize_t
xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap);
int
xo_ssize_t
xo_attr (const char *name, const char *fmt, ...);
void
@ -362,16 +377,16 @@ xo_error_h (xo_handle_t *xop, const char *fmt, ...);
void
xo_error (const char *fmt, ...);
int
xo_ssize_t
xo_flush_h (xo_handle_t *xop);
int
xo_ssize_t
xo_flush (void);
int
xo_ssize_t
xo_finish_h (xo_handle_t *xop);
int
xo_ssize_t
xo_finish (void);
void
@ -644,16 +659,16 @@ char *
xo_simplify_format (xo_handle_t *xop, const char *fmt, int with_numbers,
xo_simplify_field_func_t field_cb);
int
xo_ssize_t
xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents,
const char *fmt, const char *efmt,
va_list vap);
int
xo_ssize_t
xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...);
int
xo_ssize_t
xo_emit_field (const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...);

View File

@ -28,7 +28,7 @@
typedef struct xo_buffer_s {
char *xb_bufp; /* Buffer memory */
char *xb_curp; /* Current insertion point */
unsigned xb_size; /* Size of buffer */
ssize_t xb_size; /* Size of buffer */
} xo_buffer_t;
/*
@ -111,10 +111,10 @@ xo_buf_cleanup (xo_buffer_t *xbp)
* return 0 to tell the caller they are in trouble.
*/
static inline int
xo_buf_has_room (xo_buffer_t *xbp, int len)
xo_buf_has_room (xo_buffer_t *xbp, ssize_t len)
{
if (xbp->xb_curp + len >= xbp->xb_bufp + xbp->xb_size) {
int sz = xbp->xb_size + XO_BUFSIZ;
ssize_t sz = xbp->xb_size + XO_BUFSIZ;
char *bp = xo_realloc(xbp->xb_bufp, sz);
if (bp == NULL)
return 0;
@ -131,7 +131,7 @@ xo_buf_has_room (xo_buffer_t *xbp, int len)
* Append the given string to the given buffer
*/
static inline void
xo_buf_append (xo_buffer_t *xbp, const char *str, int len)
xo_buf_append (xo_buffer_t *xbp, const char *str, ssize_t len)
{
if (!xo_buf_has_room(xbp, len))
return;
@ -146,7 +146,7 @@ xo_buf_append (xo_buffer_t *xbp, const char *str, int len)
static inline void
xo_buf_append_str (xo_buffer_t *xbp, const char *str)
{
int len = strlen(str);
ssize_t len = strlen(str);
if (!xo_buf_has_room(xbp, len))
return;

View File

@ -139,7 +139,7 @@ xo_encoder_list_add (const char *name)
xo_encoder_node_t *xep = xo_realloc(NULL, sizeof(*xep));
if (xep) {
int len = strlen(name) + 1;
ssize_t len = strlen(name) + 1;
xep->xe_name = xo_realloc(NULL, len);
if (xep->xe_name == NULL) {
xo_free(xep);
@ -241,7 +241,7 @@ xo_encoder_discover (const char *name)
bzero(&xei, sizeof(xei));
xei.xei_version = XO_ENCODER_VERSION;
int rc = func(&xei);
ssize_t rc = func(&xei);
if (rc == 0 && xei.xei_handler) {
xep = xo_encoder_list_add(name);
if (xep) {

View File

@ -630,7 +630,7 @@ The format string has the form:
\(aq%\(aq format\-modifier * format\-character
.Ed
.Pp
The format\- modifier can be:
The format\-modifier can be:
.Bl -bullet
.It
a \(aq#\(aq character, indicating the output value should be prefixed with

View File

@ -0,0 +1,147 @@
.\" #
.\" # Copyright (c) 2014-2017, Juniper Networks, Inc.
.\" # All rights reserved.
.\" # This SOFTWARE is licensed under the LICENSE provided in the
.\" # ../Copyright file. By downloading, installing, copying, or
.\" # using the SOFTWARE, you agree to be bound by the terms of that
.\" # LICENSE.
.\" # Phil Shafer, July 2014
.\"
.Dd May 11, 2017
.Dt LIBXO 3
.Os
.Sh NAME
.Nm xo_options
.Nd common options for libxo\-based commands
.Sh DESCRIPTION
.Pp
.Nm libxo
allows the rendering of data into
various output styles, including
.Em text ,
.Em XML ,
.Em JSON ,
and
.Em HTML .
.Nm libxo
uses command line options to trigger rendering behavior.
Options are recognised in three forms:
.Bl -bullet
.It
\-\-libxo <options>
.It
\-\-libxo=<options>
.It
\-\-libxo:<brief\-options>
.El
.Pp
The first two forms accept a comma\-separated set of words, detailed
below, while the third form accepts a set of letters, also below.
The triggered functionality is identical.
.Bl -column "Token2341234"
.It Sy "Option " "Action"
.It "color " "Enable colors/effects for display styles (TEXT, HTML)"
.It "flush " "Flush after each emit call"
.It "flush\-line " "Flush each line of output"
.It "html " "Emit HTML output"
.It "indent=xx " "Set the indentation level"
.It "info " "Add info attributes (HTML)"
.It "json " "Emit JSON output"
.It "keys " "Emit the key attribute for keys (XML)"
.It "log\-gettext" "Log (via stderr) each gettext(3) string lookup"
.It "log\-syslog " "Log (via stderr) each syslog message (via xo_syslog)"
.It "no\-humanize" "Ignore the {h:} modifier (TEXT, HTML)"
.It "no\-locale " "Do not initialize the locale setting"
.It "no\-retain " "Prevent retaining formatting information"
.It "pretty " "Emit pretty\-printed output"
.It "retain " "Force retaining formatting information"
.It "text " "Emit TEXT output"
.It "underscores" "Replace XML\-friendly \"\-\"s with JSON friendly \"_\"s"
.It "units " "Add the 'units' (XML) or 'data\-units (HTML) attribute"
.It "warn " "Emit warnings when libxo detects bad calls"
.It "warn\-xml " "Emit warnings in XML"
.It "xml " "Emit XML output"
.It "xpath " "Add XPath expressions (HTML)"
.El
.Pp
The brief options are a set of single\-letter aliases for the longer
terms, used as a single string:
.Bl -column "Value" "Equivalent Token"
.It Sy "Value" "Equivalent Token"
.It "c
.It "f " "flush"
.It "F " "flush\-line"
.It "H " "html"
.It "I " "info"
.It "i<num>" "indent=<num>"
.It "J " "json"
.It "k " "keys"
.It "n " "no\-humanize"
.It "P " "pretty"
.It "T " "text"
.It "U " "units"
.It "u " "underscore
.It "W " "warn"
.It "X " "xml"
.It "x " "xpath"
.El
.Pp
Most of these option are simple and direct, but some require
additional details:
.Pp
.Fa "flush\-line"
performs line buffering, even when the output is not directed to
a TTY device.
.Pp
.Fa info
generates additional data for HTML, encoded in attributes using
names that state with "data\-".
.Pp
.Fa keys
adds a "key" attribute for XML output to indicate that a leaf is
an identifier for the list member.
.Pp
.Fa no\-humanize
avoids "humanizing" numeric output (see
.Xr humanize_number 3
for details).
.Pp
.Fa no\-locale
instructs
.Nm libxo
to avoid translating output to the current locale.
.Pp
.Fa no\-retain
disables the ability of
.Nm libxo
to internally retain "compiled" information about formatting strings.
.Pp
.Fa underscores
can be used with
.Em JSON
output to change
.Em XML \-friendly
names with dashes into
.Em JSON \-friendly
name with underscores.
.Pp
.Fa warn
allows
.Nm libxo
to emit warnings on stderr when application code make incorrect calls.
.Fa warn\-xml causes those warnings to be placed in
.Em XML
inside the output.
.Sh EXAMPLES
The following are three example invocations of
.Xr ps 1 :
.Bd -literal
ps \-\-libxo json,pretty,warn \-ux
ps \-\-libxo=xml \-lg
ps \-\-libxo:Hxc 1
.Ed
.Sh SEE ALSO
.Xr libxo 3 ,
.Xr xo_format 5

View File

@ -53,6 +53,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/time.h>
@ -94,11 +95,13 @@
#define XO_DEFAULT_EID 32473 /* Fallback to the "example" number */
#endif
#ifndef HOST_NAME_MAX
#ifdef _SC_HOST_NAME_MAX
#define HOST_NAME_MAX _SC_HOST_NAME_MAX
#else
#define HOST_NAME_MAX 255
#endif /* _SC_HOST_NAME_MAX */
#endif /* HOST_NAME_MAX */
#ifndef UNUSED
#define UNUSED __attribute__ ((__unused__))
@ -425,12 +428,13 @@ xo_set_syslog_handler (xo_syslog_open_t open_func,
xo_syslog_close = close_func;
}
static size_t
xo_snprintf (char *out, size_t outsize, const char *fmt, ...)
static ssize_t
xo_snprintf (char *out, ssize_t outsize, const char *fmt, ...)
{
int status;
size_t retval = 0;
ssize_t status;
ssize_t retval = 0;
va_list ap;
if (out && outsize) {
va_start(ap, fmt);
status = vsnprintf(out, outsize, fmt, ap);
@ -443,10 +447,11 @@ xo_snprintf (char *out, size_t outsize, const char *fmt, ...)
}
va_end(ap);
}
return retval;
}
static int
static xo_ssize_t
xo_syslog_handle_write (void *opaque, const char *data)
{
xo_buffer_t *xbp = opaque;

View File

@ -1,5 +1,7 @@
op create: [] []
op open_container: [top] []
op content: [kve_start] [0xdeadbeef]
op content: [kve_end] [0xcabb1e]
op string: [host] [my-box]
op string: [domain] [example.com]
op string: [host] [my-box]

View File

@ -1,2 +1,2 @@
{"top": {"host":"my-box","domain":"example.com","host":"my-box","domain":"example.com","label":"value","max-chaos":"very","min-chaos":42,"some-chaos":"[42]","host":"my-box","domain":"example.com", "data": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17,"in-stock":14,"on-order":2}]}, "data2": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412.0,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85.0,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123.0,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17.0,"in-stock":14,"on-order":2}]}, "data3": {"item": [{"sku":"GRO-000-533","name":"fish","sold":1321.0,"in-stock":45,"on-order":1}]}, "data4": {"item": ["gum","rope","ladder","bolt","water"]},"cost":425,"cost":455,"mode":"mode","mode_octal":"octal","links":"links","user":"user","group":"group","mode":"/some/file","mode_octal":640,"links":1,"user":"user","group":"group"}
{"top": {"kve_start":"0xdeadbeef","kve_end":"0xcabb1e","host":"my-box","domain":"example.com","host":"my-box","domain":"example.com","label":"value","max-chaos":"very","min-chaos":42,"some-chaos":"[42]","host":"my-box","domain":"example.com", "data": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17,"in-stock":14,"on-order":2}]}, "data2": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412.0,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85.0,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123.0,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17.0,"in-stock":14,"on-order":2}]}, "data3": {"item": [{"sku":"GRO-000-533","name":"fish","sold":1321.0,"in-stock":45,"on-order":1}]}, "data4": {"item": ["gum","rope","ladder","bolt","water"]},"cost":425,"cost":455,"mode":"mode","mode_octal":"octal","links":"links","user":"user","group":"group","mode":"/some/file","mode_octal":640,"links":1,"user":"user","group":"group"}
}

View File

@ -1,5 +1,7 @@
{
"top": {
"kve_start": "0xdeadbeef",
"kve_end": "0xcabb1e",
"host": "my-box",
"domain": "example.com",
"host": "my-box",

View File

@ -1 +1 @@
<top><host>my-box</host><domain>example.com</domain><host>my-box</host><domain>example.com</domain><label>value</label><max-chaos>very</max-chaos><min-chaos>42</min-chaos><some-chaos>[42]</some-chaos><host>my-box</host><domain>example.com</domain><data test="value"><item test2="value2"><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data2><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data2><data3><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data3><data4><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data4><cost>425</cost><cost>455</cost><mode>mode</mode><mode_octal>octal</mode_octal><links>links</links><user>user</user><group>group</group><mode>/some/file</mode><mode_octal>640</mode_octal><links>1</links><user>user</user><group>group</group></top>
<top><kve_start>0xdeadbeef</kve_start><kve_end>0xcabb1e</kve_end><host>my-box</host><domain>example.com</domain><host>my-box</host><domain>example.com</domain><label>value</label><max-chaos>very</max-chaos><min-chaos>42</min-chaos><some-chaos>[42]</some-chaos><host>my-box</host><domain>example.com</domain><data test="value"><item test2="value2"><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data2><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data2><data3><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data3><data4><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data4><cost>425</cost><cost>455</cost><mode>mode</mode><mode_octal>octal</mode_octal><links>links</links><user>user</user><group>group</group><mode>/some/file</mode><mode_octal>640</mode_octal><links>1</links><user>user</user><group>group</group></top>

View File

@ -1,4 +1,6 @@
<top>
<kve_start>0xdeadbeef</kve_start>
<kve_end>0xcabb1e</kve_end>
<host>my-box</host>
<domain>example.com</domain>
<host>my-box</host>

View File

@ -1 +1 @@
<top __version="3.1.4"><data test="value"><data test2="value2">bold</data><data>bold-ul</data><data>triple</data><data>inv-ul</data><data>underline</data><data>plain</data><item><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data><data><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data><cost>425</cost><cost>455</cost></top>
<top version="3.1.4"><data test="value"><data test2="value2">bold</data><data>bold-ul</data><data>triple</data><data>inv-ul</data><data>underline</data><data>plain</data><item><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data><data><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data><cost>425</cost><cost>455</cost></top>

View File

@ -1,4 +1,4 @@
<top __version="3.1.4">
<top version="3.1.4">
<data test="value">
<data test2="value2">bold</data>
<data>bold-ul</data>

View File

@ -14,4 +14,4 @@
{{test-program: }}
{{An application 1011 log entry}}
<top __version="3.1.4"></top>
<top version="3.1.4"></top>

View File

@ -14,5 +14,5 @@
{{test-program: }}
{{An application 1011 log entry}}
<top __version="3.1.4">
<top version="3.1.4">
</top>

View File

@ -9,6 +9,7 @@
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
@ -79,6 +80,9 @@ main (int argc, char **argv)
xo_open_container_h(NULL, "top");
xo_emit("{e:kve_start/%#jx}", (uintmax_t) 0xdeadbeef);
xo_emit("{e:kve_end/%#jx}", (uintmax_t) 0xcabb1e);
xo_emit("testing argument modifier {a:}.{a:}...\n",
"host", "my-box", "domain", "example.com");

View File

@ -1,2 +1,2 @@
{"top": {"adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay","adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay", "bytes": [0,1,2,3,4],"total":1234,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"marzlevanes":3,"version":"1.2.3","date":"Tue Jun 23 18:47:09 UTC 2015", "__warning": {"program":"gt_01.test","message":"Nableuay otay ectulatobjay orwardfay elocipingvay","verb":ectulatobjay,"error":"Ermissionpay eniedday"}, "__warning": {"program":"gt_01.test","message":"automaticyay ynchronizationsay ofyay ardinalyay ammetersgray ailedfay","style":automaticyay,"type":"ardinalyay","target":"ammetersgray","error":"Ermissionpay eniedday"},"marzlevanes":6,"windings":"otuslay-oyay-eltayay"}
{"top": {"adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay","adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay", "bytes": [0,1,2,3,4],"total":1234,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"marzlevanes":3,"version":"1.2.3","date":"Tue Jun 23 18:47:09 UTC 2015", "__warning": {"program":"gt_01.test","message":"Nableuay otay ectulatobjay orwardfay elocipingvay","verb":ectulatobjay,"error":"Ermissionpay eniedday"}, "__warning": {"program":"gt_01.test","message":"automaticyay ynchronizationsay ofyay ardinalyay ammetersgray ailedfay","style":"automaticyay","type":"ardinalyay","target":"ammetersgray","error":"Ermissionpay eniedday"},"marzlevanes":6,"windings":"otuslay-oyay-eltayay"}
}

View File

@ -42,7 +42,7 @@
"__warning": {
"program": "gt_01.test",
"message": "automaticyay ynchronizationsay ofyay ardinalyay ammetersgray ailedfay",
"style": automaticyay,
"style": "automaticyay",
"type": "ardinalyay",
"target": "ammetersgray",
"error": "Ermissionpay eniedday"

View File

@ -90,8 +90,8 @@ checkpoint (xo_handle_t *xop UNUSED, va_list vap UNUSED, int restore)
* with our command line arguments to build strings. This involves faking
* some printf-style logic.
*/
static int
formatter (xo_handle_t *xop, char *buf, int bufsiz,
static xo_ssize_t
formatter (xo_handle_t *xop, char *buf, xo_ssize_t bufsiz,
const char *fmt, va_list vap UNUSED)
{
int lflag UNUSED = 0; /* Parse long flag, though currently ignored */

View File

@ -34,6 +34,9 @@ __RCSID("$NetBSD: t_realpath.c,v 1.2 2012/03/27 07:54:58 njoly Exp $");
#include <sys/param.h>
#include <atf-c.h>
#ifdef __FreeBSD__
#include <errno.h>
#endif
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@ -122,8 +125,15 @@ ATF_TC_BODY(realpath_symlink, tc)
char resb[MAXPATHLEN] = { 0 };
int fd;
#ifdef __FreeBSD__
ATF_REQUIRE_MSG(getcwd(path, sizeof(path)) != NULL,
"getcwd(path) failed: %s", strerror(errno));
ATF_REQUIRE_MSG(getcwd(slnk, sizeof(slnk)) != NULL,
"getcwd(slnk) failed: %s", strerror(errno));
#else
(void)getcwd(path, sizeof(path));
(void)getcwd(slnk, sizeof(slnk));
#endif
(void)strlcat(path, "/realpath", sizeof(path));
(void)strlcat(slnk, "/symbolic", sizeof(slnk));

View File

@ -386,12 +386,14 @@ read_body()
{
prog="$(atf_get_srcdir)/h_read"
h_pass "$prog 1024" "echo foo |"
# Begin FreeBSD
if true; then
h_fail "$prog 1027" "echo bar |"
MAX_PATH=$(getconf _XOPEN_PATH_MAX) || atf_fail "getconf failed"
h_pass "$prog $MAX_PATH" "echo foo |"
h_fail "$prog $(( $MAX_PATH + 3 ))" "echo bar |"
else
# End FreeBSD
h_pass "$prog 1024" "echo foo |"
h_fail "$prog 1025" "echo bar |"
# Begin FreeBSD
fi

View File

@ -31,6 +31,10 @@
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_wait.c,v 1.8 2017/01/13 19:28:55 christos Exp $");
#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
#include <sys/wait.h>
#include <sys/resource.h>
@ -147,6 +151,14 @@ ATF_TC_BODY(wait6_coredumped, tc)
pid_t pid;
static const struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
#ifdef __FreeBSD__
int coredump_enabled;
size_t ce_len = sizeof(coredump_enabled);
if (sysctlbyname("kern.coredump", &coredump_enabled, &ce_len, NULL,
0) == 0 && !coredump_enabled)
atf_tc_skip("Coredumps disabled");
#endif
switch (pid = fork()) {
case 0:
ATF_REQUIRE(setrlimit(RLIMIT_CORE, &rl) == 0);

View File

@ -399,11 +399,6 @@ wflag_emptypat_head()
}
wflag_emptypat_body()
{
grep_type
if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then
atf_expect_fail "this test does not pass with GNU grep in base"
fi
printf "" > test1
printf "\n" > test2
printf "qaz" > test3
@ -522,6 +517,63 @@ grep_nomatch_flags_body()
atf_check -o empty grep -q -A 1 -e "B" test1
atf_check -o empty grep -q -C 1 -e "B" test1
}
atf_test_case badcontext
badcontext_head()
{
atf_set "descr" "Check for handling of invalid context arguments"
}
badcontext_body()
{
printf "A\nB\nC\n" > test1
atf_check -s not-exit:0 -e ignore grep -A "-1" "B" test1
atf_check -s not-exit:0 -e ignore grep -B "-1" "B" test1
atf_check -s not-exit:0 -e ignore grep -C "-1" "B" test1
atf_check -s not-exit:0 -e ignore grep -A "B" "B" test1
atf_check -s not-exit:0 -e ignore grep -B "B" "B" test1
atf_check -s not-exit:0 -e ignore grep -C "B" "B" test1
}
atf_test_case binary_flags
binary_flags_head()
{
atf_set "descr" "Check output for binary flags (-a, -I, -U, --binary-files)"
}
binary_flags_body()
{
printf "A\000B\000C" > test1
printf "A\n\000B\n\000C" > test2
binmatchtext="Binary file test1 matches\n"
# Binaries not treated as text (default, -U)
atf_check -o inline:"${binmatchtext}" grep 'B' test1
atf_check -o inline:"${binmatchtext}" grep 'B' -C 1 test1
atf_check -o inline:"${binmatchtext}" grep -U 'B' test1
atf_check -o inline:"${binmatchtext}" grep -U 'B' -C 1 test1
# Binary, -a, no newlines
atf_check -o inline:"A\000B\000C\n" grep -a 'B' test1
atf_check -o inline:"A\000B\000C\n" grep -a 'B' -C 1 test1
# Binary, -a, newlines
atf_check -o inline:"\000B\n" grep -a 'B' test2
atf_check -o inline:"A\n\000B\n\000C\n" grep -a 'B' -C 1 test2
# Binary files ignored
atf_check -s exit:1 grep -I 'B' test2
# --binary-files equivalence
atf_check -o inline:"${binmatchtext}" grep --binary-files=binary 'B' test1
atf_check -o inline:"A\000B\000C\n" grep --binary-files=text 'B' test1
atf_check -s exit:1 grep --binary-files=without-match 'B' test2
}
# End FreeBSD
atf_init_test_cases()
@ -556,5 +608,7 @@ atf_init_test_cases()
atf_add_test_case egrep_sanity
atf_add_test_case grep_sanity
atf_add_test_case grep_nomatch_flags
atf_add_test_case binary_flags
atf_add_test_case badcontext
# End FreeBSD
}

View File

@ -799,7 +799,8 @@ sshpam_query(void *ctx, char **name, char **info,
free(msg);
return (0);
}
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
BLACKLIST_NOTIFY(BLACKLIST_BAD_USER,
sshpam_authctxt->user);
error("PAM: %s for %s%.100s from %.100s", msg,
sshpam_authctxt->valid ? "" : "illegal user ",
sshpam_authctxt->user,

View File

@ -311,7 +311,7 @@ auth_log(Authctxt *authctxt, int authenticated, int partial,
else {
authmsg = authenticated ? "Accepted" : "Failed";
if (authenticated)
BLACKLIST_NOTIFY(BLACKLIST_AUTH_OK);
BLACKLIST_NOTIFY(BLACKLIST_AUTH_OK, "ssh");
}
authlog("%s %s%s%s for %s%.100s from %.200s port %d ssh2%s%s",
@ -664,7 +664,7 @@ getpwnamallow(const char *user)
}
#endif
if (pw == NULL) {
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
BLACKLIST_NOTIFY(BLACKLIST_BAD_USER, user);
logit("Invalid user %.100s from %.100s port %d",
user, ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));
#ifdef CUSTOM_FAILED_LOGIN

View File

@ -338,7 +338,7 @@ do_authloop(Authctxt *authctxt)
char *msg;
size_t len;
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
error("Access denied for user %s by PAM account "
"configuration", authctxt->user);
len = buffer_len(&loginmsg);
@ -364,6 +364,7 @@ do_authloop(Authctxt *authctxt)
if (authenticated)
return;
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
if (++authctxt->failures >= options.max_authtries) {
#ifdef SSH_AUDIT_EVENTS
PRIVSEP(audit_event(SSH_LOGIN_EXCEED_MAXTRIES));
@ -406,7 +407,7 @@ do_authentication(Authctxt *authctxt)
else {
debug("do_authentication: invalid user %s", user);
authctxt->pw = fakepw();
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
BLACKLIST_NOTIFY(BLACKLIST_BAD_USER, user);
}
/* Configuration may have changed as a result of Match */

View File

@ -245,7 +245,6 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
} else {
logit("input_userauth_request: invalid user %s", user);
authctxt->pw = fakepw();
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
#ifdef SSH_AUDIT_EVENTS
PRIVSEP(audit_event(SSH_INVALID_USER));
#endif
@ -386,8 +385,10 @@ userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
/* Allow initial try of "none" auth without failure penalty */
if (!partial && !authctxt->server_caused_failure &&
(authctxt->attempt > 1 || strcmp(method, "none") != 0))
(authctxt->attempt > 1 || strcmp(method, "none") != 0)) {
authctxt->failures++;
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
}
if (authctxt->failures >= options.max_authtries) {
#ifdef SSH_AUDIT_EVENTS
PRIVSEP(audit_event(SSH_LOGIN_EXCEED_MAXTRIES));

View File

@ -46,8 +46,8 @@
#include "log.h"
#include "misc.h"
#include "servconf.h"
#include "blacklist_client.h"
#include <blacklist.h>
#include "blacklist_client.h"
static struct blacklist *blstate = NULL;
@ -88,10 +88,10 @@ blacklist_init(void)
}
void
blacklist_notify(int action)
blacklist_notify(int action, const char *msg)
{
if (blstate != NULL && packet_connection_is_on_socket())
(void)blacklist_r(blstate, action,
packet_get_connection_in(), "ssh");
packet_get_connection_in(), msg);
}

View File

@ -34,22 +34,26 @@
#ifndef BLACKLIST_CLIENT_H
#define BLACKLIST_CLIENT_H
#ifndef BLACKLIST_API_ENUM
enum {
BLACKLIST_AUTH_OK = 0,
BLACKLIST_AUTH_FAIL
BLACKLIST_AUTH_FAIL,
BLACKLIST_ABUSIVE_BEHAVIOR,
BLACKLIST_BAD_USER
};
#endif
#ifdef USE_BLACKLIST
void blacklist_init(void);
void blacklist_notify(int);
void blacklist_notify(int, const char *);
#define BLACKLIST_INIT() blacklist_init()
#define BLACKLIST_NOTIFY(x) blacklist_notify(x)
#define BLACKLIST_NOTIFY(x,msg) blacklist_notify(x,msg)
#else
#define BLACKLIST_INIT()
#define BLACKLIST_NOTIFY(x)
#define BLACKLIST_NOTIFY(x,msg)
#endif

View File

@ -2104,7 +2104,7 @@ sshpkt_fatal(struct ssh *ssh, const char *tag, int r)
case SSH_ERR_NO_KEX_ALG_MATCH:
case SSH_ERR_NO_HOSTKEY_ALG_MATCH:
if (ssh && ssh->kex && ssh->kex->failed_choice) {
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
logdie("Unable to negotiate with %.200s port %d: %s. "
"Their offer: %s", ssh_remote_ipaddr(ssh),
ssh_remote_port(ssh), ssh_err(r),

View File

@ -371,7 +371,7 @@ grace_alarm_handler(int sig)
kill(0, SIGTERM);
}
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
/* Log error and exit. */
sigdie("Timeout before authentication for %s port %d",

View File

@ -8,7 +8,8 @@ FILESGROUPS= FILES
# No need as it is empty and just causes rebuilds since this file does so much.
UPDATE_DEPENDFILE= no
SUBDIR= \
newsyslog.conf.d
newsyslog.conf.d \
syslog.d
.if ${MK_SENDMAIL} != "no"
SUBDIR+=sendmail

View File

@ -650,6 +650,8 @@
..
printf
..
procstat
..
sdiff
..
sed

View File

@ -18,7 +18,6 @@
#
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/all.log 600 7 * @T00 J
/var/log/amd.log 644 7 1000 * J
/var/log/auth.log 600 7 1000 @0101T JC
/var/log/console.log 600 5 1000 * J
/var/log/cron 600 3 1000 * JC
@ -26,18 +25,13 @@
/var/log/debug.log 600 7 1000 * JC
/var/log/init.log 644 3 1000 * J
/var/log/kerberos.log 600 7 1000 * J
/var/log/lpd-errs 644 7 1000 * JC
/var/log/maillog 640 7 * @T00 JC
/var/log/messages 644 5 1000 @0101T JC
/var/log/monthly.log 640 12 * $M1D0 JN
/var/log/pflog 600 3 1000 * JB /var/run/pflogd.pid
/var/log/ppp.log root:network 640 3 1000 * JC
/var/log/devd.log 644 3 1000 * JC
/var/log/security 600 10 1000 * JC
/var/log/sendmail.st 640 10 * 168 BN
/var/log/utx.log 644 3 * @01T05 B
/var/log/weekly.log 640 5 * $W6D0 JN
/var/log/xferlog 600 7 1000 * JC
<include> /etc/newsyslog.conf.d/*
<include> /usr/local/etc/newsyslog.conf.d/*

View File

@ -6,8 +6,32 @@ BINDIR= /etc/newsyslog.conf.d
FILES=
.if ${MK_AMD} != "no"
FILES+= amd.conf
.endif
.if ${MK_FTP} != "no"
FILES+= ftp.conf
.endif
.if ${MK_LPR} != "no"
FILES+= lpr.conf
.endif
.if ${MK_OFED} != "no"
FILES+= opensm.conf
.endif
.if ${MK_PF} != "no"
FILES+= pf.conf
.endif
.if ${MK_PPP} != "no"
FILES+= ppp.conf
.endif
.if ${MK_SENDMAIL} != "no"
FILES+= sendmail.conf
.endif
.include <bsd.prog.mk>

View File

@ -0,0 +1,2 @@
# $FreeBSD$
/var/log/amd.log 644 7 1000 * J

View File

@ -0,0 +1,2 @@
# $FreeBSD$
/var/log/xferlog 600 7 1000 * JC

View File

@ -0,0 +1,2 @@
# $FreeBSD$
/var/log/lpd-errs 644 7 1000 * JC

View File

@ -0,0 +1,2 @@
# $FreeBSD$
/var/log/pflog 600 3 1000 * JB /var/run/pflogd.pid

View File

@ -0,0 +1,2 @@
# $FreeBSD$
/var/log/ppp.log root:network 640 3 1000 * JC

View File

@ -0,0 +1,2 @@
# $FreeBSD$
/var/log/sendmail.st 640 10 * 168 BN

View File

@ -10,8 +10,6 @@
security.* /var/log/security
auth.info;authpriv.info /var/log/auth.log
mail.info /var/log/maillog
lpr.info /var/log/lpd-errs
ftp.info /var/log/xferlog
cron.* /var/log/cron
!-devd
*.=debug /var/log/debug.log
@ -31,8 +29,6 @@ cron.* /var/log/cron
# Uncomment this if you wish to see messages produced by devd
# !devd
# *.>=notice /var/log/devd.log
!ppp
*.* /var/log/ppp.log
!*
include /etc/syslog.d
include /usr/local/etc/syslog.d

19
etc/syslog.d/Makefile Normal file
View File

@ -0,0 +1,19 @@
# $FreeBSD$
.include <src.opts.mk>
.if ${MK_FTP} != "no"
FILES+= ftp.conf
.endif
.if ${MK_LPR} != "no"
FILES+= lpr.conf
.endif
.if ${MK_PPP} != "no"
FILES+= ppp.conf
.endif
BINDIR= /etc/syslog.d
.include <bsd.prog.mk>

2
etc/syslog.d/ftp.conf Normal file
View File

@ -0,0 +1,2 @@
# $FreeBSD$
ftp.info /var/log/xferlog

2
etc/syslog.d/lpr.conf Normal file
View File

@ -0,0 +1,2 @@
# $FreeBSD$
lpr.info /var/log/lpd-errs

Some files were not shown because too many files have changed in this diff Show More