Skip to content

Commit

Permalink
GH-86 Fix default P4_CORE_PATH soas not to include the current
Browse files Browse the repository at this point in the history
working directory, which should be added only by the user if
needed.  Fix p4FindFilePath() initial check for an absolute or
relative path.  Fix FILE-PATH to NUL terminate the empty path.
Fix makefile files to not include the current directory.
  • Loading branch information
SirWumpus committed Dec 20, 2024
1 parent 73243aa commit c353b0e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion jni/makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bindir = @bindir@
libdir = @libdir@/post4

PROG = ${top_srcdir}/src/post4$E
POST4_PATH = .:${top_srcdir}/src:${top_srcdir}/examples
POST4_PATH = ${top_srcdir}/examples:${top_srcdir}/src

# Override from the command-line, eg. make DBG='-O0 -g'
DBG := @DBG@
Expand Down
4 changes: 2 additions & 2 deletions src/post4.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ p4FindFilePath(const char *path_list, size_t plen, const char *file, size_t flen
if ((str.string = calloc(1, PATH_MAX)) == NULL) {
goto error0;
}
/* Try the given file relative the current working directory. */
/* Try the given file directly. */
str.length = snprintf(str.string, PATH_MAX, "%.*s", (int)flen, file);
if (stat(str.string, &sb) == 0) {
if (strchr("./", *str.string) != NULL && stat(str.string, &sb) == 0) {
return str;
}
/* Path list supplied or use the default? */
Expand Down
2 changes: 1 addition & 1 deletion src/post4.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ extern "C" {
#endif

#ifndef P4_CORE_PATH
#define P4_CORE_PATH ".:/usr/pkg/lib/post4:/usr/local/lib/post4:/usr/lib/post4"
#define P4_CORE_PATH "/usr/local/lib/post4:/usr/pkg/lib/post4:/usr/lib/post4"
#endif

#ifndef P4_CORE_FILE
Expand Down
2 changes: 1 addition & 1 deletion src/post4.p4
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,7 @@ VARIABLE SCR
256 CONSTANT path_max

\ (S: <spaces>name -- )
: file-path CREATE 0 , path_max ALLOT DOES> @+ ;
: file-path CREATE 0 , 0 , path_max ALLOT DOES> @+ ;

\ (S: sd.path xt -- )
: set-file-path
Expand Down
2 changes: 1 addition & 1 deletion test/makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LIBS = @LIBS@

PROG = ${top_srcdir}/src/post4$E
WORDS = ${top_srcdir}/src/post4.p4
POST4_PATH = POST4_PATH='.:${top_srcdir}/src:${top_srcdir}/examples'
POST4_PATH = POST4_PATH='${top_srcdir}/examples:${top_srcdir}/src'

BUILT := `date +'%a, %d %b %Y %H:%M:%S %z'`

Expand Down

0 comments on commit c353b0e

Please sign in to comment.