Makefile now automatically updates the program_version variable before compilation based on the latest debian/changelog entry, since I always forget to update that variable

This commit is contained in:
Andrew S. Rightenburg 2023-04-10 01:17:05 -04:00
parent 6412fa138c
commit 6ebbe09ec8
6 changed files with 19 additions and 16 deletions

View File

@ -26,10 +26,6 @@ int main(int argc, char* argv[]) {
string program_name = "polonius";
string program_version = "0.1";
string program_author = "rail5";
string helpstring = "No help here.\n";
/*

View File

@ -16,10 +16,6 @@ int main(int argc, char* argv[]) {
string program_name = "polonius-editor";
string program_version = "0.3";
string program_author = "rail5";
string helpstring = program_name + " " + program_version + "\nCopyright (C) 2023 " + program_author + "\n\nThis is free software (GNU GPL 3), and you are welcome to redistribute it under certain conditions.\n\nUsage: " + program_name + " -i filename -a \"{INSTRUCTION}\"\n\nOptions:\n -i\n --input\n Specify input file to edit\n\n -a\n --add-instruction\n Instruct the program on how to edit your file\n Example instructions:\n REPLACE 5 hello world\n (Replaces text, starting from byte #5, with \"hello world\")\n INSERT 7 salut a tous\n (Inserts \"salut a tous\" at byte #7, shifting the rest of the file without replacing it)\n REMOVE 9 15\n (Removes bytes #9 to #15 from the file)\n\n -s\n --add-instruction-set\n Provide a set of multiple instructions for editing the file\n Each instruction in the set should be on its own line, as in the following example:\n --add-instruction-set \"REPLACE 20 hello world\n INSERT 50 hello again\n REMOVE 70 75\"\n\n -c\n --special-chars\n Interpret escaped character sequences (\\n, \\t and \\\\)\n\n -b\n --block-size\n Specify the amount of data from the file we're willing to load into memory at any given time\n Example:\n -b 10M\n -b 200K\n (Default 10 kilobytes)\n\n -v\n --verbose\n Verbose mode\n\n -V\n --version\n Print version number\n\n -h\n --help\n Display this message\n\nExamples:\n " + program_name + " --input ./file.txt --add-instruction \"REPLACE 20 hello \\n world\" --add-instruction \"REMOVE 10 12\" --block-size 10K --special-chars\n\n " + program_name + " -a \"insert 0 hello world\" ./file.txt\n";

View File

@ -1,5 +1,14 @@
all: reader editor curses
all: update-version reader editor curses
update-version:
# Read the latest version number from debian/changelog
# And update shared/version.h with that number
# This ensures that the output of the --version arg
# For each of the binaries is always up-to-date
# On each compilation
VERSION=`grep -P -o -e "([0-9\.]*)" debian/changelog | head -n 1`; \
echo "#define program_version \"$$VERSION\"" > shared/version.h
reader:
cd read && $(MAKE)
mv read/bin/polonius-reader ./

View File

@ -15,10 +15,6 @@ using namespace std;
int main(int argc, char* argv[]) {
string program_name = "polonius-reader";
string program_version = "0.3";
string program_author = "rail5";
string helpstring = program_name + " " + program_version + "\nCopyright (C) 2023 " + program_author + "\n\nThis is free software (GNU GPL 3), and you are welcome to redistribute it under certain conditions.\n\nUsage: " + program_name + " -i filename\n\nOptions:\n -i\n --input\n Specify input file to read\n\n -s\n --start\n Specify byte number to start reading from\n\n -l\n --length\n Specify how many bytes to read\n\n -b\n --block-size\n Specify the amount of data from the file we're willing to load into memory at any given time\n Example:\n -b 10M\n -b 200K\n (Default 10 kilobytes)\n\n -f\n --find\n --search\n Search for a string in the file\n If -s / --start is specified, the program will only search for matches after that start position\n If -l / --length is specified, the program will only search for matches within that length from the start\n Returns nothing (blank) if no matches were found\n\n -p\n --output-pos\n Output the start and end position, rather than the text (in the format \"start,end\", for example 10,15)\n If used with searches, this will output the start and end position of the search result\n Outside of searches, it will return the values of -s / --start and the end position (start + length)\n\n -V\n --version\n Print version number\n\n -h\n --help\n Display this message\n\nExamples:\n " + program_name + " --input ./file.txt --start 50 --length 10\n\n " + program_name + " -s 50 -l 10 ./file.txt\n\n " + program_name + " -i ./file.txt --start 75 --search \"hello world\" --length 10\n\n " + program_name + " ./file.txt -f \"hello world\" --output-pos\n";

View File

@ -1,7 +1,12 @@
// Basic info:
#include "version.h"
#define program_author "rail5"
// KEY_FRESH is used by the CLI for window updates
// Just a useless key that we ungetch() to overcome an input-eating issue with ncurses
#define KEY_FRESH 0X4FE
// Exit codes:
#define EXIT_SUCCESS 0
#define EXIT_BADFILE 1
#define EXIT_BADARG 2
@ -9,9 +14,9 @@
#define EXIT_OTHER 4
#define EXIT_INTERRUPT 5
// Clang doesn't have fopen64
#ifdef __clang__
#define fopen64 fopen
// clang doesn't have fopen64
// This might(?) mean that we can't open >2GB files on 32-bit systems which use clang/llvm
// Testing is needed
#endif

1
shared/version.h Normal file
View File

@ -0,0 +1 @@
#define program_version "0.4"