summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile.am4
-rwxr-xr-xbootstrap618
-rw-r--r--bootstrap.conf68
-rw-r--r--configure.ac5
-rw-r--r--gnulib.modules4
m---------grecs0
-rw-r--r--src/Makefile.am5
-rw-r--r--src/backup.c165
-rw-r--r--src/builtin.c10
-rw-r--r--src/config.c26
-rw-r--r--src/dictionary.c11
-rw-r--r--src/directive.c8
-rw-r--r--src/diskio.c6
-rw-r--r--src/exec.c2
-rw-r--r--src/gpg.c7
-rw-r--r--src/job.c2
-rw-r--r--src/lock.c12
-rw-r--r--src/mail.c14
-rw-r--r--src/net.c4
-rw-r--r--src/process.c4
-rw-r--r--src/sql.c4
-rw-r--r--src/timer.c5
-rw-r--r--src/triplet.c17
-rw-r--r--src/txtacc.c16
-rw-r--r--src/verify.c4
-rw-r--r--src/wydawca.c8
-rw-r--r--src/wydawca.h20
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/Makefile.am14
-rw-r--r--tests/backup01.at33
-rw-r--r--tests/backup02.at43
-rw-r--r--tests/backup03.at41
-rw-r--r--tests/bkupname.c79
-rw-r--r--tests/testsuite.at4
34 files changed, 485 insertions, 779 deletions
diff --git a/Makefile.am b/Makefile.am
index a182931..29641e2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,9 +14,9 @@
14# You should have received a copy of the GNU General Public License 14# You should have received a copy of the GNU General Public License
15# along with wydawca. If not, see <http://www.gnu.org/licenses/>. 15# along with wydawca. If not, see <http://www.gnu.org/licenses/>.
16 16
17ACLOCAL_AMFLAGS = -I m4 -I grecs/am 17ACLOCAL_AMFLAGS = -I grecs/am
18 18
19SUBDIRS=gnu grecs src doc etc tests 19SUBDIRS=grecs src doc etc tests
20 20
21# We never remove files from the configuration directory 21# We never remove files from the configuration directory
22distuninstallcheck_listfiles = \ 22distuninstallcheck_listfiles = \
diff --git a/bootstrap b/bootstrap
index 760a095..ae677ac 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,615 +1,5 @@
1#! /bin/sh 1#! /bin/sh
2 2set -e
3# Bootstrap this package from checked-out sources. 3git submodule init
4 4git submodule update
5# Copyright (C) 2003-2008, 2009 Free Software Foundation, Inc. 5autoreconf -f -i -s
6
7# Dico is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11
12# Dico is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16
17# You should have received a copy of the GNU General Public License
18# along with Dico. If not, see <http://www.gnu.org/licenses/>.
19
20# Written by Paul Eggert.
21
22nl='
23'
24
25# Ensure file names are sorted consistently across platforms.
26LC_ALL=C
27export LC_ALL
28
29local_gl_dir=gl
30
31# Temporary directory names.
32bt='._bootmp'
33bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
34bt2=${bt}2
35
36usage() {
37 echo >&2 "\
38Usage: $0 [OPTION]...
39Bootstrap this package from the checked-out sources.
40
41Options:
42 --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
43 sources reside. Use this if you already
44 have gnulib sources on your machine, and
45 do not want to waste your bandwidth downloading
46 them again.
47 --copy Copy files instead of creating symbolic links.
48 --force Attempt to bootstrap even if the sources seem
49 not to have been checked out.
50 --skip-po Do not download po files.
51
52If the file bootstrap.conf exists in the current working directory, its
53contents are read as shell variables to configure the bootstrap.
54
55Running without arguments will suffice in most cases.
56"
57}
58
59# Configuration.
60
61# Name of the Makefile.am
62gnulib_mk=gnulib.mk
63
64# List of gnulib modules needed.
65gnulib_modules=
66
67# Any gnulib files needed that are not in modules.
68gnulib_files=
69
70# The command to download all .po files for a specified domain into
71# a specified directory. Fill in the first %s is the domain name, and
72# the second with the destination directory. Use rsync's -L and -r
73# options because the latest/%s directory and the .po files within are
74# all symlinks.
75po_download_command_format=\
76"rsync -Lrtvz 'translationproject.org::tp/latest/%s/' '%s'"
77
78extract_package_name='
79 /^AC_INIT(/{
80 /.*,.*,.*, */{
81 s///
82 s/[][]//g
83 s/)$//
84 p
85 q
86 }
87 s/AC_INIT(\[*//
88 s/]*,.*//
89 s/^GNU //
90 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
91 s/[^A-Za-z0-9_]/-/g
92 p
93 }
94'
95package=`sed -n "$extract_package_name" configure.ac` || exit
96gnulib_name=lib$package
97
98build_aux=build-aux
99source_base=lib
100m4_base=m4
101doc_base=doc
102tests_base=tests
103
104# Extra files from gnulib, which override files from other sources.
105gnulib_extra_files="
106 $build_aux/install-sh
107 $build_aux/missing
108 $build_aux/mdate-sh
109 $build_aux/texinfo.tex
110 $build_aux/depcomp
111 $build_aux/config.guess
112 $build_aux/config.sub
113 doc/INSTALL
114"
115
116# Additional gnulib-tool options to use. Use "\newline" to break lines.
117gnulib_tool_option_extras=
118
119# Other locale categories that need message catalogs.
120EXTRA_LOCALE_CATEGORIES=
121
122# Additional xgettext options to use. Use "\\\newline" to break lines.
123XGETTEXT_OPTIONS='\\\
124 --flag=_:1:pass-c-format\\\
125 --flag=N_:1:pass-c-format\\\
126 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
127'
128
129# Package bug report address for gettext files
130MSGID_BUGS_ADDRESS=bug-$package@gnu.org
131
132# Files we don't want to import.
133excluded_files=
134
135# File that should exist in the top directory of a checked out hierarchy,
136# but not in a distribution tarball.
137checkout_only_file=README-hacking
138
139# Whether to use copies instead of symlinks.
140copy=false
141
142# Set this to '.cvsignore .gitignore' in bootstrap.conf if you want
143# those files to be generated in directories like lib/, m4/, and po/.
144# Or set it to 'auto' to make this script select which to use based
145# on which version control system (if any) is used in the source directory.
146vc_ignore=auto
147
148# Override the default configuration, if necessary.
149test -r bootstrap.conf && . ./bootstrap.conf
150
151if test "$vc_ignore" = auto; then
152 vc_ignore=
153 test -d .git && vc_ignore=.gitignore
154 test -d CVS && vc_ignore="$vc_ignore .cvsignore"
155fi
156
157# Translate configuration into internal form.
158
159# Parse options.
160
161for option
162do
163 case $option in
164 --help)
165 usage
166 exit;;
167 --gnulib-srcdir=*)
168 GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
169 --skip-po)
170 SKIP_PO=t;;
171 --force)
172 checkout_only_file=;;
173 --copy)
174 copy=true;;
175 *)
176 echo >&2 "$0: $option: unknown option"
177 exit 1;;
178 esac
179done
180
181if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
182 echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
183 exit 1
184fi
185
186# If $STR is not already on a line by itself in $FILE, insert it,
187# sorting the new contents of the file and replacing $FILE with the result.
188insert_sorted_if_absent() {
189 file=$1
190 str=$2
191 test -f $file || touch $file
192 echo "$str" | sort -u - $file | cmp -s - $file \
193 || echo "$str" | sort -u - $file -o $file \
194 || exit 1
195}
196
197# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
198found_aux_dir=no
199 grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
200 >/dev/null && found_aux_dir=yes
201 grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
202 >/dev/null && found_aux_dir=yes
203if test $found_aux_dir = no; then
204 echo "$0: expected line not found in configure.ac. Add the following:" >&2
205 echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
206 exit 1
207fi
208
209# If $build_aux doesn't exist, create it now, otherwise some bits
210# below will malfunction. If creating it, also mark it as ignored.
211if test ! -d $build_aux; then
212 mkdir $build_aux
213 for dot_ig in x $vc_ignore; do
214 test $dot_ig = x && continue
215 insert_sorted_if_absent $dot_ig $build_aux
216 done
217fi
218
219echo "$0: Bootstrapping from checked-out $package sources..."
220
221cleanup_gnulib() {
222 status=$?
223 rm -fr gnulib
224 exit $status
225}
226
227# Get gnulib files.
228
229case ${GNULIB_SRCDIR--} in
230-)
231 if [ ! -d gnulib ]; then
232 echo "$0: getting gnulib files..."
233
234 trap cleanup_gnulib 1 2 13 15
235
236 git clone --depth 2 git://git.sv.gnu.org/gnulib ||
237 cleanup_gnulib
238
239 trap - 1 2 13 15
240 fi
241 GNULIB_SRCDIR=gnulib
242esac
243
244gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
245<$gnulib_tool || exit
246
247# Get translations.
248
249download_po_files() {
250 subdir=$1
251 domain=$2
252 echo "$0: getting translations into $subdir for $domain..."
253 cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
254 eval "$cmd"
255}
256
257# Download .po files to $po_dir/.reference and copy only the new
258# or modified ones into $po_dir. Also update $po_dir/LINGUAS.
259update_po_files() {
260 # Directory containing primary .po files.
261 # Overwrite them only when we're sure a .po file is new.
262 po_dir=$1
263 domain=$2
264
265 # Download *.po files into this dir.
266 # Usually contains *.s1 checksum files.
267 ref_po_dir="$po_dir/.reference"
268
269 test -d $ref_po_dir || mkdir $ref_po_dir || return
270 download_po_files $ref_po_dir $domain \
271 && ls "$ref_po_dir"/*.po 2>/dev/null |
272 sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS"
273
274 langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
275 test "$langs" = '*' && langs=x
276 for po in `cd $ref_po_dir && echo *.po|sed 's/\.po//g'`; do
277 case $po in x) continue;; esac
278 new_po="$ref_po_dir/$po.po"
279 cksum_file="$ref_po_dir/$po.s1"
280 if ! test -f "$cksum_file" ||
281 ! test -f "$po_dir/$po.po" ||
282 ! sha1sum -c --status "$cksum_file" < "$new_po" > /dev/null; then
283 echo "updated $po_dir/$po.po..."
284 cp "$new_po" "$po_dir/$po.po" && sha1sum < "$new_po" > "$cksum_file"
285 fi
286 done
287}
288
289case $SKIP_PO in
290'')
291 if test -d po; then
292 update_po_files po $package || exit
293 fi
294
295 if test -d runtime-po; then
296 update_po_files runtime-po $package-runtime || exit
297 fi;;
298esac
299
300symlink_to_dir()
301{
302 src=$1/$2
303 dst=${3-$2}
304
305 test -f "$src" && {
306
307 # If the destination directory doesn't exist, create it.
308 # This is required at least for "lib/uniwidth/cjk.h".
309 dst_dir=`dirname "$dst"`
310 if ! test -d "$dst_dir"; then
311 mkdir -p "$dst_dir"
312
313 # If we've just created a directory like lib/uniwidth,
314 # tell version control system(s) it's ignorable.
315 # FIXME: for now, this does only one level
316 parent=`dirname "$dst_dir"`
317 for dot_ig in x $vc_ignore; do
318 test $dot_ig = x && continue
319 ig=$parent/$dot_ig
320 insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'`
321 done
322 fi
323
324 if $copy; then
325 {
326 test ! -h "$dst" || {
327 echo "$0: rm -f $dst" &&
328 rm -f "$dst"
329 }
330 } &&
331 test -f "$dst" &&
332 cmp -s "$src" "$dst" || {
333 echo "$0: cp -fp $src $dst" &&
334 cp -fp "$src" "$dst"
335 }
336 else
337 test -h "$dst" &&
338 src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
339 dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
340 test "$src_i" = "$dst_i" || {
341 dot_dots=
342 case $src in
343 /*) ;;
344 *)
345 case /$dst/ in
346 *//* | */../* | */./* | /*/*/*/*/*/)
347 echo >&2 "$0: invalid symlink calculation: $src -> $dst"
348 exit 1;;
349 /*/*/*/*/)dot_dots=../../../;;
350 /*/*/*/)dot_dots=../../;;
351 /*/*/)dot_dots=../;;
352 esac;;
353 esac
354
355 echo "$0: ln -fs $dot_dots$src $dst" &&
356 ln -fs "$dot_dots$src" "$dst"
357 }
358 fi
359 }
360}
361
362cp_mark_as_generated()
363{
364 cp_src=$1
365 cp_dst=$2
366
367 if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
368 symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst"
369 elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then
370 symlink_to_dir $local_gl_dir "$cp_dst"
371 else
372 case $cp_dst in
373 *.[ch]) c1='/* '; c2=' */';;
374 *.texi) c1='@c '; c2= ;;
375 *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
376 *) c1= ; c2= ;;
377 esac
378
379 # If the destination directory doesn't exist, create it.
380 # This is required at least for "lib/uniwidth/cjk.h".
381 dst_dir=`dirname "$cp_dst"`
382 test -d "$dst_dir" || mkdir -p "$dst_dir"
383
384 if test -z "$c1"; then
385 cmp -s "$cp_src" "$cp_dst" || {
386 echo "$0: cp -f $cp_src $cp_dst" &&
387 rm -f "$cp_dst" &&
388 sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst"
389 }
390 else
391 # Copy the file first to get proper permissions if it
392 # doesn't already exist. Then overwrite the copy.
393 cp "$cp_src" "$cp_dst-t" &&
394 (
395 echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
396 echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
397 sed "s!$bt_regex/!!g" "$cp_src"
398 ) > $cp_dst-t &&
399 if cmp -s "$cp_dst-t" "$cp_dst"; then
400 rm -f "$cp_dst-t"
401 else
402 echo "$0: cp $cp_src $cp_dst # with edits" &&
403 mv -f "$cp_dst-t" "$cp_dst"
404 fi
405 fi
406 fi
407}
408
409version_controlled_file() {
410 dir=$1
411 file=$2
412 found=no
413 if test -d CVS; then
414 grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
415 grep '^/[^/]*/[0-9]' > /dev/null && found=yes
416 elif test -d .git; then
417 git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
418 elif test -d .svn; then
419 svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes
420 else
421 echo "$0: no version control for $dir/$file?" >&2
422 fi
423 test $found = yes
424}
425
426slurp() {
427 for dir in . `(cd $1 && find * -type d -print)`; do
428 copied=
429 sep=
430 for file in `ls -a $1/$dir`; do
431 case $file in
432 .|..) continue;;
433 .*) continue;; # FIXME: should all file names starting with "." be ignored?
434 esac
435 test -d $1/$dir/$file && continue
436 for excluded_file in $excluded_files; do
437 test "$dir/$file" = "$excluded_file" && continue 2
438 done
439 if test $file = Makefile.am; then
440 copied=$copied${sep}$gnulib_mk; sep=$nl
441 remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
442 sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
443 echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
444 rm -f $dir/$gnulib_mk &&
445 sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
446 }
447 elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
448 version_controlled_file $dir $file; then
449 echo "$0: $dir/$file overrides $1/$dir/$file"
450 else
451 copied=$copied$sep$file; sep=$nl
452 if test $file = gettext.m4; then
453 echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
454 rm -f $dir/$file
455 sed '
456 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
457 AC_DEFUN([AM_INTL_SUBDIR], [
458 /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
459 AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
460 $a\
461 AC_DEFUN([gl_LOCK_EARLY], [])
462 ' $1/$dir/$file >$dir/$file
463 else
464 cp_mark_as_generated $1/$dir/$file $dir/$file
465 fi
466 fi || exit
467 done
468
469 for dot_ig in x $vc_ignore; do
470 test $dot_ig = x && continue
471 ig=$dir/$dot_ig
472 if test -n "$copied"; then
473 insert_sorted_if_absent $ig "$copied"
474 # If an ignored file name ends with .in.h, then also add
475 # the name with just ".h". Many gnulib headers are generated,
476 # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
477 # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
478 f=`echo "$copied"|sed 's/\.in\.h$/.h/;s/\.sin$/.sed/;s/\.y$/.c/;s/\.gperf$/.h/'`
479 insert_sorted_if_absent $ig "$f"
480
481 # For files like sys_stat.in.h and sys_time.in.h, record as
482 # ignorable the directory we might eventually create: sys/.
483 f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
484 insert_sorted_if_absent $ig "$f"
485 fi
486 done
487 done
488}
489
490
491# Create boot temporary directories to import from gnulib and gettext.
492rm -fr $bt $bt2 &&
493mkdir $bt $bt2 || exit
494
495# Import from gnulib.
496
497gnulib_tool_options="\
498 --import\
499 --no-changelog\
500 --aux-dir $bt/$build_aux\
501 --doc-base $bt/$doc_base\
502 --lib $gnulib_name\
503 --m4-base $bt/$m4_base/\
504 --source-base $bt/$source_base/\
505 --tests-base $bt/$tests_base\
506 --local-dir $local_gl_dir\
507 $gnulib_tool_option_extras\
508"
509echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
510$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
511slurp $bt || exit
512
513for file in $gnulib_files; do
514 symlink_to_dir "$GNULIB_SRCDIR" $file || exit
515done
516
517
518# Import from gettext.
519with_gettext=yes
520 grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
521 with_gettext=no
522
523if test $with_gettext = yes; then
524 echo "$0: (cd $bt2; autopoint) ..."
525 cp configure.ac $bt2 &&
526 (cd $bt2 && autopoint && rm configure.ac) &&
527 slurp $bt2 $bt || exit
528
529 rm -fr $bt $bt2 || exit
530fi
531
532# Coreutils is unusual in that it generates some of its test-related
533# Makefile.am files. That must be done before invoking automake.
534mam_template=tests/Makefile.am.in
535if test -f $mam_template; then
536 PERL=perl
537 for tool in cut head join pr sort tac tail test tr uniq wc; do
538 m=tests/$tool/Makefile.am
539 t=${m}t
540 rm -f $m $t
541 sed -n '1,/^##test-files-begin/p' $mam_template > $t
542 echo "x = $tool" >> $t
543 srcdir=tests/$tool
544 $PERL -I$srcdir -w -- tests/mk-script $srcdir --list >> $t
545 sed -n '/^##test-files-end/,$p' $mam_template >> $t
546 chmod -w $t
547 mv $t $m
548 done
549fi
550
551# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
552# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
553# The following requires GNU find 4.2.3 or newer. Considering the usual
554# portability constraints of this script, that may seem a very demanding
555# requirement, but it should be ok. Ignore any failure, which is fine,
556# since this is only a convenience to help developers avoid the relatively
557# unusual case in which a symlinked-to .m4 file is git-removed from gnulib
558# between successive runs of this script.
559find "$m4_base" "$source_base" \
560 -depth \( -name '*.m4' -o -name '*.[ch]' \) \
561 -type l -xtype l -delete > /dev/null 2>&1
562
563# Reconfigure, getting other files.
564
565echo "$0: autoreconf --force --install --symlink ..."
566autoreconf --force --install --symlink
567
568# FIXME: A kludge to avoid unnecessary data in the distribution.
569test -d libltdl/config && rm -rf libltdl/config
570test -d libltdl/m4 && rm -rf libltdl/m4
571
572# Get some extra files from gnulib, overriding existing files.
573for file in $gnulib_extra_files; do
574 case $file in
575 */INSTALL) dst=INSTALL;;
576 build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
577 *) dst=$file;;
578 esac
579 symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
580done
581
582if test $with_gettext = yes; then
583 # Create gettext configuration.
584 echo "$0: Creating po/Makevars from po/Makevars.template ..."
585 rm -f po/Makevars
586 sed '
587 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
588 /^MSGID_BUGS_ADDRESS *=/s/=.*/= '"$MSGID_BUGS_ADDRESS"'/
589 /^XGETTEXT_OPTIONS *=/{
590 s/$/ \\/
591 a\
592 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
593 }
594 ' po/Makevars.template >po/Makevars
595
596 if test -d runtime-po; then
597 # Similarly for runtime-po/Makevars, but not quite the same.
598 rm -f runtime-po/Makevars
599 sed '
600 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
601 /^subdir *=.*/s/=.*/= runtime-po/
602 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
603 /^XGETTEXT_OPTIONS *=/{
604 s/$/ \\/
605 a\
606 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
607 }
608 ' <po/Makevars.template >runtime-po/Makevars
609
610 # Copy identical files from po to runtime-po.
611 (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
612 fi
613fi
614
615echo "$0: done. Now you can run './configure'."
diff --git a/bootstrap.conf b/bootstrap.conf
deleted file mode 100644
index 8464d0d..0000000
--- a/bootstrap.conf
+++ b/dev/null
@@ -1,68 +0,0 @@
1# Bootstrap configuration.
2
3# Copyright (C) 2007, 2009, 2010 Sergey Poznyakoff
4#
5# Wydawca is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3, or (at your option)
8# any later version.
9#
10# Wydawca is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with wydawca. If not, see <http://www.gnu.org/licenses/>.
17
18source_base=gnu
19gnulib_name=libgnu
20gnulib_mk=Makefile.am
21
22test -d $source_base || mkdir -p $source_base
23
24git submodule init || exit $?
25git submodule update || exit $?
26
27# We don't need these modules, even though gnulib-tool mistakenly
28# includes them because of gettext dependencies.
29avoided_gnulib_modules='
30 --avoid=lock
31 --avoid=size_max
32'
33
34# gnulib modules used by this package.
35gnulib_modules="`grep -h '^[^#]' gnulib.modules | sort | uniq`"
36
37# Additional xgettext options to use. Use "\\\newline" to break lines.
38XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
39 --flag=_:1:pass-c-format\\\
40 --flag=N_:1:pass-c-format\\\
41 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
42 --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format\\\
43 --flag=gconf_warning:3:c-format\\\
44 --flag=gconf_error:3:c-format\\\
45'
46
47# Gettext supplies these files, but we don't need them since
48# we don't have an intl subdirectory.
49excluded_files='
50 m4/glibc2.m4
51 m4/intdiv0.m4
52 m4/lcmessage.m4
53 m4/lock.m4
54 m4/uintmax_t.m4
55 m4/ulonglong.m4
56 m4/visibility.m4
57'
58
59# Read local configuration file
60if [ -r .bootstrap ]; then
61 echo "$0: Reading configuration file .bootstrap"
62 eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*"
63fi
64
65test -f Changelog || cat > ChangeLog <<EOT
66This file is a placeholder. It will be replaced with the actual ChangeLog
67by make dist. Run make ChangeLog if you wish to create it earlier.
68EOT
diff --git a/configure.ac b/configure.ac
index 7002fb9..344c3b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,9 +26,6 @@ AM_SILENT_RULES([yes])
26 26
27# Checks for programs. 27# Checks for programs.
28AC_PROG_CC 28AC_PROG_CC
29 gl_EARLY
30AC_PROG_LEX
31AC_PROG_YACC
32AC_PROG_RANLIB 29AC_PROG_RANLIB
33 30
34# Checks for libraries. 31# Checks for libraries.
@@ -47,7 +44,6 @@ AC_TYPE_SIZE_T
47AC_HEADER_STDBOOL 44AC_HEADER_STDBOOL
48 45
49# Checks for library functions. 46# Checks for library functions.
50gl_INIT
51AC_FUNC_FORK 47AC_FUNC_FORK
52AC_FUNC_MALLOC 48AC_FUNC_MALLOC
53AC_FUNC_MEMCMP 49AC_FUNC_MEMCMP
@@ -135,7 +131,6 @@ fi
135 131
136AC_CONFIG_FILES([Makefile 132AC_CONFIG_FILES([Makefile
137 doc/Makefile 133 doc/Makefile
138 gnu/Makefile
139 src/Makefile 134 src/Makefile
140 etc/Makefile]) 135 etc/Makefile])
141 136
diff --git a/gnulib.modules b/gnulib.modules
deleted file mode 100644
index dd5124a..0000000
--- a/gnulib.modules
+++ b/dev/null
@@ -1,4 +0,0 @@
1xalloc
2getline
3mkdtemp
4backupfile
diff --git a/grecs b/grecs
Subproject f8ca129aaf4876dfa9778c34ed5bd8a669ca22e Subproject 4c1056b45580fcb687cac656834f42dd9fba4ae
diff --git a/src/Makefile.am b/src/Makefile.am
index 8139849..3b524ba 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,6 +16,7 @@
16 16
17sbin_PROGRAMS=wydawca 17sbin_PROGRAMS=wydawca
18wydawca_SOURCES=\ 18wydawca_SOURCES=\
19 backup.c\
19 builtin.c\ 20 builtin.c\
20 builtin.h\ 21 builtin.h\
21 cmdline.h\ 22 cmdline.h\
@@ -60,8 +61,8 @@ SUFFIXES=.opt .c .h
60incdir=$(pkgdatadir)/$(VERSION)/include 61incdir=$(pkgdatadir)/$(VERSION)/include
61inc_DATA = $(PP_SETUP_FILE) 62inc_DATA = $(PP_SETUP_FILE)
62 63
63LDADD=../grecs/src/libgrecs.a ../gnu/libgnu.a @SQLLIB@ @GPGMELIB@ @MAILUTILS_LIBS@ 64LDADD=../grecs/src/libgrecs.a @SQLLIB@ @GPGMELIB@ @MAILUTILS_LIBS@
64INCLUDES = -I$(top_srcdir)/grecs/src/ -I$(top_srcdir)/gnu -I../gnu @MAILUTILS_INCLUDES@ 65INCLUDES = -I$(top_srcdir)/grecs/src/ @MAILUTILS_INCLUDES@
65AM_CPPFLAGS= \ 66AM_CPPFLAGS= \
66 -DSYSCONFDIR=\"$(sysconfdir)\"\ 67 -DSYSCONFDIR=\"$(sysconfdir)\"\
67 -DLOCALSTATEDIR=\"$(localstatedir)\"\ 68 -DLOCALSTATEDIR=\"$(localstatedir)\"\
diff --git a/src/backup.c b/src/backup.c
new file mode 100644
index 0000000..312375d
--- a/dev/null
+++ b/src/backup.c
@@ -0,0 +1,165 @@
1/* wydawca - automatic release submission daemon
2 Copyright (C) 2011 Sergey Poznyakoff
3
4 Wydawca 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 Wydawca 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 wydawca. If not, see <http://www.gnu.org/licenses/>. */
16
17#include "wydawca.h"
18
19char const *simple_backup_suffix = "~";
20
21static const char *
22split_filename (char const *file, char **pdir)
23{
24 const char *p = strrchr (file, '/');
25
26 if (!p)
27 {
28 *pdir = grecs_strdup (".");
29 p = file;
30 }
31 else
32 {
33 size_t len = p - file;
34 char *dir = grecs_malloc (len + 1);
35 memcpy (dir, file, len);
36 dir[len] = 0;
37 *pdir = dir;
38 p++;
39 }
40 return p;
41}
42
43#define MINSUFSIZE 8
44#define ISDIGIT(c) ('0' <= (c) && (c) <= '9')
45
46static char *
47get_backup_suffix (char const *file, enum backup_type type)
48{
49 char *dirname;
50 const char *basename;
51 size_t baselen;
52 DIR *dir;
53 struct dirent *ent;
54 char *lastsuf = NULL;
55 size_t lastsuflen = 0;
56 size_t lastsufsize = 0;
57 int carry;
58 char *newsuf;
59 char *q;
60
61 if (type == simple_backups)
62 return grecs_strdup (simple_backup_suffix);
63
64 basename = split_filename (file, &dirname);
65 baselen = strlen (basename);
66 dir = opendir (dirname);
67 if (!dir)
68 {
69 int ec = errno;
70 free (dirname);
71 errno = ec;
72 return NULL;
73 }
74
75 while ((ent = readdir (dir)))
76 {
77 size_t len = strlen (ent->d_name);
78 const char *p;
79 size_t suflen;
80
81 if (len < baselen + 4 || memcmp (ent->d_name, basename, baselen))
82 continue;
83 p = ent->d_name + baselen;
84 suflen = len - baselen;
85 if (p[0] == '.' && p[1] == '~' && p[suflen-1] == '~' &&
86 (suflen > lastsuflen
87 || (suflen == lastsuflen &&
88 memcmp (p, lastsuf, lastsuflen) > 0)))
89 {
90 carry = 1;
91 for (q = (char*) p + suflen - 2; q > p + 1 && ISDIGIT (*q); q--)
92 if (*q != '9')
93 carry = 0;
94 q++;
95 if (!ISDIGIT (*q))
96 continue;
97
98 if (suflen > lastsufsize)
99 {
100 lastsufsize = suflen;
101 if (!lastsuf)
102 {
103 if (lastsufsize < MINSUFSIZE)
104 lastsufsize = MINSUFSIZE;
105 lastsuf = grecs_malloc (lastsufsize);
106 }
107 else
108 lastsuf = grecs_realloc (lastsuf, lastsufsize);
109 }
110 memcpy (lastsuf, p, suflen);
111 lastsuflen = suflen;
112 }
113 }
114 closedir (dir);
115 free (dirname);
116
117 if (lastsuf)
118 {
119 size_t newsuflen;
120
121 newsuflen = lastsuflen + carry;
122 newsuf = grecs_malloc (newsuflen + 1);
123 newsuf[0] = '.';
124 newsuf[1] = '~';
125 newsuf[2] = '0';
126 memcpy (newsuf + 2 + carry, lastsuf + 2, lastsuflen - 3);
127 newsuf[newsuflen-1] = '~';
128 newsuf[newsuflen] = 0;
129
130 for (q = newsuf + newsuflen - 2; *q == '9'; q--)
131 *q = '0';
132 ++*q;
133 free (lastsuf);
134 }
135 else if (type == numbered_existing_backups)
136 newsuf = grecs_strdup (simple_backup_suffix);
137 else
138 newsuf = grecs_strdup (".~1~");
139 return newsuf;
140}
141
142char *
143find_backup_file_name (char const *file, enum backup_type type)
144{
145 size_t flen;
146 char *suffix;
147 char *newname;
148
149 if (type == no_backups)
150 {
151 errno = 0;
152 return NULL;
153 }
154
155 suffix = get_backup_suffix (file, type);
156 if (!suffix)
157 return NULL;
158 flen = strlen (file);
159 newname = grecs_malloc (flen + strlen (suffix) + 1);
160 memcpy (newname, file, flen);
161 strcpy (newname + flen, suffix);
162 free (suffix);
163 /* FIXME: Check newname length */
164 return newname;
165}
diff --git a/src/builtin.c b/src/builtin.c
index 9d1063c..8a07eab 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -16,8 +16,10 @@
16 16
17#include "wydawca.h" 17#include "wydawca.h"
18#include "builtin.h" 18#include "builtin.h"
19#include "fnmatch.h" 19
20#include "regex.h" 20#ifndef FNM_CASEFOLD
21# define FNM_CASEFOLD 0
22#endif
21 23
22int 24int
23builtin_init (struct dictionary *dict) 25builtin_init (struct dictionary *dict)
@@ -220,9 +222,9 @@ builtin_lookup (struct dictionary *dict, void *handle, const char *req)
220 size_t i; 222 size_t i;
221 char *p; 223 char *p;
222 224
223 bds = xmalloc (sizeof (*bds)); 225 bds = grecs_malloc (sizeof (*bds));
224 count *= ncol; 226 count *= ncol;
225 bds->wp = xcalloc (count, sizeof (bds->wp[0])); 227 bds->wp = grecs_calloc (count, sizeof (bds->wp[0]));
226 bds->acc = acc; 228 bds->acc = acc;
227 p = txtacc_finish (acc, 0); 229 p = txtacc_finish (acc, 0);
228 230
diff --git a/src/config.c b/src/config.c
index df9816e..8250749 100644
--- a/src/config.c
+++ b/src/config.c
@@ -146,7 +146,7 @@ safe_file_name (char *file_name)
146char * 146char *
147safe_file_name_alloc (const char *file_name) 147safe_file_name_alloc (const char *file_name)
148{ 148{
149 char *s = xstrdup (file_name); 149 char *s = grecs_strdup (file_name);
150 char *ns = safe_file_name (s); 150 char *ns = safe_file_name (s);
151 if (!ns) 151 if (!ns)
152 free (s); 152 free (s);
@@ -549,8 +549,8 @@ cb_sql_host (enum grecs_callback_command cmd,
549 *p++ = 0; 549 *p++ = 0;
550 if (p[0] == '/') 550 if (p[0] == '/')
551 { 551 {
552 pconn->socket = xstrdup (p); 552 pconn->socket = grecs_strdup (p);
553 pconn->host = xstrdup ("localhost"); 553 pconn->host = grecs_strdup ("localhost");
554 } 554 }
555 else 555 else
556 { 556 {
@@ -569,11 +569,11 @@ cb_sql_host (enum grecs_callback_command cmd,
569 } 569 }
570 pconn->port = n; 570 pconn->port = n;
571 /* Save host name */ 571 /* Save host name */
572 pconn->host = xstrdup (value->v.string); 572 pconn->host = grecs_strdup (value->v.string);
573 } 573 }
574 } 574 }
575 else 575 else
576 pconn->host = xstrdup (value->v.string); 576 pconn->host = grecs_strdup (value->v.string);
577 return 0; 577 return 0;
578} 578}
579 579
@@ -594,7 +594,7 @@ cb_sql (enum grecs_callback_command cmd,
594 grecs_error(locus, 0, _("tag must be a string")); 594 grecs_error(locus, 0, _("tag must be a string"));
595 return 0; 595 return 0;
596 } 596 }
597 pconn = xzalloc (sizeof (*pconn)); 597 pconn = grecs_zalloc (sizeof (*pconn));
598 pconn->ident = strdup (value->v.string); 598 pconn->ident = strdup (value->v.string);
599 *pdata = pconn; 599 *pdata = pconn;
600 break; 600 break;
@@ -896,7 +896,7 @@ cb_notify_event (enum grecs_callback_command cmd,
896 896
897 switch (cmd) { 897 switch (cmd) {
898 case grecs_callback_section_begin: 898 case grecs_callback_section_begin:
899 ntf = xzalloc (sizeof (*ntf)); 899 ntf = grecs_zalloc (sizeof (*ntf));
900 *pdata = ntf; 900 *pdata = ntf;
901 break; 901 break;
902 902
@@ -984,7 +984,7 @@ cb_dictionary_params (enum grecs_callback_command cmd,
984 struct grecs_list_entry *ep; 984 struct grecs_list_entry *ep;
985 985
986 meth->parmc = size; 986 meth->parmc = size;
987 meth->parmv = xcalloc (size + 1, sizeof (meth->parmv[0])); 987 meth->parmv = grecs_calloc (size + 1, sizeof (meth->parmv[0]));
988 988
989 for (i = 0, ep = value->v.list->head; ep; ep = ep->next, i++) 989 for (i = 0, ep = value->v.list->head; ep; ep = ep->next, i++)
990 { 990 {
@@ -993,7 +993,7 @@ cb_dictionary_params (enum grecs_callback_command cmd,
993 if (assert_string_arg (locus, cmd, vp)) 993 if (assert_string_arg (locus, cmd, vp))
994 break; 994 break;
995 995
996 meth->parmv[i] = xstrdup (vp->v.string); 996 meth->parmv[i] = grecs_strdup (vp->v.string);
997 } 997 }
998 meth->parmv[i] = NULL; 998 meth->parmv[i] = NULL;
999 } 999 }
@@ -1159,8 +1159,8 @@ cb_spool (enum grecs_callback_command cmd,
1159 grecs_error (locus, 0, _("tag must be a string")); 1159 grecs_error (locus, 0, _("tag must be a string"));
1160 return 1; 1160 return 1;
1161 } 1161 }
1162 spool = xzalloc (sizeof (*spool)); 1162 spool = grecs_zalloc (sizeof (*spool));
1163 spool->tag = xstrdup (value->v.string); 1163 spool->tag = grecs_strdup (value->v.string);
1164 spool->file_sweep_time = file_sweep_time; 1164 spool->file_sweep_time = file_sweep_time;
1165 for (i = 0; i < NITEMS (spool->dictionary); i++) 1165 for (i = 0; i < NITEMS (spool->dictionary); i++)
1166 spool->dictionary[i] = default_dictionary[i]; 1166 spool->dictionary[i] = default_dictionary[i];
@@ -1277,8 +1277,8 @@ cb_supp_groups (enum grecs_callback_command cmd,
1277 int i; 1277 int i;
1278 struct grecs_list_entry *ep; 1278 struct grecs_list_entry *ep;
1279 1279
1280 wydawca_supp_groups = xcalloc (wydawca_supp_groupc, 1280 wydawca_supp_groups = grecs_calloc (wydawca_supp_groupc,
1281 sizeof (wydawca_supp_groups[0])); 1281 sizeof (wydawca_supp_groups[0]));
1282 1282
1283 for (i = 0, ep = value->v.list->head; ep; ep = ep->next, i++) 1283 for (i = 0, ep = value->v.list->head; ep; ep = ep->next, i++)
1284 { 1284 {
diff --git a/src/dictionary.c b/src/dictionary.c
index b7baf05..2b995d4 100644
--- a/src/dictionary.c
+++ b/src/dictionary.c
@@ -48,8 +48,7 @@ static struct dictionary_descr dictionary_tab[] = {
48struct dictionary * 48struct dictionary *
49dictionary_new (enum dictionary_id id, enum dictionary_type type) 49dictionary_new (enum dictionary_id id, enum dictionary_type type)
50{ 50{
51 struct dictionary *mp = xmalloc (sizeof mp[0]); 51 struct dictionary *mp = grecs_zalloc (sizeof mp[0]);
52 memset (mp, 0, sizeof mp[0]);
53 mp->id = id; 52 mp->id = id;
54 mp->type = type; 53 mp->type = type;
55 return mp; 54 return mp;
@@ -92,6 +91,8 @@ int
92dictionary_close (struct dictionary *dict, void *handle) 91dictionary_close (struct dictionary *dict, void *handle)
93{ 92{
94 struct dictionary_descr *mp = dictionary_tab + dict->type; 93 struct dictionary_descr *mp = dictionary_tab + dict->type;
94 if (mp->free)
95 mp->free (dict, handle);
95 if (!mp->close) 96 if (!mp->close)
96 return 0; 97 return 0;
97 return mp->close (dict, handle); 98 return mp->close (dict, handle);
@@ -186,7 +187,7 @@ dictionary_copy_result (struct dictionary *dict, const char *res, size_t size)
186 if (dict->result_size < size + 1) 187 if (dict->result_size < size + 1)
187 { 188 {
188 dict->result_size = size + 1; 189 dict->result_size = size + 1;
189 dict->result = x2realloc (dict->result, &dict->result_size); 190 dict->result = grecs_realloc (dict->result, dict->result_size);
190 } 191 }
191 memcpy (dict->result, res, size); 192 memcpy (dict->result, res, size);
192 dict->result[size] = 0; 193 dict->result[size] = 0;
@@ -206,7 +207,7 @@ dictionary_quote_string (struct dictionary *dict, void *handle,
206 207
207 if (!input) 208 if (!input)
208 { 209 {
209 *poutput = xmalloc (1); 210 *poutput = grecs_malloc (1);
210 (*poutput)[0] = 0; 211 (*poutput)[0] = 0;
211 *psize = 1; 212 *psize = 1;
212 return 0; 213 return 0;
@@ -216,7 +217,7 @@ dictionary_quote_string (struct dictionary *dict, void *handle,
216 return mp->quote (dict, handle, input, poutput, psize); 217 return mp->quote (dict, handle, input, poutput, psize);
217 218
218 size = wordsplit_c_quoted_length (input, 0, &quote); 219 size = wordsplit_c_quoted_length (input, 0, &quote);
219 output = xmalloc (size + 1); 220 output = grecs_malloc (size + 1);
220 wordsplit_c_quote_copy (output, input, 0); 221 wordsplit_c_quote_copy (output, input, 0);
221 output[size] = 0; 222 output[size] = 0;
222 223
diff --git a/src/directive.c b/src/directive.c
index 08a14df..fadaedf 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -34,7 +34,7 @@ directive_parse (struct file_triplet *trp)
34 if (*p == '\n') 34 if (*p == '\n')
35 dcount++; 35 dcount++;
36 36
37 trp->directive = xcalloc (dcount + 1, sizeof trp->directive[0]); 37 trp->directive = grecs_calloc (dcount + 1, sizeof trp->directive[0]);
38 p = trp->blurb; 38 p = trp->blurb;
39 for (i = j = 0; i < dcount; i++) 39 for (i = j = 0; i < dcount; i++)
40 { 40 {
@@ -111,7 +111,7 @@ _directive_seq_get (int n, struct file_triplet *trp,
111 if (len + 1 > trp->tmpsize) 111 if (len + 1 > trp->tmpsize)
112 { 112 {
113 trp->tmpsize = len + 1; 113 trp->tmpsize = len + 1;
114 trp->tmp = x2realloc (trp->tmp, &trp->tmpsize); 114 trp->tmp = grecs_realloc (trp->tmp, trp->tmpsize);
115 } 115 }
116 memcpy (trp->tmp, trp->directive[n], len); 116 memcpy (trp->tmp, trp->directive[n], len);
117 trp->tmp[len] = 0; 117 trp->tmp[len] = 0;
@@ -380,7 +380,7 @@ stderr_redirector (const char *tag)
380 fp = fdopen (p[0], "r"); 380 fp = fdopen (p[0], "r");
381 if (!fp) 381 if (!fp)
382 _exit (127); 382 _exit (127);
383 while (getline (&buf, &size, fp) >= 0) 383 while (grecs_getline (&buf, &size, fp) >= 0)
384 { 384 {
385 trim_crlf (buf); 385 trim_crlf (buf);
386 logmsg (LOG_NOTICE, "%s: %s", tag, buf); 386 logmsg (LOG_NOTICE, "%s: %s", tag, buf);
@@ -493,7 +493,7 @@ run_check_script (const char *script, struct file_triplet *trp,
493 size = total = 0; 493 size = total = 0;
494 if (debug_level > 2) 494 if (debug_level > 2)
495 logmsg (LOG_DEBUG, _("reading script output...")); 495 logmsg (LOG_DEBUG, _("reading script output..."));
496 while (getline (&buf, &size, fp) > 0) 496 while (grecs_getline (&buf, &size, fp) > 0)
497 { 497 {
498 size_t len = strlen (buf); 498 size_t len = strlen (buf);
499 if (debug_level > 2) 499 if (debug_level > 2)
diff --git a/src/diskio.c b/src/diskio.c
index 9addd9b..b175a45 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -46,7 +46,7 @@ concat_dir (const char *base, const char *name, size_t *pbaselen)
46 len--; 46 len--;
47 47
48 size = len + 1 + strlen (name); 48 size = len + 1 + strlen (name);
49 dir = xmalloc (size + 1); 49 dir = grecs_malloc (size + 1);
50 memcpy (dir, base, len); 50 memcpy (dir, base, len);
51 dir[len++] = '/'; 51 dir[len++] = '/';
52 strcpy (dir + len, name); 52 strcpy (dir + len, name);
@@ -171,7 +171,7 @@ copy_file (const char *file, const char *dst_file)
171 bufsize /= 2) 171 bufsize /= 2)
172 ; 172 ;
173 if (bufsize == 0) 173 if (bufsize == 0)
174 xalloc_die (); 174 grecs_alloc_die ();
175 175
176 rc = 0; 176 rc = 0;
177 while (fsize > 0) 177 while (fsize > 0)
@@ -492,7 +492,7 @@ make_signame (const char *file_name)
492 if (((len = strlen (file_name)) > SUF_SIG_LEN 492 if (((len = strlen (file_name)) > SUF_SIG_LEN
493 && memcmp (file_name + len - SUF_SIG_LEN, SUF_SIG, SUF_SIG_LEN))) 493 && memcmp (file_name + len - SUF_SIG_LEN, SUF_SIG, SUF_SIG_LEN)))
494 { 494 {
495 char *signame = xmalloc (len + SUF_SIG_LEN + 1); 495 char *signame = grecs_malloc (len + SUF_SIG_LEN + 1);
496 strcpy (signame, file_name); 496 strcpy (signame, file_name);
497 return strcat (signame, SUF_SIG); 497 return strcat (signame, SUF_SIG);
498 } 498 }
diff --git a/src/exec.c b/src/exec.c
index ed7ee1e..7ebf152 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -75,7 +75,7 @@ log_output (int prio, const char *prog, FILE *fp)
75 char *buf = NULL; 75 char *buf = NULL;
76 76
77 logmsg (prio, _("%s output follows:"), prog); 77 logmsg (prio, _("%s output follows:"), prog);
78 while (getline (&buf, &size, fp) > 0) 78 while (grecs_getline (&buf, &size, fp) > 0)
79 logmsg (prio, "%s", buf); 79 logmsg (prio, "%s", buf);
80 logmsg (prio, _("end of %s output"), prog); 80 logmsg (prio, _("end of %s output"), prog);
81 free (buf); 81 free (buf);
diff --git a/src/gpg.c b/src/gpg.c
index 474d94b..d4f9b71 100644
--- a/src/gpg.c
+++ b/src/gpg.c
@@ -132,7 +132,7 @@ create_gpg_homedir ()
132 if (temp_homedir) 132 if (temp_homedir)
133 return 0; 133 return 0;
134 134
135 temp_homedir = xstrdup ("/tmp/wydawca-XXXXXX"); 135 temp_homedir = grecs_strdup ("/tmp/wydawca-XXXXXX");
136 if (!mkdtemp (temp_homedir)) 136 if (!mkdtemp (temp_homedir))
137 { 137 {
138 logmsg (LOG_CRIT, _("cannot create GPG home directory (%s): %s"), 138 logmsg (LOG_CRIT, _("cannot create GPG home directory (%s): %s"),
@@ -237,7 +237,7 @@ verify_directive_signature (struct file_triplet *trp)
237 fail_if_err (gpgme_op_import (ctx, key_data)); 237 fail_if_err (gpgme_op_import (ctx, key_data));
238 res = gpgme_op_import_result (ctx); 238 res = gpgme_op_import_result (ctx);
239 pstat = res->imports; 239 pstat = res->imports;
240 uptr->fpr = xstrdup (pstat->fpr); 240 uptr->fpr = grecs_strdup (pstat->fpr);
241 if (debug_level > 2) 241 if (debug_level > 2)
242 logmsg (LOG_DEBUG, _("imported key: user = %s, fingerprint = %s"), 242 logmsg (LOG_DEBUG, _("imported key: user = %s, fingerprint = %s"),
243 uptr->name, uptr->fpr); 243 uptr->name, uptr->fpr);
@@ -271,7 +271,8 @@ verify_directive_signature (struct file_triplet *trp)
271 271
272 gpgme_data_release (directive_data); 272 gpgme_data_release (directive_data);
273 gpgme_data_release (key_data); 273 gpgme_data_release (key_data);
274 274 gpgme_release (ctx);
275
275 return rc; 276 return rc;
276} 277}
277 278
diff --git a/src/job.c b/src/job.c
index 7e3fdf5..764e463 100644
--- a/src/job.c
+++ b/src/job.c
@@ -205,7 +205,7 @@ schedule_job (const struct spool *spool, uid_t uid)
205 job = job_locate (spool, uid); 205 job = job_locate (spool, uid);
206 if (!job) 206 if (!job)
207 { 207 {
208 job = xzalloc (sizeof (*job)); 208 job = grecs_zalloc (sizeof (*job));
209 job->spool = spool; 209 job->spool = spool;
210 job->uid = uid; 210 job->uid = uid;
211 job->pid = -1; 211 job->pid = -1;
diff --git a/src/lock.c b/src/lock.c
index 32367de..dece75d 100644
--- a/src/lock.c
+++ b/src/lock.c
@@ -187,15 +187,15 @@ host_name ()
187 if (!hostbuf) 187 if (!hostbuf)
188 { 188 {
189 size = 256; 189 size = 256;
190 hostbuf = xmalloc (size); 190 hostbuf = grecs_malloc (size);
191 } 191 }
192 else 192 else
193 { 193 {
194 size_t ns = size * 2; 194 size_t ns = size * 2;
195 if (size < ns) 195 if (size < ns)
196 xalloc_die (); 196 grecs_alloc_die ();
197 size = ns; 197 size = ns;
198 hostbuf = xrealloc (hostbuf, size); 198 hostbuf = grecs_realloc (hostbuf, size);
199 } 199 }
200 } 200 }
201 while ((rc = gethostname (hostbuf, size )) == -1 && 201 while ((rc = gethostname (hostbuf, size )) == -1 &&
@@ -261,7 +261,7 @@ wydawca_unlock (const char *lockfile)
261static char * 261static char *
262fix_tagname (const char *tag) 262fix_tagname (const char *tag)
263{ 263{
264 char *tagname = xstrdup (tag); 264 char *tagname = grecs_strdup (tag);
265 char *p; 265 char *p;
266 266
267 for (p = tagname; *p; p++) 267 for (p = tagname; *p; p++)
@@ -278,7 +278,7 @@ wydawca_lockname (const char *tag)
278 char *tagname = fix_tagname (tag); 278 char *tagname = fix_tagname (tag);
279 grecs_asprintf (&lockname, &size, "%s/LCK.%s", lockdir, tagname); 279 grecs_asprintf (&lockname, &size, "%s/LCK.%s", lockdir, tagname);
280 if (!lockname) 280 if (!lockname)
281 xalloc_die (); 281 grecs_alloc_die ();
282 free (tagname); 282 free (tagname);
283 return lockname; 283 return lockname;
284} 284}
@@ -289,7 +289,7 @@ wydawca_lock_init ()
289 if (enable_locking) 289 if (enable_locking)
290 { 290 {
291 if (!lockdir) 291 if (!lockdir)
292 lockdir = xstrdup (LOCALSTATEDIR "/lock/" PACKAGE); 292 lockdir = grecs_strdup (LOCALSTATEDIR "/lock/" PACKAGE);
293 if (create_hierarchy (lockdir, 0)) 293 if (create_hierarchy (lockdir, 0))
294 exit (EX_OSFILE); 294 exit (EX_OSFILE);
295 } 295 }
diff --git a/src/mail.c b/src/mail.c
index bac0381..6855ed7 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -291,7 +291,7 @@ mail_send_message (mu_address_t rcpt, const char *text,
291 if (rcpt) 291 if (rcpt)
292 { 292 {
293 mu_address_to_string (rcpt, NULL, 0, &size); 293 mu_address_to_string (rcpt, NULL, 0, &size);
294 buf = xmalloc (size + 1); 294 buf = grecs_malloc (size + 1);
295 mu_address_to_string (rcpt, buf, size + 1, NULL); 295 mu_address_to_string (rcpt, buf, size + 1, NULL);
296 296
297 mu_header_set_value (hdr, "To", buf, 1); 297 mu_header_set_value (hdr, "To", buf, 1);
@@ -300,7 +300,7 @@ mail_send_message (mu_address_t rcpt, const char *text,
300 if (from_address && mu_header_sget_value (hdr, "From", &sval)) 300 if (from_address && mu_header_sget_value (hdr, "From", &sval))
301 { 301 {
302 mu_address_to_string (from_address, NULL, 0, &size); 302 mu_address_to_string (from_address, NULL, 0, &size);
303 buf = xmalloc (size + 1); 303 buf = grecs_malloc (size + 1);
304 mu_address_to_string (from_address, buf, size + 1, NULL); 304 mu_address_to_string (from_address, buf, size + 1, NULL);
305 mu_header_set_value (hdr, "From", buf, 1); 305 mu_header_set_value (hdr, "From", buf, 1);
306 free (buf); 306 free (buf);
@@ -434,7 +434,7 @@ mail_stats ()
434 size_t size; 434 size_t size;
435 char *buf; 435 char *buf;
436 mu_address_to_string (admin_address, NULL, 0, &size); 436 mu_address_to_string (admin_address, NULL, 0, &size);
437 buf = xmalloc (size + 1); 437 buf = grecs_malloc (size + 1);
438 mu_address_to_string (admin_address, buf, size + 1, NULL); 438 mu_address_to_string (admin_address, buf, size + 1, NULL);
439 logmsg (LOG_DEBUG, _("sending stats to %s"), buf); 439 logmsg (LOG_DEBUG, _("sending stats to %s"), buf);
440 free (buf); 440 free (buf);
@@ -444,7 +444,7 @@ mail_stats ()
444 exp = make_stat_expansion (tc + 1); 444 exp = make_stat_expansion (tc + 1);
445 time (&t); 445 time (&t);
446 exp[0].kw = "date"; 446 exp[0].kw = "date";
447 exp[0].value = exp[0].storage = xstrdup (ctime (&t)); 447 exp[0].value = exp[0].storage = grecs_strdup (ctime (&t));
448 exp[0].value [strlen (exp[0].value) - 1] = 0; 448 exp[0].value [strlen (exp[0].value) - 1] = 0;
449 timer_fill_meta (exp + 1, tc); 449 timer_fill_meta (exp + 1, tc);
450 450
@@ -598,7 +598,7 @@ do_notify (struct file_triplet *trp, enum notification_event ev,
598 size_t size; 598 size_t size;
599 char *buf; 599 char *buf;
600 mu_address_to_string (rcpt, NULL, 0, &size); 600 mu_address_to_string (rcpt, NULL, 0, &size);
601 buf = xmalloc (size + 1); 601 buf = grecs_malloc (size + 1);
602 mu_address_to_string (rcpt, buf, size + 1, NULL); 602 mu_address_to_string (rcpt, buf, size + 1, NULL);
603 logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"), 603 logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"),
604 buf, trp->project, notification_event_str (ev)); 604 buf, trp->project, notification_event_str (ev));
@@ -642,7 +642,7 @@ expand_email_admin (struct metadef *def, void *data)
642 if (mu_address_to_string (admin_address, NULL, 0, &size) == 0) 642 if (mu_address_to_string (admin_address, NULL, 0, &size) == 0)
643 { 643 {
644 size++; 644 size++;
645 def->storage = xmalloc (size); 645 def->storage = grecs_malloc (size);
646 mu_address_to_string (admin_address, def->storage, size, NULL); 646 mu_address_to_string (admin_address, def->storage, size, NULL);
647 def->value = def->storage; 647 def->value = def->storage;
648 } 648 }
@@ -670,7 +670,7 @@ expand_email_owner (struct metadef *def, void *data)
670 else if (mu_address_to_string (addr, NULL, 0, &size) == 0) 670 else if (mu_address_to_string (addr, NULL, 0, &size) == 0)
671 { 671 {
672 size++; 672 size++;
673 def->storage = xmalloc (size); 673 def->storage = grecs_malloc (size);
674 mu_address_to_string (addr, def->storage, size, NULL); 674 mu_address_to_string (addr, def->storage, size, NULL);
675 def->value = def->storage; 675 def->value = def->storage;
676 mu_address_destroy (&addr); 676 mu_address_destroy (&addr);
diff --git a/src/net.c b/src/net.c
index 3e9fe30..d08a6ba 100644
--- a/src/net.c
+++ b/src/net.c
@@ -103,7 +103,7 @@ handle_connection (FILE *in, FILE *out)
103 char *p; 103 char *p;
104 struct passwd *pw; 104 struct passwd *pw;
105 105
106 if (getline (&buf, &buflen, in) <= 0) 106 if (grecs_getline (&buf, &buflen, in) <= 0)
107 return; 107 return;
108 trim_crlf (buf); 108 trim_crlf (buf);
109 if (debug_level) 109 if (debug_level)
@@ -125,7 +125,7 @@ handle_connection (FILE *in, FILE *out)
125 else 125 else
126 fprintf (out, "+ OK, spool %s\r\n", spool->tag); 126 fprintf (out, "+ OK, spool %s\r\n", spool->tag);
127 127
128 if (getline (&buf, &buflen, in) < 0) 128 if (grecs_getline (&buf, &buflen, in) < 0)
129 { 129 {
130 logmsg (LOG_ERR, "protocol error"); 130 logmsg (LOG_ERR, "protocol error");
131 free (buf); 131 free (buf);
diff --git a/src/process.c b/src/process.c
index e41709d..200d987 100644
--- a/src/process.c
+++ b/src/process.c
@@ -27,7 +27,7 @@ static struct spool_list *spool_list;
27void 27void
28register_spool (struct spool *spool) 28register_spool (struct spool *spool)
29{ 29{
30 struct spool_list *sp = xmalloc (sizeof *sp); 30 struct spool_list *sp = grecs_malloc (sizeof *sp);
31 sp->spool = *spool; 31 sp->spool = *spool;
32 sp->next = spool_list; 32 sp->next = spool_list;
33 spool_list = sp; 33 spool_list = sp;
@@ -113,7 +113,7 @@ parse_file_name (const char *name, struct file_info *finfo)
113 && memcmp (name + len - suftab[i].len, 113 && memcmp (name + len - suftab[i].len,
114 suftab[i].suf, suftab[i].len) == 0) 114 suftab[i].suf, suftab[i].len) == 0)
115 { 115 {
116 finfo->name = xstrdup (name); 116 finfo->name = grecs_strdup (name);
117 finfo->type = suftab[i].type; 117 finfo->type = suftab[i].type;
118 finfo->root_len = len - suftab[i].len; 118 finfo->root_len = len - suftab[i].len;
119 return; 119 return;
diff --git a/src/sql.c b/src/sql.c
index a4b311e..80eb344 100644
--- a/src/sql.c
+++ b/src/sql.c
@@ -30,7 +30,7 @@ static struct sql_list *sql_list;
30void 30void
31sql_register_conn (struct sqlconn *conn) 31sql_register_conn (struct sqlconn *conn)
32{ 32{
33 struct sql_list *ent = xmalloc (sizeof *ent); 33 struct sql_list *ent = grecs_malloc (sizeof *ent);
34 ent->conn = *conn; 34 ent->conn = *conn;
35 ent->next = sql_list; 35 ent->next = sql_list;
36 sql_list = ent; 36 sql_list = ent;
@@ -198,7 +198,7 @@ sql_quote (struct dictionary *dict, void *handle, const char *input,
198 198
199 len = strlen (input); 199 len = strlen (input);
200 size = 2 * len + 1; 200 size = 2 * len + 1;
201 output = xmalloc (size); 201 output = grecs_malloc (size);
202 mysql_real_escape_string (&conn->mysql, output, input, len); 202 mysql_real_escape_string (&conn->mysql, output, input, len);
203 *poutput = output; 203 *poutput = output;
204 if (psize) 204 if (psize)
diff --git a/src/timer.c b/src/timer.c
index 1634462..cece63a 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -20,7 +20,6 @@
20#include <unistd.h> 20#include <unistd.h>
21#include <string.h> 21#include <string.h>
22#include <ctype.h> 22#include <ctype.h>
23#include <xalloc.h>
24 23
25struct timer_slot 24struct timer_slot
26{ 25{
@@ -182,7 +181,7 @@ timer_format_time (double t)
182 grecs_asprintf (&str, &size, "%02ld:%02ld", m, s); 181 grecs_asprintf (&str, &size, "%02ld:%02ld", m, s);
183 } 182 }
184 if (!str) 183 if (!str)
185 xalloc_die (); 184 grecs_alloc_die ();
186 return str; 185 return str;
187} 186}
188 187
@@ -210,7 +209,7 @@ _fill_meta (void *sym, void *data)
210 size_t size = 0; \ 209 size_t size = 0; \
211 grecs_asprintf (&buf, &size, "timer:%s:%s", slot->name, #arg); \ 210 grecs_asprintf (&buf, &size, "timer:%s:%s", slot->name, #arg); \
212 if (!buf) \ 211 if (!buf) \
213 xalloc_die (); \ 212 grecs_alloc_die (); \
214 tp->def->kw = buf; \ 213 tp->def->kw = buf; \
215 tp->def->storage = timer_format_time (__cat2__(timer_get_,arg) (slot)); \ 214 tp->def->storage = timer_format_time (__cat2__(timer_get_,arg) (slot)); \
216 tp->def->value = tp->def->storage; \ 215 tp->def->value = tp->def->storage; \
diff --git a/src/triplet.c b/src/triplet.c
index 3083c64..9dfdf2c 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -60,6 +60,7 @@ hash_triplet_free (void *data)
60 for (up = tp->uploader_list; up; ) 60 for (up = tp->uploader_list; up; )
61 { 61 {
62 struct uploader_info *next = up->next; 62 struct uploader_info *next = up->next;
63 free (up->fpr);
63 free (up); 64 free (up);
64 up = next; 65 up = next;
65 } 66 }
@@ -94,7 +95,7 @@ register_file (struct file_info *finfo, const struct spool *spool)
94 grecs_alloc_die (); 95 grecs_alloc_die ();
95 } 96 }
96 97
97 key.name = xmalloc (finfo->root_len + 1); 98 key.name = grecs_malloc (finfo->root_len + 1);
98 memcpy (key.name, finfo->name, finfo->root_len); 99 memcpy (key.name, finfo->name, finfo->root_len);
99 key.name[finfo->root_len] = 0; 100 key.name[finfo->root_len] = 0;
100 101
@@ -378,7 +379,7 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
378 379
379 /* Size */ 380 /* Size */
380 if (grecs_asprintf (&sptr, &slen, "%lu", (unsigned long) info->sb.st_size)) 381 if (grecs_asprintf (&sptr, &slen, "%lu", (unsigned long) info->sb.st_size))
381 xalloc_die (); 382 grecs_alloc_die ();
382 383
383 /* Figure out padding and format the buffer */ 384 /* Figure out padding and format the buffer */
384 slen = strlen (sptr); 385 slen = strlen (sptr);
@@ -391,7 +392,7 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
391 modes, user_name, group_name, ugswidth - pad + slen, 392 modes, user_name, group_name, ugswidth - pad + slen,
392 sptr, 393 sptr,
393 timebuf, info->name)) 394 timebuf, info->name))
394 xalloc_die (); 395 grecs_alloc_die ();
395 free (sptr); 396 free (sptr);
396 *pret = buf; 397 *pret = buf;
397 return 0; 398 return 0;
@@ -411,7 +412,7 @@ expand_triplet_ls_full (struct metadef *def, void *data)
411 if (format_file_data (trp, file_directive, &buf[file_directive]) == 0) 412 if (format_file_data (trp, file_directive, &buf[file_directive]) == 0)
412 size += strlen (buf[file_directive]) + 1; 413 size += strlen (buf[file_directive]) + 1;
413 414
414 def->value = def->storage = xmalloc (size + 1); 415 def->value = def->storage = grecs_malloc (size + 1);
415 def->value[0] = 0; 416 def->value[0] = 0;
416 if (buf[file_dist]) 417 if (buf[file_dist])
417 { 418 {
@@ -446,7 +447,7 @@ expand_triplet_ls_upload (struct metadef *def, void *data)
446 if (format_file_data (trp, file_signature, &buf[file_signature]) == 0) 447 if (format_file_data (trp, file_signature, &buf[file_signature]) == 0)
447 size += strlen (buf[file_signature]) + 1; 448 size += strlen (buf[file_signature]) + 1;
448 449
449 def->value = def->storage = xmalloc (size + 1); 450 def->value = def->storage = grecs_malloc (size + 1);
450 def->value[0] = 0; 451 def->value[0] = 0;
451 if (buf[file_dist]) 452 if (buf[file_dist])
452 { 453 {
@@ -552,7 +553,7 @@ expand_email_user (struct metadef *def, void *data)
552 size_t size = 0; 553 size_t size = 0;
553 if (grecs_asprintf (&def->storage, &size, "\"%s\" <%s>", 554 if (grecs_asprintf (&def->storage, &size, "\"%s\" <%s>",
554 trp->uploader->realname, trp->uploader->email)) 555 trp->uploader->realname, trp->uploader->email))
555 xalloc_die (); 556 grecs_alloc_die ();
556 def->value = def->storage; 557 def->value = def->storage;
557 } 558 }
558 return def->value; 559 return def->value;
@@ -594,7 +595,7 @@ expand_check_result (struct metadef *def, void *data)
594 def->storage = NULL; 595 def->storage = NULL;
595 if (grecs_asprintf (&def->storage, &size, 596 if (grecs_asprintf (&def->storage, &size,
596 "%d", WEXITSTATUS (status))) 597 "%d", WEXITSTATUS (status)))
597 xalloc_die (); 598 grecs_alloc_die ();
598 } 599 }
599 else if (WIFSIGNALED (status)) 600 else if (WIFSIGNALED (status))
600 { 601 {
@@ -602,7 +603,7 @@ expand_check_result (struct metadef *def, void *data)
602 def->storage = NULL; 603 def->storage = NULL;
603 if (grecs_asprintf (&def->storage, &size, "SIG+%d", 604 if (grecs_asprintf (&def->storage, &size, "SIG+%d",
604 WTERMSIG (status))) 605 WTERMSIG (status)))
605 xalloc_die (); 606 grecs_alloc_die ();
606 } 607 }
607 else 608 else
608 return def->value = "[unrecognized return code]"; 609 return def->value = "[unrecognized return code]";
diff --git a/src/txtacc.c b/src/txtacc.c
index 91659f6..442e27e 100644
--- a/src/txtacc.c
+++ b/src/txtacc.c
@@ -34,8 +34,8 @@ struct txtacc
34static struct txtacc_entry * 34static struct txtacc_entry *
35txtacc_alloc_entry (struct grecs_list *list, size_t size) 35txtacc_alloc_entry (struct grecs_list *list, size_t size)
36{ 36{
37 struct txtacc_entry *p = xmalloc (sizeof (*p)); 37 struct txtacc_entry *p = grecs_malloc (sizeof (*p));
38 p->buf = xmalloc (size); 38 p->buf = grecs_malloc (size);
39 p->size = size; 39 p->size = size;
40 p->len = 0; 40 p->len = 0;
41 grecs_list_append (list, p); 41 grecs_list_append (list, p);
@@ -89,7 +89,7 @@ txtacc_entry_free (void *p)
89struct txtacc * 89struct txtacc *
90txtacc_create () 90txtacc_create ()
91{ 91{
92 struct txtacc *acc = xmalloc (sizeof (*acc)); 92 struct txtacc *acc = grecs_malloc (sizeof (*acc));
93 acc->cur = grecs_list_create (); 93 acc->cur = grecs_list_create ();
94 acc->cur->free_entry = txtacc_entry_free; 94 acc->cur->free_entry = txtacc_entry_free;
95 acc->mem = grecs_list_create (); 95 acc->mem = grecs_list_create ();
@@ -137,6 +137,7 @@ txtacc_finish (struct txtacc *acc, int steal)
137 txtent = acc->cur->head->data; 137 txtent = acc->cur->head->data;
138 acc->cur->head->data = NULL; 138 acc->cur->head->data = NULL;
139 txtacc_entry_tailor (txtent); 139 txtacc_entry_tailor (txtent);
140 grecs_list_append (acc->mem, txtent);
140 break; 141 break;
141 142
142 default: 143 default:
@@ -158,9 +159,10 @@ txtacc_finish (struct txtacc *acc, int steal)
158 grecs_list_clear (acc->cur); 159 grecs_list_clear (acc->cur);
159 p = txtent->buf; 160 p = txtent->buf;
160 if (steal) 161 if (steal)
161 free (txtent); 162 {
162 else 163 grecs_list_remove_tail (acc->mem);
163 grecs_list_append (acc->mem, txtent); 164 free (txtent);
165 }
164 return p; 166 return p;
165} 167}
166 168
@@ -173,7 +175,7 @@ txtacc_free_string (struct txtacc *acc, char *str)
173 struct txtacc_entry *tp = ep->data; 175 struct txtacc_entry *tp = ep->data;
174 if (tp->buf == str) 176 if (tp->buf == str)
175 { 177 {
176 grecs_list_remove_entry(acc->mem, ep); 178 grecs_list_remove_entry (acc->mem, ep);
177 free (tp->buf); 179 free (tp->buf);
178 return; 180 return;
179 } 181 }
diff --git a/src/verify.c b/src/verify.c
index a49983c..c8fef11 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -113,7 +113,7 @@ fill_project_name (struct file_triplet *trp)
113 return 1; 113 return 1;
114 } 114 }
115 115
116 blurb = xmalloc (size + 1); 116 blurb = grecs_malloc (size + 1);
117 117
118 rc = fread (blurb, size, 1, fp); 118 rc = fread (blurb, size, 1, fp);
119 fclose (fp); 119 fclose (fp);
@@ -182,7 +182,7 @@ fill_project_name (struct file_triplet *trp)
182struct uploader_info * 182struct uploader_info *
183new_uploader_info (struct uploader_info *src) 183new_uploader_info (struct uploader_info *src)
184{ 184{
185 struct uploader_info *p = xmalloc (sizeof (*p)); 185 struct uploader_info *p = grecs_malloc (sizeof (*p));
186 p->next = NULL; 186 p->next = NULL;
187 p->name = src->name; 187 p->name = src->name;
188 p->realname = src->realname; 188 p->realname = src->realname;
diff --git a/src/wydawca.c b/src/wydawca.c
index cc1815b..36aa8b7 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -71,7 +71,7 @@ syslog_printer (int prio, const char *fmt, va_list ap)
71 if (size > fmtsize) 71 if (size > fmtsize)
72 { 72 {
73 fmtsize = size; 73 fmtsize = size;
74 fmtbuf = x2realloc (fmtbuf, &fmtsize); 74 fmtbuf = grecs_realloc (fmtbuf, fmtsize);
75 } 75 }
76 sprintf (fmtbuf, "[%s] %s", p, fmt); 76 sprintf (fmtbuf, "[%s] %s", p, fmt);
77 fmt = fmtbuf; 77 fmt = fmtbuf;
@@ -179,7 +179,7 @@ stat_expand (struct metadef *def, void *data)
179 def->storage = NULL; 179 def->storage = NULL;
180 if (grecs_asprintf (&def->storage, &size, "%u", 180 if (grecs_asprintf (&def->storage, &size, "%u",
181 wydawca_stat[(int) def->data])) 181 wydawca_stat[(int) def->data]))
182 xalloc_die (); 182 grecs_alloc_die ();
183 def->value = def->storage; 183 def->value = def->storage;
184 return def->value; 184 return def->value;
185} 185}
@@ -189,7 +189,7 @@ make_stat_expansion (size_t count)
189{ 189{
190 int i; 190 int i;
191 struct metadef *def, *p; 191 struct metadef *def, *p;
192 def = xcalloc (MAX_STAT + count + 1, sizeof (def[0])); 192 def = grecs_calloc (MAX_STAT + count + 1, sizeof (def[0]));
193 p = def + count; 193 p = def + count;
194 for (i = 0; i < MAX_STAT; i++, p++) 194 for (i = 0; i < MAX_STAT; i++, p++)
195 { 195 {
@@ -252,7 +252,7 @@ collect_uids (int argc, char **argv)
252 int i; 252 int i;
253 253
254 uidc = argc; 254 uidc = argc;
255 uidv = xcalloc (uidc, sizeof (uidv[0])); 255 uidv = grecs_calloc (uidc, sizeof (uidv[0]));
256 for (i = 0; i < argc; i++) 256 for (i = 0; i < argc; i++)
257 { 257 {
258 struct passwd *pw = getpwnam (argv[i]); 258 struct passwd *pw = getpwnam (argv[i]);
diff --git a/src/wydawca.h b/src/wydawca.h
index 2307bad..94b7ee3 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -41,14 +41,13 @@
41#include <fcntl.h> 41#include <fcntl.h>
42#include <time.h> 42#include <time.h>
43#include <sysexits.h> 43#include <sysexits.h>
44#include <fnmatch.h>
45#include <regex.h>
44 46
45#include <mailutils/types.h> 47#include <mailutils/types.h>
46#include <mailutils/url.h> 48#include <mailutils/url.h>
47#include <mailutils/errno.h> 49#include <mailutils/errno.h>
48 50
49#include "error.h"
50#include "xalloc.h"
51#include "backupfile.h"
52#include "grecs.h" 51#include "grecs.h"
53#include "wordsplit.h" 52#include "wordsplit.h"
54 53
@@ -110,6 +109,21 @@ struct dictionary
110}; 109};
111 110
112 111
112enum backup_type
113 {
114 no_backups, /* Don't make backups */
115 simple_backups, /* Make only simple backups */
116 numbered_existing_backups,/* Make numbered backups for files that already
117 have such backups and simple backups for the
118 rest */
119 numbered_backups, /* Make only numbered backups */
120 };
121
122extern char const *simple_backup_suffix;
123
124char *find_backup_file_name (char const *, enum backup_type);
125
126
113/* Archive types */ 127/* Archive types */
114 128
115enum archive_type 129enum archive_type
diff --git a/tests/.gitignore b/tests/.gitignore
index 7c8bd6b..1df6b71 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -9,3 +9,4 @@ dest
9wstest 9wstest
10wsbatch 10wsbatch
11pushck 11pushck
12bkupname
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b174fcd..cc52dbf 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,7 +24,7 @@ SUBDIRS = etc
24## ------------ ## 24## ------------ ##
25 25
26$(srcdir)/package.m4: $(top_srcdir)/configure.ac 26$(srcdir)/package.m4: $(top_srcdir)/configure.ac
27 { \ 27 $(AM_V_GEN){ \
28 echo '# Signature of the current package.'; \ 28 echo '# Signature of the current package.'; \
29 echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \ 29 echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
30 echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \ 30 echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
@@ -40,6 +40,10 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
40## ------------ ## 40## ------------ ##
41 41
42TESTSUITE_AT = \ 42TESTSUITE_AT = \
43 backup00.at\
44 backup01.at\
45 backup02.at\
46 backup03.at\
43 check-fail.at\ 47 check-fail.at\
44 check-notify.at\ 48 check-notify.at\
45 check-ok.at\ 49 check-ok.at\
@@ -73,9 +77,11 @@ check-local: atconfig atlocal $(TESTSUITE)
73#installcheck-local: 77#installcheck-local:
74 #$(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin 78 #$(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
75 79
76check_PROGRAMS = wstest wsbatch pushck 80check_PROGRAMS = wstest wsbatch pushck bkupname
77INCLUDES = -I$(top_srcdir)/grecs/src -I$(top_srcdir)/gnu -I../gnu -I$(top_srcdir)/src 81INCLUDES = -I$(top_srcdir)/grecs/src -I$(top_srcdir)/src
78LDADD=../grecs/src/libgrecs.a ../gnu/libgnu.a 82LDADD=../grecs/src/libgrecs.a
79 83
80pushck_LDADD=../src/pushd.o 84pushck_LDADD=../src/pushd.o
85bkupname_LDADD=../src/backup.o ../grecs/src/libgrecs.a
86
81 87
diff --git a/tests/backup01.at b/tests/backup01.at
new file mode 100644
index 0000000..7cf4f93
--- a/dev/null
+++ b/tests/backup01.at
@@ -0,0 +1,33 @@
1# This file is part of wydawca testsuite -*- Autotest -*-
2# Copyright (C) 2009, 2010 Sergey Poznyakoff
3#
4# Wydawca is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# Wydawca 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
15# along with Wydawca. If not, see <http://www.gnu.org/licenses/>.
16
17AT_SETUP(simple backups)
18AT_KEYWORDS([backup backup01 simple_backups])
19
20AT_CHECK([bkupname -simple a],
21[0],
22[a~
23])
24
25AT_CHECK([
26touch a
27bkupname -simple a
28],
29[0],
30[a~
31])
32
33AT_CLEANUP
diff --git a/tests/backup02.at b/tests/backup02.at
new file mode 100644
index 0000000..b5bcc54
--- a/dev/null
+++ b/tests/backup02.at
@@ -0,0 +1,43 @@
1# This file is part of wydawca testsuite -*- Autotest -*-
2# Copyright (C) 2009, 2010 Sergey Poznyakoff
3#
4# Wydawca is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# Wydawca 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
15# along with Wydawca. If not, see <http://www.gnu.org/licenses/>.
16
17AT_SETUP(numbered backups)
18AT_KEYWORDS([backup backup02 numbered_backups])
19
20AT_CHECK([bkupname -numbered a],
21[0],
22[a.~1~
23])
24
25AT_CHECK([
26touch a.~1~
27bkupname -numbered a
28],
29[0],
30[a.~2~
31])
32
33AT_CHECK([
34touch a.~99~
35bkupname -numbered a
36],
37[0],
38[a.~100~
39])
40
41
42
43AT_CLEANUP
diff --git a/tests/backup03.at b/tests/backup03.at
new file mode 100644
index 0000000..947c145
--- a/dev/null
+++ b/tests/backup03.at
@@ -0,0 +1,41 @@
1# This file is part of wydawca testsuite -*- Autotest -*-
2# Copyright (C) 2009, 2010 Sergey Poznyakoff
3#
4# Wydawca is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# Wydawca 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
15# along with Wydawca. If not, see <http://www.gnu.org/licenses/>.
16
17AT_SETUP(numbered existing backups)
18AT_KEYWORDS([backup backup03 numbered_existing_backups])
19
20AT_CHECK([bkupname -existing a],
21[0],
22[a~
23])
24
25AT_CHECK([
26touch a.~1~
27bkupname -existing a
28],
29[0],
30[a.~2~
31])
32
33AT_CHECK([
34touch a.~99~
35bkupname -existing a
36],
37[0],
38[a.~100~
39])
40
41AT_CLEANUP
diff --git a/tests/bkupname.c b/tests/bkupname.c
new file mode 100644
index 0000000..6187146
--- a/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}
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 240ab5d..2318762 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -24,6 +24,10 @@ AT_TESTED([wydawca])
24m4_include([version.at]) 24m4_include([version.at])
25m4_include([wordsplit.at]) 25m4_include([wordsplit.at])
26m4_include([pushdir.at]) 26m4_include([pushdir.at])
27m4_include([backup00.at])
28m4_include([backup01.at])
29m4_include([backup02.at])
30m4_include([backup03.at])
27 31
28m4_include([upload-dry.at]) 32m4_include([upload-dry.at])
29m4_include([upload.at]) 33m4_include([upload.at])

Return to:

Send suggestions and report system problems to the System administrator.