tconf: MKFILE_MODE specifies the access mode of new files - neatvi - [fork] simple vi-type editor with UTF-8 support
 (HTM) git clone git://src.adamsgaard.dk/neatvi
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) commit 334aa96130c257032e7d7eeef650618bf706f09a
 (DIR) parent 4f6be8c78d2b66545cbae8696af0e2ca66f4efcb
 (HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
       Date:   Sun, 19 Jan 2020 20:41:33 +0330
       
       conf: MKFILE_MODE specifies the access mode of new files
       
       Diffstat:
         M conf.c                              |      15 +++++++++------
         M conf.h                              |       3 +++
         M ex.c                                |       2 +-
         M led.c                               |       3 +--
         M vi.c                                |       7 ++-----
         M vi.h                                |       5 +++--
       
       6 files changed, 19 insertions(+), 16 deletions(-)
       ---
 (DIR) diff --git a/conf.c b/conf.c
       t@@ -69,16 +69,19 @@ int conf_filetype(int idx, char **ft, char **pat)
                return 0;
        }
        
       -int conf_highlight_revdir(int *att)
       +int conf_hlrev(void)
        {
       -        *att = SYN_REVDIR;
       -        return 0;
       +        return SYN_REVDIR;
        }
        
       -int conf_highlight_line(int *att)
       +int conf_hlline(void)
        {
       -        *att = SYN_LINE;
       -        return 0;
       +        return SYN_LINE;
       +}
       +
       +int conf_mode(void)
       +{
       +        return MKFILE_MODE;
        }
        
        char **conf_kmap(int id)
 (DIR) diff --git a/conf.h b/conf.h
       t@@ -1,5 +1,8 @@
        /* neatvi configuration file */
        
       +/* access mode of new files */
       +#define MKFILE_MODE                0600
       +
        /* map file names to file types */
        static struct filetype {
                char *ft;                /* file type */
 (DIR) diff --git a/ex.c b/ex.c
       t@@ -477,7 +477,7 @@ static int ec_write(char *ec)
                                ex_show("write failed: file exists\n");
                                return 1;
                        }
       -                fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
       +                fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, conf_mode());
                        if (fd < 0) {
                                ex_show("write failed: cannot create file\n");
                                return 1;
 (DIR) diff --git a/led.c b/led.c
       t@@ -38,8 +38,7 @@ static int led_offdir(char **chrs, int *pos, int i)
        static void led_markrev(int n, char **chrs, int *pos, int *att)
        {
                int i = 0, j;
       -        int hl = 0;
       -        conf_highlight_revdir(&hl);
       +        int hl = conf_hlrev();
                while (i + 1 < n) {
                        int dir = led_offdir(chrs, pos, i);
                        int beg = i;
 (DIR) diff --git a/vi.c b/vi.c
       t@@ -53,11 +53,8 @@ static void vi_drawmsg(void)
        static void vi_drawrow(int row)
        {
                char *s = lbuf_get(xb, row);
       -        if (xhll && row == xrow) {
       -                int hll;
       -                conf_highlight_line(&hll);
       -                syn_context(hll);
       -        }
       +        if (xhll && row == xrow)
       +                syn_context(conf_hlline());
                led_print(s ? s : (row ? "~" : ""), row - xtop, ex_filetype());
                syn_context(0);
        }
 (DIR) diff --git a/vi.h b/vi.h
       t@@ -184,8 +184,9 @@ int conf_dircontext(int idx, char **pat, int *ctx);
        int conf_placeholder(int idx, char **s, char **d, int *wid);
        int conf_highlight(int idx, char **ft, int **att, char **pat, int *end);
        int conf_filetype(int idx, char **ft, char **pat);
       -int conf_highlight_revdir(int *att);
       -int conf_highlight_line(int *att);
       +int conf_hlrev(void);
       +int conf_hlline(void);
       +int conf_mode(void);
        char **conf_kmap(int id);
        int conf_kmapfind(char *name);
        char *conf_digraph(int c1, int c2);