Resolve compiler warning

This commit is contained in:
Night Kaly 2024-11-04 23:20:21 +00:00
parent 506ec0cb6d
commit abee9ec8fd
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM

10
nsh.c
View file

@ -236,6 +236,10 @@ int main(int argc, char **argv)
while (fgets(buffer, sizeof(buffer), f) != NULL) { while (fgets(buffer, sizeof(buffer), f) != NULL) {
if (ext && strcmp(ext, "c") == 0) { if (ext && strcmp(ext, "c") == 0) {
for (int i = 0; buffer[i] != '\0'; i++) { for (int i = 0; buffer[i] != '\0'; i++) {
if (buffer[i] == '\t') {
printf(" ");
continue;
}
if (buffer[i] == '\'') { if (buffer[i] == '\'') {
highlight_char(buffer, &i); highlight_char(buffer, &i);
continue; continue;
@ -245,9 +249,9 @@ int main(int argc, char **argv)
continue; continue;
} }
if (buffer[i] == '<') { if (buffer[i] == '<') {
if (buffer[i-1] != NULL && buffer[i-1] == 'e' || if ((buffer[i-1] != '\0' && buffer[i-1] == 'e') ||
(buffer[i-1] != NULL && buffer[i-1] == ' ' && (buffer[i-1] != '\0' && buffer[i-1] == ' ' &&
buffer[i-2] != NULL && buffer[i-2] == 'e')) { buffer[i-2] != '\0' && buffer[i-2] == 'e')) {
highlight_include(buffer, &i); highlight_include(buffer, &i);
continue; continue;
} }