"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "compat_fts.c" between
mdocml-1.14.1rc1.tar.gz and mdocml-1.14.1rc2.tar.gz

About: mdocml is a suite of tools compiling "-mdoc", the roff macro package of choice for BSD manual pages, and "-man", the predominant historical package for UNIX manuals. Hint: The installed binary name is "mandoc". Release candidate.

compat_fts.c  (mdocml-1.14.1rc1):compat_fts.c  (mdocml-1.14.1rc2)
#include "config.h" #include "config.h"
#if HAVE_FTS #if HAVE_FTS
int dummy; int dummy;
#else #else
/* $Id: compat_fts.c,v 1.12 2016/10/18 23:58:12 schwarze Exp $ */ /* $Id: compat_fts.c,v 1.14 2017/02/18 12:24:24 schwarze Exp $ */
/* $OpenBSD: fts.c,v 1.56 2016/09/21 04:38:56 guenther Exp $ */ /* $OpenBSD: fts.c,v 1.56 2016/09/21 04:38:56 guenther Exp $ */
/*- /*-
* Copyright (c) 1990, 1993, 1994 * Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
skipping to change at line 66 skipping to change at line 66
static FTSENT *fts_build(FTS *); static FTSENT *fts_build(FTS *);
static void fts_lfree(FTSENT *); static void fts_lfree(FTSENT *);
static void fts_load(FTS *, FTSENT *); static void fts_load(FTS *, FTSENT *);
static size_t fts_maxarglen(char * const *); static size_t fts_maxarglen(char * const *);
static void fts_padjust(FTS *, FTSENT *); static void fts_padjust(FTS *, FTSENT *);
static int fts_palloc(FTS *, size_t); static int fts_palloc(FTS *, size_t);
static FTSENT *fts_sort(FTS *, FTSENT *, int); static FTSENT *fts_sort(FTS *, FTSENT *, int);
static unsigned short fts_stat(FTS *, FTSENT *); static unsigned short fts_stat(FTS *, FTSENT *);
#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])) ) #define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])) )
#ifndef O_DIRECTORY
#define O_DIRECTORY 0
#endif
#ifndef O_CLOEXEC #ifndef O_CLOEXEC
#define O_CLOEXEC 0 #define O_CLOEXEC 0
#endif #endif
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#define CLR(opt) (sp->fts_options &= ~(opt)) #define CLR(opt) (sp->fts_options &= ~(opt))
#define ISSET(opt) (sp->fts_options & (opt)) #define ISSET(opt) (sp->fts_options & (opt))
#define SET(opt) (sp->fts_options |= (opt)) #define SET(opt) (sp->fts_options |= (opt))
FTS * FTS *
fts_open(char * const *argv, int options, fts_open(char * const *argv, int options,
int (*compar)(const FTSENT **, const FTSENT **)) int (*compar)(const FTSENT **, const FTSENT **))
{ {
FTS *sp; FTS *sp;
FTSENT *p, *root; FTSENT *p, *root;
int nitems; int nitems;
FTSENT *parent, *tmp; FTSENT *parent, *prev;
/* Options check. */ /* Options check. */
if (options & ~FTS_OPTIONMASK) { if (options & ~FTS_OPTIONMASK) {
errno = EINVAL; errno = EINVAL;
return (NULL); return (NULL);
} }
/* At least one path must be specified. */ /* At least one path must be specified. */
if (*argv == NULL) { if (*argv == NULL) {
errno = EINVAL; errno = EINVAL;
skipping to change at line 120 skipping to change at line 114
*/ */
if (fts_palloc(sp, MAXIMUM(fts_maxarglen(argv), PATH_MAX))) if (fts_palloc(sp, MAXIMUM(fts_maxarglen(argv), PATH_MAX)))
goto mem1; goto mem1;
/* Allocate/initialize root's parent. */ /* Allocate/initialize root's parent. */
if ((parent = fts_alloc(sp, "", 0)) == NULL) if ((parent = fts_alloc(sp, "", 0)) == NULL)
goto mem2; goto mem2;
parent->fts_level = FTS_ROOTPARENTLEVEL; parent->fts_level = FTS_ROOTPARENTLEVEL;
/* Allocate/initialize root(s). */ /* Allocate/initialize root(s). */
for (root = NULL, nitems = 0; *argv; ++argv, ++nitems) { for (root = prev = NULL, nitems = 0; *argv; ++argv, ++nitems) {
if ((p = fts_alloc(sp, *argv, strlen(*argv))) == NULL) if ((p = fts_alloc(sp, *argv, strlen(*argv))) == NULL)
goto mem3; goto mem3;
p->fts_level = FTS_ROOTLEVEL; p->fts_level = FTS_ROOTLEVEL;
p->fts_parent = parent; p->fts_parent = parent;
p->fts_accpath = p->fts_name; p->fts_accpath = p->fts_name;
p->fts_info = fts_stat(sp, p); p->fts_info = fts_stat(sp, p);
/* Command-line "." and ".." are real directories. */ /* Command-line "." and ".." are real directories. */
if (p->fts_info == FTS_DOT) if (p->fts_info == FTS_DOT)
p->fts_info = FTS_D; p->fts_info = FTS_D;
skipping to change at line 142 skipping to change at line 136
/* /*
* If comparison routine supplied, traverse in sorted * If comparison routine supplied, traverse in sorted
* order; otherwise traverse in the order specified. * order; otherwise traverse in the order specified.
*/ */
if (compar) { if (compar) {
p->fts_link = root; p->fts_link = root;
root = p; root = p;
} else { } else {
p->fts_link = NULL; p->fts_link = NULL;
if (root == NULL) if (root == NULL)
tmp = root = p; root = p;
else { else
tmp->fts_link = p; prev->fts_link = p;
tmp = p; prev = p;
}
} }
} }
if (compar && nitems > 1) if (compar && nitems > 1)
root = fts_sort(sp, root, nitems); root = fts_sort(sp, root, nitems);
/* /*
* Allocate a dummy pointer and make fts_read think that we've just * Allocate a dummy pointer and make fts_read think that we've just
* finished the node before the root(s); set p->fts_info to FTS_INIT * finished the node before the root(s); set p->fts_info to FTS_INIT
* so that everything about the "current" node is ignored. * so that everything about the "current" node is ignored.
*/ */
 End of changes. 6 change blocks. 
14 lines changed or deleted 7 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS