mirror of
https://github.com/moparisthebest/pacman
synced 2025-02-28 09:21:53 -05:00
Move mbasename from pacman.c to util.c
This function can be useful in other places. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
7d37d9278d
commit
11133da587
@ -229,28 +229,6 @@ static void cleanup(int signum)
|
||||
exit(signum);
|
||||
}
|
||||
|
||||
/** Parse the basename of a program from a path.
|
||||
* Grabbed from the uClibc source.
|
||||
* @param path path to parse basename from
|
||||
*
|
||||
* @return everything following the final '/'
|
||||
*/
|
||||
static char *mbasename(const char *path)
|
||||
{
|
||||
const char *s;
|
||||
const char *p;
|
||||
|
||||
p = s = path;
|
||||
|
||||
while (*s) {
|
||||
if (*s++ == '/') {
|
||||
p = s;
|
||||
}
|
||||
}
|
||||
|
||||
return (char *)p;
|
||||
}
|
||||
|
||||
/** Parse command-line arguments for each operation.
|
||||
* @param argc argc
|
||||
* @param argv argv
|
||||
|
@ -167,6 +167,28 @@ int rmrf(const char *path)
|
||||
}
|
||||
}
|
||||
|
||||
/** Parse the basename of a program from a path.
|
||||
* Grabbed from the uClibc source.
|
||||
* @param path path to parse basename from
|
||||
*
|
||||
* @return everything following the final '/'
|
||||
*/
|
||||
char *mbasename(const char *path)
|
||||
{
|
||||
const char *s;
|
||||
const char *p;
|
||||
|
||||
p = s = path;
|
||||
|
||||
while (*s) {
|
||||
if (*s++ == '/') {
|
||||
p = s;
|
||||
}
|
||||
}
|
||||
|
||||
return (char *)p;
|
||||
}
|
||||
|
||||
/* output a string, but wrap words properly with a specified indentation
|
||||
*/
|
||||
void indentprint(const char *str, int indent)
|
||||
|
@ -42,6 +42,7 @@ int needs_transaction();
|
||||
int getcols();
|
||||
int makepath(const char *path);
|
||||
int rmrf(const char *path);
|
||||
char *mbasename(const char *path);
|
||||
void indentprint(const char *str, int indent);
|
||||
char *strtoupper(char *str);
|
||||
char *strtrim(char *str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user