From abee9ec8fdf86bb5c81231ebd6faec411d43ae47 Mon Sep 17 00:00:00 2001 From: night0721 Date: Mon, 4 Nov 2024 23:20:21 +0000 Subject: [PATCH] Resolve compiler warning --- nsh.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nsh.c b/nsh.c index 62ee84e..d9b7f7d 100644 --- a/nsh.c +++ b/nsh.c @@ -236,6 +236,10 @@ int main(int argc, char **argv) while (fgets(buffer, sizeof(buffer), f) != NULL) { if (ext && strcmp(ext, "c") == 0) { for (int i = 0; buffer[i] != '\0'; i++) { + if (buffer[i] == '\t') { + printf(" "); + continue; + } if (buffer[i] == '\'') { highlight_char(buffer, &i); continue; @@ -245,9 +249,9 @@ int main(int argc, char **argv) continue; } if (buffer[i] == '<') { - if (buffer[i-1] != NULL && buffer[i-1] == 'e' || - (buffer[i-1] != NULL && buffer[i-1] == ' ' && - buffer[i-2] != NULL && buffer[i-2] == 'e')) { + if ((buffer[i-1] != '\0' && buffer[i-1] == 'e') || + (buffer[i-1] != '\0' && buffer[i-1] == ' ' && + buffer[i-2] != '\0' && buffer[i-2] == 'e')) { highlight_include(buffer, &i); continue; }