[ 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:
parent
77d05524a9
commit
a8f60cccf6
2 changed files with 33 additions and 0 deletions
|
|
@ -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()
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue