Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-19fa
git_rec_nano
Commits
f48e15f2
Commit
f48e15f2
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: rename and shorten a small helper function
parent
6d873d37
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/browser.c
+10
-14
src/browser.c
src/proto.h
+1
-1
src/proto.h
with
11 additions
and
15 deletions
+11
-15
src/browser.c
View file @
f48e15f2
...
...
@@ -297,7 +297,7 @@ char *do_browser(char *path)
/* If we are moving up one level, remember where we came from, so
* this directory can be highlighted and easily reentered. */
if
(
strcmp
(
tail
(
filelist
[
selected
]),
".."
)
==
0
)
present_name
=
strip
onedir
(
filelist
[
selected
]);
present_name
=
strip
_last_component
(
filelist
[
selected
]);
/* Try opening and reading the selected directory. */
path
=
mallocstrcpy
(
path
,
filelist
[
selected
]);
...
...
@@ -353,7 +353,7 @@ char *do_browse_from(const char *inpath)
* at all. If so, we'll just pass the current directory to
* do_browser(). */
if
(
stat
(
path
,
&
st
)
==
-
1
||
!
S_ISDIR
(
st
.
st_mode
))
{
path
=
free_and_assign
(
path
,
strip
onedir
(
path
));
path
=
free_and_assign
(
path
,
strip
_last_component
(
path
));
if
(
stat
(
path
,
&
st
)
==
-
1
||
!
S_ISDIR
(
st
.
st_mode
))
{
char
*
currentdir
=
charalloc
(
PATH_MAX
+
1
);
...
...
@@ -781,21 +781,17 @@ void do_last_file(void)
selected
=
filelist_len
-
1
;
}
/* Strip one directory from the end of path, and return the stripped
* path. The returned string is dynamically allocated, and should be
* freed. */
char
*
striponedir
(
const
char
*
path
)
/* Strip one element from the end of path, and return the stripped path.
* The returned string is dynamically allocated, and should be freed. */
char
*
strip_last_component
(
const
char
*
path
)
{
char
*
retval
,
*
tmp
;
char
*
copy
=
mallocstrcpy
(
NULL
,
path
);
char
*
last_slash
=
strrchr
(
copy
,
'/'
);
retval
=
mallocstrcpy
(
NULL
,
path
);
if
(
last_slash
!=
NULL
)
*
last_slash
=
'\0'
;
tmp
=
strrchr
(
retval
,
'/'
);
if
(
tmp
!=
NULL
)
null_at
(
&
retval
,
tmp
-
retval
);
return
retval
;
return
copy
;
}
#endif
/* !DISABLE_BROWSER */
This diff is collapsed.
Click to expand it.
src/proto.h
View file @
f48e15f2
...
...
@@ -178,7 +178,7 @@ void do_filesearch(void);
void
do_fileresearch
(
void
);
void
do_first_file
(
void
);
void
do_last_file
(
void
);
char
*
strip
onedir
(
const
char
*
path
);
char
*
strip
_last_component
(
const
char
*
path
);
#endif
/* Most functions in chars.c. */
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment