From: nishi Date: Sat, 15 Jun 2024 01:19:38 +0000 (+0000) Subject: indent works X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=d08ab34cd4624de52255bcb653484c893688b181;p=dataworks.git indent works git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@306 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Document/README.FMT b/Document/README.FMT index c2cb8c3..4e47c01 100644 --- a/Document/README.FMT +++ b/Document/README.FMT @@ -1,3 +1,10 @@ \" $Id$ DataWorks Users' Manual \hline + +Index +\hline +\indent 4 +test +test +\indent diff --git a/Tool/docfmt.c b/Tool/docfmt.c index c1ab681..b3fb0c4 100644 --- a/Tool/docfmt.c +++ b/Tool/docfmt.c @@ -58,6 +58,7 @@ int process_doc(void) { char* full = malloc(1); full[0] = 0; char* str; + int indent = 0; str = malloc(1); str[0] = 0; @@ -72,7 +73,18 @@ int process_doc(void) { } if(cbuf[0] == '\n') { if(str[0] == '\\') { - if(strcmp(str, "\\hline") == 0) { + char* cmd = str; + char* val = NULL; + int i; + for(i = 0; str[i] != 0; i++){ + if(str[i] == ' '){ + str[i] = 0; + val = str + i + 1; + break; + } + } + if(strcmp(cmd, "\\hline") == 0) { + } else if(strcmp(cmd, "\\indent") == 0) { } else if(str[1] == '"') { } else { fprintf(stderr, "Invalid command. Aborted\n"); @@ -99,10 +111,22 @@ int process_doc(void) { if(cbuf[0] == 0) break; if(cbuf[0] == '\n') { if(str[0] == '\\') { - if(strcmp(str, "\\hline") == 0) { + char* cmd = str; + char* val = NULL; + int i; + for(i = 0; str[i] != 0; i++){ + if(str[i] == ' '){ + str[i] = 0; + val = str + i + 1; + break; + } + } + if(strcmp(cmd, "\\hline") == 0) { int i; for(i = 0; i < 79; i++) fprintf(out, "="); fprintf(out, "\n"); + } else if(strcmp(cmd, "\\indent") == 0) { + indent = val == NULL ? 0 : atoi(val); } else if(str[1] == '"') { } else { fprintf(stderr, "Invalid command. Aborted\n"); @@ -110,6 +134,8 @@ int process_doc(void) { return 1; } } else { + int i; + for(i = 0; i < indent; i++) fprintf(out, " "); fprintf(out, "%s\n", str); } free(str);