comment commit
This commit is contained in:
parent
a101d14f7c
commit
6b6bff365a
48
baked.c
48
baked.c
@ -20,24 +20,19 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/* Require space after @ABC and before STOP@ (no space required around newline) */
|
||||||
#define REQUIRE_SPACE
|
#define REQUIRE_SPACE
|
||||||
#define NEWLINE "\n"
|
|
||||||
|
|
||||||
#ifdef SHAKE_COMPAT
|
# define OTHER_START "@COMPILECMD"
|
||||||
# define START "@COMPILECMD"
|
|
||||||
# define STOP "STOP@"
|
|
||||||
# define HELP \
|
|
||||||
"target-file [arguments ...]\n" \
|
|
||||||
"Use the format `@COMPILECMD command ...\n' (STOP@ suffix supported) within the target-file\n"
|
|
||||||
#else
|
|
||||||
/* Neo-format, as suggested by Anon, as it seems to be an unspoken standard
|
|
||||||
to prefix external special macros with @ (see code analyzing tools, doctools, etc.) */
|
|
||||||
# define START "@EXEC"
|
# define START "@EXEC"
|
||||||
# define STOP "STOP@"
|
# define STOP "STOP@"
|
||||||
# define HELP \
|
# define HELP \
|
||||||
"target-file [arguments ...]\n" \
|
"target-file [arguments ...]\n" \
|
||||||
"Use the format `@EXEC command ... STOP@' within the target-file\n"
|
"Use the format `@EXEC cmd ...' within the target-file, this will execute the\n" \
|
||||||
#endif
|
"rest of line, or if found within the file, until the STOP@ marker. You may use\n" \
|
||||||
|
"@COMPILECMD instead of @EXEC. Whitespace is required after and before both\n" \
|
||||||
|
"operators always.\n"
|
||||||
|
|
||||||
|
|
||||||
#define DESC \
|
#define DESC \
|
||||||
"Options [Must always be first]\n" \
|
"Options [Must always be first]\n" \
|
||||||
@ -84,27 +79,46 @@ find_region(const char * fn)
|
|||||||
if (addr != MAP_FAILED)
|
if (addr != MAP_FAILED)
|
||||||
{
|
{
|
||||||
start = find(START, addr, s.st_size, strlen(START));
|
start = find(START, addr, s.st_size, strlen(START));
|
||||||
|
if (!start)
|
||||||
|
{
|
||||||
|
start = find(OTHER_START, addr, s.st_size, strlen(OTHER_START));
|
||||||
|
start = start - strlen(START) + strlen(OTHER_START) * (start != 0);
|
||||||
|
}
|
||||||
if (start)
|
if (start)
|
||||||
{
|
{
|
||||||
start += strlen(START);
|
start += strlen(START);
|
||||||
#ifdef REQUIRE_SPACE
|
#ifdef REQUIRE_SPACE
|
||||||
if (!isspace(*start))
|
if (!isspace(*start))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR: Found @START token without suffix spacing.\n");
|
fprintf(stderr, "ERROR: Found start without suffix spacing.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
stop = find(STOP, start, s.st_size - (start - addr), strlen(STOP));
|
stop = find(STOP, start, s.st_size - (start - addr), strlen(STOP));
|
||||||
/* NOTE this is assuming the last line of the a file is
|
|
||||||
terminated with a newline, per unix tradition. */
|
|
||||||
if (!stop)
|
if (!stop)
|
||||||
{ stop = find(NEWLINE, start, s.st_size - (start - addr), 1); }
|
{
|
||||||
|
stop = start;
|
||||||
|
while (*stop && *stop == '\n'
|
||||||
|
/* && !(*stop == '\r' */
|
||||||
|
/* || *stop == '\n') */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (stop[0] == '\\')
|
||||||
|
{
|
||||||
|
if (stop[1] == '\n')
|
||||||
|
{ stop += 2; }
|
||||||
|
/* else if (stop[1] == '\r' && stop[2] == '\n') */
|
||||||
|
/* { stop += 3; } */
|
||||||
|
}
|
||||||
|
++stop;
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifdef REQUIRE_SPACE
|
#ifdef REQUIRE_SPACE
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!isspace(*(stop - 1)))
|
if (!isspace(*(stop - 1)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR: Found STOP@ token without prefixing spacing.\n");
|
fprintf(stderr, "ERROR: Found stop without prefixing spacing.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user