Diffstat (limited to 'noncore/todayplugins/stockticker/libstocks/csv.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/csv.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/todayplugins/stockticker/libstocks/csv.c b/noncore/todayplugins/stockticker/libstocks/csv.c index 6170bed..86d8607 100644 --- a/noncore/todayplugins/stockticker/libstocks/csv.c +++ b/noncore/todayplugins/stockticker/libstocks/csv.c | |||
@@ -293,49 +293,50 @@ stock *parse_csv_history_file(char *csv_file) | |||
293 | char *line; | 293 | char *line; |
294 | char *end_line; | 294 | char *end_line; |
295 | char *ptr; | 295 | char *ptr; |
296 | 296 | ||
297 | int day; | 297 | int day; |
298 | char smonth[10]; | 298 | char smonth[10]; |
299 | int month; | 299 | int month; |
300 | int year; | 300 | int year; |
301 | 301 | ||
302 | char *date; | 302 | char *date; |
303 | 303 | ||
304 | int i; | 304 | int i; |
305 | int test; | 305 | int test; |
306 | 306 | ||
307 | stock *StockPtr=NULL; | 307 | stock *StockPtr=NULL; |
308 | stock *LastStockPtr=NULL; | 308 | stock *LastStockPtr=NULL; |
309 | 309 | ||
310 | /* Used to return the pointer to the list */ | 310 | /* Used to return the pointer to the list */ |
311 | stock *FirstStockPtr=NULL; | 311 | stock *FirstStockPtr=NULL; |
312 | 312 | ||
313 | line = csv_file; | 313 | line = csv_file; |
314 | end_line = csv_file; | 314 | end_line = csv_file; |
315 | 315 | ||
316 | /* do not use the first line */ | 316 | /* do not use the first line */ |
317 | end_line = strstr(line, "\n"); | 317 | if (!(end_line = strstr(line, "\n"))) |
318 | return 0; | ||
318 | *end_line = 0; | 319 | *end_line = 0; |
319 | end_line++; | 320 | end_line++; |
320 | line = end_line; | 321 | line = end_line; |
321 | 322 | ||
322 | while ((end_line = strstr(line, "\n"))) | 323 | while ((end_line = strstr(line, "\n"))) |
323 | { | 324 | { |
324 | *end_line = 0; | 325 | *end_line = 0; |
325 | 326 | ||
326 | StockPtr = malloc_stock(); | 327 | StockPtr = malloc_stock(); |
327 | 328 | ||
328 | /* Date */ | 329 | /* Date */ |
329 | ptr = strtok(line, ","); | 330 | ptr = strtok(line, ","); |
330 | if (!ptr) return 0; | 331 | if (!ptr) return 0; |
331 | 332 | ||
332 | sscanf(ptr,"%d-%3s-%d",&day,smonth,&year); | 333 | sscanf(ptr,"%d-%3s-%d",&day,smonth,&year); |
333 | 334 | ||
334 | i=0; | 335 | i=0; |
335 | 336 | ||
336 | #ifdef __UNIX__ | 337 | #ifdef __UNIX__ |
337 | while((test=strcasecmp(months[i], smonth))) i++; | 338 | while((test=strcasecmp(months[i], smonth))) i++; |
338 | #elif __WINDOWS__ | 339 | #elif __WINDOWS__ |
339 | while(test=_mbsnbicmp(months[i], smonth, strlen(months[i]))) i++; | 340 | while(test=_mbsnbicmp(months[i], smonth, strlen(months[i]))) i++; |
340 | #endif | 341 | #endif |
341 | 342 | ||