commit 723c0edf4794a84b5960daef2ad8672a0e8dd7e2
parent 1a7be58c4a33d902102ebfef6c38465ea37f6ff2
Author: Remy Noulin <loader2x@gmail.com>
Date: Thu, 26 Dec 2019 08:28:32 +0100
when file in argument is not found, try to add c and cp extensions
when the executable filename is given instead of a C file, sheepy finds
the associated main source file
src/sheepy.c | 52 +++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 45 insertions(+), 7 deletions(-)
Diffstat:
| M | src/sheepy.c | | | 52 | +++++++++++++++++++++++++++++++++++++++++++++------- |
1 file changed, 45 insertions(+), 7 deletions(-)
diff --git a/src/sheepy.c b/src/sheepy.c
@@ -543,10 +543,29 @@ int MAIN(int ARGC, char** ARGV) {
sheepyRun:
if (!fileExists(mainFilename)) {
- puts(BLD RED "File not found:" RST);
- puts(mainFilename);
- XFAILURE
+ // add c and cp extension and check if file exists
+ dum = catS(mainFilename, ".c");
+ if (fileExists(dum)) {
+ // add c extension to mainFilename
+ free(dum);
+ pushG(&mainFilename, ".c");
+ }
+ else {
+ free(dum);
+ dum = catS(mainFilename, ".cp");
+ if (fileExists(dum)) {
+ // add cp extension to mainFilename
+ free(dum);
+ pushG(&mainFilename, ".cp");
+ }
+ else {
+ free(dum);
+ puts(BLD RED "File not found:" RST);
+ puts(mainFilename);
+ XFAILURE
}
+ }
+ }
if (isLink(mainFilename)) {
char *tmp = endlink(mainFilename);
@@ -580,10 +599,29 @@ int MAIN(int ARGC, char** ARGV) {
}
}
if (!isC(mainSrc) && !isCP(mainSrc)) {
- puts (BLD RED "Unknown extension. Stop." RST);
- puts(mainSrc);
- XFAILURE
+ // add c and cp extension and check if file exists
+ dum = catS(mainSrc, ".c");
+ if (fileExists(dum)) {
+ // add c extension to mainSrc
+ free(dum);
+ pushG(&mainSrc, ".c");
+ }
+ else {
+ free(dum);
+ dum = catS(mainSrc, ".cp");
+ if (fileExists(dum)) {
+ // add cp extension to mainSrc
+ free(dum);
+ pushG(&mainSrc, ".cp");
+ }
+ else {
+ free(dum);
+ puts(BLD RED "Unknown extension. Stop." RST);
+ puts(mainSrc);
+ XFAILURE
}
+ }
+ }
char *exePath = strdup(mainFilename);
if (isC(mainSrc)) {
@@ -1096,7 +1134,7 @@ int MAIN(int ARGC, char** ARGV) {
continue;
}
else {
- // puts("C AND O HAVE SAME DATE SKIP COMPILATION - CHECK IF H FILES ARE UPDATED");
+ // logP("C AND O HAVE SAME DATE - CHECK IF H FILES ARE UPDATED");
// check if h file for this c file is modified
// if not check if h files dependencies are modified
// execute the code below