Revised names for lesser beings

This commit is contained in:
Emil 2023-08-16 12:27:46 -06:00
parent 26a160f6b0
commit 6c7ecaa390
No known key found for this signature in database
GPG Key ID: 5432DB986FDBCF8A

View File

@ -7,8 +7,8 @@
#define ALLOCATION_CHUNK (1024UL) #define ALLOCATION_CHUNK (1024UL)
#define ALLOCATION_LIMIT (1024UL * 1024UL) #define ALLOCATION_LIMIT (1024UL * 1024UL)
#ifndef PROGN #ifndef PROGRAM_NAME
# define PROGN "hl" # define PROGRAM_NAME "hl"
#endif #endif
enum { NORMAL, BOLD, DARKNESS, ITALIC, UNDERLINE, BLINK, DUNNO_6, REVERSE, INVISIBLE }; enum { NORMAL, BOLD, DARKNESS, ITALIC, UNDERLINE, BLINK, DUNNO_6, REVERSE, INVISIBLE };
@ -305,7 +305,7 @@ slurp(const char * fn)
b = malloc(len); b = malloc(len);
if (b && if (b &&
len != fread(b, 1, len, fp)) len != fread(b, 1, len, fp))
{ perror(PROGN); } { perror(PROGRAM_NAME); }
fclose(fp); fclose(fp);
return b; return b;
} }
@ -313,18 +313,14 @@ slurp(const char * fn)
{ return NULL; } { return NULL; }
} }
#define OPT(c,s) \ /* "Short" */
#define SHORT_OPT(c,s) \
if ((c == argv[0][0] && argv[0][1] == '\0') || \ if ((c == argv[0][0] && argv[0][1] == '\0') || \
0 == strncmp(argv[0], s, strlen(s))) 0 == strncmp(argv[0], s, strlen(s)))
#define SOPT(s) \ #define OPT(s) \
if (0 == strncmp(argv[0], s, strlen(s))) if (0 == strncmp(argv[0], s, strlen(s)))
/*
Valgrind: Depends on uninitialized value (buffer [0])...?
280 : } while ((buffer [buffer_size - 1] != '\0') || (buffer_size != ALLOCATION_LIMIT));
285 : while (buffer [offset] != '\0') {
*/
int main ( int main (
int argc, int argc,
char ** argv char ** argv
@ -336,16 +332,16 @@ int main (
while (++argv, --argc) { while (++argv, --argc) {
if (argv[0][0] == '-') { if (argv[0][0] == '-') {
argv[0]++; argv[0]++;
OPT ('?',"help") { SHORT_OPT ('?',"help") {
fprintf (stderr, PROGN ": hl [OPTIONS] FILES ...\n"); fprintf (stderr, PROGRAM_NAME ": hl [OPTIONS] FILES ...\n");
return (0); return (0);
} }
SOPT ("version") { OPT ("version") {
fprintf(stderr, PROGN ": Version 9000\n"); fprintf(stderr, PROGRAM_NAME ": Version 9000\n");
return (0); return (0);
} }
else { else {
fprintf (stderr, PROGN ": Unrecognized option '%s'\n", argv [0]); fprintf (stderr, PROGRAM_NAME ": Unrecognized option '%s'\n", argv [0]);
return (1); return (1);
} }
} else { } else {
@ -360,7 +356,7 @@ int main (
buffer = realloc (buffer, ALLOCATION_CHUNK); buffer = realloc (buffer, ALLOCATION_CHUNK);
#define MEMFAIL(v) if (v == NULL) { perror(PROGN); return (1); } #define MEMFAIL(v) if (v == NULL) { perror(PROGRAM_NAME); return (1); }
MEMFAIL(buffer); MEMFAIL(buffer);
do { do {