I think this patch is much better.

Remove "dropLeadingBlanks", it is only used once.

Also removes manual loops, uses function instead.

- Qian

diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot
index bba51e02..42cf4171 100644
--- a/src/interp/g-util.boot
+++ b/src/interp/g-util.boot
@@ -170,18 +170,6 @@ stringPrefix?(pref,str) ==
     i := i + 1
   ok

-dropLeadingBlanks str ==
-  str := object2String str
-  l := QCSIZE str
-  nb := NIL
-  i := 0
-  while (i < l) and not nb repeat
-    if SCHAR(str,i) ~= SCHAR('" ",0) then nb := i
-    else i := i + 1
-  nb = 0 => str
-  nb => SUBSTRING(str,nb,NIL)
-  '""
-
 concat(:l) == concatList l

 concatList [x,:y] ==
diff --git a/src/interp/i-syscmd.boot b/src/interp/i-syscmd.boot
index eca9f345..3337fd8c 100644
--- a/src/interp/i-syscmd.boot
+++ b/src/interp/i-syscmd.boot
@@ -2455,15 +2455,10 @@ synonymSpad2Cmd() ==
   terminateSystemCommand()

 processSynonymLine line ==
+  line := STRING_-LEFT_-TRIM('" ", line)
   key := STRING2ID_N (line, 1)
-  value := removeKeyFromLine line where
-    removeKeyFromLine line ==
-      line := dropLeadingBlanks line
-      mx := MAXINDEX line
-      for i in 0..mx repeat
-        line.i = " " =>
-          return (for j in (i+1)..mx repeat
-            line.j ~= " " => return (SUBSTRING (line, j, nil)))
+  value := SUBSTRING(line, # STRINGIMAGE key, nil)
+  value := STRING_-LEFT_-TRIM('" ", value)
   [key, :value]




On 1/21/24 17:29, Qian Yun wrote:
Yes, this is a bug.

After some glancing, this is a quick fix:

diff --git a/src/interp/i-syscmd.boot b/src/interp/i-syscmd.boot
index eca9f345..22bf47b0 100644
--- a/src/interp/i-syscmd.boot
+++ b/src/interp/i-syscmd.boot
@@ -2461,9 +2461,9 @@ processSynonymLine line ==
        line := dropLeadingBlanks line
        mx := MAXINDEX line
        for i in 0..mx repeat
-        line.i = " " =>
+        line.i = char '" " =>
            return (for j in (i+1)..mx repeat
-            line.j ~= " " => return (SUBSTRING (line, j, nil)))
+            line.j ~= char '" " => return (SUBSTRING (line, j, nil)))
    [key, :value]



I need a deeper look into this.  Seems that "synonymSpad2Cmd" is dead
code compared with "npProcessSynonym".

- Qian

On 1/21/24 16:11, Fabian Hassler wrote:
I have problems getting the command )synonym working. Most likely, I am
just interpreting the documentation wrong.

As an example: if I execute `)synonym pwd system pwd` then )pwd appears in
the list of synonyms whoever the body is empty. Also executing )pwd gives
the error `Your argument list is not valid.`


--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/8a6ced0f-48b4-4ffc-aa25-db3d25e0ac6f%40gmail.com.

Reply via email to