Get some of the last remaining C files into C++
They still need to be fixed up, but they now build with C++.
This commit is contained in:
23
dlib/dlib.cc
23
dlib/dlib.cc
@ -27,7 +27,7 @@
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "dlib.h"
|
||||
#include "dlib.hh"
|
||||
|
||||
static bool dLib_show_msg = TRUE;
|
||||
|
||||
@ -962,6 +962,27 @@ char *dGetline (FILE *stream)
|
||||
return line;
|
||||
}
|
||||
|
||||
std::optional< std::string >
|
||||
dGetline_string (FILE *stream)
|
||||
{
|
||||
int ch;
|
||||
Dstr *dstr;
|
||||
|
||||
if( stream == nullptr ) return std::nullopt;
|
||||
|
||||
dstr = dStr_sized_new(64);
|
||||
while ((ch = fgetc(stream)) != EOF) {
|
||||
dStr_append_c(dstr, ch);
|
||||
if (ch == '\n')
|
||||
break;
|
||||
}
|
||||
|
||||
std::optional< std::string > line;
|
||||
if(dstr->len) line= dstr->str;
|
||||
dStr_free(dstr, 1);
|
||||
return line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a FD handling EINTR.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user