Skip to content

Commit

Permalink
got rid of expressions that are always true
Browse files Browse the repository at this point in the history
  • Loading branch information
Tattersalt-Kanzaki committed Jan 7, 2025
1 parent 01c089b commit cc8b6e9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
18 changes: 8 additions & 10 deletions lib/xlsxio_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,17 +764,15 @@ void main_sheet_list_expat_callback_element_start (void* callbackdata, const XML
const XML_Char* sheetname;
//const XML_Char* relid = get_expat_attr_by_name(atts, X("r:id"));
if ((sheetname = get_expat_attr_by_name(atts, X("name"))) != NULL) {
if (data->callback) {
if ((*data->callback)(sheetname, data->callbackdata) != 0) {
XML_StopParser(data->xmlparser, XML_FALSE);
return;
}
if ((*data->callback)(sheetname, data->callbackdata) != 0) {
XML_StopParser(data->xmlparser, XML_FALSE);
return;
}
/*
} else {
//for non-calback method suspend here
XML_StopParser(data->xmlparser, XML_TRUE);
} else {
//for non-calback method suspend here
XML_StopParser(data->xmlparser, XML_TRUE);
*/
}
}
}
}
Expand Down Expand Up @@ -1142,7 +1140,7 @@ void data_sheet_expat_callback_find_cell_start (void* callbackdata, const XML_Ch
if ((data->flags & XLSXIOREAD_SKIP_EXTRA_CELLS) && data->cols > 0 && cellmax > data->cols)
cellmax = data->cols;
while (data->colnr < cellmax) {
if (data->colnr > 0 && data->sheet_cell_callback) {
if (data->sheet_cell_callback) {
if ((*data->sheet_cell_callback)(data->rownr, data->colnr + 1, NULL, data->callbackdata)) {
XML_StopParser(data->xmlparser, XML_FALSE);
return;
Expand Down
42 changes: 20 additions & 22 deletions lib/xlsxio_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,30 +915,28 @@ void write_cell_data (xlsxiowriter handle, const char* rowattr, const char* pref
if (suffix)
append_data(&handle->buf, &handle->buflen, suffix);
//collect cell information
if (!handle->sheetopen) {
if (!*handle->pcurrentcolumn) {
//create new column information structure
struct column_info_struct* colinfo;
if ((colinfo = (struct column_info_struct*)malloc(sizeof(struct column_info_struct))) != NULL) {
colinfo->width = 0;
colinfo->maxwidth = 0;
colinfo->next = NULL;
*handle->pcurrentcolumn = colinfo;
}
}
//keep track of biggest column width
if (data) {
//only count first line in multiline data
char* p = strchr(data, '\n');
if (p)
datalen = p - data;
//remember this length if it is the longest one so far
if (datalen > 0 && datalen > (*handle->pcurrentcolumn)->maxwidth)
(*handle->pcurrentcolumn)->maxwidth = datalen;
if (!*handle->pcurrentcolumn) {
//create new column information structure
struct column_info_struct* colinfo;
if ((colinfo = (struct column_info_struct*)malloc(sizeof(struct column_info_struct))) != NULL) {
colinfo->width = 0;
colinfo->maxwidth = 0;
colinfo->next = NULL;
*handle->pcurrentcolumn = colinfo;
}
//prepare for the next column
handle->pcurrentcolumn = &(*handle->pcurrentcolumn)->next;
}
//keep track of biggest column width
if (data) {
//only count first line in multiline data
char* p = strchr(data, '\n');
if (p)
datalen = p - data;
//remember this length if it is the longest one so far
if (datalen > 0 && datalen > (*handle->pcurrentcolumn)->maxwidth)
(*handle->pcurrentcolumn)->maxwidth = datalen;
}
//prepare for the next column
handle->pcurrentcolumn = &(*handle->pcurrentcolumn)->next;
}
#if !defined(NO_ROW_NUMBERS) && !defined(NO_COLUMN_NUMBERS)
free(cellcoord);
Expand Down

0 comments on commit cc8b6e9

Please sign in to comment.