Skip to content

Commit bd64579

Browse files
committed
fix: better punctuation of warnings emitted from igraph's C core, closes #838
1 parent 6208386 commit bd64579

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/_igraph/error.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,20 @@ PyObject* igraphmodule_handle_igraph_error() {
6161
void igraphmodule_igraph_warning_hook(const char *reason, const char *file,
6262
int line) {
6363
char buf[4096];
64-
snprintf(buf, sizeof(buf), "%s at %s:%i", reason, file, line);
64+
char end;
65+
size_t len = strlen(reason);
66+
const char* separator = " ";
67+
68+
if (len == 0) {
69+
separator = "";
70+
} else {
71+
end = reason[len - 1];
72+
if (end != '.' && end != '?' && end != '!') {
73+
separator = ". ";
74+
}
75+
}
76+
77+
snprintf(buf, sizeof(buf), "%s%sLocation: %s:%i", reason, separator, file, line);
6578
PY_IGRAPH_WARN(buf);
6679
}
6780

0 commit comments

Comments
 (0)