summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GNUmakefile6
-rw-r--r--mimetypes/Makefile.am16
-rw-r--r--mimetypes/err.c16
-rw-r--r--mimetypes/eval.c16
-rw-r--r--mimetypes/grammar.y2
-rw-r--r--mimetypes/ident.c15
-rw-r--r--mimetypes/lexer.l2
-rw-r--r--mimetypes/linetrack.c2
-rw-r--r--mimetypes/locus.c2
-rw-r--r--mimetypes/locus.h2
-rw-r--r--mimetypes/mtint.h15
-rw-r--r--mimetypes/prloc.c15
-rw-r--r--src/catfile.c16
-rw-r--r--src/config.c16
-rw-r--r--src/dirls.c15
-rw-r--r--src/dirls.h15
-rw-r--r--src/fileserv.c2
-rw-r--r--src/fileserv.h2
-rw-r--r--src/ftoc.sed6
-rw-r--r--src/httperr.c16
-rw-r--r--src/icon.c16
-rw-r--r--src/idx.c16
-rw-r--r--src/lang.c16
-rw-r--r--src/logger.c2
-rw-r--r--src/mem.c16
-rw-r--r--src/remoteip.c16
-rw-r--r--src/runas.c16
-rw-r--r--src/wordsplit.c2388
-rw-r--r--src/wordsplit.h261
29 files changed, 285 insertions, 2659 deletions
diff --git a/GNUmakefile b/GNUmakefile
index c36f6cd..b109490 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,3 +1,9 @@
+# Maintainer's makefile for fileserv
+# Copyright (C) 2019 Sergey Poznyakoff
+# Distributed under the terms of the GNU General Public License, either
+# version 3, or (at your option) any later version. See file COPYING
+# for the text of the license.
+
ifneq (,$(wildcard Makefile))
include Makefile
diff --git a/mimetypes/Makefile.am b/mimetypes/Makefile.am
index 3517a76..3ab0774 100644
--- a/mimetypes/Makefile.am
+++ b/mimetypes/Makefile.am
@@ -1,3 +1,19 @@
+# This file is part of fileserv.
+# Copyright (C) 2017-2019 Sergey Poznyakoff
+#
+# Fileserv is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Fileserv is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with fileserv. If not, see <http://www.gnu.org/licenses/>.
+
noinst_LIBRARIES = libmimetypes.a
libmimetypes_a_SOURCES = \
mimetypes.h\
diff --git a/mimetypes/err.c b/mimetypes/err.c
index 125bd2f..89e4cd8 100644
--- a/mimetypes/err.c
+++ b/mimetypes/err.c
@@ -1,3 +1,19 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
+
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/mimetypes/eval.c b/mimetypes/eval.c
index 120d041..03ed761 100644
--- a/mimetypes/eval.c
+++ b/mimetypes/eval.c
@@ -1,3 +1,19 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
+
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/mimetypes/grammar.y b/mimetypes/grammar.y
index 1864289..45c21c5 100644
--- a/mimetypes/grammar.y
+++ b/mimetypes/grammar.y
@@ -1,6 +1,6 @@
%{
/* This file is part of fileserv.
- Copyright (C) 2017, 2018 Sergey Poznyakoff
+ Copyright (C) 2017-2019 Sergey Poznyakoff
Fileserv is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/mimetypes/ident.c b/mimetypes/ident.c
index 6478e76..2438393 100644
--- a/mimetypes/ident.c
+++ b/mimetypes/ident.c
@@ -1,3 +1,18 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017-2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <errno.h>
#include <string.h>
diff --git a/mimetypes/lexer.l b/mimetypes/lexer.l
index dbd12a1..dbe3bde 100644
--- a/mimetypes/lexer.l
+++ b/mimetypes/lexer.l
@@ -1,6 +1,6 @@
%top {
/* This file is part of fileserv.
- Copyright (C) 2017, 2018 Sergey Poznyakoff
+ Copyright (C) 2017-2019 Sergey Poznyakoff
Fileserv is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/mimetypes/linetrack.c b/mimetypes/linetrack.c
index dda1636..e020782 100644
--- a/mimetypes/linetrack.c
+++ b/mimetypes/linetrack.c
@@ -1,5 +1,5 @@
/* This file is part of fileserv.
- Copyright (C) 2017, 2018 Sergey Poznyakoff
+ Copyright (C) 2017-2019 Sergey Poznyakoff
Fileserv is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/mimetypes/locus.c b/mimetypes/locus.c
index e3eba86..c383770 100644
--- a/mimetypes/locus.c
+++ b/mimetypes/locus.c
@@ -1,5 +1,5 @@
/* This file is part of fileserv.
- Copyright (C) 2017, 2018 Sergey Poznyakoff
+ Copyright (C) 2017-2019 Sergey Poznyakoff
Fileserv is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/mimetypes/locus.h b/mimetypes/locus.h
index 8a56995..08154ce 100644
--- a/mimetypes/locus.h
+++ b/mimetypes/locus.h
@@ -1,5 +1,5 @@
/* This file is part of fileserv.
- Copyright (C) 2017, 2018 Sergey Poznyakoff
+ Copyright (C) 2017-2019 Sergey Poznyakoff
Fileserv is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/mimetypes/mtint.h b/mimetypes/mtint.h
index a3324d1..9ca7b50 100644
--- a/mimetypes/mtint.h
+++ b/mimetypes/mtint.h
@@ -1,3 +1,18 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017-2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <stdio.h>
#include <regex.h>
diff --git a/mimetypes/prloc.c b/mimetypes/prloc.c
index 4555a56..8eab11a 100644
--- a/mimetypes/prloc.c
+++ b/mimetypes/prloc.c
@@ -1,3 +1,18 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017-2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <errno.h>
#include "locus.h"
diff --git a/src/catfile.c b/src/catfile.c
index bc4080a..922b3d9 100644
--- a/src/catfile.c
+++ b/src/catfile.c
@@ -1,3 +1,19 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
+
#include <stdlib.h>
#include <string.h>
#include "fileserv.h"
diff --git a/src/config.c b/src/config.c
index 19b26c7..0636a7c 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1,3 +1,19 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
+
#include "fileserv.h"
#include <errno.h>
#include <string.h>
diff --git a/src/dirls.c b/src/dirls.c
index de75f60..e9a6439 100644
--- a/src/dirls.c
+++ b/src/dirls.c
@@ -1,3 +1,18 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
#include "fileserv.h"
#include "dirls.h"
#include <errno.h>
diff --git a/src/dirls.h b/src/dirls.h
index 7ec2f3e..aef4194 100644
--- a/src/dirls.h
+++ b/src/dirls.h
@@ -1,3 +1,18 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
typedef struct dirlsent {
char *name; /* File name */
struct stat st; /* Meta-data */
diff --git a/src/fileserv.c b/src/fileserv.c
index 568ba37..42de1a4 100644
--- a/src/fileserv.c
+++ b/src/fileserv.c
@@ -1,5 +1,5 @@
/* This file is part of fileserv.
- Copyright (C) 2017, 2018 Sergey Poznyakoff
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
Fileserv is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/fileserv.h b/src/fileserv.h
index a801ed4..063bc76 100644
--- a/src/fileserv.h
+++ b/src/fileserv.h
@@ -1,5 +1,5 @@
/* This file is part of fileserv.
- Copyright (C) 2017-2018 Sergey Poznyakoff
+ Copyright (C) 2017-2019 Sergey Poznyakoff
Fileserv is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/ftoc.sed b/src/ftoc.sed
index 9e5d34f..e32349e 100644
--- a/src/ftoc.sed
+++ b/src/ftoc.sed
@@ -1,11 +1,13 @@
# This file is part of fileserv
-# Copyright (C) 2009-2018 Sergey Poznyakoff
+# Copyright (C) 2009-2019 Sergey Poznyakoff
# Distributed under the terms of the GNU General Public License, either
# version 3, or (at your option) any later version. See file COPYING
# for the text of the license.
-# Provide leading quote
+# Provide leading comment and quote
1i\
+/* -*- buffer-read-only: t -*- vi: set ro:\
+ THIS FILE IS GENERATED AUTOMATICALLY. PLEASE, DO NOT EDIT */\
"\\
# Provide trailing quote
diff --git a/src/httperr.c b/src/httperr.c
index 461d6f5..8e37523 100644
--- a/src/httperr.c
+++ b/src/httperr.c
@@ -1,3 +1,19 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
+
#include "fileserv.h"
#include <fcntl.h>
#include <errno.h>
diff --git a/src/icon.c b/src/icon.c
index 9e02f99..54b3f42 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -1,3 +1,19 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
+
#include "fileserv.h"
#include <fnmatch.h>
#include <string.h>
diff --git a/src/idx.c b/src/idx.c
index 17fdd58..d357fb9 100644
--- a/src/idx.c
+++ b/src/idx.c
@@ -1,3 +1,19 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
+
#include "fileserv.h"
#include <errno.h>
#include <assert.h>
diff --git a/src/lang.c b/src/lang.c
index 7679b1f..af4efc1 100644
--- a/src/lang.c
+++ b/src/lang.c
@@ -1,3 +1,19 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
+
#include "fileserv.h"
#include <string.h>
diff --git a/src/logger.c b/src/logger.c
index 82eec9d..50217c6 100644
--- a/src/logger.c
+++ b/src/logger.c
@@ -1,5 +1,5 @@
/* This file is part of fileserv.
- Copyright (C) 2017 Sergey Poznyakoff
+ Copyright (C) 2017-2019 Sergey Poznyakoff
Fileserv is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/mem.c b/src/mem.c
index ff8bc74..2a30c90 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -1,3 +1,19 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
+
#include "fileserv.h"
#include <string.h>
#include <errno.h>
diff --git a/src/remoteip.c b/src/remoteip.c
index 61bb015..5aa509d 100644
--- a/src/remoteip.c
+++ b/src/remoteip.c
@@ -1,3 +1,19 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
+
#include "fileserv.h"
#include <string.h>
#include <ctype.h>
diff --git a/src/runas.c b/src/runas.c
index 481fa7a..dd918c9 100644
--- a/src/runas.c
+++ b/src/runas.c
@@ -1,3 +1,19 @@
+/* This file is part of fileserv.
+ Copyright (C) 2017, 2019 Sergey Poznyakoff
+
+ Fileserv is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Fileserv is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with fileserv. If not, see <http://www.gnu.org/licenses/>. */
+
#include "fileserv.h"
#include <string.h>
#include <errno.h>
diff --git a/src/wordsplit.c b/src/wordsplit.c
deleted file mode 100644
index 5cd8daa..0000000
--- a/src/wordsplit.c
+++ /dev/null
@@ -1,2388 +0,0 @@
-/* wordsplit - a word splitter
- Copyright (C) 2009-2016 Sergey Poznyakoff
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <errno.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <pwd.h>
-#include <glob.h>
-
-#if ENABLE_NLS
-# include <gettext.h>
-#else
-# define gettext(msgid) msgid
-#endif
-#define _(msgid) gettext (msgid)
-#define N_(msgid) msgid
-
-#include <wordsplit.h>
-
-#define ISWS(c) ((c)==' '||(c)=='\t'||(c)=='\n')
-#define ISDELIM(ws,c) \
- (strchr ((ws)->ws_delim, (c)) != NULL)
-#define ISPUNCT(c) (strchr("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",(c))!=NULL)
-#define ISUPPER(c) ('A' <= ((unsigned) (c)) && ((unsigned) (c)) <= 'Z')
-#define ISLOWER(c) ('a' <= ((unsigned) (c)) && ((unsigned) (c)) <= 'z')
-#define ISALPHA(c) (ISUPPER(c) || ISLOWER(c))
-#define ISDIGIT(c) ('0' <= ((unsigned) (c)) && ((unsigned) (c)) <= '9')
-#define ISXDIGIT(c) (strchr("abcdefABCDEF", c)!=NULL)
-#define ISALNUM(c) (ISALPHA(c) || ISDIGIT(c))
-#define ISPRINT(c) (' ' <= ((unsigned) (c)) && ((unsigned) (c)) <= 127)
-
-#define ISVARBEG(c) (ISALPHA(c) || c == '_')
-#define ISVARCHR(c) (ISALNUM(c) || c == '_')
-
-#define ALLOC_INIT 128
-#define ALLOC_INCR 128
-
-static void
-_wsplt_alloc_die (struct wordsplit *wsp)
-{
- wsp->ws_error ("%s", _("memory exhausted"));
- abort ();
-}
-
-static void
-_wsplt_error (const char *fmt, ...)
-{
- va_list ap;
-
- va_start (ap, fmt);
- vfprintf (stderr, fmt, ap);
- va_end (ap);
- fputc ('\n', stderr);
-}
-
-static void wordsplit_free_nodes (struct wordsplit *);
-
-static int
-_wsplt_seterr (struct wordsplit *wsp, int ec)
-{
- wsp->ws_errno = ec;
- if (wsp->ws_flags & WRDSF_SHOWERR)
- wordsplit_perror (wsp);
- return ec;
-}
-
-static int
-_wsplt_nomem (struct wordsplit *wsp)
-{
- errno = ENOMEM;
- wsp->ws_errno = WRDSE_NOSPACE;
- if (wsp->ws_flags & WRDSF_ENOMEMABRT)
- wsp->ws_alloc_die (wsp);
- if (wsp->ws_flags & WRDSF_SHOWERR)
- wordsplit_perror (wsp);
- if (!(wsp->ws_flags & WRDSF_REUSE))
- wordsplit_free (wsp);
- wordsplit_free_nodes (wsp);
- return wsp->ws_errno;
-}
-
-static int wordsplit_run (const char *command, size_t length,
- struct wordsplit *wsp,
- int flags, int lvl);
-
-static int
-_wsplt_subsplit (struct wordsplit *wsp, struct wordsplit *wss,
- char const *str, int len,
- int flags)
-{
- wss->ws_delim = wsp->ws_delim;
- wss->ws_debug = wsp->ws_debug;
- wss->ws_error = wsp->ws_error;
- wss->ws_alloc_die = wsp->ws_alloc_die;
-
- if (!(flags & WRDSF_NOVAR))
- {
- wss->ws_env = wsp->ws_env;
- wss->ws_getvar = wsp->ws_getvar;
- flags |= wsp->ws_flags & (WRDSF_ENV | WRDSF_ENV_KV | WRDSF_GETVAR);
- }
- if (!(flags & WRDSF_NOCMD))
- {
- wss->ws_command = wsp->ws_command;
- }
-
- if ((flags & (WRDSF_NOVAR|WRDSF_NOCMD)) != (WRDSF_NOVAR|WRDSF_NOCMD))
- {
- wss->ws_closure = wsp->ws_closure;
- flags |= wsp->ws_flags & WRDSF_CLOSURE;
- }
-
- wss->ws_options = wsp->ws_options;
-
- flags |= WRDSF_DELIM
- | WRDSF_ALLOC_DIE
- | WRDSF_ERROR
- | WRDSF_DEBUG
- | (wsp->ws_flags & (WRDSF_SHOWDBG | WRDSF_SHOWERR | WRDSF_OPTIONS));
-
- return wordsplit_run (str, len, wss, flags, wsp->ws_lvl + 1);
-}
-
-static void
-_wsplt_seterr_sub (struct wordsplit *wsp, struct wordsplit *wss)
-{
- if (wsp->ws_errno == WRDSE_USERERR)
- free (wsp->ws_usererr);
- wsp->ws_errno = wss->ws_errno;
- if (wss->ws_errno == WRDSE_USERERR)
- {
- wsp->ws_usererr = wss->ws_usererr;
- wss->ws_errno = WRDSE_EOF;
- wss->ws_usererr = NULL;
- }
-}
-
-static void
-wordsplit_init0 (struct wordsplit *wsp)
-{
- if (wsp->ws_flags & WRDSF_REUSE)
- {
- if (!(wsp->ws_flags & WRDSF_APPEND))
- wordsplit_free_words (wsp);
- wordsplit_clearerr (wsp);
- }
- else
- {
- wsp->ws_wordv = NULL;
- wsp->ws_wordc = 0;
- wsp->ws_wordn = 0;
- }
-
- wsp->ws_errno = 0;
- wsp->ws_head = wsp->ws_tail = NULL;
-}
-
-char wordsplit_c_escape_tab[] = "\\\\\"\"a\ab\bf\fn\nr\rt\tv\v";
-
-static int
-wordsplit_init (struct wordsplit *wsp, const char *input, size_t len,
- int flags)
-{
- wsp->ws_flags = flags;
-
- if (!(wsp->ws_flags & WRDSF_ALLOC_DIE))
- wsp->ws_alloc_die = _wsplt_alloc_die;
- if (!(wsp->ws_flags & WRDSF_ERROR))
- wsp->ws_error = _wsplt_error;
-
- if (!(wsp->ws_flags & WRDSF_NOVAR))
- {
- /* These will be initialized on first variable assignment */
- wsp->ws_envidx = wsp->ws_envsiz = 0;
- wsp->ws_envbuf = NULL;
- }
-
- if (!(wsp->ws_flags & WRDSF_NOCMD))
- {
- if (!wsp->ws_command)
- {
- _wsplt_seterr (wsp, WRDSE_USAGE);
- errno = EINVAL;
- return wsp->ws_errno;
- }
- }
-
- if (wsp->ws_flags & WRDSF_SHOWDBG)
- {
- if (!(wsp->ws_flags & WRDSF_DEBUG))
- {
- if (wsp->ws_flags & WRDSF_ERROR)
- wsp->ws_debug = wsp->ws_error;
- else if (wsp->ws_flags & WRDSF_SHOWERR)
- wsp->ws_debug = _wsplt_error;
- else
- wsp->ws_flags &= ~WRDSF_SHOWDBG;
- }
- }
-
- wsp->ws_input = input;
- wsp->ws_len = len;
-
- if (!(wsp->ws_flags & WRDSF_DOOFFS))
- wsp->ws_offs = 0;
-
- if (!(wsp->ws_flags & WRDSF_DELIM))
- wsp->ws_delim = " \t\n";
-
- if (!(wsp->ws_flags & WRDSF_COMMENT))
- wsp->ws_comment = NULL;
-
- if (!(wsp->ws_flags & WRDSF_CLOSURE))
- wsp->ws_closure = NULL;
-
- if (!(wsp->ws_flags & WRDSF_OPTIONS))
- wsp->ws_options = 0;
-
- if (wsp->ws_flags & WRDSF_ESCAPE)
- {
- if (!wsp->ws_escape[WRDSX_WORD])
- wsp->ws_escape[WRDSX_WORD] = "";
- if (!wsp->ws_escape[WRDSX_QUOTE])
- wsp->ws_escape[WRDSX_QUOTE] = "";
- }
- else
- {
- if (wsp->ws_flags & WRDSF_CESCAPES)
- {
- wsp->ws_escape[WRDSX_WORD] = wordsplit_c_escape_tab;
- wsp->ws_escape[WRDSX_QUOTE]