Changeset 376 for trunk/src/base-tools
- Timestamp:
- 12/19/10 21:00:02 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/base-tools/base-tools.lisp ΒΆ
r375 r376 295 295 296 296 297 (defun get-literal (query-string &key (quotation "\""))297 (defun get-literal (query-string &key (quotation nil)) 298 298 "Returns a list of the form (:next-string <string> :literal <string> 299 299 where next-query is the query after the found literal and literal 300 300 is the literal string." 301 301 (declare (String query-string) 302 (String quotation)) 303 (cond ((or (string-starts-with query-string "\"\"\"") 304 (string-starts-with query-string "'''")) 305 (let ((literal-end 306 (find-literal-end (subseq query-string 3) (subseq query-string 0 3)))) 307 (when literal-end 308 (list :next-string (subseq query-string (+ 3 literal-end)) 309 :literal (concatenate 'string quotation 310 (subseq query-string 3 literal-end) 311 quotation))))) 312 ((or (string-starts-with query-string "\"") 313 (string-starts-with query-string "'")) 314 (let ((literal-end 315 (find-literal-end (subseq query-string 1) 316 (subseq query-string 0 1)))) 317 (when literal-end 318 (let ((literal 319 (escape-string (subseq query-string 1 literal-end) "\""))) 320 (list :next-string (subseq query-string (+ 1 literal-end)) 321 :literal (concatenate 'string quotation literal 322 quotation)))))))) 323 324 325 ;(defun search-first-ignore-literals (search-strings main-string) 326 ; (declare (String main-string) 327 ; (List search-strings)) 328 ; (let ((first-pos (search-first search-strings main-string))) 329 ; (when first-pos 330 ; (if (not (in-literal-string-p main-string first-pos)) 331 ; first-pos 332 ; (let* ((literal-start (search-first (list "\"" "'") main-string)) 333 ; (sub-str (subseq main-string literal-start)) 334 ; (literal-result (get-literal sub-str)) 335 ; (next-str (getf literal-result :next-string))) 336 ; (let ((next-pos 337 ; (search-first-ignore-literals search-strings next-str))) 338 ; (when next-pos 339 ; (+ (- (length main-string) (length next-str)) next-pos)))))))) 302 (type (or Null String) quotation)) 303 (let ((local-quotation quotation)) 304 (cond ((or (string-starts-with query-string "\"\"\"") 305 (string-starts-with query-string "'''")) 306 (unless local-quotation 307 (setf local-quotation (subseq query-string 0 3))) 308 (let ((literal-end 309 (find-literal-end (subseq query-string 3) (subseq query-string 0 3)))) 310 (when literal-end 311 (list :next-string (subseq query-string (+ 3 literal-end)) 312 :literal (concatenate 'string quotation 313 (subseq query-string 3 literal-end) 314 quotation))))) 315 ((or (string-starts-with query-string "\"") 316 (string-starts-with query-string "'")) 317 (unless local-quotation 318 (setf local-quotation (subseq query-string 0 1))) 319 (let ((literal-end 320 (find-literal-end (subseq query-string 1) 321 (subseq query-string 0 1)))) 322 (when literal-end 323 (let ((literal 324 (escape-string (subseq query-string 1 literal-end) "\""))) 325 (list :next-string (subseq query-string (+ 1 literal-end)) 326 :literal (concatenate 'string local-quotation literal 327 local-quotation))))))))) 340 328 341 329
Note: See TracChangeset
for help on using the changeset viewer.