Index: sword-1.5.9/include/swmodule.h =================================================================== --- sword-1.5.9.orig/include/swmodule.h 2006-08-28 01:39:56.000000000 +0100 +++ sword-1.5.9/include/swmodule.h 2006-11-24 17:13:59.000000000 +0000 @@ -399,16 +399,16 @@ * @param path path where to create the new module * @return error */ - static signed char createModule(const char *path) { return -1; } + static signed char createModule(const char *) { return -1; } /** Modify the current module entry text - only if module isWritable() */ - virtual void setEntry(const char *inbuf, long len = -1) { } + virtual void setEntry(const char *, long = -1) { } /** Link the current module entry to another module entry - only if * module isWritable() */ - virtual void linkEntry(const SWKey *sourceKey) { } + virtual void linkEntry(const SWKey *) { } /** Delete current module entry - only if module isWritable() */ Index: sword-1.5.9/include/swbuf.h =================================================================== --- sword-1.5.9.orig/include/swbuf.h 2006-08-28 09:14:40.000000000 +0100 +++ sword-1.5.9/include/swbuf.h 2006-11-24 17:13:59.000000000 +0000 @@ -338,7 +338,7 @@ inline bool operator >=(const SWBuf &other) const { return compare(other) >= 0; } inline bool startsWith(const char *prefix) const { return !strncmp(c_str(), prefix, strlen(prefix)); } - inline bool endsWith(const char *postfix) const { int psize = strlen(postfix); return (size() >= psize)?!strncmp(end-psize, postfix, psize):false; } + inline bool endsWith(const char *postfix) const { unsigned long psize = strlen(postfix); return (size() >= psize)?!strncmp(end-psize, postfix, psize):false; } inline int compare(const char *other) const { return strcmp(c_str(), other); } inline bool operator ==(const char *other) const { return !compare(other); } inline bool operator !=(const char *other) const { return compare(other); } Index: sword-1.5.9/src/keys/listkey.cpp =================================================================== --- sword-1.5.9.orig/src/keys/listkey.cpp 2006-11-24 17:20:25.000000000 +0000 +++ sword-1.5.9/src/keys/listkey.cpp 2006-11-24 17:20:48.000000000 +0000 @@ -293,7 +293,6 @@ void ListKey::setText(const char *ikey) { // at least try to set the current element to this text - int pos = arraypos; for (arraypos = 0; arraypos < arraycnt; arraypos++) { SWKey *key = array[arraypos]; if (key) { Index: sword-1.5.9/src/keys/treekeyidx.cpp =================================================================== --- sword-1.5.9.orig/src/keys/treekeyidx.cpp 2006-11-24 17:21:17.000000000 +0000 +++ sword-1.5.9/src/keys/treekeyidx.cpp 2006-11-24 20:50:55.000000000 +0000 @@ -159,11 +159,11 @@ bool TreeKeyIdx::previousSibling() { TreeNode iterator; - __u32 target = currentNode.offset; + __s32 target = currentNode.offset; if (currentNode.parent > -1) { getTreeNodeFromIdxOffset(currentNode.parent, &iterator); getTreeNodeFromIdxOffset(iterator.firstChild, &iterator); - if (iterator.offset != target) { + if (iterator.offset != currentNode.offset) { while ((iterator.next != target) && (iterator.next > -1)) getTreeNodeFromIdxOffset(iterator.next, &iterator); if (iterator.next > -1) { Index: sword-1.5.9/src/keys/versekey.cpp =================================================================== --- sword-1.5.9.orig/src/keys/versekey.cpp 2006-11-24 20:51:27.000000000 +0000 +++ sword-1.5.9/src/keys/versekey.cpp 2006-11-24 20:55:34.000000000 +0000 @@ -329,7 +329,7 @@ int VerseKey::getBookAbbrev(const char *iabbr) { - int loop, diff, abLen, min, max, target, retVal = -1; + int diff, abLen, min, max, target, retVal = -1; char *abbr = 0; @@ -417,7 +417,7 @@ SWKey tmpDefaultKey = defaultKey; char lastPartial = 0; bool inTerm = true; - int notAllDigits; + int notAllDigits = 0; curkey.AutoNormalize(0); tmpListKey << tmpDefaultKey; @@ -1530,7 +1530,7 @@ const char *VerseKey::getOSISRef() const { static char buf[5][254]; - static char loop = 0; + static int loop = 0; if (loop > 4) loop = 0; @@ -1541,7 +1541,7 @@ sprintf(buf[loop], "%s.%d", osisbooks[Testament()-1][Book()-1], (int)Chapter()); else if (Book()) sprintf(buf[loop], "%s", osisbooks[Testament()-1][Book()-1]); - else sprintf(buf[loop], ""); + else buf[loop][0] = 0; return buf[loop++]; } Index: sword-1.5.9/src/utilfuns/ftpparse.c =================================================================== --- sword-1.5.9.orig/src/utilfuns/ftpparse.c 2006-11-24 22:50:00.000000000 +0000 +++ sword-1.5.9/src/utilfuns/ftpparse.c 2006-11-24 22:51:53.000000000 +0000 @@ -109,6 +109,7 @@ if (now - t < 350 * 86400) return t; } + return 0; } static int check(char *buf,char *monthname) @@ -145,10 +146,10 @@ int i; int j; int state; - long size; + long size = 0; long year; - long month; - long mday; + long month = 0; + long mday = 0; long hour; long minute; Index: sword-1.5.9/src/utilfuns/swbuf.cpp =================================================================== --- sword-1.5.9.orig/src/utilfuns/swbuf.cpp 2006-11-24 20:55:56.000000000 +0000 +++ sword-1.5.9/src/utilfuns/swbuf.cpp 2006-11-24 22:49:42.000000000 +0000 @@ -108,7 +108,7 @@ */ void SWBuf::setSize(unsigned long len) { assureSize(len+1); - if ((end - buf) < len) + if ((end - buf) < (signed)len) memset(end, fillByte, len - (end-buf)); end = buf + len; *end = 0; Index: sword-1.5.9/src/utilfuns/url.cpp =================================================================== --- sword-1.5.9.orig/src/utilfuns/url.cpp 2006-11-24 22:52:02.000000000 +0000 +++ sword-1.5.9/src/utilfuns/url.cpp 2006-11-24 22:52:13.000000000 +0000 @@ -93,7 +93,6 @@ //1. Init const char* urlPtr = url.c_str(); - int pos = 0; protocol = ""; hostname = ""; Index: sword-1.5.9/src/utilfuns/zlib/untgz.c =================================================================== --- sword-1.5.9.orig/src/utilfuns/zlib/untgz.c 2006-11-24 22:52:48.000000000 +0000 +++ sword-1.5.9/src/utilfuns/zlib/untgz.c 2006-11-25 13:08:49.000000000 +0000 @@ -1,8 +1,9 @@ /* - * untgz.c -- Display contents and/or extract file from - * a gzip'd TAR file - * written by "Pedro A. Aranda Guti\irrez" + * untgz.c -- Display contents and extract files from a gzip'd TAR file + * + * written by Pedro A. Aranda Gutierrez * adaptation to Unix by Jean-loup Gailly + * various fixes by Cosmin Truta */ #include @@ -10,205 +11,318 @@ #include #include #include -#include + +#include "zlib.h" + #ifdef unix -# include +# include +# include #else -# include -# include +# include +# include #endif -#include "zlib.h" - #ifdef WIN32 -# include +#include # ifndef F_OK -# define F_OK (0) +# define F_OK 0 # endif +# define mkdir(dirname,mode) _mkdir(dirname) # ifdef _MSC_VER -# define mkdir(dirname,mode) _mkdir(dirname) -# define strdup(str) _strdup(str) -# define unlink(fn) _unlink(fn) # define access(path,mode) _access(path,mode) -# else -# define mkdir(dirname,mode) _mkdir(dirname) +# define chmod(path,mode) _chmod(path,mode) +# define strdup(str) _strdup(str) # endif #else # include #endif -/* Values used in typeflag field. */ +/* values used in typeflag field */ + +#define REGTYPE '0' /* regular file */ +#define AREGTYPE '\0' /* regular file */ +#define LNKTYPE '1' /* link */ +#define SYMTYPE '2' /* reserved */ +#define CHRTYPE '3' /* character special */ +#define BLKTYPE '4' /* block special */ +#define DIRTYPE '5' /* directory */ +#define FIFOTYPE '6' /* FIFO special */ +#define CONTTYPE '7' /* reserved */ + +/* GNU tar extensions */ + +#define GNUTYPE_DUMPDIR 'D' /* file names from dumped directory */ +#define GNUTYPE_LONGLINK 'K' /* long link name */ +#define GNUTYPE_LONGNAME 'L' /* long file name */ +#define GNUTYPE_MULTIVOL 'M' /* continuation of file from another volume */ +#define GNUTYPE_NAMES 'N' /* file name that does not fit into main hdr */ +#define GNUTYPE_SPARSE 'S' /* sparse file */ +#define GNUTYPE_VOLHDR 'V' /* tape/volume header */ -#define REGTYPE '0' /* regular file */ -#define AREGTYPE '\0' /* regular file */ -#define LNKTYPE '1' /* link */ -#define SYMTYPE '2' /* reserved */ -#define CHRTYPE '3' /* character special */ -#define BLKTYPE '4' /* block special */ -#define DIRTYPE '5' /* directory */ -#define FIFOTYPE '6' /* FIFO special */ -#define CONTTYPE '7' /* reserved */ -#define BLOCKSIZE 512 +/* tar header */ + +#define BLOCKSIZE 512 +#define SHORTNAMESIZE 100 struct tar_header -{ /* byte offset */ - char name[100]; /* 0 */ - char mode[8]; /* 100 */ - char uid[8]; /* 108 */ - char gid[8]; /* 116 */ - char size[12]; /* 124 */ - char mtime[12]; /* 136 */ - char chksum[8]; /* 148 */ - char typeflag; /* 156 */ - char linkname[100]; /* 157 */ - char magic[6]; /* 257 */ - char version[2]; /* 263 */ - char uname[32]; /* 265 */ - char gname[32]; /* 297 */ - char devmajor[8]; /* 329 */ - char devminor[8]; /* 337 */ - char prefix[155]; /* 345 */ - /* 500 */ +{ /* byte offset */ + char name[100]; /* 0 */ + char mode[8]; /* 100 */ + char uid[8]; /* 108 */ + char gid[8]; /* 116 */ + char size[12]; /* 124 */ + char mtime[12]; /* 136 */ + char chksum[8]; /* 148 */ + char typeflag; /* 156 */ + char linkname[100]; /* 157 */ + char magic[6]; /* 257 */ + char version[2]; /* 263 */ + char uname[32]; /* 265 */ + char gname[32]; /* 297 */ + char devmajor[8]; /* 329 */ + char devminor[8]; /* 337 */ + char prefix[155]; /* 345 */ + /* 500 */ }; -union tar_buffer { +union tar_buffer +{ char buffer[BLOCKSIZE]; struct tar_header header; }; -enum { TGZ_EXTRACT = 0, TGZ_LIST }; +struct attr_item +{ + struct attr_item *next; + char *fname; + int mode; + time_t time; +}; -static char *TGZfname OF((const char *)); -void TGZnotfound OF((const char *)); +enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID }; -int getoct OF((char *, int)); -char *strtime OF((time_t *)); -int ExprMatch OF((char *,char *)); +char *TGZfname OF((const char *)); +void TGZnotfound OF((const char *)); -int makedir OF((char *)); -int matchname OF((int,int,char **,char *)); +int getoct OF((char *, int)); +char *strtime OF((time_t *)); +int setfiletime OF((char *, time_t)); +void push_attr OF((struct attr_item **, char *, int, time_t)); +void restore_attr OF((struct attr_item **)); -void error OF((const char *)); -int tar OF((gzFile, int, int, int, char **)); +int ExprMatch OF((char *, char *)); -void help OF((int)); -int main OF((int, char **)); +int makedir OF((char *)); +int matchname OF((int, int, char **, char *)); -char *prog; +void error OF((const char *)); +int tar OF((gzFile, int, const char *, int, int, char **)); -/* This will give a benign warning */ +void help OF((int)); +int main OF((int, char **)); + +char *prog; -static char *TGZprefix[] = { "\0", ".tgz", ".tar.gz", ".tar", NULL }; +const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL }; -/* Return the real name of the TGZ archive */ -/* or NULL if it does not exist. */ +/* return the file name of the TGZ archive */ +/* or NULL if it does not exist */ -static char *TGZfname OF((const char *fname)) +char *TGZfname (const char *arcname) { static char buffer[1024]; int origlen,i; - - strcpy(buffer,fname); + + strcpy(buffer,arcname); origlen = strlen(buffer); - for (i=0; TGZprefix[i]; i++) + for (i=0; TGZsuffix[i]; i++) { - strcpy(buffer+origlen,TGZprefix[i]); + strcpy(buffer+origlen,TGZsuffix[i]); if (access(buffer,F_OK) == 0) return buffer; } return NULL; } + /* error message for the filename */ -void TGZnotfound OF((const char *fname)) +void TGZnotfound (const char *arcname) { int i; - fprintf(stderr,"%s : couldn't find ",prog); - for (i=0;TGZprefix[i];i++) - fprintf(stderr,(TGZprefix[i+1]) ? "%s%s, " : "or %s%s\n", - fname, - TGZprefix[i]); + fprintf(stderr,"%s: Couldn't find ",prog); + for (i=0;TGZsuffix[i];i++) + fprintf(stderr,(TGZsuffix[i+1]) ? "%s%s, " : "or %s%s\n", + arcname, + TGZsuffix[i]); exit(1); } -/* help functions */ +/* convert octal digits to int */ +/* on error return -1 */ -int getoct(char *p,int width) +int getoct (char *p,int width) { int result = 0; char c; - - while (width --) + + while (width--) { c = *p++; - if (c == ' ') - continue; if (c == 0) - break; + break; + if (c == ' ') + continue; + if (c < '0' || c > '7') + return -1; result = result * 8 + (c - '0'); } return result; } + +/* convert time_t to string */ +/* use the "YYYY/MM/DD hh:mm:ss" format */ + char *strtime (time_t *t) { struct tm *local; static char result[32]; local = localtime(t); - sprintf(result,"%2d/%02d/%4d %02d:%02d:%02d", - local->tm_mday, local->tm_mon+1, local->tm_year+1900, - local->tm_hour, local->tm_min, local->tm_sec); + sprintf(result,"%4d/%02d/%02d %02d:%02d:%02d", + local->tm_year+1900, local->tm_mon+1, local->tm_mday, + local->tm_hour, local->tm_min, local->tm_sec); + return result; +} + + +/* set file time */ + +int setfiletime (char *fname,time_t ftime) +{ +#ifdef WIN32 + static int isWinNT = -1; + SYSTEMTIME st; + FILETIME locft, modft; + struct tm *loctm; + HANDLE hFile; + int result; + + loctm = localtime(&ftime); + if (loctm == NULL) + return -1; + + st.wYear = (WORD)loctm->tm_year + 1900; + st.wMonth = (WORD)loctm->tm_mon + 1; + st.wDayOfWeek = (WORD)loctm->tm_wday; + st.wDay = (WORD)loctm->tm_mday; + st.wHour = (WORD)loctm->tm_hour; + st.wMinute = (WORD)loctm->tm_min; + st.wSecond = (WORD)loctm->tm_sec; + st.wMilliseconds = 0; + if (!SystemTimeToFileTime(&st, &locft) || + !LocalFileTimeToFileTime(&locft, &modft)) + return -1; + + if (isWinNT < 0) + isWinNT = (GetVersion() < 0x80000000) ? 1 : 0; + hFile = CreateFile(fname, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, + (isWinNT ? FILE_FLAG_BACKUP_SEMANTICS : 0), + NULL); + if (hFile == INVALID_HANDLE_VALUE) + return -1; + result = SetFileTime(hFile, NULL, NULL, &modft) ? 0 : -1; + CloseHandle(hFile); return result; +#else + struct utimbuf settime; + + settime.actime = settime.modtime = ftime; + return utime(fname,&settime); +#endif +} + + +/* push file attributes */ + +void push_attr(struct attr_item **list,char *fname,int mode,time_t time) +{ + struct attr_item *item; + + item = (struct attr_item *)malloc(sizeof(struct attr_item)); + if (item == NULL) + error("Out of memory"); + item->fname = strdup(fname); + item->mode = mode; + item->time = time; + item->next = *list; + *list = item; +} + + +/* restore file attributes */ + +void restore_attr(struct attr_item **list) +{ + struct attr_item *item, *prev; + + for (item = *list; item != NULL; ) + { + setfiletime(item->fname,item->time); + chmod(item->fname,item->mode); + prev = item; + item = item->next; + free(prev); + } + *list = NULL; } -/* regular expression matching */ +/* match regular expression */ #define ISSPECIAL(c) (((c) == '*') || ((c) == '/')) -int ExprMatch(char *string,char *expr) +int ExprMatch (char *string,char *expr) { while (1) { if (ISSPECIAL(*expr)) - { - if (*expr == '/') - { - if (*string != '\\' && *string != '/') - return 0; - string ++; expr++; - } - else if (*expr == '*') - { - if (*expr ++ == 0) - return 1; - while (*++string != *expr) - if (*string == 0) - return 0; - } - } + { + if (*expr == '/') + { + if (*string != '\\' && *string != '/') + return 0; + string ++; expr++; + } + else if (*expr == '*') + { + if (*expr ++ == 0) + return 1; + while (*++string != *expr) + if (*string == 0) + return 0; + } + } else - { - if (*string != *expr) - return 0; - if (*expr++ == 0) - return 1; - string++; - } + { + if (*string != *expr) + return 0; + if (*expr++ == 0) + return 1; + string++; + } } } -/* recursive make directory */ -/* abort if you get an ENOENT errno somewhere in the middle */ -/* e.g. ignore error "mkdir on existing directory" */ -/* */ + +/* recursive mkdir */ +/* abort on ENOENT; ignore other errors like "directory already exists" */ /* return 1 if OK */ /* 0 on error */ @@ -217,7 +331,7 @@ char *buffer = strdup(newdir); char *p; int len = strlen(buffer); - + if (len <= 0) { free(buffer); return 0; @@ -225,7 +339,7 @@ if (buffer[len-1] == '/') { buffer[len-1] = '\0'; } - if (mkdir(buffer, 0775) == 0) + if (mkdir(buffer, 0755) == 0) { free(buffer); return 1; @@ -235,202 +349,356 @@ while (1) { char hold; - + while(*p && *p != '\\' && *p != '/') - p++; + p++; hold = *p; *p = 0; - if ((mkdir(buffer, 0775) == -1) && (errno == ENOENT)) - { - fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer); - free(buffer); - return 0; - } + if ((mkdir(buffer, 0755) == -1) && (errno == ENOENT)) + { + fprintf(stderr,"%s: Couldn't create directory %s\n",prog,buffer); + free(buffer); + return 0; + } if (hold == 0) - break; + break; *p++ = hold; } free(buffer); return 1; } + int matchname (int arg,int argc,char **argv,char *fname) { - if (arg == argc) /* no arguments given (untgz tgzarchive) */ + if (arg == argc) /* no arguments given (untgz tgzarchive) */ return 1; while (arg < argc) if (ExprMatch(fname,argv[arg++])) - return 1; + return 1; return 0; /* ignore this for the moment being */ } -/* Tar file list or extract */ +/* tar file list or extract */ -int untar (gzFile in, const char *dest) { - union tar_buffer buffer; - int len; - int err; - int getheader = 1; - int remaining = 0; - FILE *outfile = NULL; - char fname[BLOCKSIZE]; - time_t tartime; - - while (1) { - len = gzread(in, &buffer, BLOCKSIZE); - if (len < 0) - error (gzerror(in, &err)); - /* - * Always expect complete blocks to process - * the tar information. - */ - if (len != BLOCKSIZE) - error("gzread: incomplete block read"); - - /* - * If we have to get a tar header - */ - if (getheader == 1) { - /* - * if we met the end of the tar - * or the end-of-tar block, - * we are done - */ - if ((len == 0) || (buffer.header.name[0]== 0)) break; - - tartime = (time_t)getoct(buffer.header.mtime,12); - strcpy(fname, dest); - if ((fname[strlen(fname)-1] != '/') && (fname[strlen(fname)-1] != '\\')) - strcat(fname, "/"); - strcat(fname, buffer.header.name); - - switch (buffer.header.typeflag) { - case DIRTYPE: - makedir(fname); - break; - case REGTYPE: - case AREGTYPE: - remaining = getoct(buffer.header.size,12); - if (remaining) { - outfile = fopen(fname,"wb"); - if (outfile == NULL) { - // try creating directory - char *p = strrchr(fname, '/'); - if (p != NULL) { - *p = '\0'; - makedir(fname); - *p = '/'; - outfile = fopen(fname,"wb"); - } - } -/* - fprintf(stderr, - "%s %s\n", - (outfile) ? "Extracting" : "Couldn't create", - fname); -*/ - } - else - outfile = NULL; - /* - * could have no contents - */ - getheader = (remaining) ? 0 : 1; - break; - default: - break; - } - } - else { - unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; - - if (outfile != NULL) { - if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) { - fprintf(stderr,"%s : error writing %s skipping...\n",prog,fname); - fclose(outfile); - unlink(fname); - } - } - remaining -= bytes; - if (remaining == 0) { - getheader = 1; - if (outfile != NULL) { -#ifdef WIN32 - HANDLE hFile; - FILETIME ftm,ftLocal; - SYSTEMTIME st; - struct tm localt; - - fclose(outfile); - - localt = *localtime(&tartime); - - hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE, - 0, NULL, OPEN_EXISTING, 0, NULL); - - st.wYear = (WORD)localt.tm_year+1900; - st.wMonth = (WORD)localt.tm_mon; - st.wDayOfWeek = (WORD)localt.tm_wday; - st.wDay = (WORD)localt.tm_mday; - st.wHour = (WORD)localt.tm_hour; - st.wMinute = (WORD)localt.tm_min; - st.wSecond = (WORD)localt.tm_sec; - st.wMilliseconds = 0; - SystemTimeToFileTime(&st,&ftLocal); - LocalFileTimeToFileTime(&ftLocal,&ftm); - SetFileTime(hFile,&ftm,NULL,&ftm); - CloseHandle(hFile); +//int tar (gzFile in,int action,int arg,int argc,char **argv) +int tar (gzFile in,int action,const char *dest,int arg,int argc,char **argv) +{ + union tar_buffer buffer; + int len; + int err; + int getheader = 1; + int remaining = 0; + FILE *outfile = NULL; + char fname[BLOCKSIZE]; + int tarmode = 0; + time_t tartime; + struct attr_item *attributes = NULL; + + if (action == TGZ_LIST) + printf(" date time size file\n" + " ---------- -------- --------- -------------------------------------\n"); + while (1) + { + len = gzread(in, &buffer, BLOCKSIZE); + if (len < 0) + error(gzerror(in, &err)); + /* + * Always expect complete blocks to process + * the tar information. + */ + if (len != BLOCKSIZE) + { + action = TGZ_INVALID; /* force error exit */ + remaining = 0; /* force I/O cleanup */ + } + + /* + * If we have to get a tar header + */ + if (getheader >= 1) + { + /* + * if we met the end of the tar + * or the end-of-tar block, + * we are done + */ + if (len == 0 || buffer.header.name[0] == 0) + break; + + tarmode = getoct(buffer.header.mode,8); + tartime = (time_t)getoct(buffer.header.mtime,12); + + // ADDED for Sword + strncpy(fname, dest, SHORTNAMESIZE); + if ((fname[strlen(fname)-1] != '/') && (fname[strlen(fname)-1] != '\\')) + strcat(fname, "/"); + // END addition + if (tarmode == -1 || tartime == (time_t)-1) + { + buffer.header.name[0] = 0; + action = TGZ_INVALID; + } + // MODIFIED for Sword + strncat(fname, buffer.header.name, BLOCKSIZE - strlen(fname) - 10); +#if 0 + if (getheader == 1) + { + strncpy(fname,buffer.header.name,SHORTNAMESIZE); + if (fname[SHORTNAMESIZE-1] != 0) + fname[SHORTNAMESIZE] = 0; + } + // END modification + else + { + /* + * The file name is longer than SHORTNAMESIZE + */ + if (strncmp(fname,buffer.header.name,SHORTNAMESIZE-1) != 0) + error("bad long name"); + getheader = 1; + } +#endif + /* + * Act according to the type flag + */ + switch (buffer.header.typeflag) + { + case DIRTYPE: + if (action == TGZ_LIST) + printf(" %s %s\n",strtime(&tartime),fname); + if (action == TGZ_EXTRACT) + { + makedir(fname); + push_attr(&attributes,fname,tarmode,tartime); + } + break; + case REGTYPE: + case AREGTYPE: + remaining = getoct(buffer.header.size,12); + if (remaining == -1) + { + action = TGZ_INVALID; + break; + } + if (action == TGZ_LIST) + printf(" %s %9d %s\n",strtime(&tartime),remaining,fname); + else if (action == TGZ_EXTRACT) + { + if (matchname(arg,argc,argv,fname)) + { + outfile = fopen(fname,"wb"); + if (outfile == NULL) { + /* try creating directory */ + char *p = strrchr(fname, '/'); + if (p != NULL) { + *p = '\0'; + makedir(fname); + *p = '/'; + outfile = fopen(fname,"wb"); + } + } + if (outfile != NULL) + printf("Extracting %s\n",fname); + else + fprintf(stderr, "%s: Couldn't create %s",prog,fname); + } + else + outfile = NULL; + } + getheader = 0; + break; + case GNUTYPE_LONGLINK: + case GNUTYPE_LONGNAME: + remaining = getoct(buffer.header.size,12); + if (remaining < 0 || remaining >= BLOCKSIZE) + { + action = TGZ_INVALID; + break; + } + len = gzread(in, fname, BLOCKSIZE); + if (len < 0) + error(gzerror(in, &err)); + if (fname[BLOCKSIZE-1] != 0 || (int)strlen(fname) > remaining) + { + action = TGZ_INVALID; + break; + } + getheader = 2; + break; + default: + if (action == TGZ_LIST) + printf(" %s <---> %s\n",strtime(&tartime),fname); + break; + } + } + else + { + unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; - outfile = NULL; -#else - struct utimbuf settime; + if (outfile != NULL) + { + if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) + { + fprintf(stderr, + "%s: Error writing %s -- skipping\n",prog,fname); + fclose(outfile); + outfile = NULL; + remove(fname); + } + } + remaining -= bytes; + } + + if (remaining == 0) + { + getheader = 1; + if (outfile != NULL) + { + fclose(outfile); + outfile = NULL; + if (action != TGZ_INVALID) + push_attr(&attributes,fname,tarmode,tartime); + } + } + + /* + * Abandon if errors are found + */ + if (action == TGZ_INVALID) + { + error("broken archive"); + break; + } + } - settime.actime = settime.modtime = tartime; + /* + * Restore file modes and time stamps + */ + restore_attr(&attributes); - fclose(outfile); - outfile = NULL; - utime(fname,&settime); -#endif - } - } - } - } - return 0; + if (gzclose(in) != Z_OK) + error("failed gzclose"); + + return 0; } -/* =========================================================== */ +/* ============================================================ */ void help(int exitval) { - fprintf(stderr, - "untgz v 0.1\n" - " an sample application of zlib 1.0.4\n\n" - "Usage : untgz TGZfile to extract all files\n" - " untgz TGZfile fname ... to extract selected files\n" - " untgz -l TGZfile to list archive contents\n" - " untgz -h to display this help\n\n"); + printf("untgz version 0.2.1\n" + " using zlib version %s\n\n", + zlibVersion()); + printf("Usage: untgz file.tgz extract all files\n" + " untgz file.tgz fname ... extract selected files\n" + " untgz -l file.tgz list archive contents\n" + " untgz -h display this help\n"); exit(exitval); } void error(const char *msg) { - fprintf(stderr, "%s: %s\n", prog, msg); - exit(1); + fprintf(stderr, "%s: %s\n", prog, msg); + exit(1); } +/* ============================================================ */ + +#if defined(WIN32) && defined(__GNUC__) +int _CRT_glob = 0; /* disable argument globbing in MinGW */ +#endif + +int untar(gzFile in, const char *dest) +{ + return tar(in, TGZ_EXTRACT, dest, 0, 0 , NULL); +} + int untargz(int fd, const char *dest) { - gzFile *f; + gzFile *f; - f = gzdopen(fd, "rb"); - if (f == NULL) { - fprintf(stderr,"%s: Couldn't gzopen file\n", prog); - return 1; - } + f = gzdopen(fd, "rb"); + if (f == NULL) { + fprintf(stderr,"%s: Couldn't gzopen file\n", prog); + return 1; + } - return untar(f, dest); + return untar(f, dest); } + +#if 0 +int main(int argc,char **argv) +{ + int action = TGZ_EXTRACT; + int arg = 1; + char *TGZfile; + gzFile *f; + + prog = strrchr(argv[0],'\\'); + if (prog == NULL) + { + prog = strrchr(argv[0],'/'); + if (prog == NULL) + { + prog = strrchr(argv[0],':'); + if (prog == NULL) + prog = argv[0]; + else + prog++; + } + else + prog++; + } + else + prog++; + + if (argc == 1) + help(0); + + if (strcmp(argv[arg],"-l") == 0) + { + action = TGZ_LIST; + if (argc == ++arg) + help(0); + } + else if (strcmp(argv[arg],"-h") == 0) + { + help(0); + } + + if ((TGZfile = TGZfname(argv[arg])) == NULL) + TGZnotfound(argv[arg]); + + ++arg; + if ((action == TGZ_LIST) && (arg != argc)) + help(1); + +/* + * Process the TGZ file + */ + switch(action) + { + case TGZ_LIST: + case TGZ_EXTRACT: + f = gzopen(TGZfile,"rb"); + if (f == NULL) + { + fprintf(stderr,"%s: Couldn't gzopen %s\n",prog,TGZfile); + return 1; + } + exit(tar(f, action, arg, argc, argv)); + break; + + default: + error("Unknown option"); + exit(1); + } + + return 0; +} +#endif Index: sword-1.5.9/include/ftptrans.h =================================================================== --- sword-1.5.9.orig/include/ftptrans.h 2006-11-25 11:56:18.000000000 +0000 +++ sword-1.5.9/include/ftptrans.h 2006-11-25 11:59:03.000000000 +0000 @@ -18,7 +18,8 @@ /** Class for reporting status */ class SWDLLEXPORT StatusReporter { -public: +public: + virtual ~StatusReporter() {}; /** Messages before stages of a batch download */ virtual void preStatus(long totalBytes, long completedBytes, const char *message); Index: sword-1.5.9/src/mgr/filemgr.cpp =================================================================== --- sword-1.5.9.orig/src/mgr/filemgr.cpp 2006-11-25 12:01:21.000000000 +0000 +++ sword-1.5.9/src/mgr/filemgr.cpp 2006-11-25 12:08:34.000000000 +0000 @@ -490,7 +490,7 @@ int FileMgr::copyDir(const char *srcDir, const char *destDir) { DIR *dir; struct dirent *ent; - if (dir = opendir(srcDir)) { + if ((dir = opendir(srcDir))) { rewinddir(dir); while ((ent = readdir(dir))) { if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) { Index: sword-1.5.9/src/mgr/ftptrans.cpp =================================================================== --- sword-1.5.9.orig/src/mgr/ftptrans.cpp 2006-11-25 12:08:52.000000000 +0000 +++ sword-1.5.9/src/mgr/ftptrans.cpp 2006-11-25 12:09:27.000000000 +0000 @@ -86,7 +86,7 @@ int FTPTransport::copyDirectory(const char *urlPrefix, const char *dir, const char *dest, const char *suffix) { - int i; + unsigned int i; int retVal = 0; SWBuf url = SWBuf(urlPrefix) + SWBuf(dir); Index: sword-1.5.9/src/mgr/installmgr.cpp =================================================================== --- sword-1.5.9.orig/src/mgr/installmgr.cpp 2006-11-25 12:09:52.000000000 +0000 +++ sword-1.5.9/src/mgr/installmgr.cpp 2006-11-25 12:10:41.000000000 +0000 @@ -145,7 +145,7 @@ FileMgr::removeDir(modDir.c_str()); - if (dir = opendir(manager->configPath)) { // find and remove .conf file + if ((dir = opendir(manager->configPath))) { // find and remove .conf file rewinddir(dir); while ((ent = readdir(dir))) { if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) { @@ -210,7 +210,6 @@ int InstallMgr::ftpCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer, const char *suffix) { int retVal = 0; - long i; FTPTransport *trans = createFTPTransport(is->source, statusReporter); transport = trans; // set classwide current transport for other thread terminate() call trans->setPassive(passive); @@ -364,7 +363,7 @@ } if (!aborted) { SWBuf confDir = sourceDir + "/mods.d/"; - if (dir = opendir(confDir.c_str())) { // find and copy .conf file + if ((dir = opendir(confDir.c_str()))) { // find and copy .conf file rewinddir(dir); while ((ent = readdir(dir))) { if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) { Index: sword-1.5.9/src/modules/comments/swcom.cpp =================================================================== --- sword-1.5.9.orig/src/modules/comments/swcom.cpp 2006-11-25 12:40:13.000000000 +0000 +++ sword-1.5.9/src/modules/comments/swcom.cpp 2006-11-25 12:40:22.000000000 +0000 @@ -75,7 +75,7 @@ VerseKey &SWCom::getVerseKey() const { - VerseKey *key; + VerseKey *key = NULL; // see if we have a VerseKey * or decendant SWTRY { key = SWDYNAMIC_CAST(VerseKey, this->key); Index: sword-1.5.9/src/modules/common/entriesblk.cpp =================================================================== --- sword-1.5.9.orig/src/modules/common/entriesblk.cpp 2006-11-25 12:15:11.000000000 +0000 +++ sword-1.5.9/src/modules/common/entriesblk.cpp 2006-11-25 12:15:32.000000000 +0000 @@ -142,9 +142,7 @@ unsigned long dataSize; getRawData(&dataSize); getMetaEntry(entryIndex, &offset, &size); - unsigned long len = size - 1; int count = getCount(); - unsigned long dataStart = METAHEADERSIZE + (count * METAENTRYSIZE); if (!offset) // already deleted return; Index: sword-1.5.9/src/modules/common/rawstr.cpp =================================================================== --- sword-1.5.9.orig/src/modules/common/rawstr.cpp 2006-11-25 12:11:58.000000000 +0000 +++ sword-1.5.9/src/modules/common/rawstr.cpp 2006-11-25 12:12:36.000000000 +0000 @@ -124,7 +124,6 @@ void RawStr::getIDXBuf(long ioffset, char **buf) { - char *trybuf, *targetbuf; long offset; if (idxfd > 0) { @@ -152,7 +151,7 @@ signed char RawStr::findOffset(const char *ikey, long *start, unsigned short *size, long away, long *idxoff) { - char *trybuf, *targetbuf, *key = 0, quitflag = 0; + char *trybuf, *key = 0, quitflag = 0; signed char retval = -1; long headoff, tailoff, tryoff = 0, maxoff = 0; Index: sword-1.5.9/src/modules/common/rawstr4.cpp =================================================================== --- sword-1.5.9.orig/src/modules/common/rawstr4.cpp 2006-11-25 12:12:41.000000000 +0000 +++ sword-1.5.9/src/modules/common/rawstr4.cpp 2006-11-25 12:13:43.000000000 +0000 @@ -123,7 +123,6 @@ void RawStr4::getIDXBuf(long ioffset, char **buf) { - char *trybuf, *targetbuf; long offset; if (idxfd > 0) { @@ -160,7 +159,7 @@ signed char RawStr4::findOffset(const char *ikey, long *start, unsigned long *size, long away, long *idxoff) { - char *trybuf, *targetbuf, *key = 0, quitflag = 0; + char *trybuf, *key = 0, quitflag = 0; signed char retval = -1; long headoff, tailoff, tryoff = 0, maxoff = 0; @@ -372,7 +371,7 @@ while (true); // while we're resolving links if (idxbuflocal) { - int localsize = strlen(idxbuflocal); + unsigned int localsize = strlen(idxbuflocal); localsize = (localsize < (*isize - 1)) ? localsize : (*isize - 1); strncpy(*idxbuf, idxbuflocal, localsize); (*idxbuf)[localsize] = 0; Index: sword-1.5.9/src/modules/common/zstr.cpp =================================================================== --- sword-1.5.9.orig/src/modules/common/zstr.cpp 2006-11-25 12:14:25.000000000 +0000 +++ sword-1.5.9/src/modules/common/zstr.cpp 2006-11-25 12:14:57.000000000 +0000 @@ -619,7 +619,7 @@ rawZFilter(buf, 1); // 1 = encipher long zdxSize = zdxfd->seek(0, SEEK_END); - long zdtSize = zdtfd->seek(0, SEEK_END); + unsigned long zdtSize = zdtfd->seek(0, SEEK_END); if ((cacheBlockIndex * ZDXENTRYSIZE) > (zdxSize - ZDXENTRYSIZE)) { // New Block start = zdtSize; Index: sword-1.5.9/src/modules/common/zverse.cpp =================================================================== --- sword-1.5.9.orig/src/modules/common/zverse.cpp 2006-11-25 12:13:58.000000000 +0000 +++ sword-1.5.9/src/modules/common/zverse.cpp 2006-11-25 12:14:08.000000000 +0000 @@ -140,7 +140,6 @@ unsigned long ulCompOffset=0; // compressed buffer start unsigned long ulCompSize=0; // buffer size compressed unsigned long ulUnCompSize=0; // buffer size uncompressed - char *pcCompText=NULL; // compressed text *start = *size = 0; //printf ("Finding offset %ld\n", idxoff); Index: sword-1.5.9/src/modules/filters/gbfheadings.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/gbfheadings.cpp 2006-11-25 12:29:24.000000000 +0000 +++ sword-1.5.9/src/modules/filters/gbfheadings.cpp 2006-11-25 12:29:37.000000000 +0000 @@ -31,7 +31,6 @@ char token[2048]; // cheese. Fix. int tokpos = 0; bool intoken = false; - int len; bool hide = false; const char *from; Index: sword-1.5.9/src/modules/filters/gbfhtmlhref.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/gbfhtmlhref.cpp 2006-11-25 12:27:35.000000000 +0000 +++ sword-1.5.9/src/modules/filters/gbfhtmlhref.cpp 2006-11-25 12:28:00.000000000 +0000 @@ -72,9 +72,6 @@ bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { const char *tok; - char val[128]; - char *valto; - const char *num; MyUserData *u = (MyUserData *)userData; if (!substituteToken(buf, token)) { @@ -227,7 +224,7 @@ else if (!strcmp(tag.getName(), "RF")) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); - VerseKey *vkey; + VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { vkey = SWDYNAMIC_CAST(VerseKey, u->key); Index: sword-1.5.9/src/modules/filters/gbfmorph.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/gbfmorph.cpp 2006-11-25 12:30:20.000000000 +0000 +++ sword-1.5.9/src/modules/filters/gbfmorph.cpp 2006-11-25 12:30:31.000000000 +0000 @@ -31,7 +31,6 @@ char token[2048]; // cheese. Fix. int tokpos = 0; bool intoken = false; - int len; bool lastspace = false; SWBuf orig = text; Index: sword-1.5.9/src/modules/filters/gbfosis.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/gbfosis.cpp 2006-11-25 12:35:45.000000000 +0000 +++ sword-1.5.9/src/modules/filters/gbfosis.cpp 2006-11-25 12:36:22.000000000 +0000 @@ -36,8 +36,6 @@ SWBuf tmp; SWBuf value; - bool newtext = false; - bool suspendTextPassThru = false; bool handled = false; bool newWord = false; @@ -45,15 +43,13 @@ bool lastspace = false; const char *wordStart = text.c_str(); - const char *wordEnd; + const char *wordEnd = NULL; - const char *textStart; - const char *textEnd; + const char *textStart = NULL; + const char *textEnd = NULL; SWBuf textNode = ""; - char wordstr[5]; - SWBuf buf; text = ""; Index: sword-1.5.9/src/modules/filters/gbfredletterwords.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/gbfredletterwords.cpp 2006-11-25 12:29:53.000000000 +0000 +++ sword-1.5.9/src/modules/filters/gbfredletterwords.cpp 2006-11-25 12:30:08.000000000 +0000 @@ -35,7 +35,6 @@ char token[4096]; // cheese. Fix. int tokpos = 0; bool intoken = false; - int len; bool hide = false; const char *from; Index: sword-1.5.9/src/modules/filters/gbfrtf.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/gbfrtf.cpp 2006-11-25 12:28:19.000000000 +0000 +++ sword-1.5.9/src/modules/filters/gbfrtf.cpp 2006-11-25 12:28:34.000000000 +0000 @@ -23,14 +23,12 @@ char *num; int tokpos = 0; bool intoken = false; - int len; const char *tok; SWBuf strongnum; SWBuf strongtense; bool hideText = false; int wordLen = 0; int wordCount = 0; - int i; const char *from; SWBuf orig = text; Index: sword-1.5.9/src/modules/filters/gbfstrongs.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/gbfstrongs.cpp 2006-11-25 12:28:46.000000000 +0000 +++ sword-1.5.9/src/modules/filters/gbfstrongs.cpp 2006-11-25 12:29:05.000000000 +0000 @@ -32,13 +32,11 @@ char token[2048]; // cheese. Fix. int tokpos = 0; bool intoken = false; - int len; bool lastspace = false; int word = 1; char val[128]; char wordstr[5]; char *valto; - char *ch; unsigned int textStart = 0, textEnd = 0; bool newText = false; SWBuf tmp; Index: sword-1.5.9/src/modules/filters/gbfthml.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/gbfthml.cpp 2006-11-25 12:35:23.000000000 +0000 +++ sword-1.5.9/src/modules/filters/gbfthml.cpp 2006-11-25 12:35:32.000000000 +0000 @@ -30,7 +30,6 @@ char token[2048]; int tokpos = 0; bool intoken = false; - int len; const char *tok; SWBuf orig = text; Index: sword-1.5.9/src/modules/filters/gbfwordjs.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/gbfwordjs.cpp 2006-11-25 12:30:42.000000000 +0000 +++ sword-1.5.9/src/modules/filters/gbfwordjs.cpp 2006-11-25 12:31:25.000000000 +0000 @@ -44,11 +44,8 @@ bool lastspace = false; int word = 1; char val[128]; - char *valto; - char *ch; char wordstr[5]; unsigned int textStart = 0, lastAppendLen = 0, textEnd = 0; - char gh = 0; SWBuf tmp; bool newText = false; bool needWordOut = false; @@ -166,7 +163,7 @@ else { wordID = key->getText(); } - for (int i = 0; i < wordID.size(); i++) { + for (unsigned int i = 0; i < wordID.size(); i++) { if ((!isdigit(wordID[i])) && (!isalpha(wordID[i]))) { wordID[i] = '_'; } @@ -258,7 +255,7 @@ else { wordID = key->getText(); } - for (int i = 0; i < wordID.size(); i++) { + for (unsigned int i = 0; i < wordID.size(); i++) { if ((!isdigit(wordID[i])) && (!isalpha(wordID[i]))) { wordID[i] = '_'; } Index: sword-1.5.9/src/modules/filters/greeklexattribs.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/greeklexattribs.cpp 2006-11-25 12:37:37.000000000 +0000 +++ sword-1.5.9/src/modules/filters/greeklexattribs.cpp 2006-11-25 12:37:50.000000000 +0000 @@ -29,7 +29,7 @@ string freq; char val[128], *valto; char wordstr[7]; - const char *currentPhrase = 0, *ch = 0; + const char *currentPhrase = 0; const char *currentPhraseEnd = 0; int number = 0; Index: sword-1.5.9/src/modules/filters/latin1utf16.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/latin1utf16.cpp 2006-11-25 12:15:59.000000000 +0000 +++ sword-1.5.9/src/modules/filters/latin1utf16.cpp 2006-11-25 12:16:06.000000000 +0000 @@ -18,7 +18,6 @@ char Latin1UTF16::processText(SWBuf &text, const SWKey *key, const SWModule *module) { const unsigned char *from; - int len; if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering return (char)-1; Index: sword-1.5.9/src/modules/filters/osishtmlhref.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/osishtmlhref.cpp 2006-11-25 12:17:56.000000000 +0000 +++ sword-1.5.9/src/modules/filters/osishtmlhref.cpp 2006-11-25 12:19:37.000000000 +0000 @@ -114,19 +114,19 @@ const char *attrib; const char *val; - if (attrib = tag.getAttribute("xlit")) { + if ((attrib = tag.getAttribute("xlit"))) { val = strchr(attrib, ':'); val = (val) ? (val + 1) : attrib; outText(" ", buf, u); outText(val, buf, u); } - if (attrib = tag.getAttribute("gloss")) { + if ((attrib = tag.getAttribute("gloss"))) { val = strchr(attrib, ':'); val = (val) ? (val + 1) : attrib; outText(" ", buf, u); outText(val, buf, u); } - if (attrib = tag.getAttribute("lemma")) { + if ((attrib = tag.getAttribute("lemma"))) { int count = tag.getAttributePartCount("lemma", ' '); int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 do { @@ -155,7 +155,7 @@ } while (++i < count); } - if (attrib = tag.getAttribute("morph")) { // && (show)) { + if ((attrib = tag.getAttribute("morph"))) { // && (show)) { SWBuf savelemma = tag.getAttribute("savlm"); //if ((strstr(savelemma.c_str(), "3588")) && (lastText.length() < 1)) // show = false; @@ -179,7 +179,7 @@ } while (++i < count); //} } - if (attrib = tag.getAttribute("POS")) { + if ((attrib = tag.getAttribute("POS"))) { val = strchr(attrib, ':'); val = (val) ? (val + 1) : attrib; outText(" ", buf, u); @@ -204,7 +204,7 @@ if (!strongsMarkup) { // leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); - VerseKey *vkey; + VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { vkey = SWDYNAMIC_CAST(VerseKey, u->key); @@ -341,7 +341,7 @@ outText(firstChar, buf, u); outText("", buf, u); - for(int i=0;i", buf, u); } Index: sword-1.5.9/src/modules/filters/osisredletterwords.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/osisredletterwords.cpp 2006-11-25 12:24:54.000000000 +0000 +++ sword-1.5.9/src/modules/filters/osisredletterwords.cpp 2006-11-25 12:25:04.000000000 +0000 @@ -33,7 +33,6 @@ SWBuf token; bool intoken = false; - char buf[254]; SWBuf orig = text; const char *from = orig.c_str(); Index: sword-1.5.9/src/modules/filters/osisrtf.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/osisrtf.cpp 2006-11-25 12:23:28.000000000 +0000 +++ sword-1.5.9/src/modules/filters/osisrtf.cpp 2006-11-25 12:24:35.000000000 +0000 @@ -162,19 +162,19 @@ const char *attrib; const char *val; - if (attrib = tag.getAttribute("xlit")) { + if ((attrib = tag.getAttribute("xlit"))) { val = strchr(attrib, ':'); val = (val) ? (val + 1) : attrib; scratch.setFormatted(" {\\fs15 <%s>}", val); outText(scratch.c_str(), buf, u); } - if (attrib = tag.getAttribute("gloss")) { + if ((attrib = tag.getAttribute("gloss"))) { val = strchr(attrib, ':'); val = (val) ? (val + 1) : attrib; scratch.setFormatted(" {\\fs15 <%s>}", val); outText(scratch.c_str(), buf, u); } - if (attrib = tag.getAttribute("lemma")) { + if ((attrib = tag.getAttribute("lemma"))) { int count = tag.getAttributePartCount("lemma", ' '); int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 do { @@ -213,7 +213,7 @@ } while (++i < count); } } - if (attrib = tag.getAttribute("POS")) { + if ((attrib = tag.getAttribute("POS"))) { val = strchr(attrib, ':'); val = (val) ? (val + 1) : attrib; scratch.setFormatted(" {\\fs15 <%s>}", val); @@ -235,7 +235,7 @@ && (type != "strongsMarkup") // deprecated ) { SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); - VerseKey *vkey; + VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { vkey = SWDYNAMIC_CAST(VerseKey, u->key); Index: sword-1.5.9/src/modules/filters/osisscripref.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/osisscripref.cpp 2006-11-25 12:25:18.000000000 +0000 +++ sword-1.5.9/src/modules/filters/osisscripref.cpp 2006-11-25 12:25:25.000000000 +0000 @@ -33,9 +33,6 @@ bool hide = false; SWBuf tagText; XMLTag startTag; - int tagTextNum = 1; - int footnoteNum = 1; - char buf[254]; SWBuf orig = text; const char *from = orig.c_str(); Index: sword-1.5.9/src/modules/filters/osisstrongs.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/osisstrongs.cpp 2006-11-25 12:21:41.000000000 +0000 +++ sword-1.5.9/src/modules/filters/osisstrongs.cpp 2006-11-25 12:22:57.000000000 +0000 @@ -38,8 +38,6 @@ bool lastspace = false; int wordNum = 1; char wordstr[5]; - char *valto; - char *ch; const char *wordStart = 0; const SWBuf orig = text; @@ -72,9 +70,8 @@ SWBuf lemmaClass = ""; const char *attrib; - const char *val; sprintf(wordstr, "%03d", wordNum); - if (attrib = wtag.getAttribute("morph")) { + if ((attrib = wtag.getAttribute("morph"))) { int count = wtag.getAttributePartCount("morph", ' '); int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 do { @@ -106,7 +103,7 @@ } while (++i < count); } - if (attrib = wtag.getAttribute("lemma")) { + if ((attrib = wtag.getAttribute("lemma"))) { int count = wtag.getAttributePartCount("lemma", ' '); int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 do { @@ -147,7 +144,7 @@ module->getEntryAttributes()["Word"][wordstr]["PartCount"].setFormatted("%d", count); } - if (attrib = wtag.getAttribute("src")) { + if ((attrib = wtag.getAttribute("src"))) { int count = wtag.getAttributePartCount("src", ' '); int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 do { Index: sword-1.5.9/src/modules/filters/osisvariants.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/osisvariants.cpp 2006-11-25 12:25:40.000000000 +0000 +++ sword-1.5.9/src/modules/filters/osisvariants.cpp 2006-11-25 12:26:14.000000000 +0000 @@ -62,7 +62,7 @@ const char *from = orig.c_str(); //we use a fixed comparision string to make sure the loop is as fast as the original two blocks with almost the same code - const char* variantCompareString = (option == 0) ? "div type=\"variant\" class=\"1\"" : "div type=\"variant\" class=\"2\""; + //const char* variantCompareString = (option == 0) ? "div type=\"variant\" class=\"1\"" : "div type=\"variant\" class=\"2\""; for (text = ""; *from; from++) { if (*from == '<') { Index: sword-1.5.9/src/modules/filters/osiswebif.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/osiswebif.cpp 2006-11-25 12:20:00.000000000 +0000 +++ sword-1.5.9/src/modules/filters/osiswebif.cpp 2006-11-25 12:21:25.000000000 +0000 @@ -69,17 +69,17 @@ const char *attrib; const char *val; - if (attrib = tag.getAttribute("xlit")) { + if ((attrib = tag.getAttribute("xlit"))) { val = strchr(attrib, ':'); val = (val) ? (val + 1) : attrib; // buf.appendFormatted(" %s", val); } - if (attrib = tag.getAttribute("gloss")) { + if ((attrib = tag.getAttribute("gloss"))) { val = strchr(attrib, ':'); val = (val) ? (val + 1) : attrib; buf.appendFormatted(" %s", val); } - if (attrib = tag.getAttribute("lemma")) { + if ((attrib = tag.getAttribute("lemma"))) { int count = tag.getAttributePartCount("lemma", ' '); int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 do { @@ -114,7 +114,7 @@ } while (++i < count); } } - if (attrib = tag.getAttribute("POS")) { + if ((attrib = tag.getAttribute("POS"))) { val = strchr(attrib, ':'); val = (val) ? (val + 1) : attrib; buf.appendFormatted(" %s", val); @@ -138,7 +138,7 @@ if (!strongsMarkup) { // leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); SWBuf modName = (u->module) ? u->module->Name() : ""; - VerseKey *vkey; + VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { vkey = SWDYNAMIC_CAST(VerseKey, u->key); Index: sword-1.5.9/src/modules/filters/osiswordjs.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/osiswordjs.cpp 2006-11-25 12:26:29.000000000 +0000 +++ sword-1.5.9/src/modules/filters/osiswordjs.cpp 2006-11-25 12:27:19.000000000 +0000 @@ -47,9 +47,6 @@ bool lastspace = false; int wordNum = 1; char wordstr[5]; - char val[128]; - char *valto; - char *ch; SWBuf modName = (module)?module->Name():""; // add TR to w src in KJV then remove this next line SWBuf wordSrcPrefix = (modName == "KJV")?SWBuf("TR"):modName; @@ -143,7 +140,7 @@ } wordID.appendFormatted("_%s", src.c_str()); // clean up our word ID for XHTML - for (int i = 0; i < wordID.size(); i++) { + for (unsigned int i = 0; i < wordID.size(); i++) { if ((!isdigit(wordID[i])) && (!isalpha(wordID[i]))) { wordID[i] = '_'; } Index: sword-1.5.9/src/modules/filters/teiplain.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/teiplain.cpp 2006-11-25 12:38:04.000000000 +0000 +++ sword-1.5.9/src/modules/filters/teiplain.cpp 2006-11-25 12:38:56.000000000 +0000 @@ -42,7 +42,7 @@ bool TEIPlain::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { // manually process if it wasn't a simple substitution if (!substituteToken(buf, token)) { - MyUserData *u = (MyUserData *)userData; + //MyUserData *u = (MyUserData *)userData; XMLTag tag(token); //

paragraph tag Index: sword-1.5.9/src/modules/filters/teirtf.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/teirtf.cpp 2006-11-25 12:38:34.000000000 +0000 +++ sword-1.5.9/src/modules/filters/teirtf.cpp 2006-11-25 12:38:48.000000000 +0000 @@ -54,7 +54,7 @@ bool TEIRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { // manually process if it wasn't a simple substitution if (!substituteToken(buf, token)) { - MyUserData *u = (MyUserData *)userData; + //MyUserData *u = (MyUserData *)userData; XMLTag tag(token); //

paragraph tag Index: sword-1.5.9/src/modules/filters/thmlgbf.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/thmlgbf.cpp 2006-11-25 12:32:12.000000000 +0000 +++ sword-1.5.9/src/modules/filters/thmlgbf.cpp 2006-11-25 12:32:19.000000000 +0000 @@ -31,7 +31,6 @@ char token[2048]; int tokpos = 0; bool intoken = false; - int len; bool ampersand = false; bool sechead = false; bool title = false; Index: sword-1.5.9/src/modules/filters/thmlhtmlhref.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/thmlhtmlhref.cpp 2006-11-25 12:33:24.000000000 +0000 +++ sword-1.5.9/src/modules/filters/thmlhtmlhref.cpp 2006-11-25 12:33:54.000000000 +0000 @@ -45,7 +45,6 @@ bool ThMLHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { - const char *tok; if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; @@ -88,7 +87,7 @@ if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); - VerseKey *vkey; + VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { vkey = SWDYNAMIC_CAST(VerseKey, u->key); @@ -133,7 +132,7 @@ } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); - VerseKey *vkey; + VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { vkey = SWDYNAMIC_CAST(VerseKey, u->key); Index: sword-1.5.9/src/modules/filters/thmlosis.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/thmlosis.cpp 2006-11-25 12:36:53.000000000 +0000 +++ sword-1.5.9/src/modules/filters/thmlosis.cpp 2006-11-25 12:37:16.000000000 +0000 @@ -36,17 +36,16 @@ // static QuoteStack quoteStack; bool lastspace = false; - int word = 1; char val[128]; SWBuf buf; char *valto; char *ch; const char *wordStart = text.c_str(); - const char *wordEnd; + const char *wordEnd = NULL; - const char *textStart; - const char *textEnd; + const char *textStart = NULL; + const char *textEnd = NULL; bool suspendTextPassThru = false; bool handled = false; Index: sword-1.5.9/src/modules/filters/thmlrtf.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/thmlrtf.cpp 2006-11-25 12:32:32.000000000 +0000 +++ sword-1.5.9/src/modules/filters/thmlrtf.cpp 2006-11-25 12:33:03.000000000 +0000 @@ -205,7 +205,6 @@ bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { - const char *tok; if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); @@ -238,7 +237,7 @@ if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); - VerseKey *vkey; + VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { vkey = SWDYNAMIC_CAST(VerseKey, u->key); @@ -277,7 +276,7 @@ } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); - VerseKey *vkey; + VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { vkey = SWDYNAMIC_CAST(VerseKey, u->key); Index: sword-1.5.9/src/modules/filters/thmlstrongs.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/thmlstrongs.cpp 2006-11-25 12:31:42.000000000 +0000 +++ sword-1.5.9/src/modules/filters/thmlstrongs.cpp 2006-11-25 12:31:47.000000000 +0000 @@ -34,7 +34,6 @@ const char *from; int tokpos = 0; bool intoken = false; - int len; bool lastspace = false; int word = 1; char val[128]; Index: sword-1.5.9/src/modules/filters/thmlwebif.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/thmlwebif.cpp 2006-11-25 12:34:07.000000000 +0000 +++ sword-1.5.9/src/modules/filters/thmlwebif.cpp 2006-11-25 12:34:17.000000000 +0000 @@ -28,7 +28,6 @@ } bool ThMLWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { - const char *tok; if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; Index: sword-1.5.9/src/modules/filters/thmlwordjs.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/thmlwordjs.cpp 2006-11-25 12:34:28.000000000 +0000 +++ sword-1.5.9/src/modules/filters/thmlwordjs.cpp 2006-11-25 12:35:05.000000000 +0000 @@ -50,7 +50,6 @@ char *ch; char wordstr[5]; unsigned int textStart = 0, lastAppendLen = 0, textEnd = 0; - char gh = 0; SWBuf tmp; bool newText = false; bool needWordOut = false; @@ -179,7 +178,7 @@ else { wordID = key->getText(); } - for (int i = 0; i < wordID.size(); i++) { + for (unsigned int i = 0; i < wordID.size(); i++) { if ((!isdigit(wordID[i])) && (!isalpha(wordID[i]))) { wordID[i] = '_'; } @@ -271,7 +270,7 @@ else { wordID = key->getText(); } - for (int i = 0; i < wordID.size(); i++) { + for (unsigned int i = 0; i < wordID.size(); i++) { if ((!isdigit(wordID[i])) && (!isalpha(wordID[i]))) { wordID[i] = '_'; } Index: sword-1.5.9/src/modules/filters/utf8html.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/utf8html.cpp 2006-11-25 12:17:04.000000000 +0000 +++ sword-1.5.9/src/modules/filters/utf8html.cpp 2006-11-25 12:17:35.000000000 +0000 @@ -59,7 +59,7 @@ from += subsequent; text += '&'; text += '#'; - sprintf(digit, "%d", ch); + sprintf(digit, "%ld", ch); for (char *dig = digit; *dig; dig++) text += *dig; text += ';'; Index: sword-1.5.9/src/modules/filters/utf8utf16.cpp =================================================================== --- sword-1.5.9.orig/src/modules/filters/utf8utf16.cpp 2006-11-25 12:16:34.000000000 +0000 +++ sword-1.5.9/src/modules/filters/utf8utf16.cpp 2006-11-25 12:16:44.000000000 +0000 @@ -17,7 +17,6 @@ char UTF8UTF16::processText(SWBuf &text, const SWKey *key, const SWModule *module) { const unsigned char *from; - char digit[10]; unsigned long ch; signed short utf16; unsigned char from2[7]; Index: sword-1.5.9/src/modules/swmodule.cpp =================================================================== --- sword-1.5.9.orig/src/modules/swmodule.cpp 2006-11-25 12:11:17.000000000 +0000 +++ sword-1.5.9/src/modules/swmodule.cpp 2006-11-25 12:11:32.000000000 +0000 @@ -680,7 +680,6 @@ // entry attributes else if (searchType == -3) { - int i; RenderText(); // force parse AttributeTypeList &entryAttribs = getEntryAttributes(); AttributeTypeList::iterator i1Start, i1End; Index: sword-1.5.9/src/modules/texts/swtext.cpp =================================================================== --- sword-1.5.9.orig/src/modules/texts/swtext.cpp 2006-11-25 12:39:28.000000000 +0000 +++ sword-1.5.9/src/modules/texts/swtext.cpp 2006-11-25 12:39:44.000000000 +0000 @@ -82,7 +82,7 @@ VerseKey &SWText::getVerseKey() const { - VerseKey *key; + VerseKey *key = NULL; // see if we have a VerseKey * or decendant SWTRY { key = SWDYNAMIC_CAST(VerseKey, this->key); Index: sword-1.5.9/src/modules/comments/rawfiles/rawfiles.cpp =================================================================== --- sword-1.5.9.orig/src/modules/comments/rawfiles/rawfiles.cpp 2006-11-25 12:40:48.000000000 +0000 +++ sword-1.5.9/src/modules/comments/rawfiles/rawfiles.cpp 2006-11-25 12:41:09.000000000 +0000 @@ -57,7 +57,6 @@ FileDesc *datafile; long start = 0; unsigned short size = 0; - char *tmpbuf; VerseKey *key = 0; SWTRY { @@ -155,7 +154,6 @@ long start; unsigned short size; - char *tmpbuf; const VerseKey *key = 0; SWTRY {