# HG changeset patch # User John W. Eaton # Date 1260340610 18000 # Node ID 55061c7c8d6edd245848603db474b38cc92b81b9 # Parent b4661b498a7e7177ff4d2f09c66f57cfd7ab92f9 start using gnulib diff -r b4661b498a7e -r 55061c7c8d6e ChangeLog --- a/ChangeLog Tue Dec 08 18:48:25 2009 -0500 +++ b/ChangeLog Wed Dec 09 01:36:50 2009 -0500 @@ -1,3 +1,23 @@ +2009-12-09 John W. Eaton + + * configure.ac: Remove URL argument from AC_INIT. + Use AC_CONFIG_AUX_DIR. Move AM_INIT_AUTOMAKE after other + AC_CONFIG setup macros. Use gl_EARLY and gl_INIT for gnulib. + Add libgnu/Makefile to the list of AC_CONFIG_FILES. Eliminate + special case check for for strftime. + * bootstrap: New file, from gnulib. + * bootstrap.conf: New file, from gnulib. Override bootstrap + defaults for checkout_only_file, gnulib_tool_option_extras, + gnulib_name, and source_base. + (gnulib_modules): Add strftime to the list. + * autogen.sh: Simply generate makefile fragments and call + bootstrap to do the rest of the initial setup. + * Makefile.am (SUBDIRS): Add libgnu to the list. + * libgnu/Makefile.am: New directory and file. + * INSTALL: Remove our copy so version from gnulib will be + distributed. + * HACKING: New file. + 2009-12-08 Rik * Makefile.am: add BUGS and OCTAVE.INSTALL to DISTCLEANFILES diff -r b4661b498a7e -r 55061c7c8d6e HACKING --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HACKING Wed Dec 09 01:36:50 2009 -0500 @@ -0,0 +1,117 @@ +-*- outline -*- + +This file attempts to describe the rules to use when hacking Octave. +Don't put this file into the distribution. + +* Working from the repository + +These notes intend to help people working on the checked-out sources. +These requirements do not apply when building from a distribution +tarball. + +** Requirements + +We've opted to keep only the highest-level sources in the repository. +This eases our maintenance burden, (fewer merges etc.), but imposes +more requirements on anyone wishing to build from the just-checked-out +sources. For example, you have to use the latest stable versions of +the maintainer tools we depend upon, including: + + - Autoconf + - Automake + - Bison + - Flex + - Git + - Gnulib + - GNU Make + - Gzip + - Libtool + - Mercurial + - Perl + - Rsync + - Tar + +Only building the initial full source tree will be a bit painful. +Later, after synchronizing from the repository a plain `make' should +be sufficient. + +** First checkout + +Obviously, if you are reading these notes, you did manage to check out +this package from the repository. For the record, you will find all the +relevant information on: + + http://savannah.gnu.org/hg/?group=octave + +After checking out Octave, you will need to run the autogen.sh +script: + + $ ./autogen.sh + +This script will examine the source tree and generate some Makefile +fragments and then runs the bootstrap script. The bootstrap script comes +from gnulib but is kept in the Octave source archive. It should be +updated from the gnulib source as necssary. The bootstrap script takes +care of checking out a copy of gnulib, running the autotools, and +generating the configure script. Once the autogen.sh and bootstrap +scripts complete successfully, you may run + + $ ./configure + $ make + $ make check + +At this point, there should be no difference between your local copy, +and the master copy: + + $ hg diff + +should output no difference. + +Additional information about coding style + +This file will eventually be extended to explain more about updating +Octave, preparing patches, and making releases. + +Enjoy! + +----- + +Copyright (C) 2009 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at +your option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + + +This file was adapted for Octave from the HACKING file that is part of +GNU Bison, which contained the following Copyright notice: + + Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009 + Free Software Foundation, Inc. + + This file is part of GNU Bison. + + 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . diff -r b4661b498a7e -r 55061c7c8d6e INSTALL --- a/INSTALL Tue Dec 08 18:48:25 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,236 +0,0 @@ -This file is the generic INSTALL document distributed with autoconf. -It is intended as a basic guide for all autoconf-generated configure -scripts. See the file INSTALL.OCTAVE for information specific to -installing Octave. - -======================================================================== - -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software -Foundation, Inc. - - This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is -disabled by default to prevent problems with accidental use of stale -cache files.) - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') 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: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' -for details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the `--target=TYPE' option to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -will cause the specified gcc to be used as the C compiler (unless it is -overridden in the site shell script). - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of the options to `configure', and exit. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff -r b4661b498a7e -r 55061c7c8d6e Makefile.am --- a/Makefile.am Tue Dec 08 18:48:25 2009 -0500 +++ b/Makefile.am Wed Dec 09 01:36:50 2009 -0500 @@ -67,7 +67,7 @@ include m4/module.mk # Subdirectories in which to run `make all'. -SUBDIRS = libcruft liboctave src scripts doc examples test +SUBDIRS = libgnu libcruft liboctave src scripts doc examples test BUILT_SHELL_FILES = \ mkoctfile$(SCRIPTS_EXE_SUFFIX) \ diff -r b4661b498a7e -r 55061c7c8d6e autogen.sh --- a/autogen.sh Tue Dec 08 18:48:25 2009 -0500 +++ b/autogen.sh Wed Dec 09 01:36:50 2009 -0500 @@ -4,35 +4,7 @@ set -e -# Originally copied from the accelerated glx project. - -acincludeflags="-I m4" - -echo "calling libtoolize..." - -(libtoolize --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "You must have libtoolize (part of the libtool package)" - echo "installed to build Octave. Download the appropriate" - echo "package for your distribution, or get the source" - echo "tarball at ftp://ftp.gnu.org/pub/gnu/" - exit 1 -} - -libtoolize - -echo "calling aclocal..." - -(aclocal --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "You must have aclocal (part of the automake package)" - echo "installed to build Octave. Download the appropriate" - echo "package for your distribution, or get the source" - echo "tarball at ftp://ftp.gnu.org/pub/gnu/" - exit 1 -} - -aclocal $acincludeflags +AUTOMAKE="automake --warnings=no-portability" echo "generating source lists for liboctave/Makefile..." @@ -46,51 +18,6 @@ (cd src/DLD-FUNCTIONS; ./config-module.sh) -echo "calling autoheader..." - -(autoheader --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "You must have autoheader (part of the autoconf package)" - echo "installed to build Octave. Download the appropriate" - echo "package for your distribution, or get the source" - echo "tarball at ftp://ftp.gnu.org/pub/gnu/" - exit 1 -} - -autoheader $acincludeflags --force - -echo "calling automake..." - -(automake --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "You must have automake installed to build Octave." - echo "Download the appropriate package for your distribution," - echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" - exit 1 -} +echo "bootstrapping..." -automake --warnings=no-portability --add-missing \ - Makefile \ - doc/Makefile \ - doc/faq/Makefile \ - doc/interpreter/Makefile \ - doc/liboctave/Makefile \ - doc/refcard/Makefile \ - examples/Makefile \ - libcruft/Makefile \ - liboctave/Makefile \ - scripts/Makefile \ - src/Makefile \ - test/Makefile - -echo "calling autoconf..." - -(autoconf --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "You must have autoconf installed to build Octave." - echo "Download the appropriate package for your distribution," - echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" - exit 1 -} - -autoconf $acincludeflags --force +./bootstrap "$@" diff -r b4661b498a7e -r 55061c7c8d6e bootstrap --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bootstrap Wed Dec 09 01:36:50 2009 -0500 @@ -0,0 +1,813 @@ +#! /bin/sh + +# Bootstrap this package from checked-out sources. + +# Copyright (C) 2003-2009 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 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Written by Paul Eggert. + +nl=' +' + +# Ensure file names are sorted consistently across platforms. +LC_ALL=C +export LC_ALL + +local_gl_dir=gl + +# Temporary directory names. +bt='._bootmp' +bt_regex=`echo "$bt"| sed 's/\./[.]/g'` +bt2=${bt}2 + +usage() { + cat </dev/null 2>&1; then + find_tool_res=$i + break + fi + done + else + find_tool_error_prefix="\$$find_tool_envvar: " + fi + if test x"$find_tool_res" = x; then + echo >&2 "$0: one of these is required: $find_tool_names" + exit 1 + fi + ($find_tool_res --version /dev/null 2>&1 || { + echo >&2 "$0: ${find_tool_error_prefix}cannot run $find_tool_res --version" + exit 1 + } + eval "$find_tool_envvar=\$find_tool_res" + eval "export $find_tool_envvar" +} + +# Find sha1sum, named gsha1sum on MacPorts. +find_tool SHA1SUM sha1sum gsha1sum + +# Override the default configuration, if necessary. +# Make sure that bootstrap.conf is sourced from the current directory +# if we were invoked as "sh bootstrap". +case "$0" in + */*) test -r "$0.conf" && . "$0.conf" ;; + *) test -r "$0.conf" && . ./"$0.conf" ;; +esac + + +if test "$vc_ignore" = auto; then + vc_ignore= + test -d .git && vc_ignore=.gitignore + test -d CVS && vc_ignore="$vc_ignore .cvsignore" +fi + +# Translate configuration into internal form. + +# Parse options. + +for option +do + case $option in + --help) + usage + exit;; + --gnulib-srcdir=*) + GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;; + --skip-po) + SKIP_PO=t;; + --force) + checkout_only_file=;; + --copy) + copy=true;; + *) + echo >&2 "$0: $option: unknown option" + exit 1;; + esac +done + +if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then + echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2 + exit 1 +fi + +# If $STR is not already on a line by itself in $FILE, insert it, +# sorting the new contents of the file and replacing $FILE with the result. +insert_sorted_if_absent() { + file=$1 + str=$2 + test -f $file || touch $file + echo "$str" | sort -u - $file | cmp - $file > /dev/null \ + || echo "$str" | sort -u - $file -o $file \ + || exit 1 +} + +# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac. +found_aux_dir=no +grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \ + >/dev/null && found_aux_dir=yes +grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \ + >/dev/null && found_aux_dir=yes +if test $found_aux_dir = no; then + echo "$0: expected line not found in configure.ac. Add the following:" >&2 + echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2 + exit 1 +fi + +# If $build_aux doesn't exist, create it now, otherwise some bits +# below will malfunction. If creating it, also mark it as ignored. +if test ! -d $build_aux; then + mkdir $build_aux + for dot_ig in x $vc_ignore; do + test $dot_ig = x && continue + insert_sorted_if_absent $dot_ig $build_aux + done +fi + +# Note this deviates from the version comparison in automake +# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a +# but this should suffice as we won't be specifying old +# version formats or redundant trailing .0 in bootstrap.conf. +# If we did want full compatibility then we should probably +# use m4_version_compare from autoconf. +sort_ver() { # sort -V is not generally available + ver1="$1" + ver2="$2" + + # split on '.' and compare each component + i=1 + while : ; do + p1=$(echo "$ver1" | cut -d. -f$i) + p2=$(echo "$ver2" | cut -d. -f$i) + if [ ! "$p1" ]; then + echo "$1 $2" + break + elif [ ! "$p2" ]; then + echo "$2 $1" + break + elif [ ! "$p1" = "$p2" ]; then + if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison + echo "$2 $1" + elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison + echo "$1 $2" + else # numeric, then lexicographic comparison + lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1) + if [ "$lp" = "$p2" ]; then + echo "$1 $2" + else + echo "$2 $1" + fi + fi + break + fi + i=$(($i+1)) + done +} + +get_version() { + app=$1 + + $app --version >/dev/null 2>&1 || return 1 + + $app --version 2>&1 | + sed -n 's/[^0-9.]*\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/p + t done + d + :done + q' +} + +check_versions() { + ret=0 + + while read app req_ver; do + # Honor $APP variables ($TAR, $AUTOCONF, etc.) + appvar=`echo $app | tr '[a-z]' '[A-Z]'` + test "$appvar" = TAR && appvar=AMTAR + eval "app=\${$appvar-$app}" + inst_ver=$(get_version $app) + if [ ! "$inst_ver" ]; then + echo "Error: '$app' not found" >&2 + ret=1 + elif [ ! "$req_ver" = "-" ]; then + latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2) + if [ ! "$latest_ver" = "$inst_ver" ]; then + echo "Error: '$app' version == $inst_ver is too old" >&2 + echo " '$app' version >= $req_ver is required" >&2 + ret=1 + fi + fi + done + + return $ret +} + +print_versions() { + echo "Program Min_version" + echo "----------------------" + printf "$buildreq" + echo "----------------------" + # can't depend on column -t +} + +if ! printf "$buildreq" | check_versions; then + test -f README-prereq && + echo "See README-prereq for notes on obtaining these prerequisite programs:" >&2 + echo + print_versions + exit 1 +fi + +echo "$0: Bootstrapping from checked-out $package sources..." + +# See if we can use gnulib's git-merge-changelog merge driver. +if test -d .git && (git --version) >/dev/null 2>/dev/null ; then + if git config merge.merge-changelog.driver >/dev/null ; then + : + elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then + echo "initializing git-merge-changelog driver" + git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver' + git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B' + else + echo "consider installing git-merge-changelog from gnulib" + fi +fi + + +cleanup_gnulib() { + status=$? + rm -fr gnulib + exit $status +} + +git_modules_config () { + test -f .gitmodules && git config --file .gitmodules "$@" +} + +# Get gnulib files. + +case ${GNULIB_SRCDIR--} in +-) + if git_modules_config submodule.gnulib.url >/dev/null; then + echo "$0: getting gnulib files..." + git submodule init || exit $? + git submodule update || exit $? + + elif [ ! -d gnulib ]; then + echo "$0: getting gnulib files..." + + trap cleanup_gnulib 1 2 13 15 + + git clone --help|grep depth > /dev/null && shallow='--depth 2' || shallow= + git clone $shallow git://git.sv.gnu.org/gnulib || + cleanup_gnulib + + trap - 1 2 13 15 + fi + GNULIB_SRCDIR=gnulib + ;; +*) + # Redirect the gnulib submodule to the directory on the command line + # if possible. + if test -d "$GNULIB_SRCDIR"/.git && \ + git_modules_config submodule.gnulib.url >/dev/null; then + git submodule init + GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd` + git_modules_config --replace-all submodule.gnulib.url $GNULIB_SRCDIR + echo "$0: getting gnulib files..." + git submodule update || exit $? + GNULIB_SRCDIR=gnulib + fi + ;; +esac + +gnulib_tool=$GNULIB_SRCDIR/gnulib-tool +<$gnulib_tool || exit + +# Get translations. + +download_po_files() { + subdir=$1 + domain=$2 + echo "$0: getting translations into $subdir for $domain..." + cmd=`printf "$po_download_command_format" "$domain" "$subdir"` + eval "$cmd" +} + +# Download .po files to $po_dir/.reference and copy only the new +# or modified ones into $po_dir. Also update $po_dir/LINGUAS. +update_po_files() { + # Directory containing primary .po files. + # Overwrite them only when we're sure a .po file is new. + po_dir=$1 + domain=$2 + + # Download *.po files into this dir. + # Usually contains *.s1 checksum files. + ref_po_dir="$po_dir/.reference" + + test -d $ref_po_dir || mkdir $ref_po_dir || return + download_po_files $ref_po_dir $domain \ + && ls "$ref_po_dir"/*.po 2>/dev/null | + sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" + + langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'` + test "$langs" = '*' && langs=x + for po in $langs; do + case $po in x) continue;; esac + new_po="$ref_po_dir/$po.po" + cksum_file="$ref_po_dir/$po.s1" + if ! test -f "$cksum_file" || + ! test -f "$po_dir/$po.po" || + ! $SHA1SUM -c --status "$cksum_file" \ + < "$new_po" > /dev/null; then + echo "updated $po_dir/$po.po..." + cp "$new_po" "$po_dir/$po.po" \ + && $SHA1SUM < "$new_po" > "$cksum_file" + fi + done +} + +case $SKIP_PO in +'') + if test -d po; then + update_po_files po $package || exit + fi + + if test -d runtime-po; then + update_po_files runtime-po $package-runtime || exit + fi;; +esac + +symlink_to_dir() +{ + src=$1/$2 + dst=${3-$2} + + test -f "$src" && { + + # If the destination directory doesn't exist, create it. + # This is required at least for "lib/uniwidth/cjk.h". + dst_dir=`dirname "$dst"` + if ! test -d "$dst_dir"; then + mkdir -p "$dst_dir" + + # If we've just created a directory like lib/uniwidth, + # tell version control system(s) it's ignorable. + # FIXME: for now, this does only one level + parent=`dirname "$dst_dir"` + for dot_ig in x $vc_ignore; do + test $dot_ig = x && continue + ig=$parent/$dot_ig + insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'` + done + fi + + if $copy; then + { + test ! -h "$dst" || { + echo "$0: rm -f $dst" && + rm -f "$dst" + } + } && + test -f "$dst" && + cmp -s "$src" "$dst" || { + echo "$0: cp -fp $src $dst" && + cp -fp "$src" "$dst" + } + else + test -h "$dst" && + src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 && + dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 && + test "$src_i" = "$dst_i" || { + dot_dots= + case $src in + /*) ;; + *) + case /$dst/ in + *//* | */../* | */./* | /*/*/*/*/*/) + echo >&2 "$0: invalid symlink calculation: $src -> $dst" + exit 1;; + /*/*/*/*/) dot_dots=../../../;; + /*/*/*/) dot_dots=../../;; + /*/*/) dot_dots=../;; + esac;; + esac + + echo "$0: ln -fs $dot_dots$src $dst" && + ln -fs "$dot_dots$src" "$dst" + } + fi + } +} + +cp_mark_as_generated() +{ + cp_src=$1 + cp_dst=$2 + + if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then + symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst" + elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then + symlink_to_dir $local_gl_dir "$cp_dst" + else + case $cp_dst in + *.[ch]) c1='/* '; c2=' */';; + *.texi) c1='@c '; c2= ;; + *.m4|*/Make*|Make*) c1='# ' ; c2= ;; + *) c1= ; c2= ;; + esac + + # If the destination directory doesn't exist, create it. + # This is required at least for "lib/uniwidth/cjk.h". + dst_dir=`dirname "$cp_dst"` + test -d "$dst_dir" || mkdir -p "$dst_dir" + + if test -z "$c1"; then + cmp -s "$cp_src" "$cp_dst" || { + # Copy the file first to get proper permissions if it + # doesn't already exist. Then overwrite the copy. + echo "$0: cp -f $cp_src $cp_dst" && + rm -f "$cp_dst" && + cp "$cp_src" "$cp_dst-t" && + sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst-t" && + mv -f "$cp_dst-t" "$cp_dst" + } + else + # Copy the file first to get proper permissions if it + # doesn't already exist. Then overwrite the copy. + cp "$cp_src" "$cp_dst-t" && + ( + echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" && + echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" && + sed "s!$bt_regex/!!g" "$cp_src" + ) > $cp_dst-t && + if cmp -s "$cp_dst-t" "$cp_dst"; then + rm -f "$cp_dst-t" + else + echo "$0: cp $cp_src $cp_dst # with edits" && + mv -f "$cp_dst-t" "$cp_dst" + fi + fi + fi +} + +version_controlled_file() { + dir=$1 + file=$2 + found=no + if test -d CVS; then + grep -F "/$file/" $dir/CVS/Entries 2>/dev/null | + grep '^/[^/]*/[0-9]' > /dev/null && found=yes + elif test -d .git; then + git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes + elif test -d .svn; then + svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes + else + echo "$0: no version control for $dir/$file?" >&2 + fi + test $found = yes +} + +slurp() { + for dir in . `(cd $1 && find * -type d -print)`; do + copied= + sep= + for file in `ls -a $1/$dir`; do + case $file in + .|..) continue;; + .*) continue;; # FIXME: should all file names starting with "." be ignored? + esac + test -d $1/$dir/$file && continue + for excluded_file in $excluded_files; do + test "$dir/$file" = "$excluded_file" && continue 2 + done + if test $file = Makefile.am; then + copied=$copied${sep}$gnulib_mk; sep=$nl + remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g" + sed "$remove_intl" $1/$dir/$file | cmp - $dir/$gnulib_mk > /dev/null || { + echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." && + rm -f $dir/$gnulib_mk && + sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk + } + elif { test "${2+set}" = set && test -r $2/$dir/$file; } || + version_controlled_file $dir $file; then + echo "$0: $dir/$file overrides $1/$dir/$file" + else + copied=$copied$sep$file; sep=$nl + if test $file = gettext.m4; then + echo "$0: patching m4/gettext.m4 to remove need for intl/* ..." + rm -f $dir/$file + sed ' + /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\ + AC_DEFUN([AM_INTL_SUBDIR], [ + /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\ + AC_DEFUN([gt_INTL_SUBDIR_CORE], []) + $a\ + AC_DEFUN([gl_LOCK_EARLY], []) + ' $1/$dir/$file >$dir/$file + else + cp_mark_as_generated $1/$dir/$file $dir/$file + fi + fi || exit + done + + for dot_ig in x $vc_ignore; do + test $dot_ig = x && continue + ig=$dir/$dot_ig + if test -n "$copied"; then + insert_sorted_if_absent $ig "$copied" + # If an ignored file name ends with .in.h, then also add + # the name with just ".h". Many gnulib headers are generated, + # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc. + # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed + f=`echo "$copied"|sed 's/\.in\.h$/.h/;s/\.sin$/.sed/;s/\.y$/.c/;s/\.gperf$/.h/'` + insert_sorted_if_absent $ig "$f" + + # For files like sys_stat.in.h and sys_time.in.h, record as + # ignorable the directory we might eventually create: sys/. + f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'` + insert_sorted_if_absent $ig "$f" + fi + done + done +} + + +# Create boot temporary directories to import from gnulib and gettext. +rm -fr $bt $bt2 && +mkdir $bt $bt2 || exit + +# Import from gnulib. + +gnulib_tool_options="\ + --import\ + --no-changelog\ + --aux-dir $bt/$build_aux\ + --doc-base $bt/$doc_base\ + --lib $gnulib_name\ + --m4-base $bt/$m4_base/\ + --source-base $bt/$source_base/\ + --tests-base $bt/$tests_base\ + --local-dir $local_gl_dir\ + $gnulib_tool_option_extras\ +" +echo "$0: $gnulib_tool $gnulib_tool_options --import ..." +$gnulib_tool $gnulib_tool_options --import $gnulib_modules && +slurp $bt || exit + +for file in $gnulib_files; do + symlink_to_dir "$GNULIB_SRCDIR" $file || exit +done + + +# Import from gettext. +with_gettext=yes +grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \ + with_gettext=no + +if test $with_gettext = yes; then + echo "$0: (cd $bt2; ${AUTOPOINT-autopoint}) ..." + cp configure.ac $bt2 && + (cd $bt2 && ${AUTOPOINT-autopoint} && rm configure.ac) && + slurp $bt2 $bt || exit +fi +rm -fr $bt $bt2 || exit + +# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some +# gnulib-populated directories. Such .m4 files would cause aclocal to fail. +# The following requires GNU find 4.2.3 or newer. Considering the usual +# portability constraints of this script, that may seem a very demanding +# requirement, but it should be ok. Ignore any failure, which is fine, +# since this is only a convenience to help developers avoid the relatively +# unusual case in which a symlinked-to .m4 file is git-removed from gnulib +# between successive runs of this script. +find "$m4_base" "$source_base" \ + -depth \( -name '*.m4' -o -name '*.[ch]' \) \ + -type l -xtype l -delete > /dev/null 2>&1 + +# Reconfigure, getting other files. + +# Skip autoheader if it's not needed. +grep -E '^[ ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null || + AUTOHEADER=true + +for command in \ + libtool \ + "${ACLOCAL-aclocal} --force -I m4" \ + "${AUTOCONF-autoconf} --force" \ + "${AUTOHEADER-autoheader} --force" \ + "${AUTOMAKE-automake} --add-missing --copy --force-missing" +do + if test "$command" = libtool; then + use_libtool=0 + # We'd like to use grep -E, to see if any of LT_INIT, + # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac, + # but that's not portable enough (e.g., for Solaris). + grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \ + && use_libtool=1 + grep '^[ ]*LT_INIT' configure.ac >/dev/null \ + && use_libtool=1 + test $use_libtool = 0 \ + && continue + command="${LIBTOOLIZE-libtoolize} -c -f" + fi + echo "$0: $command ..." + $command || exit +done + + +# Get some extra files from gnulib, overriding existing files. +for file in $gnulib_extra_files; do + case $file in + */INSTALL) dst=INSTALL;; + build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;; + *) dst=$file;; + esac + symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit +done + +if test $with_gettext = yes; then + # Create gettext configuration. + echo "$0: Creating po/Makevars from po/Makevars.template ..." + rm -f po/Makevars + sed ' + /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/ + /^MSGID_BUGS_ADDRESS *=/s/=.*/= '"$MSGID_BUGS_ADDRESS"'/ + /^XGETTEXT_OPTIONS *=/{ + s/$/ \\/ + a\ + '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+} + } + ' po/Makevars.template >po/Makevars + + if test -d runtime-po; then + # Similarly for runtime-po/Makevars, but not quite the same. + rm -f runtime-po/Makevars + sed ' + /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/ + /^subdir *=.*/s/=.*/= runtime-po/ + /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/ + /^XGETTEXT_OPTIONS *=/{ + s/$/ \\/ + a\ + '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+} + } + ' runtime-po/Makevars + + # Copy identical files from po to runtime-po. + (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po) + fi +fi + +bootstrap_epilogue + +echo "$0: done. Now you can run './configure'." + +# Local Variables: +# indent-tabs-mode: nil +# End: diff -r b4661b498a7e -r 55061c7c8d6e bootstrap.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bootstrap.conf Wed Dec 09 01:36:50 2009 -0500 @@ -0,0 +1,65 @@ +# Bootstrap configuration. + +# Copyright (C) 2006, 2007 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 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# gnulib modules used by this package. +gnulib_modules=" + strftime +" + +# Additional xgettext options to use. Use "\\\newline" to break lines. +XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\ + --from-code=UTF-8\\\ + --flag=asprintf:2:c-format --flag=vasprintf:2:c-format\\\ + --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format\\\ + --flag=wrapf:1:c-format\\\ +' + +# If "AM_GNU_GETTEXT(external" or "AM_GNU_GETTEXT([external]" +# appears in configure.ac, exclude some unnecessary files. +# Without grep's -E option (not portable enough, pre-configure), +# the following test is ugly. Also, this depends on the existence +# of configure.ac, not the obsolescent-named configure.in. But if +# you're using this infrastructure, you should care about such things. + +gettext_external=0 +grep '^[ ]*AM_GNU_GETTEXT(external\>' configure.ac > /dev/null && + gettext_external=1 +grep '^[ ]*AM_GNU_GETTEXT(\[external\]' configure.ac > /dev/null && + gettext_external=1 + +if test $gettext_external = 1; then + # Gettext supplies these files, but we don't need them since + # we don't have an intl subdirectory. + excluded_files=' + m4/glibc2.m4 + m4/intdiv0.m4 + m4/lcmessage.m4 + m4/lock.m4 + m4/printf-posix.m4 + m4/size_max.m4 + m4/uintmax_t.m4 + m4/ulonglong.m4 + m4/visibility.m4 + m4/xsize.m4 + ' +fi + +checkout_only_file=HACKING +gnulib_tool_option_extras="--libtool" +gnulib_name="libgnu" +source_base="libgnu" diff -r b4661b498a7e -r 55061c7c8d6e configure.ac --- a/configure.ac Tue Dec 08 18:48:25 2009 -0500 +++ b/configure.ac Wed Dec 09 01:36:50 2009 -0500 @@ -29,7 +29,7 @@ EXTERN_CFLAGS="$CFLAGS" EXTERN_CXXFLAGS="$CXXFLAGS" -AC_INIT([GNU Octave], [3.3.50+], [bug@octave.org], [octave], [http://www.octave.org]) +AC_INIT([GNU Octave], [3.3.50+], [bug@octave.org], [octave]) dnl PACKAGE_VERSION is set by the AC_INIT VERSION arg OCTAVE_VERSION="$PACKAGE_VERSION" @@ -43,13 +43,15 @@ AC_SUBST(OCTAVE_RELEASE_DATE) AC_SUBST(OCTAVE_COPYRIGHT) -AM_INIT_AUTOMAKE([1.11 tar-ustar]) AC_REVISION($Revision: 1.603 $) AC_PREREQ([2.62]) AC_CONFIG_SRCDIR([src/octave.cc]) AC_CONFIG_HEADER([config.h]) +AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) +AM_INIT_AUTOMAKE([1.11 tar-ustar]) + OCTAVE_HOST_TYPE AC_DEFINE(OCTAVE_SOURCE, 1, [Define if this is Octave.]) @@ -227,6 +229,11 @@ AC_PROG_CPP AC_PROG_GCC_TRADITIONAL +### gnulib + +gl_EARLY +gl_INIT + ### Do special things for gcc. gcc_version=`$CC -v 2>&1 | grep "^.*gcc version" | \ @@ -1494,17 +1501,6 @@ ;; esac -case "$canonical_host_type" in - *-*-msdosmsvc | *-*-mingw*) - ## The %T and %e format specifiers for strftime are not implemented - ## so use our version. We could use an actual configure test - ## for this. - ;; - *) - AC_CHECK_FUNCS(strftime) - ;; -esac - OCTAVE_HAVE_C99_VSNPRINTF OCTAVE_STRPTIME_BROKEN OCTAVE_SMART_PUTENV @@ -2143,6 +2139,7 @@ examples/Makefile libcruft/Makefile libcruft/mkf77def + libgnu/Makefile liboctave/Makefile scripts/Makefile src/Makefile diff -r b4661b498a7e -r 55061c7c8d6e liboctave/ChangeLog --- a/liboctave/ChangeLog Tue Dec 08 18:48:25 2009 -0500 +++ b/liboctave/ChangeLog Wed Dec 09 01:36:50 2009 -0500 @@ -1,3 +1,12 @@ +2009-12-09 John W. Eaton + + * oct-time.cc: Include strftime.h. Don't provide decl for strftime. + (octave_base_tm::strftime): Call my_strftime instead of ::strftime. + * Makefile.am (AM_CPPFLAGS): Add -I$(top_srcdir)/libgnu to the list. + (LINK_DEPS): Add ../libgnu/libgnu.la to the list. + (LIBOCTAVE_C_SOURCES): Remove strftime.c from the list. + * strftime.c: Delete. + 2009-12-08 Michael Goffioul * Array-d.cc (Array::is_sorted): Declare as OCTAVE_API. diff -r b4661b498a7e -r 55061c7c8d6e liboctave/Makefile.am --- a/liboctave/Makefile.am Tue Dec 08 18:48:25 2009 -0500 +++ b/liboctave/Makefile.am Wed Dec 09 01:36:50 2009 -0500 @@ -25,9 +25,7 @@ octlib_LTLIBRARIES = liboctave.la -AM_CPPFLAGS = -I$(top_srcdir)/libcruft/misc - -AUTOMAKE_OPTIONS = subdir-objects +AM_CPPFLAGS = -I$(top_srcdir)/libgnu -I$(top_srcdir)/libcruft/misc EXTRA_DIST = \ ChangeLog \ @@ -475,7 +473,6 @@ rename.c \ rmdir.c \ strcasecmp.c \ - strftime.c \ strncase.c \ strptime.c \ tempnam.c \ @@ -500,6 +497,7 @@ LINK_DEPS = \ $(RLD_FLAG) \ ../libcruft/libcruft.la \ + ../libgnu/libgnu.la \ $(SPARSE_XLIBS) \ $(ARPACK_LIBS) \ $(QRUPDATE_LIBS) \ @@ -524,7 +522,6 @@ $(ARPACK_CPPFLAGS) \ $(AM_CPPFLAGS) - liboctave_la_LDFLAGS = -release $(version) $(NO_UNDEFINED_LDFLAG) \ $(SPARSE_XLDFLAGS) \ $(ARPACK_LDFLAGS) \ diff -r b4661b498a7e -r 55061c7c8d6e liboctave/oct-time.cc --- a/liboctave/oct-time.cc Tue Dec 08 18:48:25 2009 -0500 +++ b/liboctave/oct-time.cc Wed Dec 09 01:36:50 2009 -0500 @@ -40,17 +40,13 @@ #undef max #endif +#include "strftime.h" + #include "lo-error.h" #include "lo-math.h" #include "lo-utils.h" #include "oct-time.h" -#ifndef HAVE_STRFTIME -// Override any previous definition and use local version. -extern "C" size_t -strftime (char *s, size_t maxsize, const char *format, const struct tm *tp); -#endif - octave_time::octave_time (const octave_base_tm& tm) { struct tm t; @@ -271,7 +267,7 @@ buf = new char[bufsize]; buf[0] = '\0'; - chars_written = ::strftime (buf, bufsize, fmt_str, &t); + chars_written = my_strftime (buf, bufsize, fmt_str, &t, 0, 0); bufsize *= 2; } diff -r b4661b498a7e -r 55061c7c8d6e liboctave/strftime.c --- a/liboctave/strftime.c Tue Dec 08 18:48:25 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,895 +0,0 @@ -/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc. - - NOTE: The canonical source of this file is maintained with the GNU C - Library. Bugs can be reported to bug-glibc@gnu.org. - - 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 of the License, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifndef HAVE_STRFTIME - -#ifdef _LIBC -# define HAVE_LIMITS_H 1 -# define HAVE_MBLEN 1 -# define HAVE_MBRLEN 1 -# define HAVE_STRUCT_ERA_ENTRY 1 -# define HAVE_TM_GMTOFF 1 -# define HAVE_STRUCT_TM_TM_ZONE 1 -# define MULTIBYTE_IS_FORMAT_SAFE 1 -# define STDC_HEADERS 1 -# include -# include "../locale/localeinfo.h" -#endif - -#include /* Some systems define `time_t' here. */ - -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#if HAVE_TZNAME && !HAVE_DECL_TZNAME -extern OCTAVE_IMPORT char *tzname[]; -#endif - -/* Do multibyte processing if multibytes are supported, unless - multibyte sequences are safe in formats. Multibyte sequences are - safe if they cannot contain byte sequences that look like format - conversion specifications. The GNU C Library uses UTF8 multibyte - encoding, which is safe for formats, but strftime.c can be used - with other C libraries that use unsafe encodings. */ -#define DO_MULTIBYTE (HAVE_MBLEN && ! MULTIBYTE_IS_FORMAT_SAFE) - -#if DO_MULTIBYTE -# if HAVE_MBRLEN -# include -# else - /* Simulate mbrlen with mblen as best we can. */ -# define mbstate_t int -# define mbrlen(s, n, ps) mblen (s, n) -# define mbsinit(ps) (*(ps) == 0) -# endif - static const mbstate_t mbstate_zero; -#endif - -#if HAVE_LIMITS_H -# include -#endif - -#if STDC_HEADERS -# include -# include -# include -#else -# define memcpy(d, s, n) bcopy (s, d, n) -#endif - -#ifndef __P -#if defined (__GNUC__) || (defined (__STDC__) && __STDC__) -#define __P(args) args -#else -#define __P(args) () -#endif /* GCC. */ -#endif /* Not __P. */ - -#ifndef PTR -#ifdef __STDC__ -#define PTR void * -#else -#define PTR char * -#endif -#endif - -#ifndef CHAR_BIT -#define CHAR_BIT 8 -#endif - -#define TYPE_SIGNED(t) ((t) -1 < 0) - -/* Bound on length of the string representing an integer value of type t. - Subtract one for the sign bit if t is signed; - 302 / 1000 is log10 (2) rounded up; - add one for integer division truncation; - add one more for a minus sign if t is signed. */ -#define INT_STRLEN_BOUND(t) \ - ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 100 + 1 + TYPE_SIGNED (t)) - -#define TM_YEAR_BASE 1900 - -#ifndef __isleap -/* Nonzero if YEAR is a leap year (every 4 years, - except every 100th isn't, and every 400th is). */ -#define __isleap(year) \ - ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) -#endif - - -#ifdef _LIBC -# define gmtime_r __gmtime_r -# define localtime_r __localtime_r -#else -# if ! HAVE_LOCALTIME_R -# if ! HAVE_TM_GMTOFF -/* Approximate gmtime_r as best we can in its absence. */ -#define gmtime_r my_gmtime_r -static struct tm *gmtime_r __P ((const time_t *, struct tm *)); -static struct tm * -gmtime_r (t, tp) - const time_t *t; - struct tm *tp; -{ - struct tm *l = gmtime (t); - if (! l) - return 0; - *tp = *l; - return tp; -} -# endif /* ! HAVE_TM_GMTOFF */ - -/* Approximate localtime_r as best we can in its absence. */ -#define localtime_r my_localtime_r -static struct tm *localtime_r __P ((const time_t *, struct tm *)); -static struct tm * -localtime_r (t, tp) - const time_t *t; - struct tm *tp; -{ - struct tm *l = localtime (t); - if (! l) - return 0; - *tp = *l; - return tp; -} -# endif /* ! HAVE_LOCALTIME_R */ -#endif /* ! defined (_LIBC) */ - - -#define add(n, f) \ - do \ - { \ - i += (n); \ - if (i >= maxsize) \ - return 0; \ - else \ - if (p) \ - { \ - f; \ - p += (n); \ - } \ - } while (0) -#define cpy(n, s) add ((n), memcpy((PTR) p, (PTR) (s), (n))) - -#if ! HAVE_TM_GMTOFF -/* Yield the difference between *A and *B, - measured in seconds, ignoring leap seconds. */ -static int tm_diff __P ((const struct tm *, const struct tm *)); -static int -tm_diff (a, b) - const struct tm *a; - const struct tm *b; -{ - /* Compute intervening leap days correctly even if year is negative. - Take care to avoid int overflow in leap day calculations, - but it's OK to assume that A and B are close to each other. */ - int a4 = (a->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (a->tm_year & 3); - int b4 = (b->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (b->tm_year & 3); - int a100 = a4 / 25 - (a4 % 25 < 0); - int b100 = b4 / 25 - (b4 % 25 < 0); - int a400 = a100 >> 2; - int b400 = b100 >> 2; - int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); - int years = a->tm_year - b->tm_year; - int days = (365 * years + intervening_leap_days - + (a->tm_yday - b->tm_yday)); - return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) - + (a->tm_min - b->tm_min)) - + (a->tm_sec - b->tm_sec)); -} -#endif /* ! HAVE_TM_GMTOFF */ - - - -/* The number of days from the first day of the first ISO week of this - year to the year day YDAY with week day WDAY. ISO weeks start on - Monday; the first ISO week has the year's first Thursday. YDAY may - be as small as YDAY_MINIMUM. */ -#define ISO_WEEK_START_WDAY 1 /* Monday */ -#define ISO_WEEK1_WDAY 4 /* Thursday */ -#define YDAY_MINIMUM (-366) -static int iso_week_days __P ((int, int)); -#ifdef __GNUC__ -inline -#endif -static int -iso_week_days (yday, wday) - int yday; - int wday; -{ - /* Add enough to the first operand of % to make it nonnegative. */ - int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; - return (yday - - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7 - + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY); -} - - -#ifndef _NL_CURRENT -static char const weekday_name[][10] = - { - "Sunday", "Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday" - }; -static char const month_name[][10] = - { - "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December" - }; -#endif - -/* Write information from TP into S according to the format - string FORMAT, writing no more that MAXSIZE characters - (including the terminating '\0') and returning number of - characters written. If S is NULL, nothing will be written - anywhere, so to determine how many characters would be - written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ -size_t -strftime (s, maxsize, format, tp) - char *s; - size_t maxsize; - const char *format; - register const struct tm *tp; -{ - int hour12 = tp->tm_hour; -#ifdef _NL_CURRENT - const char *const a_wkday = _NL_CURRENT (LC_TIME, ABDAY_1 + tp->tm_wday); - const char *const f_wkday = _NL_CURRENT (LC_TIME, DAY_1 + tp->tm_wday); - const char *const a_month = _NL_CURRENT (LC_TIME, ABMON_1 + tp->tm_mon); - const char *const f_month = _NL_CURRENT (LC_TIME, MON_1 + tp->tm_mon); - const char *const ampm = _NL_CURRENT (LC_TIME, - hour12 > 11 ? PM_STR : AM_STR); - size_t aw_len = strlen (a_wkday); - size_t am_len = strlen (a_month); - size_t ap_len = strlen (ampm); -#else - const char *const f_wkday = weekday_name[tp->tm_wday]; - const char *const f_month = month_name[tp->tm_mon]; - const char *const a_wkday = f_wkday; - const char *const a_month = f_month; - const char *const ampm = "AMPM" + 2 * (hour12 > 11); - size_t aw_len = 3; - size_t am_len = 3; - size_t ap_len = 2; -#endif - size_t wkday_len = strlen (f_wkday); - size_t month_len = strlen (f_month); - const char *zone; - size_t zonelen; - register size_t i = 0; - register char *p = s; - register const char *f; - - zone = 0; -#if HAVE_STRUCT_TM_TM_ZONE - zone = (const char *) tp->tm_zone; -#endif -#if HAVE_TZNAME - if (!(zone && *zone) && tp->tm_isdst >= 0) - zone = tzname[tp->tm_isdst]; -#endif - if (! zone) - zone = ""; /* POSIX.2 requires the empty string here. */ - - zonelen = strlen (zone); - - if (hour12 > 12) - hour12 -= 12; - else - if (hour12 == 0) hour12 = 12; - - for (f = format; *f != '\0'; ++f) - { - int pad; /* Padding for number ('-', '_', or 0). */ - int modifier; /* Field modifier ('E', 'O', or 0). */ - int digits; /* Max digits for numeric format. */ - int number_value; /* Numeric value to be printed. */ - int negative_number; /* 1 if the number is negative. */ - const char *subfmt; - char *bufp; - char buf[1 + (sizeof (int) < sizeof (time_t) - ? INT_STRLEN_BOUND (time_t) - : INT_STRLEN_BOUND (int))]; - -#if DO_MULTIBYTE - - switch (*f) - { - case '%': - break; - - case '\a': case '\b': case '\t': case '\n': - case '\v': case '\f': case '\r': - case ' ': case '!': case '"': case '#': case '&': case'\'': - case '(': case ')': case '*': case '+': case ',': case '-': - case '.': case '/': case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': case '?': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': case '[': case'\\': case ']': case '^': - case '_': case 'a': case 'b': case 'c': case 'd': case 'e': - case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': - case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': - case 'r': case 's': case 't': case 'u': case 'v': case 'w': - case 'x': case 'y': case 'z': case '{': case '|': case '}': - case '~': - /* The C Standard requires these 98 characters (plus '%') to - be in the basic execution character set. None of these - characters can start a multibyte sequence, so they need - not be analyzed further. */ - add (1, *p = *f); - continue; - - default: - /* Copy this multibyte sequence until we reach its end, find - an error, or come back to the initial shift state. */ - { - mbstate_t mbstate = mbstate_zero; - size_t len = 0; - - do - { - size_t bytes = mbrlen (f + len, (size_t) -1, &mbstate); - - if (bytes == 0) - break; - - if (bytes == (size_t) -2 || bytes == (size_t) -1) - { - len++; - break; - } - - len += bytes; - } - while (! mbsinit (&mbstate)); - - cpy (len, f); - continue; - } - } - -#else /* ! DO_MULTIBYTE */ - - /* Either multibyte encodings are not supported, or they are - safe for formats, so any non-'%' byte can be copied through. */ - if (*f != '%') - { - add (1, *p = *f); - continue; - } - -#endif /* ! DO_MULTIBYTE */ - - /* Check for flags that can modify a number format. */ - ++f; - switch (*f) - { - case '_': - case '-': - pad = *f++; - break; - - default: - pad = 0; - break; - } - - /* Check for modifiers. */ - switch (*f) - { - case 'E': - case 'O': - modifier = *f++; - break; - - default: - modifier = 0; - break; - } - - /* Now do the specified format. */ - switch (*f) - { -#define DO_NUMBER(d, v) \ - digits = d; number_value = v; goto do_number -#define DO_NUMBER_SPACEPAD(d, v) \ - digits = d; number_value = v; goto do_number_spacepad - - case '%': - if (modifier != 0) - goto bad_format; - add (1, *p = *f); - break; - - case 'a': - if (modifier != 0) - goto bad_format; - cpy (aw_len, a_wkday); - break; - - case 'A': - if (modifier != 0) - goto bad_format; - cpy (wkday_len, f_wkday); - break; - - case 'b': - case 'h': /* POSIX.2 extension. */ - if (modifier != 0) - goto bad_format; - cpy (am_len, a_month); - break; - - case 'B': - if (modifier != 0) - goto bad_format; - cpy (month_len, f_month); - break; - - case 'c': - if (modifier == 'O') - goto bad_format; -#ifdef _NL_CURRENT - if (! (modifier == 'E' - && *(subfmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT)) != '\0')) - subfmt = _NL_CURRENT (LC_TIME, D_T_FMT); -#else - subfmt = "%a %b %e %H:%M:%S %Y"; -#endif - - subformat: - { - size_t len = strftime (p, maxsize - i, subfmt, tp); - if (len == 0 && *subfmt) - return 0; - add (len, ;); - } - break; - - case 'C': /* POSIX.2 extension. */ - if (modifier == 'O') - goto bad_format; -#if HAVE_STRUCT_ERA_ENTRY - if (modifier == 'E') - { - struct era_entry *era = _nl_get_era_entry (tp); - if (era) - { - size_t len = strlen (era->name_fmt); - cpy (len, era->name_fmt); - break; - } - } -#endif - { - int year = tp->tm_year + TM_YEAR_BASE; - DO_NUMBER (1, year / 100 - (year % 100 < 0)); - } - - case 'x': - if (modifier == 'O') - goto bad_format; -#ifdef _NL_CURRENT - if (! (modifier == 'E' - && *(subfmt = _NL_CURRENT (LC_TIME, ERA_D_FMT)) != '\0')) - subfmt = _NL_CURRENT (LC_TIME, D_FMT); - goto subformat; -#endif - /* Fall through. */ - case 'D': /* POSIX.2 extension. */ - if (modifier != 0) - goto bad_format; - subfmt = "%m/%d/%y"; - goto subformat; - - case 'd': - if (modifier == 'E') - goto bad_format; - - DO_NUMBER (2, tp->tm_mday); - - case 'e': /* POSIX.2 extension. */ - if (modifier == 'E') - goto bad_format; - - DO_NUMBER_SPACEPAD (2, tp->tm_mday); - - /* All numeric formats set DIGITS and NUMBER_VALUE and then - jump to one of these two labels. */ - - do_number_spacepad: - /* Force `_' flag. */ - pad = '_'; - - do_number: - /* Format the number according to the MODIFIER flag. */ - -#ifdef _NL_CURRENT - if (modifier == 'O' && 0 <= number_value) - { - /* Get the locale specific alternate representation of - the number NUMBER_VALUE. If none exist NULL is returned. */ - const char *cp = _nl_get_alt_digit (number_value); - - if (cp != NULL) - { - size_t digitlen = strlen (cp); - if (digitlen != 0) - { - cpy (digitlen, cp); - break; - } - } - } -#endif - { - unsigned int u = number_value; - - bufp = buf + sizeof (buf); - negative_number = number_value < 0; - - if (negative_number) - u = -u; - - do - *--bufp = u % 10 + '0'; - while ((u /= 10) != 0); - } - - do_number_sign_and_padding: - if (negative_number) - *--bufp = '-'; - - if (pad != '-') - { - int padding = digits - (buf + sizeof (buf) - bufp); - - if (pad == '_') - { - while (0 < padding--) - *--bufp = ' '; - } - else - { - bufp += negative_number; - while (0 < padding--) - *--bufp = '0'; - if (negative_number) - *--bufp = '-'; - } - } - - cpy (buf + sizeof (buf) - bufp, bufp); - break; - - - case 'H': - if (modifier == 'E') - goto bad_format; - - DO_NUMBER (2, tp->tm_hour); - - case 'I': - if (modifier == 'E') - goto bad_format; - - DO_NUMBER (2, hour12); - - case 'k': /* GNU extension. */ - if (modifier == 'E') - goto bad_format; - - DO_NUMBER_SPACEPAD (2, tp->tm_hour); - - case 'l': /* GNU extension. */ - if (modifier == 'E') - goto bad_format; - - DO_NUMBER_SPACEPAD (2, hour12); - - case 'j': - if (modifier == 'E') - goto bad_format; - - DO_NUMBER (3, 1 + tp->tm_yday); - - case 'M': - if (modifier == 'E') - goto bad_format; - - DO_NUMBER (2, tp->tm_min); - - case 'm': - if (modifier == 'E') - goto bad_format; - - DO_NUMBER (2, tp->tm_mon + 1); - - case 'n': /* POSIX.2 extension. */ - add (1, *p = '\n'); - break; - - case 'p': - cpy (ap_len, ampm); - break; - - case 'R': /* GNU extension. */ - subfmt = "%H:%M"; - goto subformat; - - case 'r': /* POSIX.2 extension. */ -#ifdef _NL_CURRENT - if (*(subfmt = _NL_CURRENT (LC_TIME, T_FMT_AMPM)) == '\0') -#endif - subfmt = "%I:%M:%S %p"; - goto subformat; - - case 'S': - if (modifier == 'E') - goto bad_format; - - DO_NUMBER (2, tp->tm_sec); - - case 's': /* GNU extension. */ - { - struct tm ltm; - time_t t; - - ltm = *tp; - t = mktime (<m); - - /* Generate string value for T using time_t arithmetic; - this works even if sizeof (long) < sizeof (time_t). */ - - bufp = buf + sizeof (buf); - negative_number = t < 0; - - do - { - int d = t % 10; - t /= 10; - - if (negative_number) - { - d = -d; - - /* Adjust if division truncates to minus infinity. */ - if (0 < -1 % 10 && d < 0) - { - t++; - d += 10; - } - } - - *--bufp = d + '0'; - } - while (t != 0); - - digits = 1; - goto do_number_sign_and_padding; - } - - case 'X': - if (modifier == 'O') - goto bad_format; -#ifdef _NL_CURRENT - if (! (modifier == 'E' - && *(subfmt = _NL_CURRENT (LC_TIME, ERA_T_FMT)) != '\0')) - subfmt = _NL_CURRENT (LC_TIME, T_FMT); - goto subformat; -#endif - /* Fall through. */ - case 'T': /* POSIX.2 extension. */ - subfmt = "%H:%M:%S"; - goto subformat; - - case 't': /* POSIX.2 extension. */ - add (1, *p = '\t'); - break; - - case 'u': /* POSIX.2 extension. */ - DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1); - - case 'U': - if (modifier == 'E') - goto bad_format; - - DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7); - - case 'V': - case 'g': /* GNU extension. */ - case 'G': /* GNU extension. */ - if (modifier == 'E') - goto bad_format; - { - int year = tp->tm_year + TM_YEAR_BASE; - int days = iso_week_days (tp->tm_yday, tp->tm_wday); - - if (days < 0) - { - /* This ISO week belongs to the previous year. */ - year--; - days = iso_week_days (tp->tm_yday + (365 + __isleap (year)), - tp->tm_wday); - } - else - { - int d = iso_week_days (tp->tm_yday - (365 + __isleap (year)), - tp->tm_wday); - if (0 <= d) - { - /* This ISO week belongs to the next year. */ - year++; - days = d; - } - } - - switch (*f) - { - case 'g': - DO_NUMBER (2, (year % 100 + 100) % 100); - - case 'G': - DO_NUMBER (1, year); - - default: - DO_NUMBER (2, days / 7 + 1); - } - } - - case 'W': - if (modifier == 'E') - goto bad_format; - - DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7); - - case 'w': - if (modifier == 'E') - goto bad_format; - - DO_NUMBER (1, tp->tm_wday); - - case 'Y': -#if HAVE_STRUCT_ERA_ENTRY - if (modifier == 'E') - { - struct era_entry *era = _nl_get_era_entry (tp); - if (era) - { - subfmt = strchr (era->name_fmt, '\0') + 1; - goto subformat; - } - } -#endif - if (modifier == 'O') - goto bad_format; - else - DO_NUMBER (1, tp->tm_year + TM_YEAR_BASE); - - case 'y': -#if HAVE_STRUCT_ERA_ENTRY - if (modifier == 'E') - { - struct era_entry *era = _nl_get_era_entry (tp); - if (era) - { - int delta = tp->tm_year - era->start_date[0]; - DO_NUMBER (1, (era->offset - + (era->direction == '-' ? -delta : delta))); - } - } -#endif - DO_NUMBER (2, (tp->tm_year % 100 + 100) % 100); - - case 'Z': - cpy (zonelen, zone); - break; - - case 'z': /* GNU extension. */ - if (tp->tm_isdst < 0) - break; - - { - int diff; -#if HAVE_TM_GMTOFF - diff = tp->tm_gmtoff; -#else - struct tm gtm; - struct tm ltm; - time_t lt; - - ltm = *tp; - lt = mktime (<m); - - if (lt == (time_t) -1) - { - /* mktime returns -1 for errors, but -1 is also a - valid time_t value. Check whether an error really - occurred. */ - struct tm tm; - localtime_r (<, &tm); - - if ((ltm.tm_sec ^ tm.tm_sec) - | (ltm.tm_min ^ tm.tm_min) - | (ltm.tm_hour ^ tm.tm_hour) - | (ltm.tm_mday ^ tm.tm_mday) - | (ltm.tm_mon ^ tm.tm_mon) - | (ltm.tm_year ^ tm.tm_year)) - break; - } - - if (! gmtime_r (<, >m)) - break; - - diff = tm_diff (<m, >m); -#endif - - if (diff < 0) - { - add (1, *p = '-'); - diff = -diff; - } - else - add (1, *p = '+'); - - diff /= 60; - DO_NUMBER (4, (diff / 60) * 100 + diff % 60); - } - - case '\0': /* GNU extension: % at end of format. */ - --f; - /* Fall through. */ - default: - /* Unknown format; output the format, including the '%', - since this is most likely the right thing to do if a - multibyte string has been misparsed. */ - bad_format: - { - int flen; - for (flen = 1; f[1 - flen] != '%'; flen++) - continue; - cpy (flen, &f[1 - flen]); - } - break; - } - } - - if (p) - *p = '\0'; - return i; -} - -#endif diff -r b4661b498a7e -r 55061c7c8d6e src/ChangeLog --- a/src/ChangeLog Tue Dec 08 18:48:25 2009 -0500 +++ b/src/ChangeLog Wed Dec 09 01:36:50 2009 -0500 @@ -1,3 +1,12 @@ +2009-12-09 John W. Eaton + + * load-save.cc: Include strftime.h. + (write_header): Call my_strftime instead of strftime. + + * Makefile.am (AM_CPPFLAGS): Add -I$(top_srcdir)/libgnu to the list. + (OCTAVE_LIBS, OCTINTERP_LINK_DEPS, OCT_LINK_DEPS): + Add ../libgnu/libgnu.la to the list. + 2009-12-09 Rik * Makefile.am: Distribute DOCSTRINGS in tar.gz file diff -r b4661b498a7e -r 55061c7c8d6e src/Makefile.am --- a/src/Makefile.am Tue Dec 08 18:48:25 2009 -0500 +++ b/src/Makefile.am Wed Dec 09 01:36:50 2009 -0500 @@ -27,7 +27,7 @@ liboctinterp.la AM_CPPFLAGS = \ - @CPPFLAGS@ -I$(top_srcdir)/libcruft/misc -I../liboctave -I$(top_srcdir)/liboctave -I. -I$(srcdir) + @CPPFLAGS@ -I$(top_srcdir)/libgnu -I$(top_srcdir)/libcruft/misc -I../liboctave -I$(top_srcdir)/liboctave -I. -I$(srcdir) AUTOMAKE_OPTIONS = subdir-objects @@ -486,6 +486,7 @@ ./liboctinterp.la \ ../liboctave/liboctave.la \ ../libcruft/libcruft.la \ + ../libgnu/libgnu.la \ $(FFTW_XLDFLAGS) $(FFTW_XLIBS) \ $(SPARSE_XLDFLAGS) $(SPARSE_XLIBS) \ $(GRAPHICS_LDFLAGS) $(GRAPHICS_LIBS) \ @@ -505,6 +506,7 @@ ./liboctinterp.la \ ../liboctave/liboctave.la \ ../libcruft/libcruft.la \ + ../libgnu/libgnu.la \ $(FFTW_XLDFLAGS) $(FFTW_XLIBS) $(QHULL_LDFLAGS) $(QHULL_LIBS) \ $(ARPACK_LDFLAGS) $(ARPACK_LIBS) \ @@ -529,6 +531,7 @@ $(RLD_FLAG) \ ../liboctave/liboctave.la \ ../libcruft/libcruft.la \ + ../libgnu/libgnu.la \ $(FFTW_XLDFLAGS) $(FFTW_XLIBS) \ $(HDF5_LDFLAGS) $(HDF5_LIBS) $(Z_LDFLAGS) $(Z_LIBS) \ $(OPENGL_LIBS) $(X11_LIBS) $(CARBON_LIBS) \ @@ -544,7 +547,8 @@ $(RLD_FLAG) $(LDFLAGS) \ ./liboctinterp.la \ ../liboctave/liboctave.la \ - ../libcruft/libcruft.la + ../libcruft/libcruft.la \ + ../libgnu/libgnu.la bin_PROGRAMS = octave diff -r b4661b498a7e -r 55061c7c8d6e src/load-save.cc --- a/src/load-save.cc Tue Dec 08 18:48:25 2009 -0500 +++ b/src/load-save.cc Wed Dec 09 01:36:50 2009 -0500 @@ -39,6 +39,8 @@ #include #include +#include "strftime.h" + #include "byte-swap.h" #include "data-conv.h" #include "file-ops.h" @@ -1182,8 +1184,8 @@ bdt = *gmtime (&now); memset (headertext, ' ', 124); // ISO 8601 format date - strftime (headertext, 124, "MATLAB 5.0 MAT-file, written by Octave " - OCTAVE_VERSION ", %Y-%m-%d %T UTC", &bdt); + my_strftime (headertext, 124, "MATLAB 5.0 MAT-file, written by Octave " + OCTAVE_VERSION ", %Y-%m-%d %T UTC", &bdt, 1, 0); // The first pair of bytes give the version of the MAT file // format. The second pair of bytes form a magic number which