Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Shapiro
cmucl
Commits
4187a2f3
Commit
4187a2f3
authored
21 years ago
by
toy
Browse files
Options
Downloads
Patches
Plain Diff
Search PATH for the lisp binary and lisp.core as a last resort. Based
mostly on a patch From Mike McDonald.
parent
6539163f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lisp/lisp.c
+88
-13
88 additions, 13 deletions
lisp/lisp.c
with
88 additions
and
13 deletions
lisp/lisp.c
+
88
−
13
View file @
4187a2f3
/*
/*
* main() entry point for a stand alone lisp image.
* main() entry point for a stand alone lisp image.
*
*
* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/lisp.c,v 1.3
2
2003/0
7/28 18:52:15
toy Exp $
* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/lisp.c,v 1.3
3
2003/0
8/04 21:27:30
toy Exp $
*
*
*/
*/
...
@@ -97,6 +97,13 @@ static char* cmucllib_search_list[] =
...
@@ -97,6 +97,13 @@ static char* cmucllib_search_list[] =
NULL
NULL
};
};
/*
* Define this to get some debugging printfs for searching for the
* lisp core file. Sometimes needed because you can't debug this with
* gdb which always seems to set argv[0] to the full pathname.
*/
/* #define DEBUG_LISP_SEARCH */
/*
/*
* From the current location of the lisp executable, create a suitable
* From the current location of the lisp executable, create a suitable
...
@@ -108,17 +115,17 @@ default_cmucllib(const char const* argv0arg)
...
@@ -108,17 +115,17 @@ default_cmucllib(const char const* argv0arg)
char
*
p
;
char
*
p
;
char
*
defpath
;
char
*
defpath
;
char
*
cwd
;
char
*
cwd
;
char
*
argv0
=
strdup
(
argv0arg
);
char
*
argv0
_dir
=
strdup
(
argv0arg
);
/*
/*
* From argv[0], create the appropriate directory by lopping off the
* From argv[0], create the appropriate directory by lopping off the
* executable name
* executable name
*/
*/
p
=
strrchr
(
argv0
,
'/'
);
p
=
strrchr
(
argv0
_dir
,
'/'
);
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
*
argv0
=
'\0'
;
*
argv0
_dir
=
'\0'
;
}
else
if
(
p
!=
argv0
)
{
}
else
if
(
p
!=
argv0
_dir
)
{
*
p
=
'\0'
;
*
p
=
'\0'
;
}
}
...
@@ -126,22 +133,85 @@ default_cmucllib(const char const* argv0arg)
...
@@ -126,22 +133,85 @@ default_cmucllib(const char const* argv0arg)
* Create the full pathname of the directory containing the
* Create the full pathname of the directory containing the
* executable. argv[0] can be an absolute or relative path.
* executable. argv[0] can be an absolute or relative path.
*/
*/
if
(
argv0
[
0
]
==
'/'
)
{
#ifdef DEBUG_LISP_SEARCH
cwd
=
malloc
(
strlen
(
argv0
)
+
2
);
fprintf
(
stderr
,
"argv[0] = %s
\n
"
,
argv0arg
);
strcpy
(
cwd
,
argv0
);
fprintf
(
stderr
,
"argv_dir = %s
\n
"
,
argv0_dir
);
#endif
if
(
argv0_dir
[
0
]
==
'/'
)
{
cwd
=
malloc
(
strlen
(
argv0_dir
)
+
2
);
strcpy
(
cwd
,
argv0_dir
);
strcat
(
cwd
,
"/"
);
strcat
(
cwd
,
"/"
);
}
else
{
#ifdef DEBUG_LISP_SEARCH
fprintf
(
stderr
,
"absolute path, argv[0] = %s
\n
"
,
cwd
);
#endif
}
else
if
(
*
argv0_dir
!=
'\0'
)
{
/*
/*
* argv[0] is a relative path. Get the current directory and
* argv[0] is a relative path. Get the current directory and
* append argv[0], after stripping off the executable name.
* append argv[0], after stripping off the executable name.
*/
*/
cwd
=
malloc
(
MAXPATHLEN
+
strlen
(
argv0
)
+
100
);
cwd
=
malloc
(
MAXPATHLEN
+
strlen
(
argv0
_dir
)
+
100
);
getcwd
(
cwd
,
MAXPATHLEN
);
getcwd
(
cwd
,
MAXPATHLEN
);
strcat
(
cwd
,
"/"
);
strcat
(
cwd
,
"/"
);
if
(
*
argv0
!=
'\0'
)
{
if
(
*
argv0
_dir
!=
'\0'
)
{
strcat
(
cwd
,
argv0
);
strcat
(
cwd
,
argv0
_dir
);
strcat
(
cwd
,
"/"
);
strcat
(
cwd
,
"/"
);
}
}
#ifdef DEBUG_LISP_SEARCH
fprintf
(
stderr
,
"relative path, argv[0] = %s
\n
"
,
cwd
);
#endif
}
else
{
/*
* argv[0] is someplace on the user's PATH
*
*/
char
*
path
=
getenv
(
"PATH"
);
char
*
p1
,
*
p2
=
NULL
;
struct
stat
buf
;
#ifdef DEBUG_LISP_SEARCH
fprintf
(
stderr
,
"User's PATH = %s
\n
"
,
path
);
#endif
cwd
=
malloc
(
MAXPATHLEN
+
strlen
(
argv0arg
)
+
100
);
if
(
p
==
NULL
)
{
p
=
argv0arg
;
}
for
(
p1
=
path
;
*
p1
!=
'\0'
;
p1
=
p2
)
{
p2
=
strchr
(
p1
,
':'
);
if
(
p2
==
NULL
)
p2
=
p1
+
strlen
(
p1
);
strncpy
(
cwd
,
p1
,
p2
-
p1
);
cwd
[
p2
-
p1
]
=
'/'
;
cwd
[
p2
-
p1
+
1
]
=
'\0'
;
strcpy
(
cwd
+
(
p2
-
p1
+
1
),
p
);
#ifdef DEBUG_LISP_SEARCH
fprintf
(
stderr
,
"User's PATH, trying %s
\n
"
,
cwd
);
#endif
if
(
stat
(
cwd
,
&
buf
)
==
0
)
{
#ifdef DEBUG_LISP_SEARCH
fprintf
(
stderr
,
"User's PATH, found %s
\n
"
,
cwd
);
#endif
break
;
}
if
(
*
p2
==
':'
)
{
p2
++
;
}
}
if
(
p1
==
p2
)
{
cwd
[
0
]
=
'\0'
;
}
else
{
cwd
[
p2
-
p1
+
1
]
=
'\0'
;
}
#ifdef DEBUG_LISP_SEARCH
fprintf
(
stderr
,
"User's PATH, Final cwd %s
\n
"
,
cwd
);
#endif
}
}
/* Create the appropriate value for CMUCLLIB */
/* Create the appropriate value for CMUCLLIB */
...
@@ -189,7 +259,7 @@ default_cmucllib(const char const* argv0arg)
...
@@ -189,7 +259,7 @@ default_cmucllib(const char const* argv0arg)
}
}
}
}
free
(
argv0
);
free
(
argv0
_dir
);
free
(
cwd
);
free
(
cwd
);
return
defpath
;
return
defpath
;
...
@@ -227,6 +297,10 @@ search_core(const char* lib, const char* default_core)
...
@@ -227,6 +297,10 @@ search_core(const char* lib, const char* default_core)
*
dst
++
=
'/'
;
*
dst
++
=
'/'
;
strcpy
(
dst
,
default_core
);
strcpy
(
dst
,
default_core
);
/* If it exists, we are done! */
/* If it exists, we are done! */
#ifdef DEBUG_LISP_SEARCH
fprintf
(
stderr
,
"Looking at `%s'
\n
"
,
buf
);
#endif
if
(
stat
(
buf
,
&
statbuf
)
==
0
)
{
if
(
stat
(
buf
,
&
statbuf
)
==
0
)
{
return
buf
;
return
buf
;
}
}
...
@@ -453,6 +527,7 @@ int main(int argc, char *argv[], char *envp[])
...
@@ -453,6 +527,7 @@ int main(int argc, char *argv[], char *envp[])
fprintf
(
stderr
,
" %s"
,
core
);
fprintf
(
stderr
,
" %s"
,
core
);
}
}
fprintf
(
stderr
,
"
\n
"
);
fprintf
(
stderr
,
"
\n
"
);
fprintf
(
stderr
,
"Based on lisp binary path `%s'
\n
"
,
argv
[
0
]);
exit
(
1
);
exit
(
1
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment