Package: wcalc
Severity: normal
Tags: upstream patch
Dear Maintainer,
wcalc currently FTBFS on Hurd. The attached patch should fix this issue.
WBR,
Cyril Roelandt.
-- System Information:
Debian Release: wheezy/sid
APT prefers unreleased
APT policy: (500, 'unreleased'), (500, 'unstable')
Architecture: hurd-i386 (i686-AT386)
Kernel: GNU-Mach 1.3.99/Hurd-0.3
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
--- wcalc-2.4.orig/files.c 2012-06-04 00:18:46.000000000 +0000
+++ wcalc-2.4/files.c 2012-06-04 00:39:06.000000000 +0000
@@ -207,13 +207,23 @@
int storeVar(const char *variable)
{ /*{{{ */
int fd, retval = 0, return_error = 0;
- char filename[PATH_MAX];
+ char *filename = NULL;
+ size_t filename_len;
+ char *home;
if (!varexists(variable)) {
report_error("Variable is not defined.");
return -1;
}
- snprintf(filename, PATH_MAX, "%s/.wcalc_preload", getenv("HOME"));
+
+ home = getenv("HOME");
+ filename_len = strlen(home) + 16;
+ filename = malloc(filename_len);
+ if (filename == NULL) {
+ return_error = errno;
+ goto exit_storeVar;
+ }
+ snprintf(filename, filename_len, "%s/.wcalc_preload", home);
fd = open(filename, O_WRONLY | O_CREAT | O_APPEND,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd >= 0) {
@@ -267,5 +277,7 @@
}
}
exit_storeVar:
+ if (filename)
+ free(filename);
return return_error;
} /*}}} */
--- wcalc-2.4.orig/main.c 2012-06-04 00:18:46.000000000 +0000
+++ wcalc-2.4/main.c 2012-06-04 01:11:05.000000000 +0000
@@ -363,7 +363,9 @@
/* load the preferences */
{
- char filename[PATH_MAX];
+ char *home;
+ char *filename = NULL;
+ size_t filename_len = 0;
int foundflag = 0;
/* quick check the commandline for a --defaults argument */
@@ -375,14 +377,20 @@
}
if (foundflag == 0) {
- snprintf(filename, PATH_MAX, "%s/.wcalcrc", getenv("HOME"));
+ home = getenv("HOME");
+ filename_len = strlen(home) + 16;
+ filename = malloc(filename_len);
+ if (filename == NULL)
+ exit(EXIT_FAILURE);
+ snprintf(filename, filename_len, "%s/.wcalcrc", home);
if (read_prefs(filename)) {
perror("Writing Preferences");
}
- snprintf(filename, PATH_MAX, "%s/.wcalc_preload", getenv("HOME"));
+ snprintf(filename, filename_len, "%s/.wcalc_preload", home);
if (read_preload(filename)) {
perror("Reading Preload File");
}
+ free(filename);
}
}
@@ -541,16 +549,23 @@
if (!cmdline_input) {
#ifdef HAVE_READLINE_HISTORY
- char filename[PATH_MAX];
+ char *home;
+ char *filename;
+ size_t filename_len;
using_history();
- snprintf(filename, PATH_MAX, "%s/.wcalc_history",
- getenv("HOME"));
+ home = getenv("HOME");
+ filename_len = strlen(home) + 16;
+ filename = malloc(filename_len);
+ if (filename == NULL)
+ exit(EXIT_FAILURE);
+ snprintf(filename, filename_len, "%s/.wcalc_history", home);
if (read_history(filename)) {
if (errno != ENOENT) {
perror("Reading History");
}
}
+ free(filename);
#endif
cmdline_input = 1;
}
@@ -580,16 +595,23 @@
char * envinput = getenv("wcalc_input");
if (envinput) {
#ifdef HAVE_READLINE_HISTORY
- char filename[PATH_MAX];
+ char *home;
+ char *filename;
+ size_t filename_len;
using_history();
- snprintf(filename, PATH_MAX, "%s/.wcalc_history",
- getenv("HOME"));
+ home = getenv("HOME");
+ filename_len = strlen(home) + 16;
+ filename = malloc(filename_len);
+ if (filename == NULL)
+ exit(EXIT_FAILURE);
+ snprintf(filename, filename_len, "%s/.wcalc_history", home);
if (read_history(filename)) {
if (errno != ENOENT) {
perror("Reading History");
}
}
+ free(filename);
#endif
cmdline_input = 1;
if (conf.verbose) {
@@ -615,15 +637,23 @@
if (cmdline_input) {
#ifdef HAVE_READLINE_HISTORY
- char filename[PATH_MAX];
-
- snprintf(filename, PATH_MAX, "%s/.wcalc_history", getenv("HOME"));
+ char *home;
+ char *filename;
+ size_t filename_len;
+
+ home = getenv("HOME");
+ filename_len = strlen(home) + 16;
+ filename = malloc(filename_len);
+ if (filename == NULL)
+ exit(EXIT_FAILURE);
+ snprintf(filename, filename_len, "%s/.wcalc_history", home);
if (write_history(filename))
perror("Saving History");
if (conf.history_limit) {
if (history_truncate_file(filename, conf.history_limit_len))
perror("Truncating History");
}
+ free(filename);
#endif
clearHistory();
cleanupvar();
@@ -636,15 +666,23 @@
if (tty > 0) {
/* if stdin is a keyboard or terminal, then use readline and prompts */
#ifdef HAVE_READLINE_HISTORY
- char filename[PATH_MAX];
-
- snprintf(filename, PATH_MAX, "%s/.wcalc_history", getenv("HOME"));
+ char *home;
+ char *filename;
+ size_t filename_len;
+
+ home = getenv("HOME");
+ filename_len = strlen(home) + 16;
+ filename = malloc(filename_len);
+ if (filename == NULL)
+ exit(EXIT_FAILURE);
+ snprintf(filename, filename_len, "%s/.wcalc_history", getenv("HOME"));
using_history();
if (read_history(filename)) {
if (errno != ENOENT) {
perror("Reading History");
}
}
+ free(filename);
#endif
#ifdef HAVE_LIBREADLINE
rl_attempted_completion_function = wcalc_completion;