[ 829317 ] Adds DohSplitLines function

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5214 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2003-10-31 17:36:37 +00:00
commit a8f60cccf6
2 changed files with 33 additions and 0 deletions

View file

@ -99,6 +99,7 @@
#define DohNewHash DOH_NAMESPACE(NewHash)
#define DohNewVoid DOH_NAMESPACE(NewVoid)
#define DohSplit DOH_NAMESPACE(Split)
#define DohSplitLines DOH_NAMESPACE(SplitLines)
#define DohNone DOH_NAMESPACE(None)
#define DohCall DOH_NAMESPACE(Call)
#define DohObjMalloc DOH_NAMESPACE(ObjMalloc)
@ -304,6 +305,7 @@ extern DOHHash *DohNewHash();
extern DOHVoid *DohNewVoid(void *ptr, void (*del)(void *));
extern DOHList *DohSplit(DOHFile *input, char ch, int nsplits);
extern DOHList *DohSplitLines(DOHFile *input);
extern DOH *DohNone;
extern void DohMemoryDebug(void);
@ -378,6 +380,7 @@ extern void DohMemoryDebug(void);
#define Strchr DohStrchr
#define Copyto DohCopyto
#define Split DohSplit
#define SplitLines DohSplitLines
#define Setmark DohSetmark
#define Getmark DohGetmark
#define None DohNone

View file

@ -496,6 +496,36 @@ DohSplit(DOH *in, char ch, int nsplits) {
return list;
}
/* -----------------------------------------------------------------------------
* DohSplitLines()
*
* Split an input stream into a list of strings delimited by newline characters.
* ----------------------------------------------------------------------------- */
DOH *
DohSplitLines(DOH *in) {
DOH *list;
DOH *str;
int c = 0;
list = NewList();
if (DohIsString(in)) {
Seek(in,0,SEEK_SET);
}
while (c != EOF) {
str = NewString("");
while ((c = Getc(in)) != '\n' && c != EOF) {
Putc(c, str);
}
Append(list,str);
Delete(str);
}
return list;
}
/* -----------------------------------------------------------------------------
* DohReadline()
*