Megatest

Check-in [14e26aaf81]
Login
Overview
Comment:Added ability to have row keys containing spaces in refdb
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.55
Files: files | file ages | folders
SHA1: 14e26aaf817f7a44539c2aafc95b3c725e89b275
User & Date: matt on 2014-05-01 23:00:09
Other Links: branch diff | manifest | tags
Context
2014-05-02
09:18
Fixed bug on handling of an empty sheet in refdb check-in: 1f7e2b9d5c user: mrwellan tags: v1.55
2014-05-01
23:00
Added ability to have row keys containing spaces in refdb check-in: 14e26aaf81 user: matt tags: v1.55
22:38
Added incremental save when using refdb edit check-in: 1d18479410 user: matt tags: v1.55
Changes

Modified txtdb/txtdb.scm from [8d9f4328c7] to [3b218e28e0].

111
112
113
114
115
116
117
118

119
120
121
122
123
124
125
126
127


128

129
130
131
132
133
134
135
111
112
113
114
115
116
117

118
119
120
121
122
123
124
125
126
127
128
129

130
131
132
133
134
135
136
137







-
+









+
+
-
+







							  (hash-table-ref/default cols colname '()))))))))
	      cells)
    (let ((ref-colnums (map (lambda (c)
			      (list (cdr c)(car c)))
			    (hash-table->alist colnums))))
      (with-output-to-file (conc targdir "/" sheet-name ".dat")
	(lambda ()
	  (print "[" col0title "]")
	  (if (not (string-null? col0title))(print "[" col0title "]"))
	  (for-each (lambda (colname)
		      (print "[" colname "]")
		      (for-each (lambda (row)
				  (let ((key (car row))
					(val (cadr row)))
				    (if (string-search comment-rx key)
					(print val)
					(if (string-search blank-rx key)
					    (print)
					    (if (string-search " " key)
						(print "\"" key "\" " val)
					    (print key " " val)))))
						(print key " " val))))))
				(reverse (hash-table-ref cols colname)))
		      ;; (print)
		      )
		    (sort (hash-table-keys cols)(lambda (a b)
						  (let ((colnum-a (assoc a ref-colnums))
							(colnum-b (assoc b ref-colnums)))
						    (if (and colnum-a colnum-b)
215
216
217
218
219
220
221

222
223
224
225
226
227
228
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231







+








(define (hash-table-reverse-lookup ht val)
  (hash-table-fold ht (lambda (k v res)(if (equal? v val) k res)) #f))

(define (read-dat fname)
  (let ((section-rx  (regexp "^\\[(.*)\\]\\s*$"))
	(comment-rx  (regexp "^#.*"))          ;; This means a cell name cannot start with #
	(quoted-cell-rx (regexp "^\"([^\"]*)\" (.*)$"))
	(cell-rx     (regexp "^(\\S+) (.*)$")) ;; One space only for the cellname content separator 
	(blank-rx    (regexp "^\\s*$"))
	(continue-rx (regexp ".*\\\\$"))
	(var-no-val-rx (regexp "^(\\S+)\\s*$"))
	(inp         (open-input-file fname))
	(cmnt-indx   (make-hash-table))
	(blnk-indx   (make-hash-table))
250
251
252
253
254
255
256



257
258
259
260
261
262
263
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269







+
+
+







					  (cons (list (conc "#BLNK" curr-indx) section " ") res))))
	   (section-rx (x sname)  (begin
				    (if (not first-section)
					(set! first-section sname))
				    (loop (read-line inp) 
					  sname 
					  res)))
	   (quoted-cell-rx (x k v)(loop (read-line inp)
					section
					(cons (list k section v) res)))
	   (cell-rx   (x k v)     (loop (read-line inp)
					section
					(cons (list k section v) res)))
	   (var-no-val-rx (x k)   (loop (read-line inp)
					section
					(cons (list k section "") res)))
	   (else                  (begin