commit 3106fa352ee240777dda27af43806cfc979cdde4
parent ebe83ef8615f537a76f53f113ac9210abffc0462
Author: dwzg <dennis@wtzg.de>
Date: Wed, 22 Apr 2020 21:48:57 +0200
Fix trailing newline of product version
Diffstat:
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/paleofetch.c b/paleofetch.c
@@ -42,6 +42,11 @@ struct sysinfo my_sysinfo;
int title_length;
int status;
+void remove_newline(char *s) {
+ while (*(++s) != '\n');
+ *s = '\0';
+}
+
void halt_and_catch_fire(const char *message) {
if(status != 0) {
printf("%s\n", message);
@@ -155,10 +160,8 @@ char *get_host() {
fread(version, 1, BUF_SIZE, product_version);
fclose(product_version);
- // trim trailing newline
- char *s = host;
- while(*(++s) != '\n') ;
- *s = '\0';
+ remove_newline(host);
+ remove_newline(version);
strcat(host, " ");
strcat(host, version);