nodebug and doc
This commit is contained in:
parent
be4ed76d84
commit
35b8abdb82
8
bake.1
8
bake.1
@ -36,6 +36,14 @@ returns target\-file without suffix (abc.x.txt \-> abc.x)
|
|||||||
.B $+
|
.B $+
|
||||||
returns
|
returns
|
||||||
.B arguments
|
.B arguments
|
||||||
|
|
||||||
|
.PP
|
||||||
|
Additional Features And Notes
|
||||||
|
|
||||||
|
\fB@{\fPEXPUNGE_THIS_FILE\fB}\fP is a inline block to delete files or directories, non-recursive, only one file per block, removed from left to right. Has no influence on the normal command execution.
|
||||||
|
|
||||||
|
\\SPECIAL_NAME will result in SPECIAL_NAME in the executed shell command. Backslashes are applicable to all symbols used by Bake, they are ignored otherwise.
|
||||||
|
|
||||||
.SH EXAMPLE
|
.SH EXAMPLE
|
||||||
.\" SRC BEGIN (example.c)
|
.\" SRC BEGIN (example.c)
|
||||||
.EX
|
.EX
|
||||||
|
80
bake.c
80
bake.c
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the GNU Public License version 3 only, see LICENSE.
|
* Licensed under the GNU Public License version 3 only, see LICENSE.
|
||||||
*
|
*
|
||||||
* @BAKE cc -std=c89 -O2 @FILENAME -o @SHORT @ARGS @STOP
|
* @BAKE cc -std=c89 -O2 @FILENAME -o @{@SHORT} @ARGS @STOP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
@ -29,7 +29,7 @@
|
|||||||
#define START "@BAKE"
|
#define START "@BAKE"
|
||||||
#define STOP "@STOP"
|
#define STOP "@STOP"
|
||||||
|
|
||||||
#define EXPUNGE_START "${"
|
#define EXPUNGE_START "@{"
|
||||||
#define EXPUNGE_STOP "}"
|
#define EXPUNGE_STOP "}"
|
||||||
|
|
||||||
#define VERSION "20240404"
|
#define VERSION "20240404"
|
||||||
@ -53,9 +53,7 @@
|
|||||||
"\tinfluence on the normal command execution.\n" \
|
"\tinfluence on the normal command execution.\n" \
|
||||||
"\t" YELLOW "\\" RESET \
|
"\t" YELLOW "\\" RESET \
|
||||||
"SPECIAL_NAME will result in SPECIAL_NAME in the executed shell command.\n" \
|
"SPECIAL_NAME will result in SPECIAL_NAME in the executed shell command.\n" \
|
||||||
"\t" RED "\\\\" RESET \
|
"Backslashing is applicable to all meaningful symbols in Bake, it is ignored otherwise."
|
||||||
"SPECIAL NAME will result as the rule above.\n" \
|
|
||||||
"\tThis is applicable to all meaningful symbols in Bake, it is ignored otherwise."
|
|
||||||
|
|
||||||
#define COPYRIGHT "2023 Emil Williams"
|
#define COPYRIGHT "2023 Emil Williams"
|
||||||
#define LICENSE "Licensed under the GNU Public License version 3 only, see LICENSE."
|
#define LICENSE "Licensed under the GNU Public License version 3 only, see LICENSE."
|
||||||
@ -160,35 +158,6 @@ find(char * buf, char * x, char * end) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
static string_t
|
|
||||||
find_region(char * buf, char * findstart, char * findstop,
|
|
||||||
char ** end) {
|
|
||||||
char * start = find(buf, findstart, *end),
|
|
||||||
* stop;
|
|
||||||
size_t findstart_len = strlen(findstart);
|
|
||||||
|
|
||||||
if (!start) {
|
|
||||||
return (string_t) {
|
|
||||||
NULL, 0
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
stop = find(start + findstart_len, findstop, *end);
|
|
||||||
|
|
||||||
if (!stop) {
|
|
||||||
return (string_t) {
|
|
||||||
NULL, 0
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
*end = stop;
|
|
||||||
return (string_t) {
|
|
||||||
start, stop - start
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_region(string_t m, char * findstart, char * findstop) {
|
get_region(string_t m, char * findstart, char * findstop) {
|
||||||
char * buf = NULL, * start, * stop, * end = m.len + m.buf;
|
char * buf = NULL, * start, * stop, * end = m.len + m.buf;
|
||||||
@ -377,44 +346,11 @@ bake_expand(char * buf, char * filename, int argc, char ** argv) {
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* this function somehow rapes the end of the string and removes one character or it's a off by one in strip */
|
|
||||||
static string_t *
|
|
||||||
remove_expand(char * buf) {
|
|
||||||
string_t * rem = malloc(sizeof(string_t));
|
|
||||||
char * start = buf, * bend = start + strlen(buf), * end = bend;
|
|
||||||
size_t i = 0;
|
|
||||||
|
|
||||||
while (rem) {
|
|
||||||
rem[i] = find_region(start, EXPUNGE_START, EXPUNGE_STOP, &end);
|
|
||||||
printf("\nrem:%d %s\n", rem[i].len, rem[i]);
|
|
||||||
|
|
||||||
if (rem[i].buf) {
|
|
||||||
start += rem[i].buf - buf + end - rem[i].buf;
|
|
||||||
rem[i].len = end - rem[i].buf - strlen(EXPUNGE_START);
|
|
||||||
printf("\nrem:%d %s\n", rem[i].len, start);
|
|
||||||
insert(start, "", bend - start, 0, 1);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
rem = realloc(rem, (1 + ++i) * sizeof(string_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
expand(buf, EXPUNGE_START, "");
|
|
||||||
|
|
||||||
return rem;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
remove_expand(char * buf) {
|
remove_expand(char * buf) {
|
||||||
size_t i, f, plen = 0, len = 1, end = strlen(buf);
|
size_t i, f, plen = 0, len = 1, end = strlen(buf);
|
||||||
char * l = NULL;
|
char * l = NULL;
|
||||||
|
|
||||||
/* "a\0b\0\0" */
|
|
||||||
/* ${a} \${} ${b} -> insert at beginning of } shift 1 -> */
|
|
||||||
/* ${a \${} ${b -> expand -> a ${} b */
|
|
||||||
for (i = 0; i < end; ++i) {
|
for (i = 0; i < end; ++i) {
|
||||||
if (!strncmp(buf + i, EXPUNGE_START, strlen(EXPUNGE_START))) {
|
if (!strncmp(buf + i, EXPUNGE_START, strlen(EXPUNGE_START))) {
|
||||||
if (buf + i > buf && buf[i - 1] == '\\') {
|
if (buf + i > buf && buf[i - 1] == '\\') {
|
||||||
@ -431,7 +367,6 @@ remove_expand(char * buf) {
|
|||||||
i += strlen(EXPUNGE_START);
|
i += strlen(EXPUNGE_START);
|
||||||
plen = (len != 1) * (len - 1);
|
plen = (len != 1) * (len - 1);
|
||||||
len += f - i + 1;
|
len += f - i + 1;
|
||||||
printf("plen: %d, len: %d\n", plen, len);
|
|
||||||
l = realloc(l, len);
|
l = realloc(l, len);
|
||||||
memcpy(l + plen, buf + i, f - i);
|
memcpy(l + plen, buf + i, f - i);
|
||||||
l[plen + f - i] = '\0';
|
l[plen + f - i] = '\0';
|
||||||
@ -449,16 +384,7 @@ stop:
|
|||||||
expand(buf, EXPUNGE_START, "");
|
expand(buf, EXPUNGE_START, "");
|
||||||
|
|
||||||
if (l) {
|
if (l) {
|
||||||
size_t i, xz = 0;
|
|
||||||
l[len - 1] = '\0';
|
l[len - 1] = '\0';
|
||||||
|
|
||||||
for (i = 0; i < len; ++i) {
|
|
||||||
if (l[i] == '\0') ++xz;
|
|
||||||
};
|
|
||||||
|
|
||||||
printf("xz: %d\n", xz);
|
|
||||||
|
|
||||||
printf("l: %s\n", l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
|
5
shake
5
shake
@ -29,6 +29,8 @@ usage() {
|
|||||||
echo -e "\t${YELLOW}@FILENAME${NORMAL} returns target-file (abc.x.txt)"
|
echo -e "\t${YELLOW}@FILENAME${NORMAL} returns target-file (abc.x.txt)"
|
||||||
echo -e "\t${YELLOW}@SHORT${NORMAL} returns target-file without suffix (^-> abc.x)"
|
echo -e "\t${YELLOW}@SHORT${NORMAL} returns target-file without suffix (^-> abc.x)"
|
||||||
echo -e "\t${YELLOW}@ARGS${NORMAL} returns ${GREEN}arguments${NORMAL}"
|
echo -e "\t${YELLOW}@ARGS${NORMAL} returns ${GREEN}arguments${NORMAL}"
|
||||||
|
echo -e "\t${YELLOW}@{${NORMAL}${BOLD}EXPUNGE_THIS_FILE${YELLOW}}${NORMAL} inline region to delete this or many files or directories,"
|
||||||
|
echo -e "\tnon-recursive, only one file per block, removed from left to right. This has no\n\tinfluence on the normal command execution.\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $# -lt 1 ]]; then
|
if [[ $# -lt 1 ]]; then
|
||||||
@ -79,8 +81,9 @@ if [[ -n $line ]]; then
|
|||||||
line=${line//@ARGS/$@}
|
line=${line//@ARGS/$@}
|
||||||
line=$(echo "$line" | sed 's/\W*@STOP.*//')
|
line=$(echo "$line" | sed 's/\W*@STOP.*//')
|
||||||
|
|
||||||
|
echo -e "${BOLD}${GREEN}$0${NORMAL}: ${line#*${MARK}}"
|
||||||
|
echo=$(echo "$line" | sed 's/@{\(.*\)\([^\\]\)}.*$/\1\2/')
|
||||||
command="${line#*${MARK}}"
|
command="${line#*${MARK}}"
|
||||||
echo -e "${BOLD}${GREEN}$0${NORMAL}: $command"
|
|
||||||
if [[ $run -eq 1 ]]; then
|
if [[ $run -eq 1 ]]; then
|
||||||
echo -e "${BOLD}${GREEN}output${NORMAL}:"
|
echo -e "${BOLD}${GREEN}output${NORMAL}:"
|
||||||
sh -c "$command"
|
sh -c "$command"
|
||||||
|
Loading…
Reference in New Issue
Block a user