Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblongpath-rsync
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liblongpath
liblongpath-rsync
Commits
c127e8aa
Commit
c127e8aa
authored
Mar 25, 2002
by
Martin Pool
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test case for trim_trailing_slashes, and make it handle other cases.
parent
bf4e725d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
8 deletions
+90
-8
Makefile.in
Makefile.in
+6
-2
syscall.c
syscall.c
+10
-6
trimslash.test
testsuite/trimslash.test
+29
-0
trimslash.c
trimslash.c
+45
-0
No files found.
Makefile.in
View file @
c127e8aa
...
...
@@ -40,7 +40,7 @@ OBJS=$(OBJS1) $(OBJS2) $(DAEMON_OBJ) $(LIBOBJ) $(ZLIBOBJ) @BUILD_POPT@
TLS_OBJ
=
tls.o syscall.o lib/permstring.o
# Programs we must have to run the test cases
CHECK_PROGS
=
rsync tls getgroups
CHECK_PROGS
=
rsync tls getgroups
trimslash
# note that the -I. is needed to handle config.h when using VPATH
.c.o
:
...
...
@@ -75,6 +75,10 @@ tls: $(TLS_OBJ)
getgroups
:
getgroups.o
$(CC)
$(CFLAGS)
$(LDFLAGS)
-o
$@
$<
$(LIBS)
TRIMSLASH_OBJ
=
trimslash.o syscall.o
trimslash
:
$(TRIMSLASH_OBJ)
$(CC)
$(CFLAGS)
$(LDFLAGS)
-o
$@
$(TRIMSLASH_OBJ)
$(LIBS)
Makefile
:
Makefile.in configure config.status
echo
"WARNING: You need to run ./config.status --recheck"
...
...
@@ -92,7 +96,7 @@ proto:
cat
$(srcdir)
/
*
.c
$(srcdir)
/lib/compat.c |
awk
-f
$(srcdir)
/mkproto.awk
>
$(srcdir)
/proto.h
clean
:
cleantests
rm
-f
*
~
$(OBJS)
rsync
$(TLS_OBJ)
tls getgroups
rm
-f
*
~
$(OBJS)
rsync
$(TLS_OBJ)
$(CHECK_PROGS)
cleantests
:
rm
-rf
./testtmp
*
...
...
syscall.c
View file @
c127e8aa
...
...
@@ -113,15 +113,19 @@ int do_rename(char *fname1, char *fname2)
void
trim_trailing_slashes
(
char
*
name
)
{
char
*
p
;
int
l
;
/* Some BSD systems cannot make a directory if the name
* contains a trailing slash.
* <http://www.opensource.apple.com/bugs/X/BSD%20Kernel/2734739.html> */
if
(
!*
name
)
return
;
/* empty string */
p
=
strchr
(
name
,
'\0'
)
-
1
;
while
(
p
==
'/'
)
{
p
--
=
'\0'
;
/* Don't change empty string; and also we can't improve on
* "/" */
l
=
strlen
(
name
);
while
(
l
>
1
)
{
if
(
name
[
--
l
]
!=
'/'
)
break
;
name
[
l
]
=
'\0'
;
}
}
...
...
testsuite/trimslash.test
0 → 100644
View file @
c127e8aa
#! /bin/sh
# Copyright (C) 2002 by Martin Pool <mbp@samba.org>
# This program is distributable under the terms of the GNU GPL (see
# COPYING).
# Test tiny function to trim trailing slashes.
.
$srcdir
/
testsuite
/
rsync
.
fns
set
-
x
"
$TOOLDIR
/trimslash"
"/usr/local/bin"
"/usr/local/bin/"
"/usr/local/bin///"
\
"//a//"
"////"
\
"/Users/Wierd Macintosh Name/// Ooh, translucent plastic/"
\
>
"
$scratchdir
/slash.out"
diff
-
c
"
$scratchdir
/slash.out"
-
<<
EOF
/
usr
/
local
/
bin
/
usr
/
local
/
bin
/
usr
/
local
/
bin
//a
/
/
Users
/
Wierd
Macintosh
Name
/// Ooh, translucent plastic
EOF
exit
0
# last [] may have failed but if we get here then we've won
trimslash.c
0 → 100644
View file @
c127e8aa
/*
* Copyright (C) 2002 by Martin Pool
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "rsync.h"
/* These are to make syscall.o shut up. */
int
dry_run
=
0
;
int
read_only
=
1
;
int
list_only
=
0
;
/**
* @file trimslash.c
*
* Test harness; not linked into release.
**/
int
main
(
int
argc
,
char
**
argv
)
{
int
i
;
if
(
argc
<=
1
)
{
fprintf
(
stderr
,
"trimslash: needs at least one argument
\n
"
);
return
1
;
}
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
trim_trailing_slashes
(
argv
[
i
]);
/* modify in place */
printf
(
"%s
\n
"
,
argv
[
i
]);
}
return
0
;
}
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