summaryrefslogtreecommitdiffstats
path: root/src/util.cpp
diff options
context:
space:
mode:
authordimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2001-09-30 15:25:14 (GMT)
committerdimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2001-09-30 15:25:14 (GMT)
commite174524c861548adb3cfd48ef59a7a4551cd2bfb (patch)
treec28047dda40b8133ff1326d80fcf662cc8065c7e /src/util.cpp
parent86502f97ecaea3254217d723b5f10b6405495184 (diff)
downloadDoxygen-e174524c861548adb3cfd48ef59a7a4551cd2bfb.zip
Doxygen-e174524c861548adb3cfd48ef59a7a4551cd2bfb.tar.gz
Doxygen-e174524c861548adb3cfd48ef59a7a4551cd2bfb.tar.bz2
Release-1.2.11
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 764ab02..96944ff 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -891,26 +891,29 @@ void setAnchors(char id,MemberList *ml,int groupId)
//----------------------------------------------------------------------------
+/*! takes the \a buf of the given lenght \a len and converts CR LF (DOS)
+ * or CR (MAC) line ending to LF (Unix). Returns the length of the
+ * converted content (i.e. the same as \a len (Unix, MAC) or
+ * smaller (DOS).
+ */
int filterCRLF(char *buf,int len)
{
- char *ps=buf;
- char *pd=buf;
- char c;
- int i;
- for (i=0;i<len;i++)
+ int src = 0; // source index
+ int dest = 0; // destination index
+ char c; // current character
+
+ while (src<len)
{
- c=*ps++;
- if (c=='\r')
- {
- if (*ps=='\n') ps++; // DOS: CR+LF -> LF
- *pd++='\n'; // MAC: CR -> LF
- }
- else
+ c = buf[src++]; // Remember the processed character.
+ if (c == '\r') // CR to be solved (MAC, DOS)
{
- *pd++=c;
+ c = '\n'; // each CR to LF
+ if (src<len && buf[src] == '\n')
+ ++src; // skip LF just after CR (DOS)
}
+ buf[dest++] = c; // copy the (modified) character to dest
}
- return len+pd-ps;
+ return dest; // length of the valid part of the buf
}
/*! reads a file with name \a name and returns it as a string. If \a filter