summaryrefslogtreecommitdiff
path: root/src/htstools.c
diff options
context:
space:
mode:
authorXavier Roche <xroche@users.noreply.github.com>2013-05-21 19:31:41 +0000
committerXavier Roche <xroche@users.noreply.github.com>2013-05-21 19:31:41 +0000
commit3e59977b2736dbe9a3c801882ec4f03a43af07b5 (patch)
treea03a1bf17406a22bf1ec5f3ba20c3390f280e9e5 /src/htstools.c
parent5fd71d61fcdad419f5cd7cb19acd200b4c483b2c (diff)
DOS 8+3 fixes.
Diffstat (limited to 'src/htstools.c')
-rw-r--r--src/htstools.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/htstools.c b/src/htstools.c
index 6f614b7..bb2915d 100644
--- a/src/htstools.c
+++ b/src/htstools.c
@@ -485,7 +485,7 @@ void longfile_to_83(int mode, char *n83, char *save) {
/:;?\#*~
0x00-0x1f and 0x80-0xff
*/
- for(i = 0; save[i] != 0; i++) {
+ for(i = 0, j = 0; save[i] != 0; i++) {
char a = save[i];
if (a >= 'a' && a <= 'z') {
@@ -494,10 +494,14 @@ void longfile_to_83(int mode, char *n83, char *save) {
if (!
((a >= 'A' && a <= 'Z') || (a >= '0' && a <= '9') || a == '_'
|| a == '.')) {
+ if (j != 0 && save[j - 1] == '_') {
+ continue; // avoid __
+ }
a = '_';
}
- save[i] = a;
+ save[j++] = a;
}
+ save[j] = '\0';
i = j = 0;
while((i < max) && (save[j]) && (save[j] != '.')) {