Hi!

22-Июн-2006 06:39 [EMAIL PROTECTED] (Blair Campbell) wrote to
[EMAIL PROTECTED]:

BC> +++ batch.c 22 Jun 2006 06:39:43 -0000      1.15
BC>     if (bc->ffind) {          /* First already done fo do next */
--------------------------------------------------------^^^^^ ?

BC> +#ifdef FEATURE_LONG_FILENAMES
BC> +        if( lfnfor ? lfnfindnext( bc->ffind ) != 0 :
BC> +                     FINDNEXT( ( struct ffblk * )bc->ffind ) != 0 ) {
BC> +            FINDSTOP( bc->ffind );
BC> +#else
BC>             if(FINDNEXT(bc->ffind) != 0) {          /* no next file */
BC> +#endif

     Comparision better to move out from branches (to make shorter code):

#ifdef FEATURE_LONG_FILENAMES
  if (lfnfor ? lfnfindnext (bc->ffind)
             : FINDNEXT ((struct ffblk*)bc->ffind)) {
    FINDSTOP (bc->ffind);
#else
  if (FINDNEXT (bc->ffind)) {          /* no next file */
#endif

Or, instead performing check directly in code, there may be introduced
separate function, which will do this check inside:

#ifdef FEATURE_LONG_FILENAMES

int ffirst (const char path [], void *fblk, int attrib) {
  return lfnfor ? lfnfindfirst (path, fblk, attrib)
                : FINDFIRST (path, (struct ffblk*)flk, attrib);
}

int fnext (void *fblk) {
  return lfnfor ? lfnfindnext (fblk) : FINDNEXT ((struct ffblk*)fblk);
}

void fstop (void *fblk) { FINDSTOP (bc->ffind); }

#else

/* All of this should be in some header */
#define ffirst(path, fblk, attrib) FINDFIRST (path, (struct ffblk*)fblk, attrib)
#define fnext(fblk) FINDNEXT ((struct ffblk*)fblk)
#define fstop(fblk)

#endif

and then:

if (fnext (bc->ffind)) {
  fstop (bc->ffind);

BC> +#ifdef FEATURE_LONG_FILENAMES
BC> +         if( lfnfor ? lfnfindfirst( fv, bc->ffind, FA_NORMAL ) == 0 :
BC> +                      FINDFIRST( fv, ( struct ffblk * )bc->ffind, FA_NORMAL
BC> )
BC> +                      == 0 ) {
BC> +#else
BC>           if(FINDFIRST(fv, bc->ffind, FA_NORMAL) == 0) {
BC> +#endif

     Same as above:

if ((lfnfor ? lfnfindfirst (fv, bc->ffind, FA_NORMAL )
            : FINDFIRST (fv, (struct ffblk*)bc->ffind, FA_NORMAL)) == 0) {

And, as above, all of this may be moved to separate function:

if (ffirst (fv, bc->ffind, FA_NORMAL)) == 0) {

All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Freedos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to