Compare commits

..

10 Commits

Author SHA1 Message Date
Dianne Skoll
5baf102bfe Update WHATSNEW. 2025-08-19 12:43:00 -04:00
Dianne Skoll
c9002d5b54 Bump version to 06.00.01 2025-08-19 12:38:38 -04:00
Dianne Skoll
ac3ee7e22b Use constant-time DBufLen instead of O(n) strlen() 2025-08-19 10:21:01 -04:00
Dianne Skoll
f366037b8d Truncate over-long variable name in DUMP. 2025-08-19 10:13:09 -04:00
Dianne Skoll
a46488a50d Remove incorrect assignment that could cause a segfault. 2025-08-19 09:58:04 -04:00
Dianne Skoll
f91a1a2d65 If we don't have readline, don't declare unused variable. 2025-08-18 21:05:56 -04:00
Dianne Skoll
2ac8fb50e1 Fix typos. 2025-08-18 21:01:48 -04:00
Dianne Skoll
7df826f635 Add whole line at a time to history buffer. 2025-08-18 20:35:10 -04:00
Dianne Skoll
f8ce7b51da Change prompt depending on whether or not we're ignoring lines. 2025-08-18 16:26:58 -04:00
Dianne Skoll
35ee94ca6b If stdin and stdout are TTYs, use readline() where possible. 2025-08-18 16:20:45 -04:00
9 changed files with 183 additions and 22 deletions

79
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.72 for remind 06.00.00.
# Generated by GNU Autoconf 2.72 for remind 06.00.01.
#
#
# Copyright (C) 1992-1996, 1998-2017, 2020-2023 Free Software Foundation,
@@ -601,8 +601,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='remind'
PACKAGE_TARNAME='remind'
PACKAGE_VERSION='06.00.00'
PACKAGE_STRING='remind 06.00.00'
PACKAGE_VERSION='06.00.01'
PACKAGE_STRING='remind 06.00.01'
PACKAGE_BUGREPORT=''
PACKAGE_URL='https://dianne.skoll.ca/projects/remind/'
@@ -1258,7 +1258,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
'configure' configures remind 06.00.00 to adapt to many kinds of systems.
'configure' configures remind 06.00.01 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1320,7 +1320,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of remind 06.00.00:";;
short | recursive ) echo "Configuration of remind 06.00.01:";;
esac
cat <<\_ACEOF
@@ -1408,7 +1408,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
remind configure 06.00.00
remind configure 06.00.01
generated by GNU Autoconf 2.72
Copyright (C) 2023 Free Software Foundation, Inc.
@@ -1871,7 +1871,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by remind $as_me 06.00.00, which was
It was created by remind $as_me 06.00.01, which was
generated by GNU Autoconf 2.72. Invocation command line was
$ $0$ac_configure_args_raw
@@ -2477,6 +2477,8 @@ as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H"
as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H"
as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H"
as_fn_append ac_header_c_list " sys/time.h sys_time_h HAVE_SYS_TIME_H"
as_fn_append ac_header_c_list " readline/readline.h readline_readline_h HAVE_READLINE_READLINE_H"
as_fn_append ac_header_c_list " readline/history.h readline_history_h HAVE_READLINE_HISTORY_H"
# Auxiliary files required by this configure script.
ac_aux_files="install-sh"
@@ -3941,6 +3943,57 @@ then :
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5
printf %s "checking for readline in -lreadline... " >&6; }
if test ${ac_cv_lib_readline_readline+y}
then :
printf %s "(cached) " >&6
else case e in #(
e) ac_check_lib_save_LIBS=$LIBS
LIBS="-lreadline $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply.
The 'extern "C"' is for builds by C++ compilers;
although this is not generally supported in C code supporting it here
has little cost and some practical benefit (sr 110532). */
#ifdef __cplusplus
extern "C"
#endif
char readline (void);
int
main (void)
{
return readline ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ac_cv_lib_readline_readline=yes
else case e in #(
e) ac_cv_lib_readline_readline=no ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS ;;
esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_readline" >&5
printf "%s\n" "$ac_cv_lib_readline_readline" >&6; }
if test "x$ac_cv_lib_readline_readline" = xyes
then :
printf "%s\n" "#define HAVE_LIBREADLINE 1" >>confdefs.h
LIBS="-lreadline $LIBS"
fi
ac_header= ac_cache=
for ac_item in $ac_header_c_list
do
@@ -3973,6 +4026,8 @@ fi
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'.
@@ -4270,6 +4325,12 @@ then :
printf "%s\n" "#define HAVE_INOTIFY_INIT1 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "readline" "ac_cv_func_readline"
if test "x$ac_cv_func_readline" = xyes
then :
printf "%s\n" "#define HAVE_READLINE 1" >>confdefs.h
fi
VERSION=$PACKAGE_VERSION
@@ -4787,7 +4848,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by remind $as_me 06.00.00, which was
This file was extended by remind $as_me 06.00.01, which was
generated by GNU Autoconf 2.72. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -4852,7 +4913,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
remind config.status 06.00.00
remind config.status 06.00.01
configured by $0, generated by GNU Autoconf 2.72,
with options \\"\$ac_cs_config\\"

