-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the procedure component-library-search(). #500
Conversation
@vzh It seems that I've found another error in ( component-library-search "/home/dmn/ee/sym/sym/" "XXX" )
The patch in this PR doesn't affect this behavior. |
Probably, it's better to avoid using diff --git a/liblepton/scheme/lepton/library/component.scm b/liblepton/scheme/lepton/library/component.scm
index 7c8339391..46ecbb064 100644
--- a/liblepton/scheme/lepton/library/component.scm
+++ b/liblepton/scheme/lepton/library/component.scm
@@ -149,6 +149,29 @@
(set! %component-libraries '())
(%reset-component-library))
+
+( define ( mk-node-name rootdir dir prefix )
+
+ ( define ( same-dirs? a b )
+ ; return:
+ ( string=?
+ (string-trim-right a file-name-separator?)
+ (string-trim-right b file-name-separator?)
+ )
+ )
+
+ ; return:
+ ( if (same-dirs? dir rootdir)
+ prefix ; if
+ ( if (string-null? prefix) ; else
+ ( basename dir ) ; if
+ ( format #f "~a/~a" prefix (basename dir) ) ; else
+ )
+ )
+
+) ; mk-node-name()
+
+
(define* (component-library-search rootdir #:optional (prefix ""))
"Add all symbol libraries found below ROOTDIR to be searched for
components, naming them with an optional PREFIX."
@@ -176,8 +199,8 @@ components, naming them with an optional PREFIX."
;; Fill component library tree.
(for-each
(lambda (dir)
- (let ((name (substring dir (string-length rootdir))))
- (component-library dir (string-append prefix name))))
+ (let ((name (mk-node-name rootdir dir prefix)))
+ (component-library dir name)))
(sort-list! (hash-map->list (lambda (key val)
(symbol->string key))
dht) |
@graahnul-grom, |
#516 compiles fine with ( reset-component-library )
( component-library-search "/home/dmn/ee/sym/sym" "dmn" ) component selection dialog (#516 + #500) - the |
Well, I'm confused. So, do you think the toplevel directory should be present, too? |
I think, yes, and it's a well established behavior. |
In some cases, when the root directory processed by the procedure contained symbol files, the procedure failed with the error as follows: ERROR: In procedure substring: Value out of range 0 to 30: 31 This has been fixed by filtering out the symbols whose directory is the same as the root directory.
Now, if toplevel symbol directory contains symbols, it is added to libraries, too. Its name is either the 'prefix' argument, or, if it is missing, the basename of the directory.
7bc9b57
to
9bf788e
Compare
@graahnul-grom, |
This is a feature, not a bug :-) I've especially checked what geda-gaf 1.8.2 does, and it does the same. If you want to add "/", just append it to PREFIX. |
I also think that it's better to choose your own separator, |
In some cases, when the root directory processed by the procedure
contained symbol files, the procedure failed with the error as
follows:
ERROR: In procedure substring:
Value out of range 0 to 30: 31
This has been fixed by filtering out the symbols whose directory
is the same as the root directory.