summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mh/tests/atlocal.in6
-rw-r--r--mh/tests/comp.at34
-rw-r--r--mh/tests/forw.at38
-rw-r--r--mh/tests/mhn.at38
-rw-r--r--mh/tests/mhpath.at30
-rw-r--r--mh/tests/repl.at12
-rw-r--r--testsuite/.gitignore1
-rw-r--r--testsuite/Makefile.am4
-rw-r--r--testsuite/cwdrepl.at59
-rw-r--r--testsuite/cwdrepl.c176
-rw-r--r--testsuite/testsuite.at1
11 files changed, 319 insertions, 80 deletions
diff --git a/mh/tests/atlocal.in b/mh/tests/atlocal.in
index 508e03f28..6a7f40528 100644
--- a/mh/tests/atlocal.in
+++ b/mh/tests/atlocal.in
@@ -5,6 +5,4 @@
-PATH=@abs_builddir@:@abs_top_builddir@/mh:$top_srcdir:$srcdir:$PATH
-remove_curdir() {
- sed "s|$HOME/*||;s| *$||" $*
-}
+PATH=@abs_builddir@:@abs_top_builddir@/testsuite:@abs_top_builddir@/mh:$top_srcdir:$srcdir:$PATH
+
# mimeflt [FILE]
diff --git a/mh/tests/comp.at b/mh/tests/comp.at
index a8d4a4129..563310cca 100644
--- a/mh/tests/comp.at
+++ b/mh/tests/comp.at
@@ -21,3 +21,3 @@ m4_pushdef([compcmd],[comp -editor $abs_top_srcdir/mh/tests/mhed])
MH_CHECK([comp -file],[comp00 comp-file],[
-echo quit | compcmd -file ./infile | remove_curdir | sed 's/ *$//'
+echo quit | compcmd -file $HOME/infile | cwdrepl | sed 's/ *$//'
sed 's/ *$//' infile
@@ -41,3 +41,3 @@ Seen by mhed
MH_CHECK([comp -file (del)],[comp01 comp-file_del],[
-echo 'quit -delete' | compcmd -file ./infile | remove_curdir
+echo 'quit -delete' | compcmd -file $HOME/infile | cwdrepl | sed 's/ *$//'
],
@@ -55,3 +55,3 @@ What now?
MH_CHECK([comp file],[comp02 comp_file],[
-echo 'quit' | compcmd file | remove_curdir | sed 's/ *$//'
+echo 'quit' | compcmd file | cwdrepl | sed 's/ *$//'
sed 's/ *$//' Mail/file
@@ -59,3 +59,3 @@ sed 's/ *$//' Mail/file
[0],
-[-- Editor invocation: Mail/file
+[-- Editor invocation: ./Mail/file
-- Input file:
@@ -66,3 +66,3 @@ Subject:
-- Input file end
-What now? draft left on "Mail/file".
+What now? draft left on "./Mail/file".
To:
@@ -82,3 +82,3 @@ message body
-echo 'quit' | compcmd -use file | remove_curdir | sed 's/ *$//'
+echo 'quit' | compcmd -use file | cwdrepl | sed 's/ *$//'
sed 's/ *$//' Mail/file
@@ -86,3 +86,3 @@ sed 's/ *$//' Mail/file
[0],
-[-- Editor invocation: Mail/file
+[-- Editor invocation: ./Mail/file
-- Input file:
@@ -94,3 +94,3 @@ message body
-- Input file end
-What now? draft left on "Mail/file".
+What now? draft left on "./Mail/file".
From: gray
@@ -112,3 +112,3 @@ message body
-echo 'quit' | compcmd +inbox 1 | remove_curdir | sed 's/ *$//'
+echo 'quit' | compcmd +inbox 1 | cwdrepl | sed 's/ *$//'
echo Mail/draft
@@ -119,3 +119,3 @@ sed 's/ *$//' Mail/inbox/1
[0],
-[-- Editor invocation: Mail/draft
+[-- Editor invocation: ./Mail/draft
-- Input file:
@@ -127,3 +127,3 @@ message body
-- Input file end
-What now? draft left on "Mail/draft".
+What now? draft left on "./Mail/draft".
Mail/draft
@@ -145,3 +145,3 @@ MH_CHECK([comp -draftfolder],[comp05 comp-draftfolder draftfolder],[
mkdir Mail/drafts
-echo 'quit' | compcmd -draftfolder drafts | remove_curdir | sed 's/ *$//'
+echo 'quit' | compcmd -draftfolder drafts | cwdrepl | sed 's/ *$//'
sed 's/ *$//' Mail/drafts/1
@@ -149,3 +149,3 @@ sed 's/ *$//' Mail/drafts/1
[0],
-[-- Editor invocation: Mail/drafts/1
+[-- Editor invocation: ./Mail/drafts/1
-- Input file:
@@ -156,3 +156,3 @@ Subject:
-- Input file end
-What now? draft left on "Mail/drafts/1".
+What now? draft left on "./Mail/drafts/1".
To:
@@ -174,3 +174,3 @@ echo "cur: 1" > Mail/drafts/.mh_sequences
-echo 'quit' | compcmd -draftfolder drafts -use| remove_curdir | sed 's/ *$//'
+echo 'quit' | compcmd -draftfolder drafts -use| cwdrepl | sed 's/ *$//'
sed 's/ *$//' Mail/drafts/1
@@ -178,3 +178,3 @@ sed 's/ *$//' Mail/drafts/1
[0],
-[-- Editor invocation: Mail/drafts/1
+[-- Editor invocation: ./Mail/drafts/1
-- Input file:
@@ -186,3 +186,3 @@ message body
-- Input file end
-What now? draft left on "Mail/drafts/1".
+What now? draft left on "./Mail/drafts/1".
From: gray
diff --git a/mh/tests/forw.at b/mh/tests/forw.at
index 4392fa2b9..e0566dfe7 100644
--- a/mh/tests/forw.at
+++ b/mh/tests/forw.at
@@ -29,3 +29,3 @@ message body
-echo quit | forwcmd +inbox 1 | remove_curdir
+echo quit | forwcmd +inbox 1 | cwdrepl
echo == Mail/draft ==
@@ -38,3 +38,3 @@ sed '/^X-IMAPbase/d' Mail/inbox/1
[0],
-[-- Editor invocation: Mail/draft
+[-- Editor invocation: ./Mail/draft
-- Input file:
@@ -55,3 +55,3 @@ message body
-- Input file end
-What now? draft left on "Mail/draft".
+What now? draft left on "./Mail/draft".
== Mail/draft ==
@@ -89,3 +89,3 @@ message body
-echo quit | forwcmd -format +inbox 1 | remove_curdir
+echo quit | forwcmd -format +inbox 1 | cwdrepl
echo == Mail/draft ==
@@ -98,3 +98,3 @@ sed '/^X-IMAPbase/d' Mail/inbox/1
[0],
-[-- Editor invocation: Mail/draft
+[-- Editor invocation: ./Mail/draft
-- Input file:
@@ -115,3 +115,3 @@ message body
-- Input file end
-What now? draft left on "Mail/draft".
+What now? draft left on "./Mail/draft".
== Mail/draft ==
@@ -155,3 +155,3 @@ Subject: 2nd message
-echo quit | forwcmd +inbox 1 2 | remove_curdir
+echo quit | forwcmd +inbox 1 2 | cwdrepl
echo == Mail/draft ==
@@ -164,3 +164,3 @@ cat Mail/inbox/2
[0],
-[-- Editor invocation: Mail/draft
+[-- Editor invocation: ./Mail/draft
-- Input file:
@@ -190,3 +190,3 @@ Subject: 2nd message
-- Input file end
-What now? draft left on "Mail/draft".
+What now? draft left on "./Mail/draft".
== Mail/draft ==
@@ -239,3 +239,3 @@ message body
-forwcmd -build +inbox 1 | remove_curdir
+forwcmd -build +inbox 1 | cwdrepl
echo == Mail/draft ==
@@ -284,5 +284,5 @@ Subject: 2nd message
-forwcmd -build -mime +inbox 1 2 | remove_curdir
+forwcmd -build -mime +inbox 1 2 | cwdrepl
echo == Mail/draft ==
-remove_curdir Mail/draft
+cwdrepl < Mail/draft
echo == Message 1 ==
@@ -298,3 +298,3 @@ Subject:
--------
-#forw [] +Mail/inbox 1 2
+#forw [] +./Mail/inbox 1 2
@@ -324,3 +324,3 @@ message body
-echo "quit" | forwcmd -draftfolder drafts 1 | remove_curdir
+echo "quit" | forwcmd -draftfolder drafts 1 | cwdrepl
echo == Mail/drafts/1 ==
@@ -331,3 +331,3 @@ sed '/^X-IMAPbase/d' Mail/inbox/1
[0],
-[-- Editor invocation: Mail/drafts/1
+[-- Editor invocation: ./Mail/drafts/1
-- Input file:
@@ -348,3 +348,3 @@ message body
-- Input file end
-What now? draft left on "Mail/drafts/1".
+What now? draft left on "./Mail/drafts/1".
== Mail/drafts/1 ==
@@ -381,6 +381,6 @@ message body
-echo "quit" | forwcmd -file infile | remove_curdir
+echo "quit" | forwcmd -file infile | cwdrepl
],
[0],
-[-- Editor invocation: Mail/draft
+[-- Editor invocation: ./Mail/draft
-- Input file:
@@ -396,3 +396,3 @@ message body
-- Input file end
-What now? draft left on "Mail/draft".
+What now? draft left on "./Mail/draft".
])
diff --git a/mh/tests/mhn.at b/mh/tests/mhn.at
index 51d579abf..30755ecb7 100644
--- a/mh/tests/mhn.at
+++ b/mh/tests/mhn.at
@@ -132,9 +132,9 @@ MH_CHECK([mhn -store -auto],[mhn03 mhn-store-auto],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
-mhn +inbox -store -auto 4 | remove_curdir || exit $?
+mhn +inbox -store -auto 4 | cwdrepl || exit $?
],
[0],
-[storing message 4 part 1 as file msg.21
-storing message 4 part 2.1 as file msg.22
-storing message 4 part 2.2.1 as file msg.23
-storing message 4 part 2.2.2 as file msg.24
+[storing message 4 part 1 as file ./msg.21
+storing message 4 part 2.1 as file ./msg.22
+storing message 4 part 2.2.1 as file ./msg.23
+storing message 4 part 2.2.2 as file ./msg.24
])
@@ -143,6 +143,6 @@ MH_CHECK([mhn -store -auto -part],[mhn04 mhn-store-auto-part],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox],[700])
-mhn +inbox -store -auto -part 2.2.1 4 | remove_curdir || exit $?
+mhn +inbox -store -auto -part 2.2.1 4 | cwdrepl || exit $?
],
[0],
-[storing message 4 part 2.2.1 as file msg.23
+[storing message 4 part 2.2.1 as file ./msg.23
])
@@ -180,9 +180,9 @@ echo "mhn-storage: $HOME/out" >> $MH
-mhn +inbox -store 4 | remove_curdir || echo $?
+mhn +inbox -store 4 | cwdrepl || echo $?
],
[0],
-[storing message 4 part 1 as file out/4.1.plain
-storing message 4 part 2.1 as file out/4.2.1.octet-stream
-storing message 4 part 2.2.1 as file out/4.2.2.1.octet-stream
-storing message 4 part 2.2.2 as file out/4.2.2.2.octet-stream
+[storing message 4 part 1 as file ./out/4.1.plain
+storing message 4 part 2.1 as file ./out/4.2.1.octet-stream
+storing message 4 part 2.2.1 as file ./out/4.2.2.1.octet-stream
+storing message 4 part 2.2.2 as file ./out/4.2.2.2.octet-stream
])
@@ -195,3 +195,3 @@ MUT_MBCHMOD(Mail/inbox, 700)
echo "mhn-store-application: %%-%m%P.%s-%p" >> $MH
-mhn +inbox -store 4 | remove_curdir || exit $?
+mhn +inbox -store 4 || exit $?
find . -name '%*' | sort
@@ -215,3 +215,3 @@ MUT_MBCHMOD(Mail/inbox, 700)
echo "mhn-store-application: $HOME/out/%m%P.%s" >> $MH
-mhn +inbox -store 4 | remove_curdir || exit $?
+mhn +inbox -store 4 | cwdrepl || exit $?
],
@@ -219,5 +219,5 @@ mhn +inbox -store 4 | remove_curdir || exit $?
[storing message 4 part 1 as file 4.1.plain
-storing message 4 part 2.1 as file out/4.2.1.octet-stream
-storing message 4 part 2.2.1 as file out/4.2.2.1.octet-stream
-storing message 4 part 2.2.2 as file out/4.2.2.2.octet-stream
+storing message 4 part 2.1 as file ./out/4.2.1.octet-stream
+storing message 4 part 2.2.1 as file ./out/4.2.2.1.octet-stream
+storing message 4 part 2.2.2 as file ./out/4.2.2.2.octet-stream
])
@@ -231,3 +231,3 @@ MUT_MBCHMOD(Mail, 700)
echo "mhn-store-application: +app" >> $MH
-mhn +inbox -store 4 | remove_curdir || exit $?
+mhn +inbox -store 4 | cwdrepl || exit $?
],
@@ -249,3 +249,3 @@ mhn-store-application/octet-stream: +
EOT
-mhn +inbox -store -part 2.2.1 4 | remove_curdir || exit $?
+mhn +inbox -store -part 2.2.1 4 | cwdrepl || exit $?
],
diff --git a/mh/tests/mhpath.at b/mh/tests/mhpath.at
index a04868710..d07a7c765 100644
--- a/mh/tests/mhpath.at
+++ b/mh/tests/mhpath.at
@@ -22,6 +22,6 @@ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
-mhpath | remove_curdir
+mhpath | cwdrepl
],
[0],
-[Mail/inbox
+[./Mail/inbox
])
@@ -31,6 +31,6 @@ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
-mhpath +| remove_curdir
+mhpath +| cwdrepl
],
[0],
-[Mail
+[./Mail
])
@@ -39,8 +39,8 @@ MH_CHECK([mhpath msgs],[mhpath02 mhparam_msgs],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
-mhpath 1-3 | remove_curdir
+mhpath 1-3 | cwdrepl
],
[0],
-[Mail/inbox/1
-Mail/inbox/2
-Mail/inbox/3
+[./Mail/inbox/1
+./Mail/inbox/2
+./Mail/inbox/3
])
@@ -49,7 +49,7 @@ MH_CHECK([mhpath msgs (some nonexistent)],[mhpath03 mhparam_msgs_some_nonex],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
-mhpath 4-10 | remove_curdir
+mhpath 4-10 | cwdrepl
],
[0],
-[Mail/inbox/4
-Mail/inbox/5
+[./Mail/inbox/4
+./Mail/inbox/5
])
@@ -58,3 +58,3 @@ MH_CHECK([mhpath msgs (all nonexistent)],[mhpath04 mhparam_msgs_all_nonex],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
-mhpath 8-10 | remove_curdir
+mhpath 8-10 | cwdrepl
],
@@ -89,3 +89,3 @@ MH_CHECK([mhpath nonexistent],[mhpath05 mhparam_nonexistent],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
-mhpath 10 | remove_curdir
+mhpath 10 | cwdrepl
],
@@ -98,6 +98,6 @@ MH_CHECK([mhpath new],[mhpath06 mhparam_new],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
-mhpath new | remove_curdir
+mhpath new | cwdrepl
],
[0],
-[Mail/inbox/6
+[./Mail/inbox/6
])
diff --git a/mh/tests/repl.at b/mh/tests/repl.at
index 3520c631b..bd58e9f33 100644
--- a/mh/tests/repl.at
+++ b/mh/tests/repl.at
@@ -30,3 +30,3 @@ message body
])
-echo "quit" | replcmd +inbox 1 | remove_curdir
+echo "quit" | replcmd +inbox 1 | cwdrepl
echo == Mail/draft ==
@@ -35,3 +35,3 @@ cat Mail/draft
[0],
-[-- Editor invocation: Mail/draft
+[-- Editor invocation: ./Mail/draft
-- Input file:
@@ -42,3 +42,3 @@ X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
-- Input file end
-What now? draft left on "Mail/draft".
+What now? draft left on "./Mail/draft".
== Mail/draft ==
@@ -60,3 +60,3 @@ message body
])
-echo "quit" | replcmd -draftfolder drafts +inbox 1 | remove_curdir
+echo "quit" | replcmd -draftfolder drafts +inbox 1 | cwdrepl
echo == Mail/drafts/1 ==
@@ -65,3 +65,3 @@ cat Mail/drafts/1
[0],
-[-- Editor invocation: Mail/drafts/1
+[-- Editor invocation: ./Mail/drafts/1
-- Input file:
@@ -72,3 +72,3 @@ X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
-- Input file end
-What now? draft left on "Mail/drafts/1".
+What now? draft left on "./Mail/drafts/1".
== Mail/drafts/1 ==
diff --git a/testsuite/.gitignore b/testsuite/.gitignore
index 60475e825..d58c1e299 100644
--- a/testsuite/.gitignore
+++ b/testsuite/.gitignore
@@ -3,2 +3,3 @@ atlocal
bs
+cwdrepl
fldel
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 403cde207..e0eeba031 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -53,2 +53,3 @@ noinst_PROGRAMS = \
bs\
+ cwdrepl\
fldel\
@@ -78,2 +79,4 @@ smtpsend_LDADD = \
+cwdrepl_LDADD = ${MU_LIB_MAILUTILS}
+
## ------------ ##
@@ -83,2 +86,3 @@ smtpsend_LDADD = \
TESTSUITE_AT = \
+ cwdrepl.at\
fldel.at\
diff --git a/testsuite/cwdrepl.at b/testsuite/cwdrepl.at
new file mode 100644
index 000000000..9cd15a903
--- /dev/null
+++ b/testsuite/cwdrepl.at
@@ -0,0 +1,59 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2017 Free Software Foundation, Inc.
+#
+# GNU Mailutils 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.
+#
+# GNU Mailutils 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 GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([cwdrepl tool])
+AT_KEYWORDS([cwdrepl])
+
+AT_CHECK([
+pwd -P >/dev/null 2>&1 || AT_SKIP_TEST
+cwd=`pwd -P`
+cwdrepl <<EOT
+$cwd
+CWD is "$cwd"
+$cwd/foo "$cwd" end
+EOT
+],
+[0],
+[.
+CWD is "."
+./foo "." end
+])
+
+AT_CHECK([
+pwd -P >/dev/null 2>&1 || AT_SKIP_TEST
+pwd -L >/dev/null 2>&1 || AT_SKIP_TEST
+mkdir physical logical
+ln -s physical logical || AT_SKIP_TEST
+cd logical
+phy=`pwd -P`
+log=`pwd -L`
+cwdrepl <<EOT
+$phy $log
+LOG is "$log", PHY is "$phy"
+$log/foo "$log" end
+$phy/foo "$phy" end
+EOT
+],
+[0],
+[. .
+LOG is ".", PHY is "."
+./foo "." end
+./foo "." end
+])
+
+AT_CLEANUP
+
+
diff --git a/testsuite/cwdrepl.c b/testsuite/cwdrepl.c
new file mode 100644
index 000000000..9f6525f18
--- /dev/null
+++ b/testsuite/cwdrepl.c
@@ -0,0 +1,176 @@
+/* This file is part of GNU Mailutils testsuite.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+
+ GNU Mailutils 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.
+
+ GNU Mailutils 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 GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
+
+/*
+
+NAME
+
+ cwdrepl - replace occurrences of CWD with .
+
+SYNOPSIS
+
+ COMMAND | cwdrepl [DIR REPL]...
+
+DESCRIPTION
+
+ Some testcases operate programs that produce full file names as part
+ of their output. To make this output independent of the actual file
+ location, this tool replaces every occurrence of the current working
+ directory with dot. Both logical (as given by the PWD environment
+ variable) and physical (as returned by getcwd(3)) locations are replaced.
+
+ The same effect could have been achieved by using "pwd -P", "pwd -L"
+ and sed, but this would pose portability problems.
+
+ Additionally, any number of DIR REPL pairs can be supplied in the command
+ line. Each pair instructs the tool to replace every occurrence of DIR
+ with REPL on output. Note that these pairs take precedence over the
+ default ones, so running "cwdrepl $PWD 'PWD'" will replace occurrences
+ of the logical current working directory name with the string PWS, instead
+ of the default dot.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/mailutils.h>
+
+struct dirtrans
+{
+ char *dir;
+ size_t dirlen;
+ char const *trans;
+ ssize_t translen;
+};
+
+mu_list_t translist;
+
+static int
+transcmp (const void *a, const void *b)
+{
+ struct dirtrans const *trans1 = a;
+ struct dirtrans const *trans2 = b;
+ return strcmp (trans1->dir, trans2->dir);
+}
+
+static void
+newdir (char const *dir, char const *trans)
+{
+ if (dir)
+ {
+ size_t dirlen = strlen (dir);
+ size_t translen = strlen (trans);
+ struct dirtrans *dt = mu_alloc (sizeof *dt);
+
+ while (dirlen > 0 && dir[dirlen-1] == '/')
+ dirlen--;
+
+ dt->dir = mu_alloc (dirlen + 1);
+ memcpy (dt->dir, dir, dirlen);
+ dt->dir[dirlen] = 0;
+ dt->dirlen = dirlen;
+ dt->trans = trans;
+ dt->translen = translen;
+
+ if (!translist)
+ {
+ MU_ASSERT (mu_list_create (&translist));
+ mu_list_set_comparator (translist, transcmp);
+ }
+ else if (mu_list_locate (translist, dt, NULL) == 0)
+ {
+ free (dt->dir);
+ free (dt);
+ return;
+ }
+
+ MU_ASSERT (mu_list_append (translist, dt));
+ }
+}
+
+static inline int
+isbnd (int c)
+{
+ return mu_c_is_class (c, MU_CTYPE_CNTRL|MU_CTYPE_PUNCT|MU_CTYPE_SPACE);
+}
+
+int
+main (int argc, char **argv)
+{
+ int i;
+ int rc;
+ char *buf = NULL;
+ size_t size, n;
+ mu_iterator_t itr;
+
+ mu_set_program_name (argv[0]);
+ mu_stdstream_setup (MU_STDSTREAM_RESET_NONE);
+
+ for (i = 1; i < argc; i += 2)
+ newdir (argv[i], (i + 1 < argc) ? argv[i + 1] : "");
+
+ newdir (getenv ("PWD"), ".");
+ newdir (mu_getcwd (), ".");
+
+ MU_ASSERT (mu_list_get_iterator (translist, &itr));
+ while ((rc = mu_stream_getline (mu_strin, &buf, &size, &n)) == 0 && n > 0)
+ {
+ n = mu_rtrim_class (buf, MU_CTYPE_SPACE);
+ for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
+ mu_iterator_next (itr))
+ {
+ struct dirtrans *dt;
+ size_t start = 0;
+ char *p;
+
+ mu_iterator_current (itr, (void**) &dt);
+ while ((p = strstr (buf + start, dt->dir)))
+ {
+ if (isbnd (p[dt->dirlen]))
+ {
+ size_t off = p - buf;
+ size_t rest = n - start;
+ ssize_t d = (ssize_t)dt->translen - dt->dirlen;
+
+ if (d > 0)
+ {
+ if (n + d + 1 > size)
+ {
+ size = n + d + 1;
+ buf = mu_realloc (buf, size);
+ p = buf + off;
+ }
+ }
+
+ memmove (p + dt->translen, p + dt->dirlen,
+ rest - dt->dirlen + 1);
+ memcpy (p, dt->trans, dt->translen);
+
+ n += d;
+ start = off + dt->translen;
+ }
+ else
+ start++;
+ }
+ }
+ mu_stream_write (mu_strout, buf, n, NULL);
+ mu_stream_write (mu_strout, "\n", 1, NULL);
+ }
+ return 0;
+}
diff --git a/testsuite/testsuite.at b/testsuite/testsuite.at
index 880f77845..addfed025 100644
--- a/testsuite/testsuite.at
+++ b/testsuite/testsuite.at
@@ -40 +40,2 @@ AT_BANNER(Various)
m4_include([ufms.at])
+m4_include([cwdrepl.at])

Return to:

Send suggestions and report system problems to the System administrator.