SQLite

Check-in [c6fe4f8d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Shell to .read any named character source file/device (again.)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c6fe4f8d639db25f0a339f4071f0ae34b90dcfec8dcc2c571f969e2614a38e05
User & Date: larrybr 2021-09-13 23:11:46
Context
2021-09-14
11:27
Minor updates to rtreedoc.test. (check-in: b22c75e4 user: dan tags: trunk)
2021-09-13
23:11
Shell to .read any named character source file/device (again.) (check-in: c6fe4f8d user: larrybr tags: trunk)
18:32
Add test cases to rtreedoc.test. (check-in: 4ee99d31 user: dan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/shell.c.in.

631
632
633
634
635
636
637
638

639

640


641
642
643
644
645
646
647


648

649
650
651
652
653
654
655
656
657
  while( *z ){
    if( (0xc0&*(z++))!=0x80 ) n++;
  }
  return n;
}

/*
** Return true if zFile does not exist or if it is not an ordinary file.

*/

#ifdef _WIN32


# define notNormalFile(X) 0
#else
static int notNormalFile(const char *zFile){
  struct stat x;
  int rc;
  memset(&x, 0, sizeof(x));
  rc = stat(zFile, &x);


  return rc || !S_ISREG(x.st_mode);

}
#endif

/*
** This routine reads a line of text from FILE in, stores
** the text in memory obtained from malloc() and returns a pointer
** to the text.  NULL is returned at end of file, or if malloc()
** fails.
**







|
>

>

>
>
|

<
|
<
<
|
>
>
|
>

<







631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646

647


648
649
650
651
652
653

654
655
656
657
658
659
660
  while( *z ){
    if( (0xc0&*(z++))!=0x80 ) n++;
  }
  return n;
}

/*
** Return true if zFile does not exist or if it is not either
** an ordinary file or an openable character stream source.
*/
static int notChrSource(const char *zFile){
#ifdef _WIN32
  struct _stat x = {0};
  int rc = _stat(zFile, &x);
# define STAT_CHR_SRC(mode) ((mode & (_S_IFCHR|_S_IFIFO|_S_IFREG))!=0)
#else

  struct stat x = {0};


  int rc = stat(zFile, &x);
# define STAT_CHR_SRC(mode) (S_ISREG(mode)||S_ISFIFO(mode)||S_ISCHR(mode))
#endif
  return rc || !STAT_CHR_SRC(x.st_mode);
#undef STAT_CHR_SRC
}


/*
** This routine reads a line of text from FILE in, stores
** the text in memory obtained from malloc() and returns a pointer
** to the text.  NULL is returned at end of file, or if malloc()
** fails.
**
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
        utf8_printf(stderr, "Error: cannot open \"%s\"\n", azArg[1]);
        rc = 1;
      }else{
        rc = process_input(p);
        pclose(p->in);
      }
#endif
    }else if( notNormalFile(azArg[1]) || (p->in = fopen(azArg[1], "rb"))==0 ){
      utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
      rc = 1;
    }else{
      rc = process_input(p);
      fclose(p->in);
    }
    p->in = inSaved;







|







9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
        utf8_printf(stderr, "Error: cannot open \"%s\"\n", azArg[1]);
        rc = 1;
      }else{
        rc = process_input(p);
        pclose(p->in);
      }
#endif
    }else if( notChrSource(azArg[1]) || (p->in = fopen(azArg[1], "rb"))==0 ){
      utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
      rc = 1;
    }else{
      rc = process_input(p);
      fclose(p->in);
    }
    p->in = inSaved;