[Tux4kids-commits] r213 - in tuxtype/trunk: . tuxtype tuxtype/data/fonts tuxtype/data/themes/espanol
dbruce-guest at alioth.debian.org
dbruce-guest at alioth.debian.org
Sat Aug 25 18:12:22 UTC 2007
Author: dbruce-guest
Date: 2007-08-25 18:12:22 +0000 (Sat, 25 Aug 2007)
New Revision: 213
Added:
tuxtype/trunk/tuxtype/data/fonts/Rachana_w01.ttf
Removed:
tuxtype/trunk/autogen.sh
tuxtype/trunk/tuxtype/data/fonts/Rachana_g01.ttf
Modified:
tuxtype/trunk/ChangeLog
tuxtype/trunk/INSTALL
tuxtype/trunk/INSTALL-Win32
tuxtype/trunk/README-CROSSBUILD.txt
tuxtype/trunk/acinclude.m4
tuxtype/trunk/config.guess
tuxtype/trunk/config.sub
tuxtype/trunk/depcomp
tuxtype/trunk/install-sh
tuxtype/trunk/missing
tuxtype/trunk/mkinstalldirs
tuxtype/trunk/tuxtype/alphabet.c
tuxtype/trunk/tuxtype/audio.c
tuxtype/trunk/tuxtype/data/fonts/Makefile.am
tuxtype/trunk/tuxtype/data/themes/espanol/Makefile.am
tuxtype/trunk/tuxtype/data/themes/espanol/Makefile.in
tuxtype/trunk/tuxtype/gettext.c
tuxtype/trunk/tuxtype/globals.h
tuxtype/trunk/tuxtype/laser.c
tuxtype/trunk/tuxtype/loaders.c
tuxtype/trunk/tuxtype/main.c
tuxtype/trunk/tuxtype/pause.c
tuxtype/trunk/tuxtype/playgame.c
tuxtype/trunk/tuxtype/practice.c
tuxtype/trunk/tuxtype/scripting.c
tuxtype/trunk/tuxtype/setup.c
tuxtype/trunk/tuxtype/snow.c
tuxtype/trunk/tuxtype/theme.c
tuxtype/trunk/tuxtype/titlescreen.c
Log:
Support for finding Rachana and Doulos fonts in Debian install (hack); Espanol display fixed; lots of code cleanup
Modified: tuxtype/trunk/ChangeLog
===================================================================
--- tuxtype/trunk/ChangeLog 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/ChangeLog 2007-08-25 18:12:22 UTC (rev 213)
@@ -1,3 +1,16 @@
+[ David Bruce ]
+ - got rid of autogen.sh - autoreconf is recommended way to
+ do the same thing.
+ - replaced acinclude.m4 with newer version to get rid of
+ "underquoted AM_PATH_SDL" message.
+ - fixed bug causing crash on exit from cascade game do to
+ double free of ptr.
+ - fixed bug with Espanol display of menus.
+ - added "static" keyword to file-scope variables.
+ - moved more of global variables to file or local scope.
+ - added hard-coded hack-work to LoadFont() to support
+ Rachana and Doulos as well as Andika in Debian.
+
v 1.5.11
19 Aug 2007
[ David Bruce ]
Modified: tuxtype/trunk/INSTALL
===================================================================
--- tuxtype/trunk/INSTALL 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/INSTALL 2007-08-25 18:12:22 UTC (rev 213)
@@ -21,7 +21,7 @@
if you run into problems rerun:
-autogen.sh
+autoreconf
We want this to work for everybody, everywhere, if it doesn't
work for you please contact calarndt at tux4kids.org
@@ -55,8 +55,8 @@
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
- The file `configure.in' is used to create `configure' by a program
-called `autoconf'. You only need `configure.in' if you want to change
+ The file `configure.ac' is used to create `configure' by a program
+called `autoconf'. You only need `configure.ac' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
Modified: tuxtype/trunk/INSTALL-Win32
===================================================================
--- tuxtype/trunk/INSTALL-Win32 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/INSTALL-Win32 2007-08-25 18:12:22 UTC (rev 213)
@@ -1,5 +1,8 @@
Tux Typing for Windows
----------------------
+
+Updated Aug 25 2007
+
2006-present Lead Developer:
David Bruce <dbruce at tampabay.rr.com>
Modified: tuxtype/trunk/README-CROSSBUILD.txt
===================================================================
--- tuxtype/trunk/README-CROSSBUILD.txt 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/README-CROSSBUILD.txt 2007-08-25 18:12:22 UTC (rev 213)
@@ -83,7 +83,7 @@
and "make distclean" to get rid of the autogenerated files.
7. From the trunk dir, run:
- ./autogen.sh
+ ./autoreconf
./cross-configure.sh --with-sdl-prefix
./cross-make.sh
./cross-make.sh nsis
Modified: tuxtype/trunk/acinclude.m4
===================================================================
--- tuxtype/trunk/acinclude.m4 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/acinclude.m4 2007-08-25 18:12:22 UTC (rev 213)
@@ -8,7 +8,7 @@
dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
dnl
-AC_DEFUN(AM_PATH_SDL,
+AC_DEFUN([AM_PATH_SDL],
[dnl
dnl Get the cflags and libraries from the sdl-config script
dnl
@@ -52,8 +52,10 @@
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_sdltest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
+ ac_save_CXXFLAGS="$CXXFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $SDL_CFLAGS"
+ CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
dnl
dnl Now check if the installed SDL is sufficiently new. (Also sanity
@@ -138,6 +140,7 @@
else
echo "*** Could not run SDL test program, checking why..."
CFLAGS="$CFLAGS $SDL_CFLAGS"
+ CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
AC_TRY_LINK([
#include <stdio.h>
@@ -162,10 +165,12 @@
echo "*** or that you have moved SDL since it was installed. In the latter case, you"
echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
CFLAGS="$ac_save_CFLAGS"
+ CXXFLAGS="$ac_save_CXXFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
SDL_CFLAGS=""
+ SDL_CXXFLAGS=""
SDL_LIBS=""
ifelse([$3], , :, [$3])
fi
Deleted: tuxtype/trunk/autogen.sh
===================================================================
--- tuxtype/trunk/autogen.sh 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/autogen.sh 2007-08-25 18:12:22 UTC (rev 213)
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-aclocal && autoheader && autoconf && automake --add-missing --copy
-
-
Modified: tuxtype/trunk/config.guess
===================================================================
--- tuxtype/trunk/config.guess 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/config.guess 2007-08-25 18:12:22 UTC (rev 213)
@@ -1,9 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
-timestamp='2006-02-23'
+timestamp='2007-07-22'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -160,6 +161,7 @@
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
@@ -210,7 +212,7 @@
echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
exit ;;
macppc:MirBSD:*:*)
- echo powerppc-unknown-mirbsd${UNAME_RELEASE}
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
exit ;;
*:MirBSD:*:*)
echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
@@ -328,7 +330,7 @@
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
- i86pc:SunOS:5.*:*)
+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:6*:*)
@@ -770,6 +772,8 @@
case ${UNAME_MACHINE} in
pc98)
echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
esac
@@ -777,12 +781,9 @@
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit ;;
- i*:MINGW*:*)
+ *:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
- i*:MSYS_NT-*:*:*)
- echo ${UNAME_MACHINE}-pc-mingw32
- exit ;;
i*:windows32*:*)
# uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32
@@ -790,12 +791,15 @@
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit ;;
- x86:Interix*:[345]*)
- echo i586-pc-interix${UNAME_RELEASE}
- exit ;;
- EM64T:Interix*:[345]*)
- echo x86_64-unknown-interix${UNAME_RELEASE}
- exit ;;
+ *:Interix*:[3456]*)
+ case ${UNAME_MACHINE} in
+ x86)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ EM64T | authenticamd)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ esac ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks
exit ;;
@@ -831,6 +835,9 @@
arm*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
+ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
cris:Linux:*:*)
echo cris-axis-linux-gnu
exit ;;
@@ -947,6 +954,9 @@
x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu
exit ;;
+ xtensa:Linux:*:*)
+ echo xtensa-unknown-linux-gnu
+ exit ;;
i*86:Linux:*:*)
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
@@ -989,7 +999,7 @@
LIBC=gnulibc1
# endif
#else
- #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun)
+ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
LIBC=gnu
#else
LIBC=gnuaout
@@ -1205,6 +1215,15 @@
SX-6:SUPER-UX:*:*)
echo sx6-nec-superux${UNAME_RELEASE}
exit ;;
+ SX-7:SUPER-UX:*:*)
+ echo sx7-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8:SUPER-UX:*:*)
+ echo sx8-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8R:SUPER-UX:*:*)
+ echo sx8r-nec-superux${UNAME_RELEASE}
+ exit ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit ;;
Modified: tuxtype/trunk/config.sub
===================================================================
--- tuxtype/trunk/config.sub 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/config.sub 2007-08-25 18:12:22 UTC (rev 213)
@@ -1,9 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
-timestamp='2006-02-23'
+timestamp='2007-06-28'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -240,15 +241,16 @@
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
| bfin \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
- | fr30 | frv \
+ | fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
- | m32r | m32rle | m68000 | m68k | m88k | maxq | mb | microblaze | mcore \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore | mep \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
@@ -274,21 +276,19 @@
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
- | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
- | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
- | sparcv8 | sparcv9 | sparcv9b \
- | strongarm \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| v850 | v850e \
| we32k \
- | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k)
basic_machine=$basic_machine-unknown
;;
- m32c)
- basic_machine=$basic_machine-unknown
- ;;
m6811 | m68hc11 | m6812 | m68hc12)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
@@ -318,18 +318,18 @@
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
- | avr-* \
+ | avr-* | avr32-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
| clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
- | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
- | m32r-* | m32rle-* \
+ | m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
@@ -358,23 +358,21 @@
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
- | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
- | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
- | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tron-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
- | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
| xstormy16-* | xtensa-* \
| ymp-* \
| z8k-*)
;;
- m32c-*)
- ;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
386bsd)
@@ -477,8 +475,8 @@
basic_machine=craynv-cray
os=-unicosmp
;;
- cr16c)
- basic_machine=cr16c-unknown
+ cr16)
+ basic_machine=cr16-unknown
os=-elf
;;
crds | unos)
@@ -685,6 +683,10 @@
basic_machine=i386-pc
os=-mingw32
;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=-mingw32ce
+ ;;
miniframe)
basic_machine=m68000-convergent
;;
@@ -912,6 +914,10 @@
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
sei)
basic_machine=mips-sei
os=-seiux
@@ -923,6 +929,9 @@
basic_machine=sh-hitachi
os=-hms
;;
+ sh5el)
+ basic_machine=sh5le-unknown
+ ;;
sh64)
basic_machine=sh64-unknown
;;
@@ -1128,7 +1137,7 @@
sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
- sparc | sparcv8 | sparcv9 | sparcv9b)
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
basic_machine=sparc-sun
;;
cydra)
@@ -1217,7 +1226,7 @@
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku* | -rdos*)
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1369,6 +1378,12 @@
# system, and we'll never get to this point.
case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
*-acorn)
os=-riscix1.2
;;
@@ -1378,9 +1393,9 @@
arm*-semi)
os=-aout
;;
- c4x-* | tic4x-*)
- os=-coff
- ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
@@ -1406,6 +1421,9 @@
m68*-cisco)
os=-aout
;;
+ mep-*)
+ os=-elf
+ ;;
mips*-cisco)
os=-elf
;;
Modified: tuxtype/trunk/depcomp
===================================================================
--- tuxtype/trunk/depcomp 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/depcomp 2007-08-25 18:12:22 UTC (rev 213)
@@ -1,8 +1,11 @@
#! /bin/sh
-
# depcomp - compile a program generating dependencies as side-effects
-# Copyright 1999, 2000 Free Software Foundation, Inc.
+scriptversion=2006-10-15.18
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
+# Foundation, Inc.
+
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
@@ -15,8 +18,8 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -25,22 +28,45 @@
# Originally written by Alexandre Oliva <oliva at dcc.unicamp.br>.
+case $1 in
+ '')
+ echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+ depmode Dependency tracking mode.
+ source Source file read by `PROGRAMS ARGS'.
+ object Object file output by `PROGRAMS ARGS'.
+ DEPDIR directory where to store dependencies.
+ depfile Dependency file to output.
+ tmpdepfile Temporary file to use when outputing dependencies.
+ libtool Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake at gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "depcomp $scriptversion"
+ exit $?
+ ;;
+esac
+
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
-# `libtool' can also be set to `yes' or `no'.
-if test -z "$depfile"; then
- base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
- dir=`echo "$object" | sed 's,/.*$,/,'`
- if test "$dir" = "$object"; then
- dir=
- fi
- # FIXME: should be _deps on DOS.
- depfile="$dir.deps/$base"
-fi
-
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+ sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
@@ -66,7 +92,20 @@
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
- "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am. Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+ for arg
+ do
+ case $arg in
+ -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+ *) set fnord "$@" "$arg" ;;
+ esac
+ shift # fnord
+ shift # $arg
+ done
+ "$@"
stat=$?
if test $stat -eq 0; then :
else
@@ -172,19 +211,25 @@
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
- # in a .u file. This file always lives in the current directory.
- # Also, the AIX compiler puts `$object:' at the start of each line;
- # $object doesn't have directory information.
- stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
+ # in a .u file. In older versions, this file always lives in the
+ # current directory. Also, the AIX compiler puts `$object:' at the
+ # start of each line; $object doesn't have directory information.
+ # Version 6 uses the directory in both cases.
+ stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
- outname="$stripped.o"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
+ stat=$?
- stat=$?
+ if test -f "$tmpdepfile"; then :
+ else
+ stripped=`echo "$stripped" | sed 's,^.*/,,'`
+ tmpdepfile="$stripped.u"
+ fi
+
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
@@ -192,6 +237,7 @@
fi
if test -f "$tmpdepfile"; then
+ outname="$stripped.o"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
@@ -206,38 +252,136 @@
rm -f "$tmpdepfile"
;;
+icc)
+ # Intel's C compiler understands `-MD -MF file'. However on
+ # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+ # ICC 7.0 will fill foo.d with something like
+ # foo.o: sub/foo.c
+ # foo.o: sub/foo.h
+ # which is wrong. We want:
+ # sub/foo.o: sub/foo.c
+ # sub/foo.o: sub/foo.h
+ # sub/foo.c:
+ # sub/foo.h:
+ # ICC 7.1 will output
+ # foo.o: sub/foo.c sub/foo.h
+ # and will wrap long lines using \ :
+ # foo.o: sub/foo.c ... \
+ # sub/foo.h ... \
+ # ...
+
+ "$@" -MD -MF "$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ # Each line is of the form `foo.o: dependent.h',
+ # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+ # Some versions of the HPUX 10.20 sed can't process this invocation
+ # correctly. Breaking it into two sed invocations is a workaround.
+ sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+ sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp2)
+ # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+ # compilers, which have integrated preprocessors. The correct option
+ # to use with these is +Maked; it writes dependencies to a file named
+ # 'foo.d', which lands next to the object file, wherever that
+ # happens to be.
+ # Much of this is similar to the tru64 case; see comments there.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+ if test "$libtool" = yes; then
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir.libs/$base.d
+ "$@" -Wc,+Maked
+ else
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir$base.d
+ "$@" +Maked
+ fi
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+ # Add `dependent.h:' lines.
+ sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
+ else
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile" "$tmpdepfile2"
+ ;;
+
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
- # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+ # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
- base=`echo "$object" | sed -e 's/\.o$//' -e 's/\.lo$//'`
- tmpdepfile1="$base.o.d"
- tmpdepfile2="$base.d"
if test "$libtool" = yes; then
+ # With Tru64 cc, shared objects can also be used to make a
+ # static library. This mechanism is used in libtool 1.4 series to
+ # handle both shared and static libraries in a single compilation.
+ # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+ #
+ # With libtool 1.5 this exception was removed, and libtool now
+ # generates 2 separate objects for the 2 libraries. These two
+ # compilations output dependencies in $dir.libs/$base.o.d and
+ # in $dir$base.o.d. We have to check for both files, because
+ # one of the two compilations can be disabled. We should prefer
+ # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+ # automatically cleaned when .libs/ is deleted, while ignoring
+ # the former would cause a distcleancheck panic.
+ tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
+ tmpdepfile2=$dir$base.o.d # libtool 1.5
+ tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
+ tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
+ tmpdepfile1=$dir$base.o.d
+ tmpdepfile2=$dir$base.d
+ tmpdepfile3=$dir$base.d
+ tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
- rm -f "$tmpdepfile1" "$tmpdepfile2"
+ rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
exit $stat
fi
- if test -f "$tmpdepfile1"; then
- tmpdepfile="$tmpdepfile1"
- else
- tmpdepfile="$tmpdepfile2"
- fi
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+ do
+ test -f "$tmpdepfile" && break
+ done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
- # That's a space and a tab in the [].
- sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ # That's a tab and a space in the [].
+ sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
@@ -250,34 +394,42 @@
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
- # always write the proprocessed file to stdout, regardless of -o,
- # because we must use -o when running libtool.
- test -z "$dashmflag" && dashmflag=-M
- ( IFS=" "
- case " $* " in
- *" --mode=compile "*) # this is libtool, let us make it quiet
- for arg
- do # cycle over the arguments
- case "$arg" in
- "--mode=compile")
- # insert --quiet before "--mode=compile"
- set fnord "$@" --quiet
- shift # fnord
- ;;
- esac
- set fnord "$@" "$arg"
- shift # fnord
- shift # "$arg"
- done
+ # always write the preprocessed file to stdout, regardless of -o.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove `-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
esac
- "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
- ) &
- proc=$!
- "$@"
- stat=$?
- wait "$proc"
- if test "$stat" != 0; then exit $stat; fi
+ done
+
+ test -z "$dashmflag" && dashmflag=-M
+ # Require at least two characters before searching for `:'
+ # in the target name. This is to cope with DOS-style filenames:
+ # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+ "$@" $dashmflag |
+ sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
@@ -295,33 +447,37 @@
;;
makedepend)
+ "$@" || exit $?
+ # Remove any Libtool call
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
# X makedepend
- (
- shift
- cleared=no
- for arg in "$@"; do
- case $cleared in no)
- set ""; shift
- cleared=yes
- esac
- case "$arg" in
- -D*|-I*)
- set fnord "$@" "$arg"; shift;;
- -*)
- ;;
- *)
- set fnord "$@" "$arg"; shift;;
- esac
- done
- obj_suffix="`echo $object | sed 's/^.*\././'`"
- touch "$tmpdepfile"
- ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
- ) &
- proc=$!
- "$@"
- stat=$?
- wait "$proc"
- if test "$stat" != 0; then exit $stat; fi
+ shift
+ cleared=no
+ for arg in "$@"; do
+ case $cleared in
+ no)
+ set ""; shift
+ cleared=yes ;;
+ esac
+ case "$arg" in
+ -D*|-I*)
+ set fnord "$@" "$arg"; shift ;;
+ # Strip any option that makedepend may not understand. Remove
+ # the object too, otherwise makedepend will parse it as a source file.
+ -*|$object)
+ ;;
+ *)
+ set fnord "$@" "$arg"; shift ;;
+ esac
+ done
+ obj_suffix="`echo $object | sed 's/^.*\././'`"
+ touch "$tmpdepfile"
+ ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
@@ -334,35 +490,40 @@
cpp)
# Important note: in order to support this mode, a compiler *must*
- # always write the proprocessed file to stdout, regardless of -o,
- # because we must use -o when running libtool.
- ( IFS=" "
- case " $* " in
- *" --mode=compile "*)
- for arg
- do # cycle over the arguments
- case $arg in
- "--mode=compile")
- # insert --quiet before "--mode=compile"
- set fnord "$@" --quiet
- shift # fnord
- ;;
- esac
- set fnord "$@" "$arg"
- shift # fnord
- shift # "$arg"
- done
+ # always write the preprocessed file to stdout.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove `-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
esac
- "$@" -E |
- sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+ done
+
+ "$@" -E |
+ sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
- ) &
- proc=$!
- "$@"
- stat=$?
- wait "$proc"
- if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
@@ -372,49 +533,27 @@
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
- # always write the proprocessed file to stdout, regardless of -o,
+ # always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
- ( IFS=" "
- case " $* " in
- *" --mode=compile "*)
- for arg
- do # cycle over the arguments
- case $arg in
- "--mode=compile")
- # insert --quiet before "--mode=compile"
- set fnord "$@" --quiet
- shift # fnord
- ;;
- esac
- set fnord "$@" "$arg"
- shift # fnord
- shift # "$arg"
- done
- ;;
- esac
- for arg
- do
- case "$arg" in
- "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+ "$@" || exit $?
+ IFS=" "
+ for arg
+ do
+ case "$arg" in
+ "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
- *)
+ *)
set fnord "$@" "$arg"
shift
shift
;;
- esac
- done
- "$@" -E |
- sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
- ) &
- proc=$!
- "$@"
- stat=$?
- wait "$proc"
- if test "$stat" != 0; then exit $stat; fi
+ esac
+ done
+ "$@" -E |
+ sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
@@ -434,3 +573,12 @@
esac
exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
Modified: tuxtype/trunk/install-sh
===================================================================
--- tuxtype/trunk/install-sh 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/install-sh 2007-08-25 18:12:22 UTC (rev 213)
@@ -1,37 +1,63 @@
#!/bin/sh
-#
# install - install a program, script, or datafile
-# This comes from X11R5 (mit/util/scripts/install.sh).
+
+scriptversion=2006-10-14.15
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
#
-# Copyright 1991 by the Massachusetts Institute of Technology
+# Copyright (C) 1994 X Consortium
#
-# Permission to use, copy, modify, distribute, and sell this software and its
-# documentation for any purpose is hereby granted without fee, provided that
-# the above copyright notice appear in all copies and that both that
-# copyright notice and this permission notice appear in supporting
-# documentation, and that the name of M.I.T. not be used in advertising or
-# publicity pertaining to distribution of the software without specific,
-# written prior permission. M.I.T. makes no representations about the
-# suitability of this software for any purpose. It is provided "as is"
-# without express or implied warranty.
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
-# from scratch. It can only install one file at a time, a restriction
-# shared with many OS's install programs.
+# from scratch.
+nl='
+'
+IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
+if test -z "$doit"; then
+ doit_exec=exec
+else
+ doit_exec=$doit
+fi
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
@@ -41,211 +67,441 @@
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
+posix_glob=
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chmodcmd=$chmodprog
+chowncmd=
+chgrpcmd=
+stripcmd=
rmcmd="$rmprog -f"
mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
+src=
+dst=
+dir_arg=
+dstarg=
+no_target_directory=
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
+usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+ or: $0 [OPTION]... -d DIRECTORIES...
- -d) dir_arg=true
- shift
- continue;;
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
+Options:
+-c (ignored)
+-d create directories instead of installing files.
+-g GROUP $chgrpprog installed files to GROUP.
+-m MODE $chmodprog installed files to MODE.
+-o USER $chownprog installed files to USER.
+-s $stripprog installed files.
+-t DIRECTORY install into DIRECTORY.
+-T report an error if DSTFILE is a directory.
+--help display this help and exit.
+--version display version info and exit.
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
+Environment variables override the default commands:
+ CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
+"
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
+while test $# -ne 0; do
+ case $1 in
+ -c) shift
+ continue;;
- -s) stripcmd="$stripprog"
- shift
- continue;;
+ -d) dir_arg=true
+ shift
+ continue;;
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
+ --help) echo "$usage"; exit $?;;
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
+ -m) mode=$2
+ shift
+ shift
+ case $mode in
+ *' '* | *' '* | *'
+'* | *'*'* | *'?'* | *'['*)
+ echo "$0: invalid mode: $mode" >&2
+ exit 1;;
+ esac
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd=$stripprog
+ shift
+ continue;;
+
+ -t) dstarg=$2
+ shift
+ shift
+ continue;;
+
+ -T) no_target_directory=true
+ shift
+ continue;;
+
+ --version) echo "$0 $scriptversion"; exit $?;;
+
+ --) shift
+ break;;
+
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;
+
+ *) break;;
+ esac
done
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- :
+if test $# -ne 0 && test -z "$dir_arg$dstarg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from $@.
+ for arg
+ do
+ if test -n "$dstarg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dstarg"
+ shift # fnord
+ fi
+ shift # arg
+ dstarg=$arg
+ done
fi
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- chmodcmd=""
- else
- instcmd=$mkdirprog
- fi
-else
+if test $# -eq 0; then
+ if test -z "$dir_arg"; then
+ echo "$0: no input file specified." >&2
+ exit 1
+ fi
+ # It's OK to call `install-sh -d' without argument.
+ # This can happen when creating conditional directories.
+ exit 0
+fi
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
+if test -z "$dir_arg"; then
+ trap '(exit $?); exit' 1 2 13 15
- if [ -f $src -o -d $src ]
- then
- :
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- :
- fi
+ # Set umask so as not to create temps with too-generous modes.
+ # However, 'strip' requires both read and write access to temps.
+ case $mode in
+ # Optimize common cases.
+ *644) cp_umask=133;;
+ *755) cp_umask=22;;
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- :
- fi
+ *[0-7])
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw='% 200'
+ fi
+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+ *)
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw=,u+rw
+ fi
+ cp_umask=$mode$u_plus_rw;;
+ esac
fi
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+for src
+do
+ # Protect names starting with `-'.
+ case $src in
+ -*) src=./$src ;;
+ esac
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
+ if test -n "$dir_arg"; then
+ dst=$src
+ dstdir=$dst
+ test -d "$dstdir"
+ dstdir_status=$?
+ else
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
- '
-IFS="${IFS-${defaultIFS}}"
+ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+ # might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ if test ! -f "$src" && test ! -d "$src"; then
+ echo "$0: $src does not exist." >&2
+ exit 1
+ fi
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
+ if test -z "$dstarg"; then
+ echo "$0: no destination specified." >&2
+ exit 1
+ fi
-pathcomp=''
+ dst=$dstarg
+ # Protect names starting with `-'.
+ case $dst in
+ -*) dst=./$dst ;;
+ esac
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
+ # If destination is a directory, append the input filename; won't work
+ # if double slashes aren't ignored.
+ if test -d "$dst"; then
+ if test -n "$no_target_directory"; then
+ echo "$0: $dstarg: Is a directory" >&2
+ exit 1
+ fi
+ dstdir=$dst
+ dst=$dstdir/`basename "$src"`
+ dstdir_status=0
+ else
+ # Prefer dirname, but fall back on a substitute if dirname fails.
+ dstdir=`
+ (dirname "$dst") 2>/dev/null ||
+ expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$dst" : 'X\(//\)[^/]' \| \
+ X"$dst" : 'X\(//\)$' \| \
+ X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+ echo X"$dst" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'
+ `
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
+ test -d "$dstdir"
+ dstdir_status=$?
+ fi
+ fi
+
+ obsolete_mkdir_used=false
+
+ if test $dstdir_status != 0; then
+ case $posix_mkdir in
+ '')
+ # Create intermediate dirs using mode 755 as modified by the umask.
+ # This is like FreeBSD 'install' as of 1997-10-28.
+ umask=`umask`
+ case $stripcmd.$umask in
+ # Optimize common cases.
+ *[2367][2367]) mkdir_umask=$umask;;
+ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+ *[0-7])
+ mkdir_umask=`expr $umask + 22 \
+ - $umask % 100 % 40 + $umask % 20 \
+ - $umask % 10 % 4 + $umask % 2
+ `;;
+ *) mkdir_umask=$umask,go-w;;
+ esac
+
+ # With -d, create the new directory with the user-specified mode.
+ # Otherwise, rely on $mkdir_umask.
+ if test -n "$dir_arg"; then
+ mkdir_mode=-m$mode
else
- :
+ mkdir_mode=
fi
- pathcomp="${pathcomp}/"
-done
-fi
+ posix_mkdir=false
+ case $umask in
+ *[123567][0-7][0-7])
+ # POSIX mkdir -p sets u+wx bits regardless of umask, which
+ # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+ ;;
+ *)
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
+ if (umask $mkdir_umask &&
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+ then
+ if test -z "$dir_arg" || {
+ # Check for POSIX incompatibilities with -m.
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+ # other-writeable bit of parent directory when it shouldn't.
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+ ls_ld_tmpdir=`ls -ld "$tmpdir"`
+ case $ls_ld_tmpdir in
+ d????-?r-*) different_mode=700;;
+ d????-?--*) different_mode=755;;
+ *) false;;
+ esac &&
+ $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+ ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+ }
+ }
+ then posix_mkdir=:
+ fi
+ rmdir "$tmpdir/d" "$tmpdir"
+ else
+ # Remove any dirs left behind by ancient mkdir implementations.
+ rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+ fi
+ trap '' 0;;
+ esac;;
+ esac
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
-else
+ if
+ $posix_mkdir && (
+ umask $mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+ )
+ then :
+ else
-# If we're going to rename the final executable, determine the name now.
+ # The umask is ridiculous, or mkdir does not conform to POSIX,
+ # or it failed possibly due to a race condition. Create the
+ # directory the slow way, step by step, checking for races as we go.
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
+ case $dstdir in
+ /*) prefix=/ ;;
+ -*) prefix=./ ;;
+ *) prefix= ;;
+ esac
-# don't allow the sed command to completely eliminate the filename
+ case $posix_glob in
+ '')
+ if (set -f) 2>/dev/null; then
+ posix_glob=true
+ else
+ posix_glob=false
+ fi ;;
+ esac
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
+ oIFS=$IFS
+ IFS=/
+ $posix_glob && set -f
+ set fnord $dstdir
+ shift
+ $posix_glob && set +f
+ IFS=$oIFS
+
+ prefixes=
+
+ for d
+ do
+ test -z "$d" && continue
+
+ prefix=$prefix$d
+ if test -d "$prefix"; then
+ prefixes=
else
- :
+ if $posix_mkdir; then
+ (umask=$mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+ # Don't fail if two instances are running concurrently.
+ test -d "$prefix" || exit 1
+ else
+ case $prefix in
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) qprefix=$prefix;;
+ esac
+ prefixes="$prefixes '$qprefix'"
+ fi
fi
+ prefix=$prefix/
+ done
-# Make a temp file name in the proper directory.
+ if test -n "$prefixes"; then
+ # Don't fail if two instances are running concurrently.
+ (umask $mkdir_umask &&
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
+ test -d "$dstdir" || exit 1
+ obsolete_mkdir_used=true
+ fi
+ fi
+ fi
- dsttmp=$dstdir/#inst.$$#
+ if test -n "$dir_arg"; then
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+ else
-# Move or copy the file name to the temp name
+ # Make a couple of temp file names in the proper directory.
+ dsttmp=$dstdir/_inst.$$_
+ rmtmp=$dstdir/_rm.$$_
- $doit $instcmd $src $dsttmp &&
+ # Trap to clean up those temp files at exit.
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
- trap "rm -f ${dsttmp}" 0 &&
+ # Copy the file name to the temp name.
+ (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
-# and set any options; do chmod last to preserve setuid bits
+ # and set any options; do chmod last to preserve setuid bits.
+ #
+ # If any of these fail, we abort the whole thing. If we want to
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
+ #
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
+ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
+ && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
+ && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
+ # Now rename the file to the real destination.
+ { $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \
+ || {
+ # The rename failed, perhaps because mv can't rename something else
+ # to itself, or perhaps because mv is so ancient that it does not
+ # support -f.
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
+ # Now remove or move aside any old file at destination location.
+ # We try this two ways since rm can't unlink itself on some
+ # systems and the destination file might be busy for other
+ # reasons. In this case, the final cleanup might fail but the new
+ # file should still install successfully.
+ {
+ if test -f "$dst"; then
+ $doit $rmcmd -f "$dst" 2>/dev/null \
+ || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \
+ && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\
+ || {
+ echo "$0: cannot unlink or rename $dst" >&2
+ (exit 1); exit 1
+ }
+ else
+ :
+ fi
+ } &&
-# Now rename the file to the real destination.
+ # Now rename the file to the real destination.
+ $doit $mvcmd "$dsttmp" "$dst"
+ }
+ } || exit 1
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
+ trap '' 0
+ fi
+done
-fi &&
-
-
-exit 0
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
Modified: tuxtype/trunk/missing
===================================================================
--- tuxtype/trunk/missing 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/missing 2007-08-25 18:12:22 UTC (rev 213)
@@ -1,6 +1,10 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
-# Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+
+scriptversion=2006-05-10.23
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
+# Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
@@ -15,8 +19,8 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -29,6 +33,8 @@
fi
run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
# In the cases where this matters, `missing' is being run in the
# srcdir already.
@@ -38,19 +44,25 @@
configure_ac=configure.in
fi
-case "$1" in
+msg="missing on your system"
+
+case $1 in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
+ # Exit code 63 means version mismatch. This often happens
+ # when the user try to use an ancient version of a tool on
+ # a file that requires a minimum version. In this case we
+ # we should proceed has if the program had been absent, or
+ # if --run hadn't been passed.
+ if test $? = 63; then
+ run=:
+ msg="probably too old"
+ fi
;;
-esac
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case "$1" in
-
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
@@ -67,6 +79,7 @@
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
+ autom4te touch the output file, or create a stub one
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
@@ -74,11 +87,15 @@
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
- yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Send bug reports to <bug-automake at gnu.org>."
+ exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
- echo "missing 0.4 - GNU automake"
+ echo "missing $scriptversion (GNU Automake)"
+ exit $?
;;
-*)
@@ -87,14 +104,44 @@
exit 1
;;
- aclocal*)
+esac
+
+# Now exit if we have it, but it failed. Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).
+case $1 in
+ lex|yacc)
+ # Not GNU programs, they don't have --version.
+ ;;
+
+ tar)
+ if test -n "$run"; then
+ echo 1>&2 "ERROR: \`tar' requires --run"
+ exit 1
+ elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+ exit 1
+ fi
+ ;;
+
+ *)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
+ elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+ # Could not run --version or --help. This is probably someone
+ # running `$TOOL --version' or `$TOOL --help' to check whether
+ # $TOOL exists and not knowing $TOOL uses missing.
+ exit 1
fi
+ ;;
+esac
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $1 in
+ aclocal*)
echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
+WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
@@ -102,13 +149,8 @@
;;
autoconf)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- fi
-
echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
+WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
@@ -116,13 +158,8 @@
;;
autoheader)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- fi
-
echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
+WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
@@ -130,7 +167,7 @@
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
- case "$f" in
+ case $f in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
@@ -140,13 +177,8 @@
;;
automake*)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- fi
-
echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
+WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
@@ -156,20 +188,15 @@
;;
autom4te)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- fi
-
echo 1>&2 "\
-WARNING: \`$1' is needed, and you do not seem to have it handy on your
- system. You might have modified some files without having the
+WARNING: \`$1' is needed, but is $msg.
+ You might have modified some files without having the
proper tools for further handling them.
- You can get \`$1Help2man' as part of \`Autoconf' from any GNU
+ You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
- file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
- test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
@@ -185,74 +212,67 @@
bison|yacc)
echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
+WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
- if [ $# -ne 1 ]; then
+ if test $# -ne 1; then
eval LASTARG="\${$#}"
- case "$LASTARG" in
+ case $LASTARG in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
- if [ -f "$SRCFILE" ]; then
+ if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
- if [ -f "$SRCFILE" ]; then
+ if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
- if [ ! -f y.tab.h ]; then
+ if test ! -f y.tab.h; then
echo >y.tab.h
fi
- if [ ! -f y.tab.c ]; then
+ if test ! -f y.tab.c; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
+WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
- if [ $# -ne 1 ]; then
+ if test $# -ne 1; then
eval LASTARG="\${$#}"
- case "$LASTARG" in
+ case $LASTARG in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
- if [ -f "$SRCFILE" ]; then
+ if test -f "$SRCFILE"; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
- if [ ! -f lex.yy.c ]; then
+ if test ! -f lex.yy.c; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- fi
-
echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
+WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
- file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
- if test -z "$file"; then
- file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
- fi
- if [ -f "$file" ]; then
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
@@ -262,54 +282,58 @@
;;
makeinfo)
- if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
- # We have makeinfo, but it failed.
- exit 1
- fi
-
echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
+WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
- file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ # The file to touch is that specified with -o ...
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -z "$file"; then
- file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
- file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+ # ... or it is the one specified with @setfilename ...
+ infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '
+ /^@setfilename/{
+ s/.* \([^ ]*\) *$/\1/
+ p
+ q
+ }' $infile`
+ # ... or it is derived from the source name (dir/f.texi becomes f.info)
+ test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
+ # If the file does not exist, the user really needs makeinfo;
+ # let's fail without touching anything.
+ test -f $file || exit 1
touch $file
;;
tar)
shift
- if test -n "$run"; then
- echo 1>&2 "ERROR: \`tar' requires --run"
- exit 1
- fi
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
- gnutar ${1+"$@"} && exit 0
+ gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
- gtar ${1+"$@"} && exit 0
+ gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
- case "$firstarg" in
+ case $firstarg in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
- tar "$firstarg" ${1+"$@"} && exit 0
+ tar "$firstarg" "$@" && exit 0
;;
esac
- case "$firstarg" in
+ case $firstarg in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
- tar "$firstarg" ${1+"$@"} && exit 0
+ tar "$firstarg" "$@" && exit 0
;;
esac
fi
@@ -323,10 +347,10 @@
*)
echo 1>&2 "\
-WARNING: \`$1' is needed, and you do not seem to have it handy on your
- system. You might have modified some files without having the
+WARNING: \`$1' is needed, and is $msg.
+ You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
- it often tells you about the needed prerequirements for installing
+ it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
@@ -334,3 +358,10 @@
esac
exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
Modified: tuxtype/trunk/mkinstalldirs
===================================================================
--- tuxtype/trunk/mkinstalldirs 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/mkinstalldirs 2007-08-25 18:12:22 UTC (rev 213)
@@ -1,31 +1,59 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <friedman at prep.ai.mit.edu>
+
+scriptversion=2006-05-11.19
+
+# Original author: Noah Friedman <friedman at prep.ai.mit.edu>
# Created: 1993-05-16
-# Public domain
+# Public domain.
+#
+# This file is maintained in Automake, please report
+# bugs to <bug-automake at gnu.org> or send patches to
+# <automake-patches at gnu.org>.
-# $Id: mkinstalldirs,v 1.6 2004/03/30 01:41:31 calarndt Exp $
-
+nl='
+'
+IFS=" "" $nl"
errstatus=0
-dirmode=""
+dirmode=
usage="\
-Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
+Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
+Create each directory DIR (with mode MODE, if specified), including all
+leading file name components.
+
+Report bugs to <bug-automake at gnu.org>."
+
# process command line arguments
while test $# -gt 0 ; do
- case "${1}" in
- -h | --help | --h* ) # -h for help
- echo "${usage}" 1>&2; exit 0 ;;
- -m ) # -m PERM arg
- shift
- test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
- dirmode="${1}"
- shift ;;
- -- ) shift; break ;; # stop option processing
- -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option
- * ) break ;; # first non-opt arg
- esac
+ case $1 in
+ -h | --help | --h*) # -h for help
+ echo "$usage"
+ exit $?
+ ;;
+ -m) # -m PERM arg
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ dirmode=$1
+ shift
+ ;;
+ --version)
+ echo "$0 $scriptversion"
+ exit $?
+ ;;
+ --) # stop option processing
+ shift
+ break
+ ;;
+ -*) # unknown option
+ echo "$usage" 1>&2
+ exit 1
+ ;;
+ *) # first non-opt arg
+ break
+ ;;
+ esac
done
for file
@@ -38,64 +66,96 @@
done
case $# in
-0) exit 0 ;;
+ 0) exit 0 ;;
esac
+# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
+# mkdir -p a/c at the same time, both will detect that a is missing,
+# one will create a, then the other will try to create a and die with
+# a "File exists" error. This is a problem when calling mkinstalldirs
+# from a parallel make. We use --version in the probe to restrict
+# ourselves to GNU mkdir, which is thread-safe.
case $dirmode in
-'')
- if mkdir -p -- . 2>/dev/null; then
- echo "mkdir -p -- $*"
- exec mkdir -p -- "$@"
- fi ;;
-*)
- if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
- echo "mkdir -m $dirmode -p -- $*"
- exec mkdir -m "$dirmode" -p -- "$@"
- fi ;;
+ '')
+ if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
+ echo "mkdir -p -- $*"
+ exec mkdir -p -- "$@"
+ else
+ # On NextStep and OpenStep, the `mkdir' command does not
+ # recognize any option. It will interpret all options as
+ # directories to create, and then abort because `.' already
+ # exists.
+ test -d ./-p && rmdir ./-p
+ test -d ./--version && rmdir ./--version
+ fi
+ ;;
+ *)
+ if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
+ test ! -d ./--version; then
+ echo "mkdir -m $dirmode -p -- $*"
+ exec mkdir -m "$dirmode" -p -- "$@"
+ else
+ # Clean up after NextStep and OpenStep mkdir.
+ for d in ./-m ./-p ./--version "./$dirmode";
+ do
+ test -d $d && rmdir $d
+ done
+ fi
+ ;;
esac
for file
do
- set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
- shift
+ case $file in
+ /*) pathcomp=/ ;;
+ *) pathcomp= ;;
+ esac
+ oIFS=$IFS
+ IFS=/
+ set fnord $file
+ shift
+ IFS=$oIFS
- pathcomp=
- for d
- do
- pathcomp="$pathcomp$d"
- case "$pathcomp" in
- -* ) pathcomp=./$pathcomp ;;
- esac
+ for d
+ do
+ test "x$d" = x && continue
- if test ! -d "$pathcomp"; then
- echo "mkdir $pathcomp"
+ pathcomp=$pathcomp$d
+ case $pathcomp in
+ -*) pathcomp=./$pathcomp ;;
+ esac
- mkdir "$pathcomp" || lasterr=$?
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp"
- if test ! -d "$pathcomp"; then
- errstatus=$lasterr
- else
- if test ! -z "$dirmode"; then
- echo "chmod $dirmode $pathcomp"
+ mkdir "$pathcomp" || lasterr=$?
- lasterr=""
- chmod "$dirmode" "$pathcomp" || lasterr=$?
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ else
+ if test ! -z "$dirmode"; then
+ echo "chmod $dirmode $pathcomp"
+ lasterr=
+ chmod "$dirmode" "$pathcomp" || lasterr=$?
- if test ! -z "$lasterr"; then
- errstatus=$lasterr
- fi
+ if test ! -z "$lasterr"; then
+ errstatus=$lasterr
fi
fi
- fi
+ fi
+ fi
- pathcomp="$pathcomp/"
- done
+ pathcomp=$pathcomp/
+ done
done
exit $errstatus
# Local Variables:
# mode: shell-script
-# sh-indentation: 3
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
# End:
-# mkinstalldirs ends here
Modified: tuxtype/trunk/tuxtype/alphabet.c
===================================================================
--- tuxtype/trunk/tuxtype/alphabet.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/alphabet.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -28,8 +28,8 @@
#include "globals.h"
#include "funcs.h"
+/* NOTE these are externed in globals.h so not static */
/* the colors we use throughout the game */
-
SDL_Color black;
SDL_Color gray;
SDL_Color dark_blue;
@@ -37,14 +37,17 @@
SDL_Color white;
SDL_Color yellow;
+
+static TTF_Font* font = NULL;
+
/* Used for word list functions (see below): */
static int num_words;
-wchar_t word_list[MAX_NUM_WORDS][MAX_WORD_SIZE + 1];
-wchar_t char_list[MAX_UNICODES]; // List of distinct letters in list
+static wchar_t word_list[MAX_NUM_WORDS][MAX_WORD_SIZE + 1];
+static wchar_t char_list[MAX_UNICODES]; // List of distinct letters in list
static int num_chars_used = 0; // Number of different letters in word list
/* These are the arrays for the red and white letters: */
-uni_glyph char_glyphs[MAX_UNICODES];
+static uni_glyph char_glyphs[MAX_UNICODES];
/* Local function prototypes: */
static void gen_char_list(void);
@@ -56,7 +59,7 @@
#ifndef WIN32
-SDLPango_Matrix* SDL_Colour_to_SDLPango_Matrix(const SDL_Color* cl);
+static SDLPango_Matrix* SDL_Colour_to_SDLPango_Matrix(const SDL_Color* cl);
#endif
@@ -144,7 +147,7 @@
ALPHABET[(int)wide_str[j]] = 1; // first character is default
}
else
- fprintf(stderr, "LoadKeyboard() - Unicode char outside supported range\n");
+ fprintf(stderr, "LoadKeyboard() - Unicode char outside Western range\n");
//for (i++; i<wcslen(wide_str); i++)
//KEYMAP[(int)wide_str[i]] = wide_str[j];
@@ -159,7 +162,7 @@
FINGER[wide_str[j]][(int)(wide_str[i] - '0')] = 1;
}
else
- fprintf(stderr, "LoadKeyboard() - Unicode char outside supported range\n");
+ fprintf(stderr, "LoadKeyboard() - Unicode char outside Western range\n");
}
}
ALPHABET_SIZE++;
@@ -730,7 +733,7 @@
{
t = char_list[i];
- if(TTF_GlyphMetrics(font, t, NULL , NULL, NULL,
+ if(TTF_GlyphMetrics(letter_font, t, NULL , NULL, NULL,
&maxy, NULL) == -1)
{
fprintf(stderr, "Could not get glyph metrics for %lc", t);
@@ -744,8 +747,8 @@
}
char_glyphs[i].unicode_value = t;
- char_glyphs[i].white_glyph = BlackOutline_wchar(t, font, &white);
- char_glyphs[i].red_glyph = BlackOutline_wchar(t, font, &red);
+ char_glyphs[i].white_glyph = BlackOutline_wchar(t, letter_font, &white);
+ char_glyphs[i].red_glyph = BlackOutline_wchar(t, letter_font, &red);
char_glyphs[i].max_y = maxy;
i++;
Modified: tuxtype/trunk/tuxtype/audio.c
===================================================================
--- tuxtype/trunk/tuxtype/audio.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/audio.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -18,12 +18,10 @@
#include "globals.h"
#include "funcs.h"
-/* NOTE these two don't really belong here - not used in this file */
-Mix_Chunk* sound[NUM_WAVES];
-Mix_Music* music;
-Mix_Music* defaultMusic = NULL; // holds music for audioMusicLoad/unload
+static Mix_Music* defaultMusic = NULL; // holds music for audioMusicLoad/unload
+
void PlaySound(Mix_Chunk* snd) {
if (!settings.sys_sound) return;
Modified: tuxtype/trunk/tuxtype/data/fonts/Makefile.am
===================================================================
--- tuxtype/trunk/tuxtype/data/fonts/Makefile.am 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/data/fonts/Makefile.am 2007-08-25 18:12:22 UTC (rev 213)
@@ -1,12 +1,12 @@
-EXTRA_DIST = AndikaDesRevG.ttf DoulosSILR.ttf Rachana_g01.ttf
+EXTRA_DIST = AndikaDesRevG.ttf DoulosSILR.ttf Rachana_w01.ttf
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts
$(INSTALL_DATA) $(srcdir)/AndikaDesRevG.ttf $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts
$(INSTALL_DATA) $(srcdir)/DoulosSILR.ttf $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts
- $(INSTALL_DATA) $(srcdir)/Rachana_g01.ttf $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts
+ $(INSTALL_DATA) $(srcdir)/Rachana_w01.ttf $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts
uninstall-local:
rm -f $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts/AndikaDesRevG.ttf
rm -f $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts/DoulosSILR.ttf
- rm -f $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts/Rachana_g01.ttf
+ rm -f $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts/Rachana_w01.ttf
Deleted: tuxtype/trunk/tuxtype/data/fonts/Rachana_g01.ttf
===================================================================
(Binary files differ)
Added: tuxtype/trunk/tuxtype/data/fonts/Rachana_w01.ttf
===================================================================
(Binary files differ)
Property changes on: tuxtype/trunk/tuxtype/data/fonts/Rachana_w01.ttf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: tuxtype/trunk/tuxtype/data/themes/espanol/Makefile.am
===================================================================
--- tuxtype/trunk/tuxtype/data/themes/espanol/Makefile.am 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/data/themes/espanol/Makefile.am 2007-08-25 18:12:22 UTC (rev 213)
@@ -4,8 +4,8 @@
EXTRA_DIST = lang.po
install-data-local:
- $(mkinstalldirs) $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/themes/armenian
- $(INSTALL_DATA) $(srcdir)/lang.po $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/themes/armenian/lang.po
+ $(mkinstalldirs) $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/themes/espanol
+ $(INSTALL_DATA) $(srcdir)/lang.po $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/themes/espanol/lang.po
uninstall-local:
- rm -f $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/themes/armenian/lang.po
+ rm -f $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/themes/espanol/lang.po
Modified: tuxtype/trunk/tuxtype/data/themes/espanol/Makefile.in
===================================================================
--- tuxtype/trunk/tuxtype/data/themes/espanol/Makefile.in 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/data/themes/espanol/Makefile.in 2007-08-25 18:12:22 UTC (rev 213)
@@ -472,11 +472,11 @@
install-data-local:
- $(mkinstalldirs) $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/themes/armenian
- $(INSTALL_DATA) $(srcdir)/lang.po $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/themes/armenian/lang.po
+ $(mkinstalldirs) $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/themes/espanol
+ $(INSTALL_DATA) $(srcdir)/lang.po $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/themes/espanol/lang.po
uninstall-local:
- rm -f $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/themes/armenian/lang.po
+ rm -f $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/themes/espanol/lang.po
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
Modified: tuxtype/trunk/tuxtype/gettext.c
===================================================================
--- tuxtype/trunk/tuxtype/gettext.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/gettext.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -33,10 +33,10 @@
typedef struct node item;
-item *HEAD=NULL;
+static item* HEAD = NULL;
/* Local function prototypes: */
-void add_word(unsigned char* in, unsigned char* out);
+static void add_word(unsigned char* in, unsigned char* out);
/* --- add a word to the linked list --- */
@@ -94,8 +94,14 @@
LOG( "Loading translation file\n" );
f = fopen( file, "r" );
- if (f == NULL) return -1;
-
+ if (f == NULL)
+ {
+ DEBUGCODE
+ {
+ fprintf(stderr, "Load_PO_File() - could not open %s\n", file);
+ }
+ return -1;
+ }
/* ### ADD ERROR CHECKING ### */
do {
Modified: tuxtype/trunk/tuxtype/globals.h
===================================================================
--- tuxtype/trunk/tuxtype/globals.h 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/globals.h 2007-08-25 18:12:22 UTC (rev 213)
@@ -189,8 +189,10 @@
extern game_option_type settings;
+/* FIXME get rid of as much global data as possible, esp. pointers */
+
extern SDL_Surface* screen;
-extern TTF_Font* font;
+//extern TTF_Font* font;
extern SDL_Event event;
extern SDL_Color black;
@@ -200,7 +202,6 @@
extern SDL_Color white;
extern SDL_Color yellow;
-extern SDL_Surface* bkg;
extern SDL_Surface* letters[255]; /* Will be going away */
/* These need some work to support Unicode & i18n: */
@@ -221,9 +222,6 @@
NUM_WAVES
};
-extern Mix_Chunk* sound[NUM_WAVES];
-extern Mix_Music* music;
-
#define MUSIC_FADE_OUT_MS 80
enum {
Modified: tuxtype/trunk/tuxtype/laser.c
===================================================================
--- tuxtype/trunk/tuxtype/laser.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/laser.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -21,14 +21,7 @@
#include "funcs.h"
#include "laser.h"
-sprite* shield = NULL;
-SDL_Surface* images[NUM_IMAGES] = {NULL};
-Mix_Chunk* sounds[NUM_SOUNDS] = {NULL};
-Mix_Music* musics[NUM_MUSICS] = {NULL};
-SDL_Surface* bkgd = NULL;
-
-
#define FPS (1000 / 15) /* 15 fps max */
#define CITY_EXPL_START 3 * 5 /* Must be mult. of 5 (number of expl frames) */
#define COMET_EXPL_START 2 * 2 /* Must be mult. of 2 (number of expl frames) */
@@ -40,26 +33,32 @@
#define COMET_ZAP_FONT_SIZE 32
/* Local (to laser.c) 'globals': */
+static sprite* shield = NULL;
+static SDL_Surface* images[NUM_IMAGES] = {NULL};
+static Mix_Chunk* sounds[NUM_SOUNDS] = {NULL};
+static Mix_Music* musics[NUM_MUSICS] = {NULL};
+static SDL_Surface* bkgd = NULL;
+static TTF_Font* font = NULL;
-int wave, speed, score, pre_wave_score, num_attackers, distanceMoved;
-wchar_t ans[NUM_ANS];
-int ans_num;
+static int wave, speed, score, pre_wave_score, num_attackers, distanceMoved;
+static wchar_t ans[NUM_ANS];
+static int ans_num;
-comet_type comets[MAX_COMETS];
-city_type cities[NUM_CITIES];
-laser_type laser;
+static comet_type comets[MAX_COMETS];
+static city_type cities[NUM_CITIES];
+static laser_type laser;
/* Local function prototypes: */
-void laser_add_comet(int diff_level);
-void laser_add_score(int inc);
-void laser_draw_console_image(int i);
-void laser_draw_let(wchar_t c, int x, int y);
-void laser_draw_line(int x1, int y1, int x2, int y2, int r, int g, int b);
-void laser_draw_numbers(const unsigned char* str, int x);
-void laser_load_data(void);
-void laser_reset_level(int diff_level);
-void laser_putpixel(SDL_Surface* surface, int x, int y, Uint32 pixel);
-void laser_unload_data(void);
+static void laser_add_comet(int diff_level);
+static void laser_add_score(int inc);
+static void laser_draw_console_image(int i);
+static void laser_draw_let(wchar_t c, int x, int y);
+static void laser_draw_line(int x1, int y1, int x2, int y2, int r, int g, int b);
+static void laser_draw_numbers(const unsigned char* str, int x);
+static void laser_load_data(void);
+static void laser_reset_level(int diff_level);
+static void laser_putpixel(SDL_Surface* surface, int x, int y, Uint32 pixel);
+static void laser_unload_data(void);
/* --- MAIN GAME FUNCTION!!! --- */
@@ -652,7 +651,7 @@
/* --- Load all media --- */
-void laser_load_data(void)
+static void laser_load_data(void)
{
int i;
@@ -679,7 +678,7 @@
/* --- unload all media --- */
-void laser_unload_data(void) {
+static void laser_unload_data(void) {
int i;
FreeLetters();
@@ -695,17 +694,18 @@
}
FreeSprite(shield);
+ shield = NULL;
PauseUnloadMedia();
-
TTF_CloseFont(font);
+ font = NULL;
}
/* Reset stuff for the next level! */
-void laser_reset_level(int diff_level)
+static void laser_reset_level(int diff_level)
{
unsigned char fname[1024];
static int last_bkgd = -1;
@@ -769,7 +769,7 @@
/* Add an comet to the game (if there's room): */
-void laser_add_comet(int diff_level) {
+static void laser_add_comet(int diff_level) {
int target, location = 0;
static int last = -1;
@@ -870,7 +870,7 @@
/* Draw numbers/symbols over the attacker: */
-void laser_draw_let(wchar_t c, int x, int y)
+static void laser_draw_let(wchar_t c, int x, int y)
{
int top_x, top_y;
SDL_Rect dst;
@@ -888,7 +888,7 @@
/* Draw status numbers: */
-void laser_draw_numbers(const unsigned char* str, int x)
+static void laser_draw_numbers(const unsigned char* str, int x)
{
int i, cur_x, c;
SDL_Rect src, dest;
@@ -937,7 +937,7 @@
/* Draw a line: */
-void laser_draw_line(int x1, int y1, int x2, int y2, int red, int grn, int blu)
+static void laser_draw_line(int x1, int y1, int x2, int y2, int red, int grn, int blu)
{
int dx, dy, tmp;
float m, b;
@@ -990,7 +990,7 @@
/* Draw a single pixel into the surface: */
-void laser_putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel)
+static void laser_putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel)
{
#ifdef PUTPIXEL_RAW
int bpp;
@@ -1055,7 +1055,7 @@
/* Draw image at lower center of screen: */
-void laser_draw_console_image(int i)
+static void laser_draw_console_image(int i)
{
SDL_Rect dest;
@@ -1070,7 +1070,7 @@
/* Increment score: */
-void laser_add_score(int inc)
+static void laser_add_score(int inc)
{
score += inc;
if (score < 0) score = 0;
Modified: tuxtype/trunk/tuxtype/loaders.c
===================================================================
--- tuxtype/trunk/tuxtype/loaders.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/loaders.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -21,8 +21,8 @@
#include "funcs.h"
/* Local function prototypes: */
-int max(int n1, int n2);
-SDL_Surface* flip(SDL_Surface *in, int x, int y);
+static int max(int n1, int n2);
+static SDL_Surface* flip(SDL_Surface *in, int x, int y);
/* Returns 1 if valid file, 2 if valid dir, 0 if neither: */
int CheckFile(const char* file)
@@ -91,6 +91,7 @@
if (0 != Load_PO_File( fn )) /* Meaning it failed! */
{
/* failed to find a lang.po file, clear gettext & return */
+ fprintf(stderr, "LoadLang() - could not load lang.po file for %s\n", fn);
return;
}
}
@@ -213,13 +214,22 @@
DEBUGCODE { fprintf(stderr, "LoadFont(): looking for %s using data paths\n", fn); }
/* try to load the font, if successful, return font*/
- loaded_font = TTF_OpenFont(fn, font_size);
- if (loaded_font != NULL)
- return loaded_font;
+ loaded_font = TTF_OpenFont(fn, font_size);
+ if (loaded_font != NULL)
+ return loaded_font;
- /* HACK hard-coded for Debian once Andika is included: */
- sprintf(fn, "%s/%s", "/usr/share/fonts/truetype/ttf-andika/", font_name);
+ /* HACK hard-coded for Debian (and current exact font names): */
+
+ if (strncmp(font_name, "AndikaDesRevG.ttf", FNLEN ) == 0)
+ sprintf(fn, "%s/%s", "/usr/share/fonts/truetype/ttf-sil-andika-desrev", font_name);
+ else if (strncmp(font_name, "DoulosSILR.ttf", FNLEN ) == 0)
+ sprintf(fn, "%s/%s", "/usr/share/fonts/truetype/ttf-sil-doulos", font_name);
+ else if (strncmp(font_name, "Rachana_w01.ttf", FNLEN ) == 0)
+ sprintf(fn, "%s/%s", "/usr/share/fonts/truetype/ttf-malayalam-fonts", font_name);
+
+
+
DEBUGCODE { fprintf(stderr, "LoadFont(): looking for %s\n in OS' font path\n", fn); }
/* try to load the font, if successful, return font*/
@@ -227,7 +237,7 @@
if (loaded_font != NULL)
return loaded_font;
- fprintf(stderr, "LoadFont(): Error - couldn't load font: %s\n", font_name);
+ fprintf(stderr, "LoadFont(): Error - couldn't load font: %s\n", fn);
return NULL;
}
@@ -370,12 +380,17 @@
return new_sprite;
}
-void FreeSprite(sprite *gfx ) {
- int x;
- for (x = 0; x < gfx->num_frames; x++)
- SDL_FreeSurface( gfx->frame[x] );
- SDL_FreeSurface( gfx->default_img );
- free(gfx);
+void FreeSprite(sprite* gfx )
+{
+ int x;
+
+ if (!gfx)
+ return;
+
+ for (x = 0; x < gfx->num_frames; x++)
+ SDL_FreeSurface(gfx->frame[x]);
+ SDL_FreeSurface(gfx->default_img);
+ free(gfx);
}
/***************************
Modified: tuxtype/trunk/tuxtype/main.c
===================================================================
--- tuxtype/trunk/tuxtype/main.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/main.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -20,7 +20,6 @@
#include "funcs.h"
SDL_Surface* screen;
-SDL_Surface* bkg;
SDL_Event event;
@@ -39,14 +38,6 @@
/* Initialize settings with hard-coded defaults: */
Opts_Initialize();
-// settings.sys_sound = 1; //default using system sounds
-// settings.speed_up = 0; //run at normal speed
-// settings.show_tux4kids = 1; //show tux4kids logo the first time in main menu
-// settings.use_english = 1; //default to no theme
-// settings.debug_on = 0; //default to not in debug mode
-// settings.hidden = 0; //default to no "hidden" background
-
-
srand(time(NULL));
// This sets settings.default_data_path to the default theme file path:
Modified: tuxtype/trunk/tuxtype/pause.c
===================================================================
--- tuxtype/trunk/tuxtype/pause.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/pause.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -19,16 +19,15 @@
#include "globals.h"
#include "funcs.h"
-Mix_Chunk *pause_sfx;
-SDL_Surface *up, *down, *left, *right;
-SDL_Rect rectUp, rectDown, rectLeft, rectRight;
-TTF_Font *f1, *f2;
-extern game_option_type settings;
+static Mix_Chunk *pause_sfx;
+static SDL_Surface *up, *down, *left, *right;
+static SDL_Rect rectUp, rectDown, rectLeft, rectRight;
+static TTF_Font *f1, *f2;
/* Local function prototypes: */
-void darkenscreen(void);
-void draw_vols(int sfx, int mus);
-void pause_draw_info(void);
+static void darkenscreen(void);
+static void draw_vols(int sfx, int mus);
+static void pause_draw_info(void);
// QUESTION: For usability sake, should escape return to the game
@@ -223,22 +222,27 @@
void PauseUnloadMedia(void) {
if (settings.sys_sound)
- Mix_FreeChunk(pause_sfx);
+ {
+ Mix_FreeChunk(pause_sfx);
+ pause_sfx = NULL;
+ }
SDL_FreeSurface(up);
SDL_FreeSurface(down);
SDL_FreeSurface(left);
SDL_FreeSurface(right);
+ up = down = left = right = NULL;
TTF_CloseFont(f1);
TTF_CloseFont(f2);
+ f1 = f2 = NULL;
}
/* Slightly useful function but not sure this file is the right place for it. */
int inRect(SDL_Rect r, int x, int y)
{
- if ((x < r.x) || (y < r.y) || (x > r.x + r.w) || (y > r.y + r.h))
- return 0;
- return 1;
+ if ((x < r.x) || (y < r.y) || (x > r.x + r.w) || (y > r.y + r.h))
+ return 0;
+ return 1;
}
@@ -250,7 +254,7 @@
-void pause_draw_info(void) {
+static void pause_draw_info(void) {
SDL_Rect s;
SDL_Surface *t;
@@ -313,7 +317,7 @@
-void draw_vols(int sfx, int mus) {
+static void draw_vols(int sfx, int mus) {
SDL_Rect s,m;
int i;
@@ -343,7 +347,7 @@
* RESULT: it will darken the screen by a factor of 4
* WARNING: only works on 16bit screens right now!
*/
-void darkenscreen(void)
+static void darkenscreen(void)
{
Uint16 rm = screen->format->Rmask;
Uint16 gm = screen->format->Gmask;
Modified: tuxtype/trunk/tuxtype/playgame.c
===================================================================
--- tuxtype/trunk/tuxtype/playgame.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/playgame.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -25,29 +25,29 @@
//void add_words( int level );
/* Should these be constants? */
-int tux_max_width; // the max width of the images of tux
-int number_max_w; // the max width of a number image
+static int tux_max_width; // the max width of the images of tux
+static int number_max_w; // the max width of a number image
//int o_lives; // something cal is working on
//int sound_vol;
+static TTF_Font* font = NULL;
+static SDL_Surface* background = NULL;
+static SDL_Surface* level[NUM_LEVELS] = {NULL};
+static SDL_Surface* number[NUM_NUMS] = {NULL};
+static SDL_Surface* curlev = NULL;
+static SDL_Surface* lives = NULL;
+static SDL_Surface* fish = NULL;
+static SDL_Surface* congrats[CONGRATS_FRAMES] = {NULL};
+static SDL_Surface* ohno[OH_NO_FRAMES] = {NULL};
+static Mix_Chunk* sound[NUM_WAVES];
-SDL_Surface* background;
+static sprite* fishy = NULL;
+static sprite* splat = NULL;
-SDL_Surface* level[NUM_LEVELS];
-SDL_Surface* number[NUM_NUMS];
-SDL_Surface* curlev;
-SDL_Surface* lives;
-SDL_Surface* fish;
-SDL_Surface* congrats[CONGRATS_FRAMES];
-SDL_Surface* ohno[OH_NO_FRAMES];
-
-sprite* fishy;
-sprite* splat;
-
/* --- Data Structure for Dirty Blitting --- */
-SDL_Rect srcupdate[MAX_UPDATES];
-SDL_Rect dstupdate[MAX_UPDATES];
-int numupdates = 0; // tracks how many blits to be done
+static SDL_Rect srcupdate[MAX_UPDATES];
+static SDL_Rect dstupdate[MAX_UPDATES];
+static int numupdates = 0; // tracks how many blits to be done
struct blit {
SDL_Surface* src;
@@ -137,7 +137,9 @@
LoadTuxAnims();
LoadFishies();
LoadOthers();
+printf("before RenderLetters\n");
RenderLetters(font);
+printf("after RenderLetters\n");
LOG( " starting game \n ");
while (still_playing) {
@@ -474,7 +476,7 @@
if(newbkg->w == screen->w && newbkg->h == screen->h) {
if( type == RANDOM_WIPE )
- type = (RANDOM_WIPE* ((float) rand()) / (RAND_MAX+1.0));
+ type = (RANDOM_WIPE * ((float) rand()) / (RAND_MAX+1.0));
switch( type ) {
case WIPE_BLINDS_VERT: {
@@ -1116,18 +1118,22 @@
FreeLetters();
TTF_CloseFont(font);
+ font = NULL;
LOG( "FreeGame():\n-Freeing Tux Animations\n" );
for ( i=0; i < TUX_NUM_STATES; i++ ) {
FreeSprite(tux_object.spr[i][RIGHT]);
FreeSprite(tux_object.spr[i][LEFT]);
+ tux_object.spr[i][RIGHT] = NULL;
+ tux_object.spr[i][LEFT] = NULL;
}
LOG( "-Freeing fishies\n" );
FreeSprite( fishy );
FreeSprite( splat );
+ fishy = splat = NULL;
LOG( "-Freeing other game graphics\n" );
@@ -1135,24 +1141,35 @@
SDL_FreeSurface(curlev);
SDL_FreeSurface(fish);
SDL_FreeSurface(lives);
+ background = curlev = fish = lives = NULL;
for (i = 0; i < NUM_LEVELS; i++)
- SDL_FreeSurface(level[i]);
-
+ {
+ SDL_FreeSurface(level[i]);
+ level[i] = NULL;
+ }
for (i = 0; i < NUM_NUMS; i++)
- SDL_FreeSurface(number[i]);
-
+ {
+ SDL_FreeSurface(number[i]);
+ number[i] = NULL;
+ }
for (i = 0; i < CONGRATS_FRAMES; i++)
- SDL_FreeSurface(congrats[i]);
-
+ {
+ SDL_FreeSurface(congrats[i]);
+ congrats[i] = NULL;
+ }
for (i = 0; i < OH_NO_FRAMES; i++)
- SDL_FreeSurface(ohno[i]);
-
+ {
+ SDL_FreeSurface(ohno[i]);
+ ohno[i] = NULL;
+ }
if (settings.sys_sound) {
- LOG( "-Freeing sound\n" );
-
- for (i = 0; i < NUM_WAVES; ++i)
- Mix_FreeChunk(sound[i]);
+ LOG( "-Freeing sound\n" );
+ for (i = 0; i < NUM_WAVES; ++i)
+ {
+ Mix_FreeChunk(sound[i]);
+ sound[i] = NULL;
+ }
}
PauseUnloadMedia();
Modified: tuxtype/trunk/tuxtype/practice.c
===================================================================
--- tuxtype/trunk/tuxtype/practice.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/practice.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -19,13 +19,14 @@
#include "globals.h"
#include "funcs.h"
-SDL_Surface* hands;
-SDL_Surface* hand[11];
-SDL_Rect hand_loc, letter_loc;
-TTF_Font* font;
-char phrase[255][FNLEN];
+static SDL_Surface* bg = NULL;
+static SDL_Surface* hands = NULL;
+static SDL_Surface* hand[11] = {NULL};
+static SDL_Rect hand_loc, letter_loc;
+static TTF_Font* font = NULL;
+static char phrase[255][FNLEN];
-Mix_Chunk* wrong;
+static Mix_Chunk* wrong = NULL;
/*local function prototypes: */
static int get_phrase(const char* phr);
@@ -65,7 +66,7 @@
totaltime[FNLEN];
practice_load_media();
- SDL_BlitSurface(bkg, NULL, screen, NULL);
+ SDL_BlitSurface(bg, NULL, screen, NULL);
SDL_BlitSurface(hands, NULL, screen, &hand_loc);
SDL_Flip(screen);
@@ -135,8 +136,8 @@
state=0;
dst2.x=40;
dst4.x=480;
- SDL_BlitSurface(bkg, &dst3, screen, &dst2);
- SDL_BlitSurface(bkg, &dst5, screen, &dst4);
+ SDL_BlitSurface(bg, &dst3, screen, &dst2);
+ SDL_BlitSurface(bg, &dst5, screen, &dst4);
SDL_Flip(screen);
SDL_BlitSurface(letters[event.key.keysym.unicode], NULL, screen, &dst);
for (z=0;z<strlen(keytime);z++){
@@ -202,7 +203,7 @@
hand_loc.w = (hand[0]->w);
hand_loc.h = (hand[0]->h);
- bkg = LoadImage("main_bkg.png", IMG_ALPHA);
+ bg = LoadImage("main_bkg.png", IMG_ALPHA);
font = LoadFont(settings.theme_font_name, 32 );
@@ -215,9 +216,10 @@
letters[i] = BlackOutline(let, font, &white);
}
- LOG("DONE - Loading practice media\n");
TTF_CloseFont(font);
+ font = NULL;
+ LOG("DONE - Loading practice media\n");
}
@@ -225,17 +227,25 @@
static void practice_unload_media(void)
{
int i;
- SDL_FreeSurface(bkg);
+ SDL_FreeSurface(bg);
+ bg = NULL;
SDL_FreeSurface(hands);
+ hands = NULL;
//TTF_CloseFont(font);
for (i=0; i<10; i++)
- SDL_FreeSurface(hand[i]);
-
+ {
+ SDL_FreeSurface(hand[i]);
+ hand[i] = NULL;
+ }
for (i=1; i<255; i++)
- if (ALPHABET[i])
- SDL_FreeSurface(letters[i]);
+ if (ALPHABET[i])
+ {
+ SDL_FreeSurface(letters[i]);
+ letters[i] = NULL;
+ }
Mix_FreeChunk(wrong);
+ wrong = NULL;
}
Modified: tuxtype/trunk/tuxtype/scripting.c
===================================================================
--- tuxtype/trunk/tuxtype/scripting.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/scripting.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -96,6 +96,8 @@
SDL_Rect spot, arrow_area;
SDL_Rect leftRect, rightRect;
SDL_Rect titleRects[8];
+
+ TTF_Font* font = NULL;
int stop = 0;
int loc = 0;
@@ -124,6 +126,7 @@
SDL_FreeSurface(left);
SDL_FreeSurface(right);
SDL_FreeSurface(bkg);
+ pointer = left = right = bkg = NULL;
return 0;
}
@@ -188,7 +191,9 @@
} while (1); /* Leave loop when readdir() returns NULL */
TTF_CloseFont(font);
+ font = NULL;
closedir(wordsDir);
+ wordsDir = NULL;
SDL_Flip(screen);
/* Should be safe - tested 'left' and 'right' above: */
@@ -308,6 +313,7 @@
SDL_FreeSurface(left);
SDL_FreeSurface(right);
SDL_FreeSurface(bkg);
+ pointer = left = right = bkg = NULL;
return;
}
@@ -336,6 +342,7 @@
SDL_FreeSurface(left);
SDL_FreeSurface(right);
SDL_FreeSurface(bkg);
+ pointer = left = right = bkg = NULL;
if (load_script( fn ) != 0)
return 0; // bail if any errors occur
@@ -422,556 +429,781 @@
return out;
}
-scriptType *curScript=NULL;
-pageType *curPage=NULL;
-itemType *curItem=NULL;
+scriptType* curScript = NULL;
+pageType* curPage = NULL;
+itemType* curItem = NULL;
static int load_script(const char* fn)
{
- int i;
- char str[FNLEN];
- FILE *f;
+ int i;
+ char str[FNLEN];
+ FILE* f = NULL;
- LOG( "loadScript()\n" );
+ LOG( "loadScript()\n" );
- if (curScript) {
- LOG( "script already in memory, removing now!\n");
- close_script();
- }
+ if (curScript)
+ {
+ LOG( "script already in memory, removing now!\n");
+ close_script();
+ }
- f = fopen( fn, "r" );
- if (f == NULL) { fprintf(stderr, "error loading script %s\n", fn); return -1; }
+ f = fopen(fn, "r");
- do {
- fscanf(f, "%[^\n]\n", str);
- if (strncmp("<script", str, 7)==0) {
-
- /* -- allocate space for the lesson info -- */
- curScript = (scriptType *)calloc(1,sizeof(scriptType));
- for (i=7; i<strlen(str) && str[i]!='>'; i++) {
- if ((str[i]=='t') && strncmp("title", &str[i], 5)==0)
- curScript->title = get_quote(&str[i+5]);
+ if (f == NULL)
+ {
+ fprintf(stderr, "error loading script %s\n", fn);
+ return -1;
+ }
- if ((str[i]=='b') && strncmp("bgcolor", &str[i], 7)==0)
- curScript->bgcolor = get_color(&str[i+7]);
+ do
+ {
+ fscanf(f, "%[^\n]\n", str);
+ if (strncmp("<script", str, 7) == 0)
+ {
+ /* -- allocate space for the lesson info -- */
+ curScript = (scriptType*)calloc(1, sizeof(scriptType));
+ for (i = 7; i < strlen(str) && str[i] != '>'; i++)
+ {
+ if ((str[i] == 't') && strncmp("title", &str[i], 5) == 0)
+ curScript->title = get_quote(&str[i + 5]);
- if ((str[i]=='b') && strncmp("background", &str[i], 10)==0)
- curScript->background = get_quote(&str[i+10]);
+ if ((str[i]=='b') && strncmp("bgcolor", &str[i], 7) == 0)
+ curScript->bgcolor = get_color(&str[i + 7]);
- if ((str[i]=='f') && strncmp("fgcolor", &str[i], 7)==0)
- curScript->fgcolor = get_color(&str[i+7]);
- }
- } else if (strncmp("<page", str, 5)==0) {
- if (curScript==NULL) { fprintf(stderr, "CRITICAL XML ERROR: <page> should be in a <script> in file %s line (todo)", fn); exit(1); }
+ if ((str[i]=='b') && strncmp("background", &str[i], 10) == 0)
+ curScript->background = get_quote(&str[i + 10]);
- if (curScript->pages==NULL) {
- curPage = (pageType *)calloc(1,sizeof(pageType));
- curPage->prev = curPage;
- curScript->pages = curPage;
- } else {
- curPage->next = (pageType *)calloc(1,sizeof(pageType));
- curPage->next->prev = curPage;
- curPage = curPage->next;
- }
+ if ((str[i]=='f') && strncmp("fgcolor", &str[i], 7) == 0)
+ curScript->fgcolor = get_color(&str[i + 7]);
+ }
+ }
+ else if (strncmp("<page", str, 5)==0)
+ {
+ if (curScript==NULL)
+ {
+ fprintf(stderr, "CRITICAL XML ERROR: <page> should be in a <script> in file %s line (todo)", fn); exit(1);
+ }
- for (i=5; i<strlen(str) && str[i]!='>'; i++) {
- if ((str[i]=='b') && strncmp("background", &str[i], 10)==0)
- curPage->background = get_quote(&str[i+10]);
+ if (curScript->pages==NULL)
+ {
+ curPage = (pageType *)calloc(1,sizeof(pageType));
+ curPage->prev = curPage;
+ curScript->pages = curPage;
+ }
+ else
+ {
+ curPage->next = (pageType*)calloc(1, sizeof(pageType));
+ curPage->next->prev = curPage;
+ curPage = curPage->next;
+ }
- if ((str[i]=='t') && strncmp("title", &str[i], 5)==0)
- curPage->title = get_quote(&str[i+5]);
+ for (i = 5; i < strlen(str) && str[i]!='>'; i++)
+ {
+ if ((str[i] == 'b') && strncmp("background", &str[i], 10) == 0)
+ curPage->background = get_quote(&str[i + 10]);
- if ((str[i]=='b') && strncmp("bgcolor", &str[i], 7)==0)
- curPage->bgcolor = get_color(&str[i+7]);
+ if ((str[i]== 't') && strncmp("title", &str[i], 5) == 0)
+ curPage->title = get_quote(&str[i + 5]);
- if ((str[i]=='f') && strncmp("fgcolor", &str[i], 7)==0)
- curPage->fgcolor = get_color(&str[i+7]);
- }
- } else if (strncmp("<text", str, 5)==0) {
- if (curPage==NULL) { fprintf(stderr, "CRITICAL XML ERROR: <text> should be in a <page> in file %s line (todo)", fn); exit(1); }
- if (curPage->items==NULL) {
- curItem = (itemType *)calloc(1,sizeof(itemType));
- curPage->items = curItem;
- } else {
- curItem->next = (itemType *)calloc(1,sizeof(itemType));
- curItem = curItem->next;
- }
-
- curItem->type = itemTEXT;
- curItem->x = curItem->y = -1;
-
- for (i=5; i<strlen(str) && str[i]!='>'; i++) {
-
- if ((str[i]=='s') && strncmp("size", &str[i], 4)==0)
- curItem->size = (char)get_int( &str[i+4] );
+ if ((str[i] == 'b') && strncmp("bgcolor", &str[i], 7) == 0)
+ curPage->bgcolor = get_color(&str[i + 7]);
- if ((str[i]=='a') && strncmp("align", &str[i], 5)==0) {
- char *t = get_quote(&str[i+5]);
-
- if (strlen(t)>=1) {
- if ((t[0] == 'l') || (t[0]=='L')) curItem->align='l'; // left
- if ((t[0] == 'c') || (t[0]=='C')) curItem->align='c'; // center
- if ((t[0] == 'r') || (t[0]=='R')) curItem->align='r'; // right
+ if ((str[i] == 'f') && strncmp("fgcolor", &str[i], 7) == 0)
+ curPage->fgcolor = get_color(&str[i + 7]);
+ }
+ }
+ else if (strncmp("<text", str, 5) == 0)
+ {
+ if (curPage == NULL)
+ {
+ fprintf(stderr, "CRITICAL XML ERROR: <text> should be in a <page> in file %s line (todo)", fn); exit(1);
+ }
- if ((t[0] == 'm') || (t[0]=='M')) curItem->align='c'; // let 'm'iddle work as "center"
- }
- free(t);
- }
+ if (curPage->items == NULL)
+ {
+ curItem = (itemType*)calloc(1, sizeof(itemType));
+ curPage->items = curItem;
+ }
+ else
+ {
+ curItem->next = (itemType*)calloc(1, sizeof(itemType));
+ curItem = curItem->next;
+ }
- if ((str[i]=='c') && strncmp("color", &str[i], 5)==0)
- curItem->color = get_color(&str[i+5]);
-
- if ((str[i]=='x') && strncmp(" x=", &str[i-1], 3)==0)
- curItem->x = get_int(&str[i+2]);
+ curItem->type = itemTEXT;
+ curItem->x = curItem->y = -1;
- if ((str[i]=='y') && strncmp(" y=", &str[i-1], 3)==0)
- curItem->y = get_int(&str[i+2]);
+ for (i = 5; i<strlen(str) && str[i]!='>'; i++)
+ {
+ if ((str[i] == 's') && strncmp("size", &str[i], 4) == 0)
+ curItem->size = (char)get_int(&str[i + 4]);
- }
-
- /* --- grab the text between <text> and </text> --- */
- {
- int start, finish;
+ if ((str[i] == 'a') && strncmp("align", &str[i], 5) == 0)
+ {
+ char* t = get_quote(&str[i+5]);
- for (start=5; start<strlen(str)-5 && str[start]!='>'; start++);
+ if (strlen(t)>=1)
+ {
+ if ((t[0] == 'l') || (t[0]=='L'))
+ curItem->align='l'; // left
+ if ((t[0] == 'c') || (t[0]=='C'))
+ curItem->align='c'; // center
+ if ((t[0] == 'r') || (t[0]=='R'))
+ curItem->align='r'; // right
+ if ((t[0] == 'm') || (t[0]=='M'))
+ curItem->align='c'; // let 'm'iddle work as "center"
+ }
+ free(t);
+ }
- start++; // advance passed the '>'
-
- for (finish=strlen(str)-6; finish>5; finish--)
- if (strncmp( "</text>", &str[finish], 7)==0) break;
-
- finish--; // advance passed the '<'
-
- if (start<=finish) {
- curItem->data = (char *)calloc(1,finish-start+2);
- strncpy( curItem->data, &str[start], finish-start+1 );
- }else{
- if (start == finish+1){
- curItem->data = (char *)calloc(1,2);
- curItem->data[0]=' ';
- }
- }
- }
- } else if (strncmp("<img", str, 4)==0) {
- if (curPage==NULL) { fprintf(stderr, "CRITICAL XML ERROR: <img> should be in a <page> in file %s line (todo)", fn); exit(1); }
- if (curPage->items==NULL) {
- curItem = (itemType *)calloc(1,sizeof(itemType));
- curPage->items = curItem;
- } else {
- curItem->next = (itemType *)calloc(1,sizeof(itemType));
- curItem = curItem->next;
- }
-
- curItem->type = itemIMG;
- curItem->x = curItem->y = -1;
+ if ((str[i] == 'c') && strncmp("color", &str[i], 5) == 0)
+ curItem->color = get_color(&str[i + 5]);
- for (i=5; i<strlen(str); i++) {
- if ((str[i]=='o') && strncmp("onclickplay", &str[i], 11)==0) {
- curItem->onclick = get_quote(&str[i+3]);
- }
+ if ((str[i]== 'x') && strncmp(" x=", &str[i - 1], 3) == 0)
+ curItem->x = get_int(&str[i + 2]);
- if ((str[i]=='x') && strncmp(" x=", &str[i-1], 3)==0)
- curItem->x = get_int(&str[i+2]);
+ if ((str[i] == 'y') && strncmp(" y=", &str[i - 1], 3) == 0)
+ curItem->y = get_int(&str[i + 2]);
+ }
- if ((str[i]=='y') && strncmp(" y=", &str[i-1], 3)==0)
- curItem->y = get_int(&str[i+2]);
+ /* --- grab the text between <text> and </text> --- */
+ {
+ int start, finish;
- if ((str[i]=='s') && strncmp("src", &str[i], 3)==0)
- curItem->data = get_quote(&str[i+3]);
-
- if ((str[i]=='a') && strncmp("align", &str[i], 5)==0) {
- char *t = get_quote(&str[i+5]);
-
- if (strlen(t)>=1) {
- if ((t[0] == 'l') || (t[0]=='L')) curItem->align='l'; // left
- if ((t[0] == 'c') || (t[0]=='C')) curItem->align='c'; // center
- if ((t[0] == 'r') || (t[0]=='R')) curItem->align='r'; // right
+ for (start = 5; start < strlen(str) - 5 && str[start] != '>'; start++);
- if ((t[0] == 'm') || (t[0]=='M')) curItem->align='c'; // let 'm'iddle work as "center"
- }
-
- free(t);
- }
+ start++; // advance passed the '>'
+
+ for (finish = strlen(str) - 6; finish > 5; finish--)
+ if (strncmp( "</text>", &str[finish], 7) == 0)
+ break;
+
+ finish--; // advance passed the '<'
+
+ if (start <= finish)
+ {
+ curItem->data = (char*)calloc(1, finish - start + 2);
+ strncpy(curItem->data, &str[start], finish - start + 1);
+ }
+ else
+ {
+ if (start == finish + 1)
+ {
+ curItem->data = (char*)calloc(1, 2);
+ curItem->data[0]=' ';
+ }
+ }
+ }
+
+ }
+ else if (strncmp("<img", str, 4) == 0)
+ {
+ if (curPage == NULL)
+ {
+ fprintf(stderr,
+ "CRITICAL XML ERROR: <img> should be in a <page> in file %s line (todo)",
+ fn);
+ exit(1); //FIXME should call cleanup() or maybe just return without exiting
+ }
+
+ if (curPage->items == NULL)
+ {
+ curItem = (itemType*)calloc(1, sizeof(itemType));
+ curPage->items = curItem;
+ }
+ else
+ {
+ curItem->next = (itemType*)calloc(1, sizeof(itemType));
+ curItem = curItem->next;
+ }
+
+ curItem->type = itemIMG;
+ curItem->x = curItem->y = -1;
+
+ for (i = 5; i < strlen(str); i++)
+ {
+ if ((str[i] == 'o') && strncmp("onclickplay", &str[i], 11) == 0)
+ curItem->onclick = get_quote(&str[i + 3]);
+
+ if ((str[i] == 'x') && strncmp(" x=", &str[i - 1], 3) == 0)
+ curItem->x = get_int(&str[i + 2]);
+
+ if ((str[i] == 'y') && strncmp(" y=", &str[i - 1], 3) == 0)
+ curItem->y = get_int(&str[i + 2]);
+
+ if ((str[i] == 's') && strncmp("src", &str[i], 3) == 0)
+ curItem->data = get_quote(&str[i + 3]);
+
+ if ((str[i] == 'a') && strncmp("align", &str[i], 5) == 0)
+ {
+ char* t = get_quote(&str[i + 5]);
+
+ if (strlen(t) >= 1)
+ {
+ if ((t[0] == 'l') || (t[0] == 'L'))
+ curItem->align='l'; // left
+
+ if ((t[0] == 'c') || (t[0]=='C'))
+ curItem->align='c'; // center
+
+ if ((t[0] == 'r') || (t[0]=='R'))
+ curItem->align='r'; // right
+
+ if ((t[0] == 'm') || (t[0]=='M'))
+ curItem->align='c'; // let 'm'iddle work as "center"
+ }
+ free(t);
+ }
+ }
+ }
+ else if (strncmp("<wav", str, 4) == 0)
+ {
+ if (curPage == NULL)
+ {
+ fprintf(stderr,
+ "CRITICAL XML ERROR: <wav> should be in a <page> in file %s line (todo)",
+ fn);
+ exit(1); /* FIXME call Cleanup() to exit */
+ }
+
+ if (curPage->items == NULL)
+ {
+ curItem = (itemType*)calloc(1, sizeof(itemType));
+ curPage->items = curItem;
+ }
+ else
+ {
+ curItem->next = (itemType*)calloc(1, sizeof(itemType));
+ curItem = curItem->next;
+ }
+
+ curItem->type = itemWAV;
+ curItem->loop = 0;
+
+ for (i =5 ; i < strlen(str); i++)
+ {
+ if ((str[i] == 's') && strncmp("src", &str[i], 3) ==0 )
+ curItem->data = get_quote(&str[i + 3]);
+
+ if ((str[i] == 'l') && strncmp("loop", &str[i], 4) == 0)
+ {
+ char* t = get_quote(&str[i + 4]);
+
+ if (strlen(t) >= 1)
+ {
+ if ((t[0] == 't') || (t[0]=='T'))
+ curItem->loop = 1;
+ }
+ free(t);
+ }
+ }
+ }
+ else if (strncmp("<prac", str, 5) == 0)
+ {
+ if (curPage == NULL)
+ {
+ fprintf(stderr,
+ "CRITICAL XML ERROR: <prac> should be in a <page> in file %s line (todo)",
+ fn);
+ exit(1); /* FIXME call cleanup() rather than exit() */
+ }
+
+ if (curPage->items == NULL)
+ {
+ curItem = (itemType*)calloc(1, sizeof(itemType));
+ curPage->items = curItem;
+ }
+ else
+ {
+ curItem->next = (itemType*)calloc(1, sizeof(itemType));
+ curItem = curItem->next;
+ }
+
+ curItem->type = itemPRAC;
+
+ for (i = 5; i < strlen(str) && str[i] != '>'; i++)
+ {
+ if ((str[i] == 's') && strncmp("size", &str[i], 4) == 0)
+ curItem->size = (char)get_int( &str[i + 4]);
+
+ if ((str[i] == 'g') && strncmp("goal", &str[i], 4) == 0)
+ curItem->goal = (char)get_int(&str[i + 4]);
+
+ if ((str[i] == 'a') && strncmp("align", &str[i], 5) == 0)
+ {
+ char* t = get_quote(&str[i + 5]);
+
+ if (strlen(t) >= 1)
+ {
+ if ((t[0] == 'l') || (t[0]=='L'))
+ curItem->align = 'l'; // left
+ if ((t[0] == 'c') || (t[0]=='C'))
+ curItem->align = 'c'; // center
+ if ((t[0] == 'r') || (t[0]=='R'))
+ curItem->align = 'r'; // right
+ if ((t[0] == 'm') || (t[0]=='M'))
+ curItem->align = 'c'; // let 'm'iddle work as "center"
+ }
+ free(t);
+ }
+
+ if ((str[i] == 'c') && strncmp("color", &str[i], 5) == 0)
+ curItem->color = get_color(&str[i + 5]);
+ }
+
+ { /* --- grab the text between <prac> and </prac> --- */
+ int start, finish;
+
+ for (start = 5; start < strlen(str) - 5 && str[start] != '>'; start++);
+
+ start++; // advance passed the '>/* --- grab the text between <prac> and </prac> --- */'
+
+ for (finish = strlen(str) - 6; finish > 5; finish--)
+ if (strncmp("</prac>", &str[finish], 7) == 0)
+ break;
+
+ finish--; // advance passed the '<'
+
+ if (start <= finish)
+ {
+ curItem->data = (char*)calloc(1, finish - start + 2);
+ strncpy(curItem->data, &str[start], finish - start + 1);
+ }
+ else
+ {
+ if (start == finish + 1)
+ {
+ curItem->data = (char*)calloc(1, 2);
+ curItem->data[0]=' ';
+ }
+ }
+ }
+ }
+ else if (strncmp("<waitforinput", str, 13) == 0)
+ {
+ if (curPage == NULL)
+ {
+ fprintf(stderr,
+ "CRITICAL XML ERROR: <waitforinput> should be in a <page> in file %s line (todo)",
+ fn);
+ exit(1);
+ }
+
+ if (curPage->items == NULL)
+ {
+ curItem = (itemType*)calloc(1, sizeof(itemType));
+ curPage->items = curItem;
+ }
+ else
+ {
+ curItem->next = (itemType*)calloc(1, sizeof(itemType));
+ curItem = curItem->next;
+ }
+
+ curItem->type = itemWFIN;
+
+ }
+ else if (strncmp("<waitforchar", str, 12) == 0)
+ {
+ if (curPage == NULL)
+ {
+ fprintf(stderr,
+ "CRITICAL XML ERROR: <waitforchar> should be in a <page> in file %s line (todo)",
+ fn);
+ exit(1);
+ }
+
+ if (curPage->items == NULL)
+ {
+ curItem = (itemType*)calloc(1, sizeof(itemType));
+ curPage->items = curItem;
+ }
+ else
+ {
+ curItem->next = (itemType*)calloc(1, sizeof(itemType));
+ curItem = curItem->next;
+ }
+
+ curItem->type = itemWFCH;
+ }
+ else if (strncmp("</",str, 2) == 0)
+ {
+ /* do nothing */
+ }
+ else
+ fprintf(stderr, "not recognized: %s\n", str);
+
+ } while(!feof(f));
+
+ fclose(f);
+ return 0;
+}
+
+
+static void run_script(void)
+{
+ /* FIXME FNLEN doesn't make sense for size of these arrays */
+ Mix_Chunk* sounds[FNLEN] = {NULL};
+
+ /* --- for on mouse click on an image --- */
+ Mix_Chunk* clickWavs[FNLEN] = {NULL};
+ SDL_Rect clickRects[FNLEN];
+
+ if (!curScript)
+ {
+ fprintf(stderr, "run_script() - Error: curScript is NULL\n");
+ return;
+ }
+
+ curPage = curScript->pages;
+
+ while (curPage)
+ {
+ int y = 0;
+ int skip = 0;
+ int numWavs = 0;
+ int numClicks = 0;
+
+ curItem = curPage->items;
+
+ /* --- setup background color --- */
+ if (curPage->bgcolor)
+ SDL_FillRect( screen, NULL, COL2RGB(curPage->bgcolor));
+ else if (curScript->bgcolor)
+ SDL_FillRect(screen, NULL, COL2RGB(curScript->bgcolor));
+
+ /* --- setup background image --- */
+ if (curPage->background)
+ {
+ SDL_Surface* img = LoadImage(curPage->background, IMG_ALPHA|IMG_NOT_REQUIRED);
+ SDL_BlitSurface(img, NULL, screen, NULL);
+ SDL_FreeSurface(img);
+ }
+ else if (curScript->background)
+ {
+ SDL_Surface* img = LoadImage(curScript->background, IMG_ALPHA|IMG_NOT_REQUIRED);
+ SDL_BlitSurface(img, NULL, screen, NULL);
+ SDL_FreeSurface(img);
+ }
+
+ /* --- go through all the items in the page --- */
+ while (curItem)
+ {
+ switch (curItem->type)
+ {
+ case itemIMG:
+ {
+ SDL_Surface* img = LoadImage(curItem->data, IMG_ALPHA|IMG_NOT_REQUIRED);
+ if (img)
+ {
+ /* --- figure out where to put it! --- */
+ SDL_Rect loc;
+ loc.w=img->w;
+ loc.h=img->h;
+
+ /* --- if user specifies y location, use it --- */
+ if (curItem->y >= 0)
+ {
+ loc.y = curItem->y;
}
- } else if (strncmp("<wav", str, 4)==0) {
- if (curPage==NULL) { fprintf(stderr, "CRITICAL XML ERROR: <wav> should be in a <page> in file %s line (todo)", fn); exit(1); }
- if (curPage->items==NULL) {
- curItem = (itemType *)calloc(1,sizeof(itemType));
- curPage->items = curItem;
- } else {
- curItem->next = (itemType *)calloc(1,sizeof(itemType));
- curItem = curItem->next;
+ else
+ {
+ loc.y=y; y+=loc.h;
}
-
- curItem->type = itemWAV;
- curItem->loop = 0;
- for (i=5; i<strlen(str); i++) {
- if ((str[i]=='s') && strncmp("src", &str[i], 3)==0)
- curItem->data = get_quote(&str[i+3]);
-
- if ((str[i]=='l') && strncmp("loop", &str[i], 4)==0) {
- char *t = get_quote(&str[i+4]);
-
- if (strlen(t)>=1)
- if ((t[0] == 't') || (t[0]=='T')) curItem->loop=1;
-
- free(t);
- }
+ /* --- if user specifies x location, use it --- */
+ if (curItem->x >= 0)
+ {
+ loc.x = curItem->x;
}
- } else if (strncmp("<prac", str, 5)==0) {
- if (curPage==NULL) { fprintf(stderr, "CRITICAL XML ERROR: <prac> should be in a <page> in file %s line (todo)", fn); exit(1); }
- if (curPage->items==NULL) {
- curItem = (itemType *)calloc(1,sizeof(itemType));
- curPage->items = curItem;
- } else {
- curItem->next = (itemType *)calloc(1,sizeof(itemType));
- curItem = curItem->next;
+ else
+ {
+ switch (curItem->align)
+ {
+ case 'r': loc.x = (screen->w)-(loc.w); break;
+ case 'c': loc.x = ((screen->w)-(loc.w))/2; break;
+ default: loc.x = 0; break;
+ }
}
-
- curItem->type = itemPRAC;
- for (i=5; i<strlen(str) && str[i]!='>'; i++) {
-
- if ((str[i]=='s') && strncmp("size", &str[i], 4)==0)
- curItem->size = (char)get_int( &str[i+4] );
- if ((str[i]=='g') && strncmp("goal", &str[i], 4)==0)
- curItem->goal = (char)get_int( &str[i+4] );
+ /* --- and blit! --- */
+ SDL_BlitSurface(img, NULL, screen, &loc);
- if ((str[i]=='a') && strncmp("align", &str[i], 5)==0) {
- char *t = get_quote(&str[i+5]);
-
- if (strlen(t)>=1) {
- if ((t[0] == 'l') || (t[0]=='L')) curItem->align='l'; // left
- if ((t[0] == 'c') || (t[0]=='C')) curItem->align='c'; // center
- if ((t[0] == 'r') || (t[0]=='R')) curItem->align='r'; // right
- if ((t[0] == 'm') || (t[0]=='M')) curItem->align='c'; // let 'm'iddle work as "center"
- }
- free(t);
- }
+ /* --- does it do click and play --- */
+ if (curItem->onclick)
+ {
+ if (settings.sys_sound)
+ clickWavs[numClicks] = LoadSound(curItem->onclick);
+ clickRects[numClicks].x = loc.x;
+ clickRects[numClicks].y = loc.y;
+ clickRects[numClicks].w = loc.w;
+ clickRects[numClicks].h = loc.h;
+ numClicks++;
+ }
+ }
+ SDL_FreeSurface(img);
+ break;
+ }
- if ((str[i]=='c') && strncmp("color", &str[i], 5)==0)
- curItem->color = get_color(&str[i+5]);
+ case itemTEXT:
+ {
+ TTF_Font* myFont;
+ SDL_Surface* img;
+ SDL_Color* col;
+
+ int shown, toshow, w, h; // used to wrap text
+ char tmp[FNLEN]; // used to hold temp text for wrapping
+
+ /* --- create font & render text --- */
+ if (curItem->size > 0)
+ myFont = LoadFont(settings.theme_font_name, (int)curItem->size);
+ else
+ myFont = LoadFont(settings.theme_font_name, 24); // default size is 24
+
+ if (curItem->color)
+ col = curItem->color;
+ else if (curPage->fgcolor)
+ col = curPage->fgcolor;
+ else if (curScript->fgcolor)
+ col = curScript->fgcolor;
+ else
+ col = &white;
+
+ shown = 0;
+
+
+ do
+ {
+ int ok = 0;
+
+ if ((shown > 0) && (curItem->data[shown] == ' '))
+ shown++;
+ strncpy(tmp, &curItem->data[shown], FNLEN - 1);
+ tmp[FNLEN - 1] = 0;
+ tmp[strlen(curItem->data) - shown] = 0;
+
+ for (toshow = strlen(&curItem->data[shown]); !ok; toshow--)
+ {
+ if (toshow + 1 > FNLEN)
+ continue;
+
+ tmp[toshow] = 0;
+ TTF_SizeText(myFont, tmp, &w, &h);
+
+ if (w + 20 < screen->w)
+ ok = 1;
}
-
- { /* --- grab the text between <prac> and </prac> --- */
- int start, finish;
- for (start=5; start<strlen(str)-5 && str[start]!='>'; start++);
+ shown += toshow + 1;
- start++; // advance passed the '>/* --- grab the text between <prac> and </prac> --- */'
-
- for (finish=strlen(str)-6; finish>5; finish--)
- if (strncmp( "</prac>", &str[finish], 7)==0) break;
-
- finish--; // advance passed the '<'
-
- if (start<=finish) {
- curItem->data = (char *)calloc(1,finish-start+2);
- strncpy( curItem->data, &str[start], finish-start+1 );
- }else{
- if (start == finish+1){
- curItem->data = (char *)calloc(1,2);
- curItem->data[0]=' ';
- }
+ img = TTF_RenderUTF8_Blended(myFont, tmp, *col);
+
+ if (img)
+ {
+ SDL_Rect loc;
+ /* --- figure out where to put it! --- */
+ loc.w = img->w;
+ loc.h = img->h;
+
+ /* --- if user specifies y location, use it --- */
+ if (curItem->y >= 0)
+ loc.y = curItem->y;
+ else
+ loc.y=y; y+=loc.h;
+
+ /* --- if user specifies x location, use it --- */
+ if (curItem->x >= 0)
+ loc.x = curItem->x;
+ else
+ {
+ switch (curItem->align)
+ {
+ case 'r':
+ loc.x = (screen->w) - (loc.w);
+ break;
+ case 'c':
+ loc.x = ((screen->w) - (loc.w))/2;
+ break;
+ default:
+ loc.x = 0;
+ break;
}
+ }
+
+ /* --- and blit! --- */
+ SDL_BlitSurface( img, NULL, screen, &loc );
+ SDL_FreeSurface( img );
}
- } else if (strncmp("<waitforinput", str, 13)==0) {
- if (curPage==NULL) { fprintf(stderr, "CRITICAL XML ERROR: <waitforinput> should be in a <page> in file %s line (todo)", fn); exit(1); }
- if (curPage->items==NULL) {
- curItem = (itemType *)calloc(1,sizeof(itemType));
- curPage->items = curItem;
- } else {
- curItem->next = (itemType *)calloc(1,sizeof(itemType));
- curItem = curItem->next;
- }
-
- curItem->type = itemWFIN;
- } else if (strncmp("<waitforchar", str, 12)==0) {
- if (curPage==NULL) { fprintf(stderr, "CRITICAL XML ERROR: <waitforchar> should be in a <page> in file %s line (todo)", fn); exit(1); }
- if (curPage->items==NULL) {
- curItem = (itemType *)calloc(1,sizeof(itemType));
- curPage->items = curItem;
- } else {
- curItem->next = (itemType *)calloc(1,sizeof(itemType));
- curItem = curItem->next;
- }
-
- curItem->type = itemWFCH;
- } else if (strncmp("</",str,2)==0);
- else printf("not recognized: %s\n", str);
- } while( !feof(f) );
- fclose(f);
- return 0;
-}
+
+ } while (shown + 1 < strlen(curItem->data));
-static void run_script(void)
-{
+ TTF_CloseFont(myFont);
+ break;
+ }
- Mix_Chunk *sounds[FNLEN];
- /* --- for on mouse click on an image --- */
- Mix_Chunk *clickWavs[FNLEN];
- SDL_Rect clickRects[FNLEN];
+ case itemWAV:
+ {
+ // HACK, we need to make sure no more than 8 sounds or so..
+ sounds[numWavs] = LoadSound( curItem->data );
+ Mix_PlayChannel( numWavs, sounds[numWavs], -curItem->loop );
+ numWavs++;
+ break;
+ }
- curPage = curScript->pages;
- while (curPage) {
- int y = 0,
- skip=0;
+ case itemWFIN:
+ {
+ int done = 0;
- int numWavs = 0;
- int numClicks = 0;
-
- curItem = curPage->items;
-
- /* --- setup background color --- */
-
- if (curPage->bgcolor) SDL_FillRect( screen, NULL, COL2RGB(curPage->bgcolor) );
- else if (curScript->bgcolor) SDL_FillRect( screen, NULL, COL2RGB(curScript->bgcolor) );
-
- /* --- setup background image --- */
-
- if (curPage->background) {
- SDL_Surface *img = LoadImage( curPage->background, IMG_ALPHA|IMG_NOT_REQUIRED );
- SDL_BlitSurface( img, NULL, screen, NULL );
- SDL_FreeSurface( img );
- } else if (curScript->background) {
- SDL_Surface *img = LoadImage( curScript->background, IMG_ALPHA|IMG_NOT_REQUIRED );
- SDL_BlitSurface( img, NULL, screen, NULL );
- SDL_FreeSurface( img );
+ // Make sure everything is on screen
+ SDL_Flip(screen);
+
+ while (!done)
+ {
+ SDL_Delay(100);
+
+ while (SDL_PollEvent(&event))
+ {
+ switch (event.type)
+ {
+ case SDL_MOUSEBUTTONDOWN:
+ {
+ int j;
+
+ for (j=0; j<numClicks; j++)
+ {
+ if (inRect(clickRects[j], event.button.x, event.button.y))
+ Mix_PlayChannel(numWavs + j, clickWavs[j], 0);
+ }
+ break;
+ }
+
+ case SDL_QUIT:
+ {
+ curPage = NULL;
+ done = 1;
+ break;
+ }
+
+ case SDL_KEYDOWN:
+ {
+ switch (event.key.keysym.sym)
+ {
+ case SDLK_ESCAPE:
+ curPage = NULL;
+ done = 1;
+ break; // quit
+ case SDLK_LEFT:
+ curPage = curPage->prev;
+ done = 1;
+ break;
+ case SDLK_RIGHT:
+ case SDLK_SPACE:
+ case SDLK_RETURN:
+ curPage = curPage->next;
+ skip = 1;
+ done = 1;
+ break;
+ default:
+ break;
+ };
+
+ break;
+ }
+ }
+ }
+ }
}
-
- /* --- go through all the items in the page --- */
-
- while (curItem) {
- switch (curItem->type) {
- case itemIMG: {
- SDL_Surface *img = LoadImage( curItem->data, IMG_ALPHA|IMG_NOT_REQUIRED );
- if (img) {
-
- /* --- figure out where to put it! --- */
- SDL_Rect loc;
+ break;
- loc.w=img->w; loc.h=img->h;
- /* --- if user specifies y location, use it --- */
- if (curItem->y >= 0) {
- loc.y = curItem->y;
- } else {
- loc.y=y; y+=loc.h;
- }
-
- /* --- if user specifies x location, use it --- */
- if (curItem->x >= 0) {
- loc.x = curItem->x;
- } else {
- switch (curItem->align) {
- case 'r': loc.x = (screen->w)-(loc.w); break;
- case 'c': loc.x = ((screen->w)-(loc.w))/2; break;
- default: loc.x = 0; break;
- }
- }
-
- /* --- and blit! --- */
- SDL_BlitSurface( img, NULL, screen, &loc );
+ case itemWFCH:
+ {
+ int done = 0;
+ // Make sure everything is on screen
+ SDL_Flip(screen);
- /* --- does it do click and play --- */
- if (curItem->onclick) {
- if (settings.sys_sound)
- clickWavs[numClicks] = LoadSound(curItem->onclick);
- clickRects[numClicks].x = loc.x;
- clickRects[numClicks].y = loc.y;
- clickRects[numClicks].w = loc.w;
- clickRects[numClicks].h = loc.h;
- numClicks++;
- }
+ while (!done)
+ {
+ SDL_Delay(100);
+ while (SDL_PollEvent(&event))
+ {
+ switch (event.type)
+ {
+ case SDL_QUIT:
+ {
+ curPage = NULL;
+ done = 1;
+ break;
+ }
+
+ case SDL_KEYDOWN:
+ {
+ switch (event.key.keysym.sym)
+ {
+ case SDLK_ESCAPE:
+ {
+ curPage = NULL;
+ done = 1;
+ break; // quit
}
- SDL_FreeSurface(img);
-
- break;
- }
- case itemTEXT: {
-
- TTF_Font *myFont;
- SDL_Surface *img;
- SDL_Color *col;
-
- int shown, toshow, w, h; // used to wrap text
- char tmp[FNLEN]; // used to hold temp text for wrapping
-
- /* --- create font & render text --- */
-
- if (curItem->size > 0)
- myFont = LoadFont(settings.theme_font_name, (int)curItem->size );
- else
- myFont = LoadFont(settings.theme_font_name, 24 ); // default size is 24
-
- if (curItem->color) col = curItem->color;
- else if (curPage->fgcolor) col = curPage->fgcolor;
- else if (curScript->fgcolor) col = curScript->fgcolor;
- else col = &white;
+ case SDLK_p:
+ {
+ curPage = curPage->next;
+ done = 1;
+ break;
+ }
+ default:
+ break;
+ };
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
- shown=0;
-
- do {
- int ok=0;
-
- if ((shown > 0) && (curItem->data[shown] == ' ')) shown++;
-
- strncpy( tmp, &curItem->data[shown], FNLEN-1 );
-
- tmp[FNLEN-1]=0;
- tmp[strlen(curItem->data)-shown]=0;
-
- for ( toshow=strlen(&curItem->data[shown]); !ok; toshow--) {
- if (toshow+1>FNLEN) continue;
- tmp[toshow]=0;
- TTF_SizeText( myFont, tmp, &w, &h);
-
- if (w+20<screen->w) ok=1;
- }
-
- shown += toshow + 1;
- //printf("Rendering %s\n", tmp);
- img = TTF_RenderUTF8_Blended( myFont, tmp, *col );
+ case itemPRAC:
+ {
+ if (curItem->goal > 0)
+ {
+ //printf( "goal is %d\n", curItem->goal );
+ Phrases(curItem->data);
+ }
+ else
+ {
+ //printf( "No goal \n" );
+ Phrases(curItem->data);
+ }
+ break;
+ }
- if (img) {
-
- SDL_Rect loc;
- /* --- figure out where to put it! --- */
- loc.w=img->w; loc.h=img->h;
-
- /* --- if user specifies y location, use it --- */
- if (curItem->y >= 0) {
- // printf("y == %d\n", y);
- loc.y = curItem->y;
- } else {
- //printf("incrementing y %d\n", y);
- loc.y=y; y+=loc.h;
- }
-
- /* --- if user specifies x location, use it --- */
- if (curItem->x >= 0) {
- loc.x = curItem->x;
- } else {
- switch (curItem->align) {
- case 'r': loc.x = (screen->w)-(loc.w); break;
- case 'c': loc.x = ((screen->w)-(loc.w))/2; break;
- default: loc.x = 0; break;
- }
- }
-
- /* --- and blit! --- */
- SDL_BlitSurface( img, NULL, screen, &loc );
- SDL_FreeSurface( img );
- }
-
- } while (shown+1 < strlen(curItem->data));
- TTF_CloseFont( myFont );
- break;
- }
- case itemWAV: {
- // HACK, we need to make sure no more than 8 sounds or so..
- sounds[numWavs] = LoadSound( curItem->data );
- Mix_PlayChannel( numWavs, sounds[numWavs], -curItem->loop );
- numWavs++;
- break;
- }
- case itemWFIN: {
- int done=0;
- // Make sure everything is on screen
- SDL_Flip( screen );
- while (!done) {
- SDL_Delay(100);
- while (SDL_PollEvent(&event)) {
- switch (event.type) {
-
- case SDL_MOUSEBUTTONDOWN: {
- int j;
- for (j=0; j<numClicks; j++)
- if (inRect( clickRects[j], event.button.x, event.button.y ))
- Mix_PlayChannel( numWavs+j, clickWavs[j], 0 );
- break;
- }
- case SDL_QUIT:
- curPage = NULL; done=1;
- break;
- case SDL_KEYDOWN:
- switch (event.key.keysym.sym) {
- case SDLK_ESCAPE:
- curPage = NULL; done=1; break; // quit
- case SDLK_LEFT:
- curPage = curPage->prev; done=1; break;
- case SDLK_RIGHT:
- case SDLK_SPACE:
- case SDLK_RETURN:
- curPage = curPage->next;
- skip=1;
- done=1;
- break;
- default: break;
- };
- break;
- }
- }
- }
- }
- break;
- case itemWFCH: {
- int done=0;
- // Make sure everything is on screen
- SDL_Flip( screen );
- while (!done) {
- SDL_Delay(100);
- while (SDL_PollEvent(&event)) {
- switch (event.type) {
- case SDL_QUIT:
- curPage = NULL; done=1;
- break;
- case SDL_KEYDOWN:
- switch (event.key.keysym.sym) {
- case SDLK_ESCAPE:
- curPage = NULL; done=1; break; // quit
- case SDLK_p:
- curPage = curPage->next; done=1; break;
- default: break;
- };
- break;
- }
- }
- }
- }
- break;
- case itemPRAC: {
- if (curItem->goal > 0) {
- //printf( "goal is %d\n", curItem->goal );
- Phrases(curItem->data);
- } else {
- //printf( "No goal \n" );
- Phrases(curItem->data);
- }
- break;
- }
- default: {
- }
+ default:
+ {
+ /* do nothing */
+ }
+ }
- }
- if (curItem->next==NULL && curPage != NULL) {
- if (!skip){
- curPage = curPage->next;
- skip=0;
- }
- break;
- } else {
- curItem=curItem->next; }
+ if (curItem->next == NULL && curPage != NULL)
+ {
+ if (!skip)
+ {
+ curPage = curPage->next;
+ skip = 0;
+ }
+ break;
}
- SDL_Flip( screen );
- SDL_Delay(30);
+ else
+ curItem = curItem->next;
+ }
+ SDL_Flip(screen);
+ SDL_Delay(30);
- /* --- cleanup memory --- changing pages --- */
+ /* --- cleanup memory --- changing pages --- */
{
int i;
@@ -989,13 +1221,12 @@
Mix_FreeChunk(clickWavs[i]);
}
}
+ }
- }
- }
+ } /* --- End of "while (curPage)" loop ----*/
}
-
static void clear_items(itemType* i)
{
itemType* n;
@@ -1045,23 +1276,23 @@
static void close_script(void)
{
- if (curScript) {
+ if (curScript)
+ {
+ /* -- remove all the pages we have --*/
+ clear_pages(curScript->pages);
- /* -- remove all the pages we have --*/
- clear_pages(curScript->pages);
+ /* -- remove attributes we are pointing to -- */
+ free(curScript->title);
+ free(curScript->bgcolor);
+ free(curScript->fgcolor);
+ free(curScript->background);
- /* -- remove attributes we are pointing to -- */
- free(curScript->title);
- free(curScript->bgcolor);
- free(curScript->fgcolor);
- free(curScript->background);
+ /* -- free yourself -- */
+ free(curScript);
- /* -- free yourself -- */
- free(curScript);
-
- /* -- and remember you did -- */
- curScript = NULL;
- }
+ /* -- and remember you did -- */
+ curScript = NULL;
+ }
}
Modified: tuxtype/trunk/tuxtype/setup.c
===================================================================
--- tuxtype/trunk/tuxtype/setup.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/setup.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -32,8 +32,8 @@
/* Local function prototypes: */
-int load_settings_fp(FILE* fp);
-int load_settings_filename(const char* fn);
+static int load_settings_fp(FILE* fp);
+static int load_settings_filename(const char* fn);
/***************************
GraphicsInit: Initializes the graphic system
@@ -163,13 +163,13 @@
/* Load the settings if given the complete pathname to the settings file. Returns 1 if
able to call load_settings_fp() successfully on named file.
*/
-int load_settings_filename(const char* fn)
+static int load_settings_filename(const char* fn)
{
FILE* fp = fopen(fn, "r");
if (!fp)
{
- fprintf(stderr, "load_settings_filename(): Settings file could not be opened! settings not loaded\n");
+ fprintf(stderr, "load_settings_filename(): no theme-specific settings found\n");
return;
}
@@ -189,7 +189,7 @@
/* Load the settings if given an open FILE* pointer to the settings file. Returns 1 if
at least one setting value found, 0 otherwise. It does not close the FILE*.
*/
-int load_settings_fp(FILE* fp)
+static int load_settings_fp(FILE* fp)
{
char setting[FNLEN]; /* these don't really need to be 'FNLEN' long */
char value[FNLEN];
Modified: tuxtype/trunk/tuxtype/snow.c
===================================================================
--- tuxtype/trunk/tuxtype/snow.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/snow.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -29,7 +29,7 @@
#define NUM_PLANES 3
extern SDL_Surface *screen;
-extern SDL_Surface *bkg;
+SDL_Surface* bkg;
Uint16 snow_color;
Modified: tuxtype/trunk/tuxtype/theme.c
===================================================================
--- tuxtype/trunk/tuxtype/theme.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/theme.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -20,7 +20,7 @@
#include "funcs.h"
-SDL_Surface *letters[255] = {NULL};
+SDL_Surface* letters[255] = {NULL}; //get rid of this
wchar_t ALPHABET[256];
unsigned char FINGER[256][10];
int ALPHABET_SIZE;
@@ -28,50 +28,52 @@
#define MAX_LANGUAGES 100
-/* setup_theme: this function is in charge of setting up
- * the paths that the loaders use. It will set a variable
- * numPaths = 1 or 2. 1 if we are just using the default,
- * 2 if there are two themes. Then it will edit the varible
- * realPaths[]. It will always put the theme path first, then
- * the default path
- */
void ChooseTheme(void)
{
- SDL_Surface* titles[MAX_LANGUAGES] = {NULL};
- SDL_Surface* select[MAX_LANGUAGES] = {NULL};
- SDL_Surface* left = NULL, *right = NULL;
- SDL_Rect leftRect, rightRect;
- SDL_Surface* world = NULL, *map = NULL, *photo = NULL;
- SDL_Rect worldRect, photoRect;
- SDL_Rect titleRects[8];
- int stop = 0;
- int loc = 0;
- int old_loc = 1;
+ SDL_Surface* titles[MAX_LANGUAGES] = {NULL};
+ SDL_Surface* select[MAX_LANGUAGES] = {NULL};
+ SDL_Surface* left = NULL, *right = NULL;
+ SDL_Rect leftRect, rightRect;
+ SDL_Surface* world = NULL, *map = NULL, *photo = NULL;
+ SDL_Surface* bkg = NULL;
+ TTF_Font* font = NULL;
+ SDL_Rect worldRect, photoRect;
+ SDL_Rect titleRects[8];
+ int stop = 0;
+ int loc = 0;
+ int old_loc = 1;
- int themes = 1;
- int i;
- unsigned char fn[FNLEN];
- unsigned char themeNames[MAX_LANGUAGES][FNLEN];
- unsigned char themePaths[MAX_LANGUAGES][FNLEN];
+ int themes = 1;
+ int i;
+ unsigned char fn[FNLEN];
+ unsigned char themeNames[MAX_LANGUAGES][FNLEN];
+ unsigned char themePaths[MAX_LANGUAGES][FNLEN];
- int old_use_english;
- char old_theme_path[FNLEN];
+ int old_use_english;
+ char old_theme_path[FNLEN];
- DIR *themesDir;
- struct dirent *themesFile;
-// struct stat fileStats;
+ DIR* themesDir = NULL;
+ struct dirent* themesFile = NULL;
- old_use_english = settings.use_english;
- strncpy(old_theme_path, settings.theme_data_path, FNLEN - 1);
+ /* save previous settings in case we back out: */
+ old_use_english = settings.use_english;
+ strncpy(old_theme_path, settings.theme_data_path, FNLEN - 1);
- sprintf(fn, "%s/themes/", settings.default_data_path);
- themesDir = opendir(fn);
+ sprintf(fn, "%s/themes/", settings.default_data_path);
+ themesDir = opendir(fn);
- do {
- themesFile = readdir(themesDir);
- if (!themesFile)
+ if (!themesDir)
+ {
+ fprintf(stderr, "ChooseTheme() - cannot open themes directory!");
+ return;
+ }
+
+ do
+ {
+ themesFile = readdir(themesDir);
+ if (!themesFile)
break;
/* we ignore any hidden file and CVS */
@@ -118,6 +120,7 @@
TTF_CloseFont(font);
+ font = NULL;
settings.use_english = old_use_english;
@@ -266,17 +269,20 @@
}
SDL_Delay(40);
old_loc = loc;
- }
+ }
- /* --- clear graphics before quiting --- */
+ /* --- clear graphics before quitting --- */
- for (i = 0; i<themes; i++) {
- SDL_FreeSurface(titles[i]);
- SDL_FreeSurface(select[i]);
- }
+ for (i = 0; i<themes; i++)
+ {
+ SDL_FreeSurface(titles[i]);
+ SDL_FreeSurface(select[i]);
+ }
- SDL_FreeSurface(world);
- SDL_FreeSurface(bkg);
- SDL_FreeSurface(left);
- SDL_FreeSurface(right);
+ SDL_FreeSurface(world);
+ SDL_FreeSurface(bkg);
+ SDL_FreeSurface(left);
+ SDL_FreeSurface(right);
+ bkg = NULL; /* the other pointers are going out of scope so we don't */
+ /* have to worry about setting them to NULL */
}
Modified: tuxtype/trunk/tuxtype/titlescreen.c
===================================================================
--- tuxtype/trunk/tuxtype/titlescreen.c 2007-08-24 01:39:50 UTC (rev 212)
+++ tuxtype/trunk/tuxtype/titlescreen.c 2007-08-25 18:12:22 UTC (rev 213)
@@ -24,34 +24,36 @@
/* --- media for menus --- */
/* images of regular and selected text of menu items: */
-SDL_Surface* reg_text[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {NULL};
-SDL_Surface* sel_text[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {NULL};
-sprite* reg = NULL;
-sprite* sel = NULL;
+static SDL_Surface* reg_text[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {NULL};
+static SDL_Surface* sel_text[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {NULL};
+static sprite* reg = NULL;
+static sprite* sel = NULL;
/* this will contain pointers to all of the menu 'icons' */
-sprite* menu_gfx[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {NULL};
+static sprite* menu_gfx[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {NULL};
/* keep track of the width of each menu: */
-int menu_width[TITLE_MENU_DEPTH + 1];
+static int menu_width[TITLE_MENU_DEPTH + 1];
/* NOTE for 'depth', think pages like a restaurant menu, */
/* not heirarchical depth - choice of term is misleading */
-int menu_depth; // how deep we are in the menu
+static int menu_depth; // how deep we are in the menu
//int menu_sound; // status of menu sound effects
//int menu_music; // status of menu sound effects
/* --- other media --- */
-SDL_Surface* title = NULL;
-SDL_Surface* speaker = NULL;
-SDL_Surface* speakeroff = NULL;
-sprite* Tux = NULL;
-Mix_Chunk* snd_move = NULL;
-Mix_Chunk* snd_select = NULL;
+static SDL_Surface* bkg = NULL;
+static SDL_Surface* title = NULL;
+static SDL_Surface* speaker = NULL;
+static SDL_Surface* speakeroff = NULL;
+static sprite* Tux = NULL;
+static Mix_Chunk* snd_move = NULL;
+static Mix_Chunk* snd_select = NULL;
+static TTF_Font* font = NULL;
/* --- locations we need --- */
-SDL_Rect text_dst[TITLE_MENU_ITEMS + 1]; // location of text for menu
-SDL_Rect menu_gfxdest[TITLE_MENU_ITEMS + 1]; // location of animated icon
+static SDL_Rect text_dst[TITLE_MENU_ITEMS + 1]; // location of text for menu
+static SDL_Rect menu_gfxdest[TITLE_MENU_ITEMS + 1]; // location of animated icon
/* These are the rectangular mouse event "buttons" for each menu item */
-SDL_Rect menu_button[TITLE_MENU_ITEMS + 1]; // size of "button"
+static SDL_Rect menu_button[TITLE_MENU_ITEMS + 1]; // size of "button"
/* Local function prototypes: */
@@ -526,7 +528,7 @@
if (menu_opt == LEVEL1)
- {
+ {
if (chooseWordlist())
{
unload_media();
@@ -536,12 +538,12 @@
case CASCADE: PlayCascade( EASY ); break;
case LASER: PlayLaserGame( EASY ); break;
}
+ }
- load_media();
+ load_media();
- if (settings.menu_music)
- MusicLoad( "tuxi.ogg", -1 );
- }
+ if (settings.menu_music)
+ MusicLoad("tuxi.ogg", -1);
redraw = 1;
}
@@ -559,12 +561,12 @@
case LASER: PlayLaserGame( MEDIUM ); break;
}
- load_media();
if (settings.menu_music)
MusicLoad( "tuxi.ogg", -1 );
}
+ load_media();
redraw = 1;
}
@@ -582,12 +584,12 @@
case LASER: PlayLaserGame( HARD ); break;
}
- load_media();
if (settings.menu_music)
MusicLoad( "tuxi.ogg", -1 );
}
+ load_media();
redraw = 1;
}
@@ -605,12 +607,11 @@
case LASER: PlayLaserGame( INSANE ); break;
}
- load_media();
-
if (settings.menu_music)
MusicLoad( "tuxi.ogg", -1 );
}
+ load_media();
redraw = 1;
}
@@ -651,6 +652,8 @@
if (redraw)
{
+ LOG("TitleScreen() - redraw requested\n");
+
SDL_BlitSurface(bkg, NULL, screen, NULL);
SDL_BlitSurface(title, NULL, screen, &Titledest);
@@ -659,7 +662,8 @@
else
SDL_BlitSurface(speakeroff, NULL, screen, &spkrdest);
- SDL_UpdateRect(screen, 0, 0, 0, 0);
+ /* Screen will be updated due to update_locs - see ~30 lines down: */
+// SDL_UpdateRect(screen, 0, 0, 0, 0);
frame = redraw = 0; // so we redraw tux
update_locs = 1; // so we redraw menu
firstloop = 1;
@@ -671,6 +675,8 @@
if (update_locs)
{
+ LOG("TitleScreen() - update_locs requested\n");
+
/* --- erase the last menu --- */
for (i = 1; i <= TITLE_MENU_ITEMS; i++)
{
@@ -691,6 +697,7 @@
SDL_BlitSurface(reg_text[j][menu_depth], NULL, screen, &text_dst[j]);
SDL_BlitSurface(menu_gfx[j][menu_depth]->default_img, NULL, screen, &menu_gfxdest[j]);
}
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
}
@@ -947,15 +954,20 @@
static void unload_menu(void)
{
int i,j;
+ printf("enter unload_menu()\n");
for (i = 1; i <= TITLE_MENU_ITEMS; i++)
{
for (j = 1; j <= TITLE_MENU_DEPTH; j++)
{
- SDL_FreeSurface(reg_text[i][j]);
- SDL_FreeSurface(sel_text[i][j]);
- FreeSprite(menu_gfx[i][j]);
- reg_text[i][j] = sel_text[i][j] = menu_gfx[i][j] = NULL;
+ if (reg_text[i][j])
+ SDL_FreeSurface(reg_text[i][j]);
+ if (sel_text[i][j])
+ SDL_FreeSurface(sel_text[i][j]);
+ if (menu_gfx[i][j])
+ FreeSprite(menu_gfx[i][j]);
+ reg_text[i][j] = sel_text[i][j] = NULL;
+ menu_gfx[i][j] = NULL;
}
}
}
@@ -970,6 +982,10 @@
fprintf(stderr, "theme_data_path = %s\n", settings.theme_data_path);
}
+ /* Make sure everything is unloaded before we start: */
+ /* FIXME have not been to do this to run without crashing: */
+ //unload_media();
+
/* --- load sounds --- */
if (settings.menu_sound)
{
@@ -1016,37 +1032,77 @@
static void unload_media(void)
{
+ LOG("Entering unload_media():\n");
+
/* --- unload sounds --- */
if (settings.menu_sound){
- Mix_FreeChunk(snd_move);
- snd_move = NULL;
- Mix_FreeChunk(snd_select);
- snd_select = NULL;
+
+ if (snd_move)
+ {
+ Mix_FreeChunk(snd_move);
+ snd_move = NULL;
+ }
+ if (snd_select)
+ {
+ Mix_FreeChunk(snd_select);
+ snd_select = NULL;
+ }
}
/* --- unload graphics --- */
- SDL_FreeSurface(title);
- title = NULL;
- SDL_FreeSurface(speaker);
- speaker = NULL;
- SDL_FreeSurface(speakeroff);
- speakeroff = NULL;
- SDL_FreeSurface(bkg);
- bkg = NULL;
- FreeSprite(sel);
- sel = NULL;
- FreeSprite(reg);
- reg = NULL;
- FreeSprite(Tux);
- Tux = NULL;
- TTF_CloseFont(font);
- font = NULL;
+ if (title)
+ {
+ SDL_FreeSurface(title);
+ title = NULL;
+ }
+ if (speaker)
+ {
+ SDL_FreeSurface(speaker);
+ speaker = NULL;
+ }
+ if (speakeroff)
+ {
+ SDL_FreeSurface(speakeroff);
+ speakeroff = NULL;
+ }
+ if (bkg)
+ {
+ SDL_FreeSurface(bkg);
+ bkg = NULL;
+ }
+
+ if (sel)
+ {
+ FreeSprite(sel);
+ sel = NULL;
+ }
+ if (reg)
+ {
+ FreeSprite(reg);
+ reg = NULL;
+ }
+ if (Tux)
+ {
+ FreeSprite(Tux);
+ Tux = NULL;
+ }
+
+ if (font)
+ {
+ TTF_CloseFont(font);
+ font = NULL;
+ }
+
+ LOG("Leaving load_media():\n");
+
unload_menu();
}
+
static void not_implemented(void)
{
+ SDL_Surface* bk = NULL;
SDL_Surface *s1 = NULL, *s2 = NULL, *s3 = NULL, *s4 = NULL;
sprite* tux = NULL;
SDL_Rect loc;
@@ -1074,12 +1130,13 @@
s4 = BlackOutline( "http://tuxtype.sf.net/forums", font, &white);
tux = LoadSprite("tux/tux-egypt", IMG_ALPHA);
+ bk = LoadImage("main_bkg.png", IMG_REGULAR);
- if (s1 && s2 && s3 && s4 && tux && bkg)
+ if (s1 && s2 && s3 && s4 && tux && bk)
{
LOG( "NotImplemented() - drawing screen\n" );
- SDL_BlitSurface( bkg, NULL, screen, NULL );
+ SDL_BlitSurface(bk, NULL, screen, NULL);
loc.x = 320-(s1->w/2); loc.y = 10;
SDL_BlitSurface( s1, NULL, screen, &loc);
loc.x = 320-(s2->w/2); loc.y = 60;
@@ -1118,8 +1175,8 @@
if (i %5 == 0)
{
NEXT_FRAME(tux);
- SDL_BlitSurface( bkg, &loc, screen, &loc);
- SDL_BlitSurface( tux->frame[tux->cur], NULL, screen, &loc);
+ SDL_BlitSurface(bk, &loc, screen, &loc);
+ SDL_BlitSurface(tux->frame[tux->cur], NULL, screen, &loc);
SDL_UpdateRect(screen, loc.x, loc.y, loc.w, loc.h);
}
@@ -1133,8 +1190,10 @@
SDL_FreeSurface(s2);
SDL_FreeSurface(s3);
SDL_FreeSurface(s4);
+ SDL_FreeSurface(bk);
+ s1 = s2 = s3 = s4 = bk = NULL;
FreeSprite(tux);
- s1 = s2 = s3 = s4 = tux = NULL;
+ tux = NULL;
}
@@ -1150,6 +1209,7 @@
SDL_Surface* titles[MAX_WORD_LISTS] = {NULL};
SDL_Surface* select[MAX_WORD_LISTS] = {NULL};
SDL_Surface* left = NULL, *right = NULL;
+ SDL_Surface* backg = NULL;
SDL_Rect leftRect, rightRect;
SDL_Rect titleRects[8];
int stop = 0;
@@ -1245,13 +1305,13 @@
select[i] = BlackOutline( wordlistName[i], font, &yellow);
}
- SDL_FreeSurface(bkg);
- bkg = LoadImage("main_bkg.png", IMG_REGULAR);
+// SDL_FreeSurface(bkg);
+ backg = LoadImage("main_bkg.png", IMG_REGULAR);
left = LoadImage("left.png", IMG_ALPHA);
right = LoadImage("right.png", IMG_ALPHA);
/* Get out if needed surface not loaded successfully: */
- if (!bkg || !left || !right)
+ if (!backg || !left || !right)
{
fprintf(stderr, "chooseWordList(): needed image not available\n");
@@ -1262,10 +1322,10 @@
titles[i] = select[i] = NULL;
}
- SDL_FreeSurface(bkg);
+ SDL_FreeSurface(backg);
SDL_FreeSurface(left);
SDL_FreeSurface(right);
- bkg = left = right = NULL;
+ backg = left = right = NULL;
return 0;
}
@@ -1368,7 +1428,7 @@
if (old_loc != loc) {
int start;
- SDL_BlitSurface( bkg, NULL, screen, NULL );
+ SDL_BlitSurface(backg, NULL, screen, NULL );
start = loc - (loc % 8);
for (i = start; i<MIN(start+8,lists); i++) {
@@ -1401,10 +1461,10 @@
titles[i] = select[i] = NULL;
}
- SDL_FreeSurface(bkg);
+ SDL_FreeSurface(backg);
SDL_FreeSurface(left);
SDL_FreeSurface(right);
- bkg = left = right = NULL; /* Maybe overkill - left and right about to be destroyed anyway */
+ backg = left = right = NULL; /* Maybe overkill - about to be destroyed anyway */
DEBUGCODE { fprintf( stderr, "Leaving chooseWordlist();\n" ); }
More information about the Tux4kids-commits
mailing list