diff --git a/SWIG/Source/DOH/doh.h b/SWIG/Source/DOH/doh.h index b3543bf77..d724a4843 100644 --- a/SWIG/Source/DOH/doh.h +++ b/SWIG/Source/DOH/doh.h @@ -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 diff --git a/SWIG/Source/DOH/fio.c b/SWIG/Source/DOH/fio.c index d42be5fa4..391396755 100644 --- a/SWIG/Source/DOH/fio.c +++ b/SWIG/Source/DOH/fio.c @@ -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() *