From ec0ed4013cd9e54455fc2f03666a3539b9f69f9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Wed, 3 Nov 1999 12:24:23 +0000 Subject: [PATCH] new SpaceLess function git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@279 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 5 +++++ src/support/filetools.C | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d697972ed..bb3b0416a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +1999-11-03 Lars Gullik Bjønnes + + * src/support/filetools.C (SpaceLess): yet another version of the + algorithm...now per Jean-Marc's suggestions. + 1999-11-02 Lars Gullik Bjønnes * src/support/filetools.C (SpaceLess): new version of the diff --git a/src/support/filetools.C b/src/support/filetools.C index 0ffc353683..311606bbba 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -74,16 +74,18 @@ string SpaceLess(string const & file) for (string::size_type i = 0; i < name.length(); ++i) { name[i] &= 0x7f; // set 8th bit to 0 - if (!isgraph(name[i])) name[i] = '_'; // get rid of cntrl chars }; + // ok so we scan through the string twice, but who cares. - string change("/"); + string keep("abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "@!\"'()*+,-./0123456789:;<=>?[]`|"); + string::size_type pos = 0; - while ((pos = name.find_first_of(change, pos)) != string::npos) { - name[pos] = '-'; + while ((pos = name.find_first_not_of(change, pos)) != string::npos) { + name[pos] = '_'; } - string temp = AddName(path, name); - return temp; + return AddName(path, name); } -- 2.39.2