Subscribe to list
Matthias Andree
matthias.andree at gmx.de
Mon Sep 22 11:12:49 CEST 2003
Evgeny Kotsuba <evgen at shatura.laser.ru> writes:
> May be it is worth to change it as
> /src/wordlists.c
> @@ -218,7 +231,7 @@ void open_wordlists(dbmode_t mode)
> default:
> if (query) /* If "-Q", failure is OK */
> return;
> - fprintf(stderr, "Can't open %s (%s), errno %d, %s\n",
> + fprintf(stderr, "Can't open %s db directory
> (%s), errno %d, %s\n",
> list->filename, list->filepath, err, strerror(err));
Fine.
> 3) Very incomprehensible filenames, paths etc for non-unix users, say lake
> I:\home\default/.bogofilter
Well, when using the proper emulation layer, the mapping of _used_ file
names should just work.
> May be changed with patch like
>
> diff -u -E -b -B -p M:\Evgen\Inet\Bogofilter\bogofilter\src\paths.c
> G:\EVGEN\INET\SpamKill\BFilter\src\paths.c
> --- M:\Evgen\Inet\Bogofilter\bogofilter\src\paths.c 2003-08-10
> 01:11:38.000000000 +0400
> +++ G:\EVGEN\INET\SpamKill\BFilter\src\paths.c 2003-09-20
> 17:13:08.000000000 +0400
> @@ -17,7 +17,20 @@ NAME:
> #include "xmalloc.h"
> #include "xstrdup.h"
> -#define BOGODIR ".bogofilter"
> +#ifdef __OS2__
> + #define BOGODIR "bogofilter"
> + #define SLASH '\\'
> + #define SLASH_STR "\\"
> +#else
> + #define BOGODIR ".bogofilter"
> + #define SLASH '/'
> + #define SLASH_STR "/"
> +#endif
> +
These BOGODIR/SLASH #defines belong into system.h.
> char *build_progtype(const char *name, const char *db_type)
> {
> @@ -41,7 +54,7 @@ char *build_progtype(const char *name, c
> int build_path(char* dest, size_t size, const char* dir, const char* file)
> {
> /* If absolute path ... */
> - if (*file == '/') {
> + if (*file == SLASH) {
> if (strlcpy(dest, file, size) >= size)
> return -1;
> else
> @@ -50,7 +63,7 @@ int build_path(char* dest, size_t size,
> if (strlcpy(dest, dir, size) >= size) return -1;
> - if ('/' != dest[strlen(dest)-1]) {
> + if (SLASH != dest[strlen(dest)-1]) {
> if (strlcat(dest, "/", size) >= size) return -1; /* RATS: ignore */
> }
> @@ -78,8 +91,8 @@ char *create_path_from_env(const char *v
> buff = xmalloc(path_size);
> strcpy(buff, env);
> - if ('/' != buff[env_size-1]) {
> - strcat(buff, "/");
> + if (SLASH != buff[env_size-1]) {
> + strcat(buff, SLASH_STR);
> }
> if (subdir != NULL) {
> strcat(buff, subdir);
These are OK.
> @@ -102,7 +115,11 @@ int check_directory(const char* path) /*
> rc = stat(path, &sb);
> if (rc < 0) {
> if (ENOENT==errno) {
> +#if defined(__IBMC__) || defined(__IBMCPP__)
> + if(mkdir(path)) {
> +#else
> if(mkdir(path, S_IRUSR|S_IWUSR|S_IXUSR)) {
> +#endif
> fprintf(stderr, "Error creating directory \"%s\": %s\n",
> path, strerror(errno));
> return -1;
Such #ifdef's don't belong in .c files, except a system.c file that
collects these changes.
We should not add #ifdef...#endif _all_ _over_ the code.
The best example why #ifdef should be avoided at all costs is the
ever-broken mini_sendmail by Jef Poskanzer (sorry, Jef, it's really
useful _IF_ it works). It has so many nested #ifdefs that the code is
hardly readable, and in addition to that, it's mostly untested.
The workaround is easy: replace all mkdir by bf_mkdir, and push the
#ifdef into bf_mkdir in a system.c file -- that way, the special
treatment is in one single file.
--
Matthias Andree
Encrypt your mail: my GnuPG key ID is 0x052E7D95
More information about the bogofilter-dev
mailing list