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:
2025-08-23 02:09:47 -04:00
parent e4f1102e32
commit f283391b46
78 changed files with 172 additions and 144 deletions

View File

@ -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.
*/