summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-13 07:21:43 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-05-13 07:33:34 (GMT)
commitde3fbe3e8d4dd2a89f7755906d76055784c437cc (patch) (unidiff)
tree65356dd7b5a9010499550c468e960c93515a7e15
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 (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
@@ -16,5 +16,5 @@
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
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
@@ -28,5 +28,2 @@ AM_SILENT_RULES([yes])
28AC_PROG_CC 28AC_PROG_CC
29 gl_EARLY
30AC_PROG_LEX
31AC_PROG_YACC
32AC_PROG_RANLIB 29AC_PROG_RANLIB
@@ -49,3 +46,2 @@ AC_HEADER_STDBOOL
49# Checks for library functions. 46# Checks for library functions.
50gl_INIT
51AC_FUNC_FORK 47AC_FUNC_FORK
@@ -137,3 +133,2 @@ AC_CONFIG_FILES([Makefile
137 doc/Makefile 133 doc/Makefile
138 gnu/Makefile
139 src/Makefile 134 src/Makefile
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
@@ -18,2 +18,3 @@ sbin_PROGRAMS=wydawca
18wydawca_SOURCES=\ 18wydawca_SOURCES=\
19 backup.c\
19 builtin.c\ 20 builtin.c\
@@ -62,4 +63,4 @@ inc_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= \
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
@@ -18,4 +18,6 @@
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
@@ -222,5 +224,5 @@ builtin_lookup (struct dictionary *dict, void *handle, const char *req)
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;
diff --git a/src/config.c b/src/config.c
index df9816e..8250749 100644
--- a/src/config.c
+++ b/src/config.c
@@ -148,3 +148,3 @@ safe_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);
@@ -551,4 +551,4 @@ cb_sql_host (enum grecs_callback_command cmd,
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 }
@@ -571,3 +571,3 @@ cb_sql_host (enum grecs_callback_command cmd,
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 }
@@ -575,3 +575,3 @@ cb_sql_host (enum grecs_callback_command cmd,
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;
@@ -596,3 +596,3 @@ cb_sql (enum grecs_callback_command cmd,
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);
@@ -898,3 +898,3 @@ cb_notify_event (enum grecs_callback_command 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;
@@ -986,3 +986,3 @@ cb_dictionary_params (enum grecs_callback_command cmd,
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
@@ -995,3 +995,3 @@ cb_dictionary_params (enum grecs_callback_command cmd,
995 995
996 meth->parmv[i] = xstrdup (vp->v.string); 996 meth->parmv[i] = grecs_strdup (vp->v.string);
997 } 997 }
@@ -1161,4 +1161,4 @@ cb_spool (enum grecs_callback_command cmd,
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;
@@ -1279,4 +1279,4 @@ cb_supp_groups (enum grecs_callback_command cmd,
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
diff --git a/src/dictionary.c b/src/dictionary.c
index b7baf05..2b995d4 100644
--- a/src/dictionary.c
+++ b/src/dictionary.c
@@ -50,4 +50,3 @@ dictionary_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;
@@ -94,2 +93,4 @@ dictionary_close (struct dictionary *dict, void *handle)
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)
@@ -188,3 +189,3 @@ dictionary_copy_result (struct dictionary *dict, const char *res, size_t size)
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 }
@@ -208,3 +209,3 @@ dictionary_quote_string (struct dictionary *dict, void *handle,
208 { 209 {
209 *poutput = xmalloc (1); 210 *poutput = grecs_malloc (1);
210 (*poutput)[0] = 0; 211 (*poutput)[0] = 0;
@@ -218,3 +219,3 @@ dictionary_quote_string (struct dictionary *dict, void *handle,
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);
diff --git a/src/directive.c b/src/directive.c
index 08a14df..fadaedf 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -36,3 +36,3 @@ directive_parse (struct file_triplet *trp)
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;
@@ -113,3 +113,3 @@ _directive_seq_get (int n, struct file_triplet *trp,
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 }
@@ -382,3 +382,3 @@ stderr_redirector (const char *tag)
382 _exit (127); 382 _exit (127);
383 while (getline (&buf, &size, fp) >= 0) 383 while (grecs_getline (&buf, &size, fp) >= 0)
384 { 384 {
@@ -495,3 +495,3 @@ run_check_script (const char *script, struct file_triplet *trp,
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 {
diff --git a/src/diskio.c b/src/diskio.c
index 9addd9b..b175a45 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -48,3 +48,3 @@ concat_dir (const char *base, const char *name, size_t *pbaselen)
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);
@@ -173,3 +173,3 @@ copy_file (const char *file, const char *dst_file)
173 if (bufsize == 0) 173 if (bufsize == 0)
174 xalloc_die (); 174 grecs_alloc_die ();
175 175
@@ -494,3 +494,3 @@ make_signame (const char *file_name)
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);
diff --git a/src/exec.c b/src/exec.c
index ed7ee1e..7ebf152 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -77,3 +77,3 @@ log_output (int prio, const char *prog, FILE *fp)
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);
diff --git a/src/gpg.c b/src/gpg.c
index 474d94b..d4f9b71 100644
--- a/src/gpg.c
+++ b/src/gpg.c
@@ -134,3 +134,3 @@ create_gpg_homedir ()
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))
@@ -239,3 +239,3 @@ verify_directive_signature (struct file_triplet *trp)
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)
@@ -273,3 +273,4 @@ verify_directive_signature (struct file_triplet *trp)
273 gpgme_data_release (key_data); 273 gpgme_data_release (key_data);
274 274 gpgme_release (ctx);
275
275 return rc; 276 return rc;
diff --git a/src/job.c b/src/job.c
index 7e3fdf5..764e463 100644
--- a/src/job.c
+++ b/src/job.c
@@ -207,3 +207,3 @@ schedule_job (const struct spool *spool, uid_t uid)
207 { 207 {
208 job = xzalloc (sizeof (*job)); 208 job = grecs_zalloc (sizeof (*job));
209 job->spool = spool; 209 job->spool = spool;
diff --git a/src/lock.c b/src/lock.c
index 32367de..dece75d 100644
--- a/src/lock.c
+++ b/src/lock.c
@@ -189,3 +189,3 @@ host_name ()
189 size = 256; 189 size = 256;
190 hostbuf = xmalloc (size); 190 hostbuf = grecs_malloc (size);
191 } 191 }
@@ -195,5 +195,5 @@ host_name ()
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 }
@@ -263,3 +263,3 @@ fix_tagname (const char *tag)
263{ 263{
264 char *tagname = xstrdup (tag); 264 char *tagname = grecs_strdup (tag);
265 char *p; 265 char *p;
@@ -280,3 +280,3 @@ wydawca_lockname (const char *tag)
280 if (!lockname) 280 if (!lockname)
281 xalloc_die (); 281 grecs_alloc_die ();
282 free (tagname); 282 free (tagname);
@@ -291,3 +291,3 @@ wydawca_lock_init ()
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))
diff --git a/src/mail.c b/src/mail.c
index bac0381..6855ed7 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -293,3 +293,3 @@ mail_send_message (mu_address_t rcpt, const char *text,
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);
@@ -302,3 +302,3 @@ mail_send_message (mu_address_t rcpt, const char *text,
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);
@@ -436,3 +436,3 @@ mail_stats ()
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);
@@ -446,3 +446,3 @@ mail_stats ()
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;
@@ -600,3 +600,3 @@ do_notify (struct file_triplet *trp, enum notification_event ev,
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);
@@ -644,3 +644,3 @@ expand_email_admin (struct metadef *def, void *data)
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);
@@ -672,3 +672,3 @@ expand_email_owner (struct metadef *def, void *data)
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);
diff --git a/src/net.c b/src/net.c
index 3e9fe30..d08a6ba 100644
--- a/src/net.c
+++ b/src/net.c
@@ -105,3 +105,3 @@ handle_connection (FILE *in, FILE *out)
105 105
106 if (getline (&buf, &buflen, in) <= 0) 106 if (grecs_getline (&buf, &buflen, in) <= 0)
107 return; 107 return;
@@ -127,3 +127,3 @@ handle_connection (FILE *in, FILE *out)
127 127
128 if (getline (&buf, &buflen, in) < 0) 128 if (grecs_getline (&buf, &buflen, in) < 0)
129 { 129 {
diff --git a/src/process.c b/src/process.c
index e41709d..200d987 100644
--- a/src/process.c
+++ b/src/process.c
@@ -29,3 +29,3 @@ register_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;
@@ -115,3 +115,3 @@ parse_file_name (const char *name, struct file_info *finfo)
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;
diff --git a/src/sql.c b/src/sql.c
index a4b311e..80eb344 100644
--- a/src/sql.c
+++ b/src/sql.c
@@ -32,3 +32,3 @@ sql_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;
@@ -200,3 +200,3 @@ sql_quote (struct dictionary *dict, void *handle, const char *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);
diff --git a/src/timer.c b/src/timer.c
index 1634462..cece63a 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -22,3 +22,2 @@
22#include <ctype.h> 22#include <ctype.h>
23#include <xalloc.h>
24 23
@@ -184,3 +183,3 @@ timer_format_time (double t)
184 if (!str) 183 if (!str)
185 xalloc_die (); 184 grecs_alloc_die ();
186 return str; 185 return str;
@@ -212,3 +211,3 @@ _fill_meta (void *sym, void *data)
212 if (!buf) \ 211 if (!buf) \
213 xalloc_die (); \ 212 grecs_alloc_die (); \
214 tp->def->kw = buf; \ 213 tp->def->kw = buf; \
diff --git a/src/triplet.c b/src/triplet.c
index 3083c64..9dfdf2c 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -62,2 +62,3 @@ hash_triplet_free (void *data)
62 struct uploader_info *next = up->next; 62 struct uploader_info *next = up->next;
63 free (up->fpr);
63 free (up); 64 free (up);
@@ -96,3 +97,3 @@ register_file (struct file_info *finfo, const struct spool *spool)
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);
@@ -380,3 +381,3 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
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
@@ -393,3 +394,3 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
393 timebuf, info->name)) 394 timebuf, info->name))
394 xalloc_die (); 395 grecs_alloc_die ();
395 free (sptr); 396 free (sptr);
@@ -413,3 +414,3 @@ expand_triplet_ls_full (struct metadef *def, void *data)
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;
@@ -448,3 +449,3 @@ expand_triplet_ls_upload (struct metadef *def, void *data)
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;
@@ -554,3 +555,3 @@ expand_email_user (struct metadef *def, void *data)
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;
@@ -596,3 +597,3 @@ expand_check_result (struct metadef *def, void *data)
596 "%d", WEXITSTATUS (status))) 597 "%d", WEXITSTATUS (status)))
597 xalloc_die (); 598 grecs_alloc_die ();
598 } 599 }
@@ -604,3 +605,3 @@ expand_check_result (struct metadef *def, void *data)
604 WTERMSIG (status))) 605 WTERMSIG (status)))
605 xalloc_die (); 606 grecs_alloc_die ();
606 } 607 }
diff --git a/src/txtacc.c b/src/txtacc.c
index 91659f6..442e27e 100644
--- a/src/txtacc.c
+++ b/src/txtacc.c
@@ -36,4 +36,4 @@ txtacc_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;
@@ -91,3 +91,3 @@ txtacc_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 ();
@@ -139,2 +139,3 @@ txtacc_finish (struct txtacc *acc, int steal)
139 txtacc_entry_tailor (txtent); 139 txtacc_entry_tailor (txtent);
140 grecs_list_append (acc->mem, txtent);
140 break; 141 break;
@@ -160,5 +161,6 @@ txtacc_finish (struct txtacc *acc, int steal)
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;
@@ -175,3 +177,3 @@ txtacc_free_string (struct txtacc *acc, char *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);
diff --git a/src/verify.c b/src/verify.c
index a49983c..c8fef11 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -115,3 +115,3 @@ fill_project_name (struct file_triplet *trp)
115 115
116 blurb = xmalloc (size + 1); 116 blurb = grecs_malloc (size + 1);
117 117
@@ -184,3 +184,3 @@ new_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;
diff --git a/src/wydawca.c b/src/wydawca.c
index cc1815b..36aa8b7 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -73,3 +73,3 @@ syslog_printer (int prio, const char *fmt, va_list ap)
73 fmtsize = size; 73 fmtsize = size;
74 fmtbuf = x2realloc (fmtbuf, &fmtsize); 74 fmtbuf = grecs_realloc (fmtbuf, fmtsize);
75 } 75 }
@@ -181,3 +181,3 @@ stat_expand (struct metadef *def, void *data)
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;
@@ -191,3 +191,3 @@ make_stat_expansion (size_t count)
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;
@@ -254,3 +254,3 @@ collect_uids (int argc, char **argv)
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++)
diff --git a/src/wydawca.h b/src/wydawca.h
index 2307bad..94b7ee3 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -43,2 +43,4 @@
43#include <sysexits.h> 43#include <sysexits.h>
44#include <fnmatch.h>
45#include <regex.h>
44 46
@@ -48,5 +50,2 @@
48 50
49#include "error.h"
50#include "xalloc.h"
51#include "backupfile.h"
52#include "grecs.h" 51#include "grecs.h"
@@ -112,2 +111,17 @@ struct dictionary
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 */
diff --git a/tests/.gitignore b/tests/.gitignore
index 7c8bd6b..1df6b71 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -11 +11,2 @@ wsbatch
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
@@ -26,3 +26,3 @@ SUBDIRS = etc
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.'; \
@@ -42,2 +42,6 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
42TESTSUITE_AT = \ 42TESTSUITE_AT = \
43 backup00.at\
44 backup01.at\
45 backup02.at\
46 backup03.at\
43 check-fail.at\ 47 check-fail.at\
@@ -75,7 +79,9 @@ check-local: atconfig atlocal $(TESTSUITE)
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
@@ -26,2 +26,6 @@ m4_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

Return to:

Send suggestions and report system problems to the System administrator.