2002-xx-xx
- added a spec file for rpm support
+ - bugfixes
2002-03-11
- readline support
{
struct stat s;
- if( ! strchr(mode, 'r') )
- return fopen(path, mode);
-
- if ( (stat(path, &s)) == -1 )
+ if((stat(path, &s)) == -1)
return NULL;
-
- return S_ISREG(s.st_mode) ? fopen(path, mode) : NULL;
+
+ if(strchr(mode, 'r'))
+ return S_ISREG(s.st_mode) ? fopen(path, mode) : NULL;
+ else
+ return S_ISDIR(s.st_mode) ? NULL : fopen(path, mode);
}
{
char *line;
char *name = NULL, *email = NULL;
+ struct stat s;
+
+ if( (fstat(fileno(stdin), &s)) == -1 || S_ISDIR(s.st_mode)) {
+ fprintf(stderr, "stdin is a directory or cannot stat stdin\n");
+ exit(1);
+ }
init_add_email();
Name: @PACKAGE@
Version: @VERSION@
Release: 1
-Source: http://prdownloads.sourceforge.net/abook/abook-%{version}.tar.gz
+Source: http://prdownloads.sourceforge.net/abook/%{name}-%{version}.tar.gz
URL: http://abook.sourceforge.net/
License: GPL
Group: Utilities
make CFLAGS="$RPM_OPT_FLAGS $CFLAGS"
%install
-make install-strip
+make install
%clean
rm -rf "$RPM_BUILD_ROOT"
#include <string.h>
#include <ctype.h>
#include <pwd.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include "abook_curses.h"
#include "filter.h"
if( i_read_file(filename, i_filters[filter].func ) )
statusline_msg("Error occured while opening the file");
- else
- if( tmp == items )
+ else if( tmp == items )
statusline_msg("Hmm.., file seems not to be a valid file");
refresh_screen();
FILE *in;
int ret = 0;
- if( ( in = fopen( filename, "r" ) ) == NULL )
+ if( ( in = abook_fopen( filename, "r" ) ) == NULL )
return 1;
ret = (*func) (in);
if( i<0 )
return -1;
- if( !strcmp(filename, "-") )
- ret = (*i_filters[i].func) (stdin);
- else
+ if( !strcmp(filename, "-") ) {
+ struct stat s;
+ if( (fstat(fileno(stdin), &s)) == -1 || S_ISDIR(s.st_mode))
+ ret = 1;
+ else
+ ret = (*i_filters[i].func) (stdin);
+ } else
ret = i_read_file(filename, i_filters[i].func);
if( tmp == items )
free(line);
}
- if( *buf == '#' ) {
+ if(buf && *buf == '#' ) {
free(buf);
return NULL;
}
ui_readline(char *prompt, char *s, int limit, int use_completion)
{
int y, x;
+ char *ret;
mvwaddstr(bottom, 1, 0, prompt);
- //mvwaddstr(stdscr, LINES - 1, 0, prompt);
- /*
- * FIXME: stdscr shoulnd't be used ???
- */
-// getyx(stdscr, y, x);
getyx(bottom, y, x);
- return abook_readline(bottom, y, x, s, limit, use_completion);
+ ret = abook_readline(bottom, y, x, s, limit, use_completion);
+
+ if(ret && !*ret)
+ my_free(ret);
+
+ if(ret)
+ strtrim(ret);
+
+ return ret;
}
int