-
-
Notifications
You must be signed in to change notification settings - Fork 206
feat: improve formatting of error messages from C #2515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
I've added punctuation at the end of most messages in the C core now, but a few are still left out. This is a nice-to-have aesthetic feature, it's not an absolute must unless you want to append extra text at the end of the message. We do correct for missing punctuation in both the Python and Mathematica interfaces. |
| /* Strip vendor/cigraph/src/ prefix from file path */ | ||
| static inline const char* simplify_file_path(const char* file) { | ||
| const char* prefix = "vendor/cigraph/src/"; | ||
| size_t prefix_len = strlen(prefix); | ||
|
|
||
| if (strncmp(file, prefix, prefix_len) == 0) { | ||
| return file + prefix_len; | ||
| } | ||
| return file; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /* Strip vendor/cigraph/src/ prefix from file path */ | |
| static inline const char* simplify_file_path(const char* file) { | |
| const char* prefix = "vendor/cigraph/src/"; | |
| size_t prefix_len = strlen(prefix); | |
| if (strncmp(file, prefix, prefix_len) == 0) { | |
| return file + prefix_len; | |
| } | |
| return file; | |
| } | |
| /* Strip vendor/cigraph/src/ prefix from file path. This prefix depends on the | |
| * build procedure, namely on the directory that the compiler is invoked from. */ | |
| static inline const char* simplify_file_path(const char *file) { | |
| const char prefix[] = "vendor/cigraph/src/"; | |
| const size_t prefix_len = sizeof(prefix) / sizeof(prefix[0]); | |
| if (strncmp(file, prefix, prefix_len) == 0) { | |
| return file + prefix_len; | |
| } | |
| return file; | |
| } |
You can get the length statically. It's good to have a comment about where this prefix comes from because it will change if changes are made to the build procedure. The reason it even appears (compared to the standard use of the C core) is the tweaked build procedure.
Isn't this already there with LGTM, but I didn't test. |
Fix #2202
One thing we might consider adding, is a period at the end of the message if it's not already there.