]> wagner.pp.ru Git - oss/catdoc.git/commitdiff
Fixed some warnings produced by GCC 4.9.2
authorVictor Wagner <vitus@wagner.pp.ru>
Wed, 7 Oct 2015 18:27:56 +0000 (21:27 +0300)
committerVictor Wagner <vitus@wagner.pp.ru>
Wed, 7 Oct 2015 18:27:56 +0000 (21:27 +0300)
.cvsignore [deleted file]
.gitignore [new file with mode: 0644]
src/analyze.c
src/charsets.c
src/ole.c
src/pptparse.c
src/sheet.c
src/writer.c
src/xls.h
src/xlsparse.c

diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644 (file)
index a7fbd2a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-.arch-ids
-.arch-ids
-.arch-inventory
-.arch-ids
-.arch-ids
-.arch-inventory
-Makefile
-autom4te.cache
-config.cache
-config.log
-config.status
-rtf-parser.txt
-semantic.cache
-tests
-{arch}
diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..cd73433
--- /dev/null
@@ -0,0 +1,24 @@
+.arch-ids
+.arch-ids
+.arch-inventory
+.arch-ids
+.arch-ids
+.arch-inventory
+Makefile
+autom4te.cache
+config.cache
+config.log
+config.status
+config.h
+tags
+*.o
+rtf-parser.txt
+semantic.cache
+tests
+doc/build
+doc/*.1
+{arch}
+src/catdoc
+src/catppt
+src/xls2csv
+src/wordview
index b721ce6d77d1191f560bf22ede79681e54d46cef..bebcbef63027a793bb055fe9db1c9e622095ca70 100644 (file)
@@ -39,18 +39,18 @@ int analyze_format(FILE *f) {
        }
        catdoc_read(buffer,4,1,f);
        buffer[4]=0;
-       if (strncmp(buffer,write_sign,2)==0) {
+       if (strncmp((char *)&buffer,write_sign,2)==0) {
                printf("[Windows Write file. Some garbage expected]\n");
                get_unicode_char=get_8bit_char;
                return process_file(f,LONG_MAX);
-       } else if (strncmp(buffer,rtf_sign,4)==0) {
+       } else if (strncmp((char *)&buffer,rtf_sign,4)==0) {
                return parse_rtf(f);
-       } else if (strncmp(buffer,old_word_sign,2)==0) {
+       } else if (strncmp((char *)&buffer,old_word_sign,2)==0) {
           fread(buffer+4,1,124,f);     
           return parse_word_header(buffer,f,128,0);
        }       
        fread(buffer+4,1,4,f);
-       if (strncmp(buffer,ole_sign,8)==0) {
+       if (strncmp((char *)&buffer,ole_sign,8)==0) {
                if ((new_file=ole_init(f, buffer, 8)) != NULL) {
                        set_ole_func();
                        while((ole_file=ole_readdir(new_file)) != NULL) {
@@ -70,8 +70,8 @@ int analyze_format(FILE *f) {
                        exit(1);
                }       
        } else {
-               set_std_func();
-               copy_out(f,buffer);
+
+               copy_out(f,(char *)&buffer);
                return 0;
        }
        
index b52a1eb651b019f91d4d3757c057c1b5333f9397..4ee0f4c09902a63ff792451b1584d7b9461ec5a2 100644 (file)
@@ -163,7 +163,7 @@ int get_utf16msb (FILE *f,long *offset,long fileend) {
 
 int get_utf8 (FILE *f,long *offset,long fileend) {
        unsigned char buf[3];
-       int d,c;
+       int c;
     int result;
        result=catdoc_read(buf, 1, 1, f);
        if (result<0) {
@@ -172,7 +172,6 @@ int get_utf8 (FILE *f,long *offset,long fileend) {
        }       
        if (result==0) return EOF;
        c=buf[0];
-       d=0;
        if (c<0x80) 
                return c;
        if (c <0xC0) 
index 9931b579cea2fc7a48cc4e536c316d519347f80a..5267dfa29f1b0bb0e000bbb0a0cf417e8fac0ca7 100644 (file)
--- a/src/ole.c
+++ b/src/ole.c
@@ -37,7 +37,7 @@ long propCurNumber, propLen, propNumber, propStart;
 unsigned char *properties=NULL;
 long int fileLength=0;
 
-static unsigned char ole_sign[]={0xD0,0xCF,0x11,0xE0,0xA1,0xB1,0x1A,0xE1,0};
+static char ole_sign[]={0xD0,0xCF,0x11,0xE0,0xA1,0xB1,0x1A,0xE1,0};
 
 
 /** 
@@ -97,7 +97,7 @@ FILE* ole_init(FILE *f, void *buffer, size_t bufSize)  {
        if ( ret != BBD_BLOCK_SIZE ) {
                return NULL;
        }
-       if (strncmp(oleBuf,ole_sign,8) != 0) {
+       if (strncmp((char *)&oleBuf,ole_sign,8) != 0) {
                return NULL;
        }
        sectorSize = 1<<getshort(oleBuf,0x1e);
index c5ebe0381bd3c78f6cb5839198343736546a0b7c..f475f07b58ee10032547a066043cb549838ebc42 100644 (file)
@@ -84,7 +84,7 @@ void do_ppt(FILE *input,char *filename) {
  */
 static void process_item (int rectype, long reclen, FILE* input) {
        int i=0, u;
-       static char buf[2];
+       static unsigned char buf[2];
 /*     fprintf(stderr,"Processing record %d length %d\n",rectype,reclen);
  *     */
        switch(rectype) {
index 9b95fe1acc6acad865f8e014d07793a452b4efc6..6d798c88d6a150467f5baf88a89f907a3cd77c63 100644 (file)
@@ -94,7 +94,7 @@ void print_value(unsigned char *value)
                        break;
                case QUOTE_ALL_STRINGS:
                        { char *endptr;
-                         strtod(value,&endptr);
+                         strtod((char *)value,&endptr);
                          quotes=(*endptr != '0');
                        break;
                        }  
index 5f95ba2fdb3659f09ba1fe8c24e3a508bf89c423..c86b6fe84afb229f9b14cb0313cd7c2b47c8484c 100644 (file)
@@ -58,7 +58,8 @@ void out_char(const char *chunk) {
                if (p==outputbuffer) {
                        /*worst case - nowhere to wrap. Will use brute force */
                        int i = wrap_margin;
-                       if (from_unicode == to_utf8) {
+                       if (target_charset == NULL) {
+                               /* NULL target_charest means UTF-8 */
                                /* go back to start of nearest utf-8 character */
                                while(i>0 && (outputbuffer[i] & 0xC0) == 0x80) i--;
                        }                       
index 084958dcf09909bd8484228c0a353396abfdd182..6c70cd1dc0b0455da69306ec9a8bcd7df4d4df77 100644 (file)
--- a/src/xls.h
+++ b/src/xls.h
@@ -29,14 +29,14 @@ extern int quote_mode;
 void print_sheet(void);
 void free_sheet(void);
 void print_value(unsigned char *value);
-char *format_double(char *rec,int offset,int format_code);
+char *format_double(unsigned char *rec,int offset,int format_code);
 char *format_int(int value,int format_code);
-char *format_rk(char *rec,short int format_code);
+char *format_rk(unsigned char *rec,short int format_code);
 char *gettypename(long rectype);
-void parse_sst(char *sstbuf,int bufsize);
-void process_item (int rectype, int reclen, char *rec); 
+void parse_sst(unsigned char *sstbuf,int bufsize);
+void process_item (int rectype, int reclen, unsigned char *rec); 
 unsigned char **allocate(int row,int col);
-char *copy_unicode_string(unsigned char **src);
+unsigned char *copy_unicode_string(unsigned char **src);
 char convert8to8(char *src,int count);
 char *convert16to8(char *src,int count);
 void do_table(FILE *input,char *filename);
index 139bcfe7a76a4084b2d505916891cd3ec0957a97..372eb087bbeefbd6f8b132c424514f86410469de 100644 (file)
@@ -51,6 +51,7 @@ void do_table(FILE *input,char *filename) {
                                        itemsread=catdoc_read(rec,4,1,input);
                                        build_year=getshort(rec+2,0);
                                        build_rel=getshort(rec,0);
+                                       (void) build_rel;
                                        if(build_year > 5 ) {
                                                itemsread=catdoc_read(rec,8,1,input);
                                                biff_version=8;
@@ -84,7 +85,7 @@ void do_table(FILE *input,char *filename) {
                exit(1);
        }    
        while(itemsread){
-               char buffer[2];
+               unsigned char buffer[2];
                rectype = 0;
                itemsread = catdoc_read(buffer, 2, 1, input);
                if (catdoc_eof(input)) {
@@ -130,7 +131,7 @@ int prev_rectype=0;
  */
 unsigned char **saved_reference = NULL;
 
-void process_item (int rectype, int reclen, char *rec) {
+void process_item (int rectype, int reclen, unsigned char *rec) {
        if (rectype != CONTINUE && prev_rectype == SST) {
                /* we have accumulated  unparsed SST, and now encountered
                 * another record, which indicates that SST is ended */
@@ -191,7 +192,7 @@ void process_item (int rectype, int reclen, char *rec) {
                if (sst != NULL)
                        free(sst);
                
-               sstBuffer=(char*)malloc(reclen);
+               sstBuffer=(unsigned char*)malloc(reclen);
                sstBytes = reclen;
                if (sstBuffer == NULL ) {
                        perror("SSTptr alloc error! ");
@@ -241,6 +242,7 @@ void process_item (int rectype, int reclen, char *rec) {
                endcol=getshort(rec,reclen-2);
                pcell=allocate(row,endcol);
                *pcell=NULL;
+               (void)startcol;
                break;
        }          
        case CONSTANT_STRING: {
@@ -261,13 +263,13 @@ void process_item (int rectype, int reclen, char *rec) {
                        exit(1);         
                } else if (sst[string_no] !=NULL) {     
                        int len;
-                       char *outptr;
-                       len=strlen(sst[string_no]);
+                       unsigned char *outptr;
+                       len=strlen((char *)sst[string_no]);
                        outptr=*pcell=malloc(len+1);
-                       strcpy(outptr,sst[string_no]);
+                       strcpy((char *)outptr,(char *)sst[string_no]);
                } else {
                        *pcell=malloc(1);
-                       strcpy(*pcell,"");
+                       **pcell = 0;
                }       
                break;
        }
@@ -282,7 +284,7 @@ void process_item (int rectype, int reclen, char *rec) {
                row = getshort(rec,0)-startrow; 
                col = getshort(rec,2);
                pcell=allocate(row,col);
-               *pcell=strdup(format_double(rec,6,getshort(rec,4)));
+               *pcell=(unsigned char *)strdup(format_double(rec,6,getshort(rec,4)));
                break;
        }
        case INTEGER_CELL: {
@@ -292,7 +294,7 @@ void process_item (int rectype, int reclen, char *rec) {
                row = getshort(rec,0)-startrow;
                col = getshort(rec,2);
                pcell=allocate(row,col);
-               *pcell=strdup(format_int(getshort(rec,7),getshort(rec,4)));               
+               *pcell=(unsigned char *)strdup(format_int(getshort(rec,7),getshort(rec,4)));              
                break;
 
        }                                 
@@ -305,7 +307,7 @@ void process_item (int rectype, int reclen, char *rec) {
                col = getshort(rec,2);
                pcell=allocate(row,col);
                format_code = getshort(rec,4);
-               *pcell=strdup(format_rk(rec+6,format_code));
+               *pcell=(unsigned char *)strdup(format_rk(rec+6,format_code));
                break;
        }
        case MULRK: {
@@ -319,7 +321,7 @@ void process_item (int rectype, int reclen, char *rec) {
                for (offset=4,col=startcol;col<=endcol;offset+=6,col++) { 
                        pcell=allocate(row,col);
                        format_code=getshort(rec,offset);
-                       *pcell=strdup(format_rk(rec+offset+2,format_code));
+                       *pcell=(unsigned char *)strdup(format_rk(rec+offset+2,format_code));
 
                }                
                break;
@@ -337,17 +339,17 @@ void process_item (int rectype, int reclen, char *rec) {
                                /*boolean*/
                                char buf[2]="0";
                                buf[0]+=rec[9];
-                               *pcell=strdup(buf);
+                               *pcell=(unsigned char *)strdup(buf);
                        } else if (rec[6]==2) {
                                /*error*/
                                char buf[6]="ERROR";
-                               *pcell=strdup(buf);
+                               *pcell=(unsigned char *)strdup(buf);
                        } else if (rec[6]==0) {
                                saved_reference=pcell;
                        }   
                } else {
                        int format_code=getshort(rec,4);
-                       *pcell=strdup(format_double(rec,6,format_code));
+                       *pcell=(unsigned char *)strdup(format_double(rec,6,format_code));
                }                
                break;
        }
@@ -415,23 +417,22 @@ void process_item (int rectype, int reclen, char *rec) {
 /*
  * Extracts string from sst and returns mallocked copy of it
  */
-char *copy_unicode_string (unsigned char **src) {
+unsigned char *copy_unicode_string (unsigned char **src) {
        int count=0;
        int flags = 0;
        int start_offset=0;
-       int to_skip=0;                                                          /* ÉÓÐÏÌØÚÕÅÔÓÑ ÄÌÑ ÐÏÄÓÞÅÔÁ ÄÌÉÎÙ ÄÁÎÎÙÈ
-                                                                                                                                * ÚÁ ËÏÎÃÏÍ ÓÔÒÏËÉ */
-       int offset = 1;                                                         /* ÄÌÑ ÕÞÅÔÁ ÐÅÒÅÍÅÎÎÏÊ ÄÌÉÎÙ ÐÅÒ×ÏÇÏ ÐÏÌÑ  */
+       int to_skip=0;  /* Used to counmt data after end of string */ 
+       int offset = 1; /* Variable length of the first field  */
        int charsize;
        /*      char *realstart=*src; */
-       char *dest;                                                                             /* ËÕÄÁ ÂÕÄÅÍ ËÏÐÉÒÏ×ÁÔØ ÓÔÒÏËÕ */
-       char *s,*d,*c;
+       unsigned char *dest;/* where to copy string */
+       unsigned char *s,*d,*c;
 
        int i,u,l,len;
 
        /*      for(i=0;i<20;i++) */
        /*              fprintf(stderr,"%02x ",(*src)[i]); */
-       /*      fprintf(stderr,"\n"); */
+               /*      fprintf(stderr,"\n"); */
 
        flags = *(*src+1+offset);
        if (! ( flags == 0 || flags == 1 || flags == 8 || flags == 9 ||
@@ -500,7 +501,7 @@ char *copy_unicode_string (unsigned char **src) {
                }
                if ( charsize == 2 ){
                        u=(unsigned short)getshort(s,0);
-                       c=convert_char(u);
+                       c=(unsigned char *)convert_char(u);
                        /*                      fprintf(stderr,"char=%02x %02x\n", *s, *(s+1)); */
                } else {
                        if (!source_charset) {
@@ -509,16 +510,16 @@ char *copy_unicode_string (unsigned char **src) {
                                source_charset=read_charset(source_csname);
                        }       
                        u=(unsigned short)to_unicode(source_charset,(unsigned char)*s);
-                       c=convert_char(u);
+                       c=(unsigned char *)convert_char(u);
                }
                if (c != NULL) {
-                       int dl = strlen(c);
+                       int dl = strlen((char *)c);
                        while (l+dl>=len) {
                                len+=16;
                                dest=realloc(dest,len+1);
                        }
                        d=dest+l;
-                       strcpy(d,c);
+                       strcpy((char *)d,(char *)c);
                        d+=dl;
                        l+=dl;
                }      
@@ -584,8 +585,8 @@ static char FormatIdxUsed[NUMOFDATEFORMATS];
 
 void CleanUpFormatIdxUsed() {
        int i;
-       for (i=0;i<NUMOFDATEFORMATS; i++);
-       FormatIdxUsed[i]=0;
+       for (i=0;i<NUMOFDATEFORMATS; i++)
+               FormatIdxUsed[i]=0;
 }
 
 /* 
@@ -681,10 +682,10 @@ char *number2string(double d,short int format_code) {
        return buffer;
 }
                
-char *format_double(char *rec,int offset,int format_code) {    
-       union { char cc[8];
+char *format_double(unsigned char *rec,int offset,int format_code) {   
+       union { unsigned char cc[8];
                double d;} dconv;
-       char *d,*s; 
+       unsigned char *d,*s; 
        int i;
 # ifdef WORDS_BIGENDIAN     
        for(s=rec+offset+8,d=dconv.cc,i=0;
@@ -707,7 +708,7 @@ char *format_int(int value,int format_code) {
 /*
  * Formats RK record
  */
-char* format_rk(char *rec,short int format_code) {
+char* format_rk(unsigned char *rec,short int format_code) {
        double value=0.0;
        int i;
 
@@ -716,9 +717,9 @@ char* format_rk(char *rec,short int format_code) {
                value=(double)(getlong(rec,0)>>2);
        }
        else { 
-               union { char cc[8];
+               union { unsigned char cc[8];
                        double d;} dconv;
-               char *d,*s;
+               unsigned char *d,*s;
                for(i=0;i<8;i++)
                        dconv.cc[i]='\0';
 # ifdef WORDS_BIGENDIAN     
@@ -753,7 +754,7 @@ time_t float2date(double f) {
 /*
  * Parses SST into array of strings
  */
-void parse_sst(char *sstbuf,int bufsize) {
+void parse_sst(unsigned char *sstbuf,int bufsize) {
        int i; /* index into sst */
        unsigned char *curString; /* pointer into unparsed buffer*/
        unsigned char *barrier=(unsigned char *)sstbuf+bufsize; /*pointer to end of buffer*/