summaryrefslogtreecommitdiff
path: root/src/htsname.c
diff options
context:
space:
mode:
authorXavier Roche <xroche@users.noreply.github.com>2012-04-20 18:05:18 +0000
committerXavier Roche <xroche@users.noreply.github.com>2012-04-20 18:05:18 +0000
commitd50e290a22425e869c1141c3685079cb1dab7cb3 (patch)
tree986851ad151970c23204e7f6a425b56e8f4c8ef6 /src/htsname.c
parent21642978d71a7dc1f2b26a617f7babaf993492de (diff)
Replace // by / when saving rather than _/
Diffstat (limited to 'src/htsname.c')
-rw-r--r--src/htsname.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/htsname.c b/src/htsname.c
index a78efbe..1630f70 100644
--- a/src/htsname.c
+++ b/src/htsname.c
@@ -102,6 +102,23 @@ static const char *hts_tbdev[] =
opt->state._hts_in_html_parsing = prev; \
} while(0)
+/* Strip all // */
+static void cleanDoubleSlash(char *s) {
+ int i, j;
+ for(i = 0, j = 0 ; s[i] != '\0' ; i++) {
+ if (s[i] == '/' && i != 0 && s[i - 1] == '/') {
+ continue;
+ }
+ if (i != j) {
+ s[j] = s[i];
+ }
+ j++;
+ }
+ if (i != j) {
+ s[j] = s[i];
+ }
+}
+
// forme le nom du fichier à sauver (save) à partir de fil et adr
// système intelligent, qui renomme en cas de besoin (exemple: deux INDEX.HTML et index.html)
@@ -1197,8 +1214,9 @@ int url_savename(char* adr_complete, char* fil_complete, char* save,
}
//
{ // éliminer les // (comme ftp://)
- char* a;
- while( (a=strstr(save,"//")) ) *a='_';
+ //char* a;
+ //while( (a=strstr(save,"//")) ) *a='_';
+ cleanDoubleSlash(save);
// Eliminer chars spéciaux
a=save -1 ;
while(*(++a))