Subversion Repositories SvarDOS

Rev

Rev 1054 | Rev 1065 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1054 Rev 1055
Line 765... Line 765...
765
/* process the ongoing forloop, returns 0 on success, non-zero otherwise (no
765
/* process the ongoing forloop, returns 0 on success, non-zero otherwise (no
766
   more things to process) */
766
   more things to process) */
767
static int forloop_process(char *res, struct forctx far *forloop) {
767
static int forloop_process(char *res, struct forctx far *forloop) {
768
  unsigned short i, t;
768
  unsigned short i, t;
769
  struct DTA *dta = (void *)0x80; /* default DTA at 80h in PSP */
769
  struct DTA *dta = (void *)0x80; /* default DTA at 80h in PSP */
-
 
770
  char *fnameptr = dta->fname;
770
 
771
 
771
  TRYAGAIN:
772
  TRYAGAIN:
772
 
773
 
773
  /* dta_inited: FindFirst() or FindNext()? */
774
  /* dta_inited: FindFirst() or FindNext()? */
774
  if (forloop->dta_inited == 0) {
775
  if (forloop->dta_inited == 0) {
Line 808... Line 809...
808
 
809
 
809
    /* move nextpat forward to next pattern */
810
    /* move nextpat forward to next pattern */
810
    i += forloop->nextpat;
811
    i += forloop->nextpat;
811
    forloop->nextpat = i;
812
    forloop->nextpat = i;
812
 
813
 
-
 
814
    /* if this is a string and not a pattern, skip all the FindFirst business
-
 
815
     * a file pattern has a wildcard (* or ?), a message doesn't */
-
 
816
    for (i = 0; (BUFFER[i] != 0) && (BUFFER[i] != '?') && (BUFFER[i] != '*'); i++);
-
 
817
    if (BUFFER[i] == 0) {
-
 
818
      fnameptr = BUFFER;
-
 
819
      goto SKIP_DTA;
-
 
820
    }
-
 
821
 
813
    /* FOR in MSDOS 6 includes hidden and system files, but not directories nor volumes */
822
    /* FOR in MSDOS 6 includes hidden and system files, but not directories nor volumes */
814
    if (findfirst(dta, BUFFER, DOS_ATTR_RO | DOS_ATTR_HID | DOS_ATTR_SYS | DOS_ATTR_ARC) != 0) {
823
    if (findfirst(dta, BUFFER, DOS_ATTR_RO | DOS_ATTR_HID | DOS_ATTR_SYS | DOS_ATTR_ARC) != 0) {
815
      goto TRYAGAIN;
824
      goto TRYAGAIN;
816
    }
825
    }
817
    forloop->dta_inited = 1;
826
    forloop->dta_inited = 1;
Line 828... Line 837...
828
  }
837
  }
829
 
838
 
830
  /* copy updated DTA to rmod */
839
  /* copy updated DTA to rmod */
831
  _fmemcpy(&(forloop->dta), dta, sizeof(*dta));
840
  _fmemcpy(&(forloop->dta), dta, sizeof(*dta));
832
 
841
 
-
 
842
  SKIP_DTA:
-
 
843
 
833
  /* fill res with command, replacing varname by actual filename */
844
  /* fill res with command, replacing varname by actual filename */
834
  /* full filename is to be built with path of curpat and fname from dta */
845
  /* full filename is to be built with path of curpat and fname from dta */
835
  t = 0;
846
  t = 0;
836
  i = 0;
847
  i = 0;
837
  for (;;) {
848
  for (;;) {
Line 843... Line 854...
843
        c++;
854
        c++;
844
        if (res[i] == '\\') lastbk = i;
855
        if (res[i] == '\\') lastbk = i;
845
        if ((res[i] == ' ') || (res[i] == 0)) break;
856
        if ((res[i] == ' ') || (res[i] == 0)) break;
846
        i++;
857
        i++;
847
      }
858
      }
848
      _fstrcpy(res + lastbk, dta->fname);
859
      strcpy(res + lastbk, fnameptr);
849
      for (i = lastbk; res[i] != 0; i++);
860
      for (i = lastbk; res[i] != 0; i++);
850
      t += 2;
861
      t += 2;
851
    } else {
862
    } else {
852
      res[i] = forloop->cmd[forloop->exec + t];
863
      res[i] = forloop->cmd[forloop->exec + t];
853
      t++;
864
      t++;