@@ -237,7 +237,7 @@ csloc(const char *dir, csloc_filenp *dat, size_t *sz, unsigned ops, size_t cr, c
237
237
#else
238
238
long long sloc = 0 ;
239
239
#endif
240
- int sfl ;
240
+ long sfl ;
241
241
int valid ;
242
242
243
243
// store data if requested
@@ -379,31 +379,57 @@ csloc(const char *dir, csloc_filenp *dat, size_t *sz, unsigned ops, size_t cr, c
379
379
}
380
380
}
381
381
}
382
- else if (! CSLOC_ISNOLNK ( ops ) && CSLOCSYMLINK == tps [i ])
382
+ else if (CSLOCSYMLINK == tps [i ])
383
383
{
384
- realpath (subdir , lnpath );
385
- if (apath == NULL )
386
- apath = realpath (dir ,apath );
387
- if (!csloc____ispref (apath , lnpath ))
384
+ if (!CSLOC_ISNOLNK (ops ))
388
385
{
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 ))
392
390
{
393
- if (stat (subdir , & fdat )== 0 )
391
+ strcpy (subdir , lnpath );
392
+ realpath (currf , lnpath );
393
+ if (!csloc____ispref (lnpath , subdir ))
394
394
{
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
+ }
399
405
else
400
- tps [i ]= CSLOCOTHER ;
401
- goto redirect ;
406
+ fprintf (stderr , "Could not stat %s.\n" , subdir );
402
407
}
403
- else
404
- fprintf (stderr , "Could not stat %s.\n" , subdir );
405
408
}
406
409
}
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
+ }
407
433
}
408
434
free (names [i ]);
409
435
}
0 commit comments