"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "longline.c" between
sarg-2.3.11.tar.gz and sarg-2.4.0.tar.gz

About: SARG ia a Squid Analysis Report Generator.

longline.c  (sarg-2.3.11):longline.c  (sarg-2.4.0)
/* /*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
* 1998, 2013 * 1998, 2015
* *
* SARG donations: * SARG donations:
* please look at http://sarg.sourceforge.net/donations.php * please look at http://sarg.sourceforge.net/donations.php
* Support: * Support:
* http://sourceforge.net/projects/sarg/forums/forum/363374 * http://sourceforge.net/projects/sarg/forums/forum/363374
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
skipping to change at line 97 skipping to change at line 97
void longline_reset(longline line) void longline_reset(longline line)
{ {
if (line!=NULL) { if (line!=NULL) {
line->start=0; line->start=0;
line->end=0; line->end=0;
line->length=0; line->length=0;
} }
} }
char *longline_read(FILE *fp_in,longline line) char *longline_read(FileObject *fp_in,longline line)
{ {
int i; int i;
char *newbuf; char *newbuf;
size_t nread; int nread;
if (line==NULL || line->buffer==NULL) return(NULL); if (line==NULL || line->buffer==NULL) return(NULL);
while (true) { while (true) {
for (i=line->end ; i<line->length && (line->buffer[i]=='\n' || li ne->buffer[i]=='\r') ; i++); for (i=line->end ; i<line->length && (line->buffer[i]=='\n' || li ne->buffer[i]=='\r') ; i++);
if (i<line->length) { if (i<line->length) {
line->end=i; line->end=i;
break; break;
} }
nread=(feof(fp_in)!=0) ? 0 : fread(line->buffer,1,line->size,fp_i nread=(FileObject_Eof(fp_in)!=0) ? 0 : FileObject_Read(fp_in,line
n); ->buffer,line->size);
if (nread==0) return(NULL); if (nread<=0) return(NULL);
line->length=nread; line->length=nread;
line->end=0; line->end=0;
} }
line->start=line->end; line->start=line->end;
while (true) { while (true) {
for (i=line->end ; i<line->length ; i++) { for (i=line->end ; i<line->length ; i++) {
if ((unsigned char)line->buffer[i]>=' ') continue; if ((unsigned char)line->buffer[i]>=' ') continue;
if (line->buffer[i]=='\n' || line->buffer[i]=='\r') break ; if (line->buffer[i]=='\n' || line->buffer[i]=='\r') break ;
} }
skipping to change at line 136 skipping to change at line 136
if (line->start>0) { if (line->start>0) {
for (i=line->start ; i<line->length ; i++) line->buffer[i -line->start]=line->buffer[i]; for (i=line->start ; i<line->length ; i++) line->buffer[i -line->start]=line->buffer[i];
line->length-=line->start; line->length-=line->start;
line->end-=line->start; line->end-=line->start;
line->start=0; line->start=0;
} }
if (line->length>=line->size) { if (line->length>=line->size) {
line->size+=LINE_BUFFER_SIZE_INCREMENT; line->size+=LINE_BUFFER_SIZE_INCREMENT;
if (line->size>=MAX_LINE_BUFFER_SIZE) { if (line->size>=MAX_LINE_BUFFER_SIZE) {
debuga(_("A text line is more than %d bytes long denoting a corrupted file\n"),MAX_LINE_BUFFER_SIZE); debuga(__FILE__,__LINE__,_("A text line is more t han %d bytes long denoting a corrupted file\n"),MAX_LINE_BUFFER_SIZE);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
newbuf=realloc(line->buffer,line->size); newbuf=realloc(line->buffer,line->size);
if (!newbuf) { if (!newbuf) {
debuga(_("Not enough memory to read one more line from the file\n")); debuga(__FILE__,__LINE__,_("Not enough memory to read one more line from the file\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
line->buffer=newbuf; line->buffer=newbuf;
} }
nread=(feof(fp_in)!=0) ? 0 : fread(line->buffer+line->length,1,li nread=(FileObject_Eof(fp_in)!=0) ? 0 : FileObject_Read(fp_in,line
ne->size-line->length,fp_in); ->buffer+line->length,line->size-line->length);
if (nread==0) { if (nread<=0) {
if (line->end<=line->start) return(NULL); if (line->end<=line->start) return(NULL);
if (line->end>=line->size) { if (line->end>=line->size) {
line->end=line->size; line->end=line->size;
line->size++; line->size++;
newbuf=realloc(line->buffer,line->size); newbuf=realloc(line->buffer,line->size);
if (!newbuf) { if (!newbuf) {
debuga(_("Not enough memory to read one m ore line from the file\n")); debuga(__FILE__,__LINE__,_("Not enough me mory to read one more line from the file\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
line->buffer=newbuf; line->buffer=newbuf;
} }
line->buffer[line->end]='\0'; line->buffer[line->end]='\0';
return(line->buffer+line->start); return(line->buffer+line->start);
} }
line->length+=nread; line->length+=nread;
} }
line->buffer[line->end++]='\0'; line->buffer[line->end++]='\0';
 End of changes. 8 change blocks. 
12 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)