View File

@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(remind, 06.00.00, , , https://dianne.skoll.ca/projects/remind/)
AC_INIT(remind, 06.00.01, , , https://dianne.skoll.ca/projects/remind/)
AC_CONFIG_SRCDIR([src/queue.c])
cat <<'EOF'
@@ -30,7 +30,8 @@ AC_PATH_PROG([PERL], [perl])
dnl Checks for libraries.
AC_CHECK_LIB(m, sqrt)
AC_CHECK_HEADERS_ONCE([sys/time.h stdint.h])
AC_CHECK_LIB(readline, readline)
AC_CHECK_HEADERS_ONCE([sys/time.h stdint.h readline/readline.h readline/history.h])
dnl Integer sizes
AC_CHECK_SIZEOF(unsigned int)
@@ -84,7 +85,7 @@ if test "$?" != 0 ; then
echo "*** COULD NOT DETERMINE RELEASE DATE: docs/WHATSNEW is incorrect!"
exit 1
fi
AC_CHECK_FUNCS(strdup strcasecmp strncasecmp setenv unsetenv glob mbstowcs setlocale initgroups inotify_init1)
AC_CHECK_FUNCS(strdup strcasecmp strncasecmp setenv unsetenv glob mbstowcs setlocale initgroups inotify_init1 readline)
VERSION=$PACKAGE_VERSION
CONFIG_CMD="$0$ac_configure_args_raw"

View File

@@ -1,5 +1,14 @@
CHANGES TO REMIND
* VERSION 6.0 Patch 1 - 2025-08-19
- NEW FEATURE: remind: Add readline support if input is taken from stdin
(ie, "remind -"). This gives you full editing support if you run
Remind interactively.
- BUG FIX: remind: Fix buffer overflow in DUMPVARS command.
Thanks to Jochen Sprickerhof for helping me find this bug.
* VERSION 6.0 Patch 0 - 2025-08-18
- MAJOR NEW FEATURE: remind: Introduction of TODOs. These are similar

View File

@@ -45,6 +45,9 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `readline' function. */
#undef HAVE_READLINE
/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP
@@ -81,6 +84,12 @@
/* Define to 1 if you have the <wctype.h> header file. */
#undef HAVE_WCTYPE_H
/* Define to 1 if you have the <readline/history.h> header file. */
#undef HAVE_READLINE_HISTORY_H
/* Define to 1 if you have the <readline/readline.h> header file. */
#undef HAVE_READLINE_READLINE_H
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT

View File

@@ -159,3 +159,15 @@
#else
#undef REM_USE_WCHAR
#endif
#if defined(HAVE_READLINE) && defined(HAVE_READLINE_READLINE_H)
#define USE_READLINE 1
#else
#undef USE_READLINE
#endif
#if defined(HAVE_READLINE) && defined(HAVE_READLINE_READLINE_H) && defined(HAVE_READLINE_HISTORY_H)
#define USE_READLINE_HISTORY 1
#else
#undef USE_READLINE_HISTORY
#endif

View File

@@ -22,8 +22,8 @@
/* The default values are initially set to the city hall in Ottawa, */
/* Ontario, Canada. */
/*---------------------------------------------------------------------*/
#define DEFAULT_LATITUDE 45.420556
#define DEFAULT_LONGITUDE -75.689722
#define DEFAULT_LATITUDE 45.42055555555555
#define DEFAULT_LONGITUDE -75.68944444444445
#define LOCATION "Ottawa"
/*---------------------------------------------------------------------*/
@@ -159,3 +159,15 @@
#else
#undef REM_USE_WCHAR
#endif
#if defined(HAVE_READLINE) && defined(HAVE_READLINE_READLINE_H)
#define USE_READLINE 1
#else
#undef USE_READLINE
#endif
#if defined(HAVE_READLINE) && defined(HAVE_READLINE_READLINE_H) && defined(HAVE_READLINE_HISTORY_H)
#define USE_READLINE_HISTORY 1
#else
#undef USE_READLINE_HISTORY
#endif

View File

@@ -41,6 +41,13 @@
#include "globals.h"
#include "err.h"
#ifdef USE_READLINE
#include <readline/readline.h>
#endif
#ifdef USE_READLINE_HISTORY
#include <readline/history.h>
#endif
/* Convenient macros for closing files */
#define FCLOSE(fp) ((((fp)!=stdin)) ? (fclose(fp),(fp)=NULL) : ((fp)=NULL))
@@ -134,6 +141,9 @@ void InitFiles(void)
fprintf(ErrFp, "Unable to initialize filename hash table: Out of memory. Exiting.\n");
exit(1);
}
#ifdef USE_READLINE_HISTORY
using_history();
#endif
}
void SetCurrentFilename(char const *fname)
@@ -280,6 +290,11 @@ static int ReadLineFromFile(int use_pclose)
int l;
char copy_buffer[4096];
size_t n;
int force_eof = 0;
#ifdef USE_READLINE
int read_some = 0;
#endif
DynamicBuffer buf;
@@ -288,17 +303,51 @@ static int ReadLineFromFile(int use_pclose)
LineNoStart = LineNo+1;
while(fp) {
#ifdef USE_READLINE
if (fileno(fp) == STDIN_FILENO && isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
char *lin;
if (should_ignore_line()) {
if (read_some) {
lin = readline("Rem...? ");
} else {
lin = readline("Remind? ");
}
} else {
if (read_some) {
lin = readline("Rem...> ");
} else {
lin = readline("Remind> ");
}
}
if (lin) {
read_some = 1;
DBufFree(&buf);
if (DBufPuts(&buf, lin) != OK) {
free(lin);
DBufFree(&buf);
return E_NO_MEM;
}
free(lin);
force_eof = 0;
} else {
force_eof = 1;
}
} else {
#endif
if (DBufGets(&buf, fp) != OK) {
DBufFree(&LineBuffer);
return E_NO_MEM;
}
#ifdef USE_READLINE
}
#endif
LineNo++;
if (ferror(fp)) {
DBufFree(&buf);
DBufFree(&LineBuffer);
return E_IO_ERR;
}
if (feof(fp)) {
if (feof(fp) || force_eof) {
if (use_pclose) {
PCLOSE(fp);
} else {
@@ -360,6 +409,9 @@ static int ReadLineFromFile(int use_pclose)
CurLine = DBufValue(&LineBuffer);
}
#ifdef USE_READLINE_HISTORY
add_history(CurLine);
#endif
got_a_fresh_line();
clear_callstack();
if (DebugFlag & DB_ECHO_LINE) OutputLine(ErrFp);

View File

@@ -786,9 +786,14 @@ int DoDump(ParsePtr p)
DumpSysVarByName(DBufValue(&buf)+1);
} else {
v = FindVar(DBufValue(&buf), 0);
DBufValue(&buf)[VAR_NAME_LEN] = 0;
if (!v) fprintf(ErrFp, "%s %s\n",
if (!v) {
if (DBufLen(&buf) > VAR_NAME_LEN) {
/* Truncate over-long variable name */
DBufValue(&buf)[VAR_NAME_LEN] = 0;
}
fprintf(ErrFp, "%s %s\n",
DBufValue(&buf), UNDEF);
}
else {
fprintf(ErrFp, "%s ", v->name);
PrintValue(&(v->v), ErrFp);

View File

@@ -1042,7 +1042,7 @@ set a057 value("a05"+"6")
"a05" + "6" => "a056"
value("a056") => "SDFJHSDF KSJDFH KJSDFH KSJDFH"
set a058 version()
version() => "06.00.00"
version() => "06.00.01"
set a059 wkday(today())
today() => 1991-02-16
wkday(1991-02-16) => "Saturday"
@@ -2605,7 +2605,7 @@ a056 "SDFJHSDF KSJDFH KJSDFH KSJDFH"
a007 "1991-02-16"
a057 "SDFJHSDF KSJDFH KJSDFH KSJDFH"
a008 "11:44"
a058 "06.00.00"
a058 "06.00.01"
a059 "Saturday"
a010 12
a060 6
@@ -5550,8 +5550,8 @@ REM SATISFY ""
REM SATISFY [version() > "01.00.00"]
../tests/test.rem(1064): SATISFY: expression has no reference to trigdate() or $T...
../tests/test.rem(1064): Trig = Saturday, 16 February, 1991
version() => "06.00.00"
"06.00.00" > "01.00.00" => 1
version() => "06.00.01"
"06.00.01" > "01.00.00" => 1
../tests/test.rem(1064): Trig(satisfied) = Saturday, 16 February, 1991
REM SATISFY [max(x, max(x, 1, 2, 3), 4, 5, 6) * 5]
../tests/test.rem(1065): SATISFY: expression has no reference to trigdate() or $T...
@@ -23647,7 +23647,7 @@ SECURITY: Won't read world-writable file or directory!
Error reading include_dir/ww: Can't open file
SECURITY: Won't read world-writable file or directory!
Error reading include_dir/ww: No files matching *.rem
06.00.00
06.00.01
Enabling test mode: This is meant for the acceptance test.
Do not use --test in production.
In test mode, the system time is fixed at 2025-01-06@19:00