diff options
author | pgen <p.gen.progs@gmail.com> | 2018-08-02 01:07:31 +0200 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2018-08-02 01:07:31 +0200 |
commit | c7e38f5559e9378f4d991dfd32a2f173f7618fc2 (patch) | |
tree | e050a1a8f81a46226c448cdb28567eb796283b81 /smenu.c | |
parent | e801fc30d0b4a58a1737305a54a8036dbfb69a36 (diff) |
Add the s sub-options to the -D option
This sub-option (start) allows to set the start of the automatic number
sequence used by the direct access mechanism.
By default this start number is set to 1.
Diffstat (limited to 'smenu.c')
-rw-r--r-- | smenu.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -961,7 +961,8 @@ short_usage(void) fprintf(stderr, " <arg> ::= [l|r:<char>]|[a:l|r]|[p:i|a]|"); fprintf(stderr, "[w:<size>]|\n"); fprintf(stderr, " [f:y|n]|[o:<num>]|[n:<num>]|"); - fprintf(stderr, "[i:<num>][d:<char>]\n"); + fprintf(stderr, "[i:<num>]|[d:<char>]|\n"); + fprintf(stderr, " [s:<num>]\n"); fprintf(stderr, " Ex: l:'(' a:l\n"); fprintf(stderr, " <attr> ::= [fg][/bg][,style] \n"); fprintf(stderr, " Ex: 7/4,bu\n"); @@ -6635,7 +6636,7 @@ main(int argc, char * argv[]) long index; /* generic counter */ - long daccess_index = 1; + long daccess_index = 1; /* First index of the numbered words */ char * daccess_np = NULL; regex_t daccess_np_re; /* variable to store the compiled direct access * @@ -7684,6 +7685,21 @@ main(int argc, char * argv[]) "after d: -- "); break; + case 's': /* start index */ + { + long pos; + + if (sscanf(argv[optind] + 2, "%ld%n", &daccess_index, &pos) + == 1) + { + if (daccess_index < 0 || *(argv[optind] + 2 + pos) != '\0') + daccess_index = 1; + } + else + TELL("Invalid first index after s: -- "); + } + break; + default: TELL("Bad format -- "); } |