Skip to content

Commit 5aee083

Browse files
committed
remove unused char* getline(char*& _lineptr, FILE* _stream), add couple of fixes M_PI
1 parent 6f4290b commit 5aee083

File tree

3 files changed

+6
-61
lines changed

3 files changed

+6
-61
lines changed

libs/EXTERNAL/libezgl/include/ezgl/graphics.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
#include <functional>
4040
#include <string>
4141
#include <vector>
42+
#ifdef _WIN32
43+
#define _USE_MATH_DEFINES // ensure (non-standard) value of M_PI is brought in from math.h
44+
#endif
4245
#include <cfloat>
4346
#include <cmath>
4447
#include <algorithm>

libs/libvtrutil/src/vtr_util.cpp

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -375,67 +375,6 @@ char* fgets(char* buf, int max_size, FILE* fp) {
375375
return nullptr;
376376
}
377377

378-
/**
379-
* @brief to get an arbitrary long input line and cut off any
380-
* comment part
381-
*
382-
* the getline function is exaly like the __get_delim function
383-
* in GNU with '\n' delimiter. As a result, to make the function
384-
* behaviour identical for Windows (\r\n) and Linux (\n) compiler
385-
* macros for checking operating systems have been used.
386-
*
387-
* @note user need to take care of the given pointer,
388-
* which will be dynamically allocated by getdelim
389-
*/
390-
char* getline(char*& _lineptr, FILE* _stream) {
391-
int i;
392-
int ch;
393-
size_t _n = 0;
394-
ssize_t nread;
395-
396-
#if defined(__unix__)
397-
nread = getdelim(&_lineptr, &_n, '\n', _stream);
398-
#elif defined(_WIN32)
399-
#define __WIN_NLTK "\r\n"
400-
nread = getdelim(&_lineptr, &_n, __WIN_NLTK, _stream);
401-
#endif
402-
403-
if (nread == -1) {
404-
int errsv = errno;
405-
std::string error_msg;
406-
407-
if (errsv == EINVAL)
408-
error_msg = string_fmt("[%s] Bad arguments (_lineptr is NULL, or _stream is not valid).", strerror(errsv));
409-
else if (errsv == ENOMEM)
410-
error_msg = string_fmt("[%s] Allocation or reallocation of the line buffer failed.", strerror(errsv));
411-
else
412-
/* end of file so it will return null */
413-
return nullptr;
414-
415-
/* getline was unsuccessful, so error */
416-
throw VtrError(string_fmt("Error -- %s\n",
417-
error_msg.c_str()),
418-
__FILE__, __LINE__);
419-
return nullptr;
420-
}
421-
422-
cont = 0; /* line continued? */
423-
file_line_number++; /* global variable */
424-
425-
for (i = 0; i < nread; i++) { /* Keep going until the line finishes */
426-
427-
ch = _lineptr[i];
428-
429-
if (ch == '#') { /* comment */
430-
_lineptr[i] = '\0';
431-
/* skip the rest of the line */
432-
break;
433-
}
434-
}
435-
436-
return (_lineptr);
437-
}
438-
439378
///@brief Returns line number of last opened and read file
440379
int get_file_line_number_of_last_opened_file() {
441380
return file_line_number;

vpr/src/draw/draw_basic.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#ifndef NO_GRAPHICS
55

66
#include <cstdio>
7+
#ifdef _WIN32
8+
#define _USE_MATH_DEFINES // ensure (non-standard) value of M_PI is brought in from math.h
9+
#endif
710
#include <cmath>
811
#include <algorithm>
912
#include <sstream>

0 commit comments

Comments
 (0)