]> gitweb.factorcode.org Git - factor.git/commitdiff
fix millis; fix <resource-stream>
authorSlava Pestov <slava@factorcode.org>
Mon, 6 Sep 2004 00:14:37 +0000 (00:14 +0000)
committerSlava Pestov <slava@factorcode.org>
Mon, 6 Sep 2004 00:14:37 +0000 (00:14 +0000)
TODO.FACTOR.txt
factor/ReadTable.java
factor/jedit/FactorPlugin.java
library/math/pow.factor
library/platform/jvm/parser.factor
library/platform/jvm/stream.factor
library/platform/native/parse-stream.factor
library/platform/native/stream.factor
native/misc.c

index 14dc94dbfea4a12490c765749ec0035077fec2e1..6212d76b4618151026df54280cf9f7aaba06ee64 100644 (file)
@@ -1,7 +1,5 @@
-- move <resource-stream> from parser\r
 - quit responder breaks with multithreading\r
 - nicer way to combine two paths\r
-- -1.1 3 ^ shouldn't give a complex number\r
 - don't show listener on certain commands\r
 - plugin should not exit jEdit on fatal errors\r
 - wordpreview: don't show for string literals and comments\r
@@ -11,7 +9,6 @@
 - introduce ifte* and ?str-head/?str-tail where appropriate\r
 - namespace clone drops static var bindings\r
 - solaris: -lsocket -lnsl\r
-- unparsing: \u000c\r
 \r
 + bignums:\r
 \r
@@ -49,8 +46,6 @@
 \r
 - NPE in activate()/deactivate()\r
 - NPE in ErrorHighlight\r
-- caret at start of word: problem\r
-- don't use jEdit's word finding API\r
 - some way to not have previous definitions from a source file\r
   clutter the namespace\r
 - use inferior.factor for everything not just listener\r
index 4fe180cf2ae946c3ea6de9a9be786be19d583e16..10233fbcbaeb29daf2c917a92b11ea3b5a5518c9 100644 (file)
@@ -43,10 +43,6 @@ public class ReadTable
 
                DEFAULT_READTABLE.setCharacterType('\t',ReadTable.WHITESPACE);
                DEFAULT_READTABLE.setCharacterType('\n',ReadTable.WHITESPACE);
-
-               // ^L
-               DEFAULT_READTABLE.setCharacterType((char)12,ReadTable.WHITESPACE);
-
                DEFAULT_READTABLE.setCharacterType('\r',ReadTable.WHITESPACE);
                DEFAULT_READTABLE.setCharacterType(' ',ReadTable.WHITESPACE);
 
index 656d551760eaf200feef86af0269facea965afcc..cffd7927d8fdefdea73c015f67f476e99a6f23a0 100644 (file)
@@ -210,13 +210,40 @@ public class FactorPlugin extends EditPlugin
                if(caret == line.length())
                        caret--;
 
-               String noWordSep = textArea.getBuffer().getStringProperty(
-                       "noWordSep");
-               int wordStart = TextUtilities.findWordStart(line,caret,
-                       noWordSep);
-               int wordEnd = TextUtilities.findWordEnd(line,caret,
-                       noWordSep);
-               return line.substring(wordStart,wordEnd);
+               ReadTable readtable = ReadTable.DEFAULT_READTABLE;
+
+               if(readtable.getCharacterType(line.charAt(caret))
+                       == ReadTable.WHITESPACE)
+               {
+                       return null;
+               }
+
+               int start = caret;
+               while(start > 0)
+               {
+                       if(readtable.getCharacterType(line.charAt(start - 1))
+                               == ReadTable.WHITESPACE)
+                       {
+                               break;
+                       }
+                       else
+                               start--;
+               }
+
+               int end = caret;
+               do
+               {
+                       if(readtable.getCharacterType(line.charAt(end))
+                               == ReadTable.WHITESPACE)
+                       {
+                               break;
+                       }
+                       else
+                               end++;
+               }
+               while(end < line.length());
+
+               return line.substring(start,end);
        } //}}}
        
        //{{{ showStatus() method
