Subversion Repositories SvarDOS

Rev

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

Rev 1444 Rev 1448
Line 32... Line 32...
32
#include "mdr\dos.h"
32
#include "mdr\dos.h"
33
 
33
 
34
#include "svarlang\svarlang.h"
34
#include "svarlang\svarlang.h"
35
 
35
 
36
 
36
 
37
#define PVER "2023.0"
37
#define PVER "2023.1"
38
#define PDATE "2023"
38
#define PDATE "2023"
39
 
39
 
40
/*****************************************************************************
40
/*****************************************************************************
41
 * global variables and definitions                                          *
41
 * global variables and definitions                                          *
42
 *****************************************************************************/
42
 *****************************************************************************/
Line 542... Line 542...
542
  char buff[512]; /* read one entire sector at a time (faster) */
542
  char buff[512]; /* read one entire sector at a time (faster) */
543
  char *buffptr;
543
  char *buffptr;
544
  unsigned int len, llen;
544
  unsigned int len, llen;
545
  int fd;
545
  int fd;
546
  unsigned char eolfound;
546
  unsigned char eolfound;
-
 
547
  int err = 0;
547
 
548
 
548
  /* free the entire linked list of lines */
549
  /* free the entire linked list of lines */
549
  db_rewind(db);
550
  db_rewind(db);
550
  while (db->cursor) {
551
  while (db->cursor) {
551
    struct line far *victim;
552
    struct line far *victim;
Line 555... Line 556...
555
  }
556
  }
556
 
557
 
557
  /* zero out the struct */
558
  /* zero out the struct */
558
  bzero(db, sizeof(struct file));
559
  bzero(db, sizeof(struct file));
559
 
560
 
-
 
561
  /* start by adding an empty line */
-
 
562
  if (line_add(db, NULL, 0) != 0) return(2);
-
 
563
 
560
  if (fname == NULL) goto SKIPLOADING;
564
  if (fname == NULL) goto SKIPLOADING;
561
 
565
 
562
  mdr_dos_truename(db->fname, fname);
566
  mdr_dos_truename(db->fname, fname);
563
 
567
 
564
  if (_dos_open(fname, O_RDONLY, &fd) != 0) {
568
  if (_dos_open(fname, O_RDONLY, &fd) != 0) {
565
    return(1);
569
    err = 1;
-
 
570
    goto SKIPLOADING;
566
  }
571
  }
567
 
572
 
568
  db->lfonly = 1;
573
  db->lfonly = 1;
569
 
574
 
570
  /* start by adding an empty line */
-
 
571
  if (line_add(db, NULL, 0) != 0) {
-
 
572
    /* TODO ERROR HANDLING */
-
 
573
  }
-
 
574
 
-
 
575
  for (eolfound = 0;;) {
575
  for (eolfound = 0;;) {
576
    unsigned short consumedbytes;
576
    unsigned short consumedbytes;
577
 
577
 
578
    if ((_dos_read(fd, buff, sizeof(buff), &len) != 0) || (len == 0)) break;
578
    if ((_dos_read(fd, buff, sizeof(buff), &len) != 0) || (len == 0)) break;
579
    buffptr = buff;
579
    buffptr = buff;
Line 641... Line 641...
641
 
641
 
642
  _dos_close(fd);
642
  _dos_close(fd);
643
 
643
 
644
  SKIPLOADING:
644
  SKIPLOADING:
645
 
645
 
646
  /* add an empty line at end if not present already, also rewind cursor to top of file */
-
 
647
  if ((db->cursor == NULL) || (db->cursor->len != 0)) line_add(db, NULL, 0);
646
  /* rewind cursor to top of file because it has been used by line_add() */
648
  db_rewind(db);
647
  db_rewind(db);
649
 
648
 
650
  return(0);
649
  return(err);
651
 
650
 
652
  IOERR:
651
  IOERR:
653
  _dos_close(fd);
652
  _dos_close(fd);
654
  return(2);
653
  return(2);
655
}
654
}
Line 725... Line 724...
725
    mdr_coutraw_puts(arg);
724
    mdr_coutraw_puts(arg);
726
    err = loadfile(&(dbarr[count]), arg);
725
    err = loadfile(&(dbarr[count]), arg);
727
    if (err) {
726
    if (err) {
728
      if (err == 1) { /* file not found */
727
      if (err == 1) { /* file not found */
729
        if ((count == 0) && (lastarg != 0)) { /* a 'file not found' is fine if only one file was given */
728
        if ((count == 0) && (lastarg != 0)) { /* a 'file not found' is fine if only one file was given */
730
          mdr_dos_truename(dbarr[count].fname, arg);
-
 
731
          err = 0;
729
          err = 0;
732
        } else {
730
        } else {
733
          err = 11;
731
          err = 11;
734
        }
732
        }
735
      } else { /* general error */
733
      } else { /* general error */