]> Nishi Git Mirror - dataworks.git/commitdiff
indent works
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sat, 15 Jun 2024 01:19:38 +0000 (01:19 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sat, 15 Jun 2024 01:19:38 +0000 (01:19 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@306 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Document/README.FMT
Tool/docfmt.c

index c2cb8c389d83f4db7b7584f6ea328fc9c69e4200..4e47c017d2abc5ead85ad56329d3bac551d8eef1 100644 (file)
@@ -1,3 +1,10 @@
 \" $Id$
 DataWorks Users' Manual
 \hline
+
+Index
+\hline
+\indent 4
+test
+test
+\indent
index c1ab681397a4cbad54dec3c1db7c829cbd906331..b3fb0c48114f7dd9fbe932f179f9212e733da363 100644 (file)
@@ -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);