Proper handling of tabs
This commit is contained in:
9
src/io.c
9
src/io.c
@@ -38,20 +38,11 @@ char *getline(struct linefile *file) {
|
|||||||
ret[len] = '\0';
|
ret[len] = '\0';
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if (c == '\t') {
|
|
||||||
do {
|
|
||||||
ret = append(ret, ' ', &len, &alloc);
|
|
||||||
if (ret == NULL)
|
|
||||||
return NULL;
|
|
||||||
} while (len % 4 != 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ret = append(ret, c, &len, &alloc);
|
ret = append(ret, c, &len, &alloc);
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
struct linefile *newlinefile(FILE *file) {
|
struct linefile *newlinefile(FILE *file) {
|
||||||
struct linefile *ret;
|
struct linefile *ret;
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ void identifyline(char *line, struct linedata *prev, struct linedata *ret) {
|
|||||||
}
|
}
|
||||||
if (prev->type != PLAIN) {
|
if (prev->type != PLAIN) {
|
||||||
for (i = 0; i < 4; ++i) {
|
for (i = 0; i < 4; ++i) {
|
||||||
if (!isspace(line[i]))
|
if (line[i] == '\t')
|
||||||
|
break;
|
||||||
|
if (line[i] != ' ')
|
||||||
goto notspacecode;
|
goto notspacecode;
|
||||||
}
|
}
|
||||||
ret->type = SPACECODE;
|
ret->type = SPACECODE;
|
||||||
|
|||||||
Reference in New Issue
Block a user