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

@ -4,5 +4,5 @@ AM_CPPFLAGS = \
noinst_LIBRARIES = libDlib.a
libDlib_a_SOURCES = \
dlib.h \
dlib.hh \
dlib.cc

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

View File

@ -6,7 +6,8 @@
#include <stdarg.h> /* for va_list */
#include <string.h> /* for strerror */
#include <stdbool.h>
#include <string>
#include <optional>
#include "d_size.h"
@ -184,6 +185,7 @@ void dLib_show_messages(bool show);
*/
char *dGetcwd(void);
char *dGethomedir(void);
std::optional< std::string > dGetline_string(FILE *stream);
char *dGetline(FILE *stream);
int dClose(int fd);
int dUsleep(unsigned long us);