index d4e3abc302d6f0ce387e1699d57a8a64e18bce5d..a8ffae1d47b8366fff411716dc35980deb45d295 100644 (file)
@@ -34,6 +34,7 @@ USE: stack
 
 ! Power-related functions:
 !     exp log sqrt pow
+USE: logic
 
 : exp >rect swap fexp swap polar> ;
 : log >polar swap flog swap rect> ;
@@ -52,4 +53,8 @@ USE: stack
     [ [ >rect ] dip flog * swap ] dip * + ;
 
 : ^ ( z w -- z^w )
-    swap >polar 3dup ^theta [ ^mag ] dip polar> ;
+    over real? over integer? and [
+        fpow
+    ] [
+        swap >polar 3dup ^theta >r ^mag r> polar>
+    ] ifte ;
index be49b87a94e2a09135d8288e8c4c43e4a8f27cb1..013db286743e068965cd19b290be97a881796f2c 100644 (file)
@@ -39,13 +39,10 @@ USE: strings
 : run-file ( path -- )
     parse-file call ;
 
-: <resource-stream> ( path -- stream )
-    <rreader> f <char-stream> ;
-
 : parse-resource* ( resource -- list )
     dup <rreader> swap "resource:" swap cat2 swap parse-stream ;
 
-: parse-resource ( file -- )
+: parse-resource ( resource -- list )
      #! Override this to be slightly more useful for development.
     global [ "resource-path" get ] bind dup [
         swap cat2 parse-file
index 89063534e67ea5ef5f70be522fd239b8827c1863..12eac0509cb51d18e14ee48fe6e5871d54a1a439 100644 (file)
@@ -254,3 +254,6 @@ USE: strings
     #! Accept a connection from a server socket.
     [ "socket" get ] bind
     [ ] "java.net.ServerSocket" "accept" jinvoke <socket-stream> ;
+
+: <resource-stream> ( path -- stream )
+    <rreader> f <char-stream> ;
index cdbe65b2495756d734efe10abb99fb05ce3c64ea..63acdef74e7bbc237f00a18f23150baae7add1fd 100644 (file)
@@ -96,12 +96,6 @@ USE: strings
     #! the current interactive interpreter.
     (parse-file) call ;
 
-: resource-path ( -- path )
-    "resource-path" get [ "." ] unless* ;
-
-: <resource-stream> ( path -- stream )
-    resource-path swap cat2 <filecr> ;
-
 : parse-resource ( path -- quot )
     #! Resources are loaded from the resource-path variable, or
     #! the current directory if it is not set. Words defined in
index fef1fa3e39922b96aae381f9698ab6a82b7fa0a7..3b6959d462de718cbc15e345bff43b5dada39a20 100644 (file)
@@ -90,3 +90,9 @@ USE: namespaces
     #! Copy the contents of the fd-stream 'from' to the
     #! fd-stream 'to'.
     [ 2dup (fcopy) ] [ -rot fclose fclose rethrow ] catch ;
+
+: resource-path ( -- path )
+    "resource-path" get [ "." ] unless* ;
+
+: <resource-stream> ( path -- stream )
+    resource-path swap cat2 <filecr> ;
index 636e6dbd679197731eb6b71c5d82b8628792b13a..ddc6bf1bc79609baf90f328cc78f2fc66729d9aa 100644 (file)
@@ -24,8 +24,8 @@ void primitive_millis(void)
 {
        struct timeval t;
        gettimeofday(&t,NULL);
-       dpush(tag_object(s48_long_to_bignum(
-               t.tv_sec * 1000 + t.tv_usec/1000)));
+       dpush(tag_object(s48_long_long_to_bignum(
+               (long long)t.tv_sec * 1000 + t.tv_usec/1000)));
 }
 
 void primitive_init_random(void)