@@ -237,7 +237,7 @@ csloc(const char *dir, csloc_filenp *dat, size_t *sz, unsigned ops, size_t cr, c
237237#else
238238 long long sloc = 0 ;
239239#endif
240- int sfl ;
240+ long sfl ;
241241 int valid ;
242242
243243 // store data if requested
@@ -379,31 +379,57 @@ csloc(const char *dir, csloc_filenp *dat, size_t *sz, unsigned ops, size_t cr, c
379379 }
380380 }
381381 }
382- else if (! CSLOC_ISNOLNK ( ops ) && CSLOCSYMLINK == tps [i ])
382+ else if (CSLOCSYMLINK == tps [i ])
383383 {
384- realpath (subdir , lnpath );
385- if (apath == NULL )
386- apath = realpath (dir ,apath );
387- if (!csloc____ispref (apath , lnpath ))
384+ if (!CSLOC_ISNOLNK (ops ))
388385 {
389- strcpy (subdir , lnpath );
390- realpath (currf , lnpath );
391- if (!csloc____ispref (lnpath , subdir ))
386+ realpath (subdir , lnpath );
387+ if (apath == NULL )
388+ apath = realpath (dir ,apath );
389+ if (!csloc____ispref (apath , lnpath ))
392390 {
393- if (stat (subdir , & fdat )== 0 )
391+ strcpy (subdir , lnpath );
392+ realpath (currf , lnpath );
393+ if (!csloc____ispref (lnpath , subdir ))
394394 {
395- if (S_ISDIR (fdat .st_mode ))
396- tps [i ]= DIRECTORY ;
397- else if (S_ISREG (fdat .st_mode ))
398- tps [i ]= NFILE ;
395+ if (stat (subdir , & fdat )== 0 )
396+ {
397+ if (S_ISDIR (fdat .st_mode ))
398+ tps [i ]= DIRECTORY ;
399+ else if (S_ISREG (fdat .st_mode ))
400+ tps [i ]= NFILE ;
401+ else
402+ tps [i ]= CSLOCOTHER ;
403+ goto redirect ;
404+ }
399405 else
400- tps [i ]= CSLOCOTHER ;
401- goto redirect ;
406+ fprintf (stderr , "Could not stat %s.\n" , subdir );
402407 }
403- else
404- fprintf (stderr , "Could not stat %s.\n" , subdir );
405408 }
406409 }
410+ else
411+ {
412+ if (CSLOC_ISFSIZE (ops ))
413+ {
414+ lstat (subdir , & fdat );
415+ sfl = fdat .st_size ;
416+ }
417+ else
418+ sfl = 1 ;
419+ if (CSLOC_ISSIF (ops ))
420+ {
421+ if (datsz == datc )
422+ {
423+ datc += datc >> 1 ;
424+ d = realloc (d , sizeof (* d ) * datc );
425+ }
426+ d [datsz ].val = sfl ;
427+ d [datsz ].name = malloc (strlen (subdir ) + 1 );
428+ strcpy (d [datsz ].name , subdir );
429+ ++ datsz ;
430+ }
431+ sloc += sfl ;
432+ }
407433 }
408434 free (names [i ]);
409435 }
0 commit comments