aboutsummaryrefslogtreecommitdiff
path: root/tests/bkupname.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-13 10:21:43 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-13 10:33:34 +0300
commitde3fbe3e8d4dd2a89f7755906d76055784c437cc (patch)
tree65356dd7b5a9010499550c468e960c93515a7e15 /tests/bkupname.c
parentf569a6f2628b9ddef4dfb4424aff2dad644a8f19 (diff)
downloadwydawca-de3fbe3e8d4dd2a89f7755906d76055784c437cc.tar.gz
wydawca-de3fbe3e8d4dd2a89f7755906d76055784c437cc.tar.bz2
Drop gnulib.
* bootstrap: Rewrite. * bootstrap.conf: Remove. * configure.ac: Remove gl_EARLY/gl_INIT * src/backup.c: New file. * src/txtacc.c (txtacc_finish): Make sure a new entry is appended only once to the list. * (all sources): Use grecs memory allocation functions. * src/wydawca.h" Include fnmatch.h and regex.h (backup_type): New enum. (simple_backup_suffix): New extern. (find_backup_file_name): New proto. * tests/bkupname.c: New file. * tests/backup00.at: New file. * tests/backup01.at: New file. * tests/backup02.at: New file. * tests/backup03.at: New file. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Add new tests. * grecs: Update.
Diffstat (limited to 'tests/bkupname.c')
-rw-r--r--tests/bkupname.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/bkupname.c b/tests/bkupname.c
new file mode 100644
index 0000000..6187146
--- /dev/null
+++ b/tests/bkupname.c
@@ -0,0 +1,79 @@
1/* wordsplit - a word splitter
2 Copyright (C) 2009, 2010 Sergey Poznyakoff
3
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 3 of the License, or (at your
7 option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17#include <config.h>
18#include "wydawca.h"
19
20char *progname;
21
22void
23usage (int code)
24{
25 FILE *fp = code ? stderr : stdout;
26
27 fprintf (fp, "usage: %s [-no] [-simple] [-existing] [-numbered] [-suffix=S] FILE\n",
28 progname);
29 exit (code);
30}
31
32int
33main (int argc, char **argv)
34{
35 enum backup_type type = numbered_backups;
36 char *file = NULL;
37 char *backup;
38
39 progname = argv[0];
40 while (--argc)
41 {
42 char *arg = *++argv;
43 if (strcmp (arg, "-no") == 0)
44 type = no_backups;
45 else if (strcmp (arg, "-simple") == 0)
46 type = simple_backups;
47 else if (strcmp (arg, "-existing") == 0)
48 type = numbered_existing_backups;
49 else if (strcmp (arg, "-numbered") == 0)
50 type = numbered_backups;
51 else if (strncmp (arg, "-suffix=", 8) == 0)
52 simple_backup_suffix = arg + 8;
53 else if (arg[0] == '-')
54 usage (2);
55 else
56 {
57 if (argc != 1)
58 usage (2);
59 file = arg;
60 }
61 }
62
63 if (!file)
64 usage (2);
65 backup = find_backup_file_name (file, type);
66 if (!backup)
67 {
68 if (errno)
69 {
70 perror (file);
71 exit (1);
72 }
73 printf ("no backup\n");
74 }
75 else
76 printf ("%s\n", backup);
77 free (backup);
78 exit (0);
79}

Return to:

Send suggestions and report system problems to the System administrator.