Repositories » TXT0
Clone URL:  
Pushed to one repository · View In Graph Contained in v0.1 and tip

Prettyprinting .t docs fixed.

Changeset 2d83b2072450

Parent 9161201e6d94

by Rup Palchowdhury

Changes to 3 files · Browse files at 2d83b2072450 Showing diff from parent 9161201e6d94 Diff from another changeset...

Change 1 of 1 Show Entire File Makefile Stacked
 
56
57
58
59
60
 
 
 
 
56
57
58
 
 
59
60
61
@@ -56,5 +56,6 @@
   .PHONY: quicktest  quicktest: - ./t2mem <test/tinytrecdoc.txt | diff -q - test/tinytrecdoc.out - ./t2mem <test/smalltrecdoc.txt | diff -q - test/smalltrecdoc.out + ./t2mem <test/tiny.t | diff -q - test/tiny.out + ./t2mem <test/two.t | diff -q - test/two.out + ./t2mem <test/big.t | diff -q - test/big.out
Change 1 of 3 Show Entire File tok.c Stacked
 
54
55
56
57
 
58
59
60
 
61
62
63
 
90
91
92
93
94
95
96
97
98
99
100
 
 
 
 
 
 
 
101
102
103
104
105
106
107
108
109
110
111
 
 
 
 
 
 
 
 
 
 
 
 
112
113
114
 
116
117
118
119
120
121
122
 
 
123
124
125
 
126
127
 
54
55
56
 
57
58
59
 
60
61
62
63
 
90
91
92
 
 
 
 
 
 
 
 
93
94
95
96
97
98
99
100
101
102
103
 
 
 
 
 
 
 
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
 
120
121
122
 
123
124
125
126
127
128
129
 
130
131
132
@@ -54,10 +54,10 @@
 int writetok(Tok *tok, FILE *fp)  {   /* TODO: test n */ - int i, n; + int n;   Node *p;   Tokdoc *tokdoc; - n = fwrite(tok->header->block, 4, 8, fp); + n = fwrite(tok->header->block, 4, TOK_HEADER_BLOCKS, fp);   for (p = tok->list; p != NULL; p = p->next) {   tokdoc = p->data;   n = fwrite(tokdoc->header->block, @@ -90,25 +90,29 @@
   void _printtokheader(Tokheader *h)  { - printf("%16s %u\n", "Magic", h->block[MAGIC]); - printf("%16s %u\n", "CRC32", h->block[CRC32]); - printf("%16s %u\n", "Version", h->block[VERSION]); - printf("%16s %u\n", "Type", h->block[TYPE]); - printf("%16s %u\n", "Length", h->block[LENGTH]); - printf("%16s %u\n", "N", h->block[NUMDOCS]); - printf("%16s %u\n", "R", h->block[NUMRES]); - printf("%16s %u\n", "Offset", h->block[OFFSET]); + printf("%-2s %-10s %-1s %-1s %-10s %-10s %-2s %-2s\n", + "MG", "CRC", "V", "T", "BYTES", "N", "R", "BO"); + printf("%-2u %-10u %-1u %-1u %-10u %-10u %-2u %-2u\n", + h->block[MAGIC], h->block[CRC32], + h->block[VERSION], h->block[TYPE], + h->block[LENGTH], h->block[NUMDOCS], + h->block[NUMRES], h->block[OFFSET]);  }    void _printtokdocheader(Tokdocheader *h, int numres)  { - int i, size; - /* TODO */ - /* printf(""); */ - /* for (i = 0; i < numres; i++) */ - /* printf("%d ", h->block[i]); */ - for (i = 0; i < numres; i++) - printf("%u ", h->block[i]); + int i; + static int flag = 1; + if (flag) { + flag = 0; + printf("%-10s %-10s ", "CRC", "BYTES"); + for (i = 2; i < numres; i++) + printf("RSRC%-6u ", i); + printf("\n"); + } + for (i = 0; i < numres; i++) + printf("%-10u ", h->block[i]); + printf("\n");  }    void printtok(Tok *tok) @@ -116,12 +120,13 @@
  Node *p;   Tokdoc *tokdoc;   _printtokheader(tok->header); - printf("\n");   for (p = tok->list; p != NULL; p = p->next) {   tokdoc = p->data;   _printtokdocheader(tokdoc->header, tok->header->block[NUMRES]); + /* Avoid printing a huge doc */ + /*   ((char *)tokdoc->buf->b)[tokdoc->buf->i] = '\0';   printf(":%s:\n", tokdoc->buf->b); - printf("\n"); + */   }  }
Change 1 of 3 Show Entire File tok.h Stacked
 
1
2
 
3
4
5
 
7
8
9
10
11
12
13
 
14
15
16
 
37
38
39
40
 
41
 
1
 
2
3
4
5
 
7
8
9
 
 
 
 
10
11
12
13
 
34
35
36
 
37
38
@@ -1,5 +1,5 @@
 #define TOK_HEADER_BLOCKS 8 -#define TOKDOC_HEADER_BLOCKS 12 +#define TOKDOC_HEADER_BLOCKS 3    typedef struct Tok Tok;  typedef struct Tokheader Tokheader; @@ -7,10 +7,7 @@
 typedef struct Tokdoc Tokdoc;  typedef enum {TREC_ADHOC, TREC_WEB, TREC_TWITTER} E_doctype;  typedef enum {MAGIC, CRC32, VERSION, TYPE, LENGTH, NUMDOCS, NUMRES, OFFSET} E_tokheader; -typedef enum {RES0CRC32, RES1DOCLEN, RES2IDLEN, - RES3, RES4, RES5, - RES6, RES7, RES8, RES9, RES10} E_tokdocheader; - +typedef enum {RES0CRC32, RES1DOCLEN, RES2IDLEN} E_tokdocheader;    struct Tokheader {   uint32_t block[TOK_HEADER_BLOCKS]; @@ -37,5 +34,5 @@
 int writetok(Tok*, FILE*);  int readtok(Tok*, FILE*);  void _printtokheader(Tokheader*); -void _printtokdocheader(Tokdocheader*, int); +void _printtokdocheader(Tokdocheader*, int numres);  void printtok(Tok*);