Here's a patch that fixes the readline bug that happens when readline is * disabled*. It also addresses the casing issue with SQL.apl.
Now, the file is called sql.apl in the source, but SQL.apl in the wslib5 directory. It's still not possible to build on OSX with readline enabled. This is because readline defines a type called Function which clashes with a GNU APL class of the same name. Either C++ namespaces or a rename of the class to, say, APLFunction would solve this. Patch is attached. Regards, Elias
Index: src/Input.cc =================================================================== --- src/Input.cc (revision 387) +++ src/Input.cc (working copy) @@ -64,14 +64,14 @@ static void stifle_history(int) {} static void read_history(const char *) {} static void rl_stuff_char(char) {} -static char * readline(const char *) {} +static char * readline(const char *) { return NULL; } void rl_list_funmap_names() {} -int rl_bind_key(int, int) {} -int rl_parse_and_bind(const char *) {} +int rl_bind_key(int, int) { return 0; } +int rl_parse_and_bind(const char *) { return 0; } const char * rl_readline_name = "GnuAPL"; int rl_catch_signals = 1; -void (*rl_startup_hook)() = 0; +int (*rl_startup_hook)() = 0; #endif // HAVE_LIBREADLINE @@ -379,6 +379,7 @@ int Input::init_readline_control_C() { +#ifdef HAVE_LIBREADLINE // CERR << "init_readline_control_C()" << endl; // rl_parse_and_bind(strdup("set echo-control-characters off")); @@ -388,12 +389,14 @@ // first time where readline() is being called // rl_startup_hook = 0; +#endif return 0; } //----------------------------------------------------------------------------- int Input::readline_control_C(int count, int key) { +#ifdef HAVE_LIBREADLINE control_C(SIGINT); rl_crlf(); rl_delete_text(0, rl_end); @@ -402,6 +405,7 @@ attention_raised = false; interrupt_raised = false; interrupt_when = 0; +#endif return 0; } //----------------------------------------------------------------------------- Index: src/Makefile.am =================================================================== --- src/Makefile.am (revision 387) +++ src/Makefile.am (working copy) @@ -167,7 +167,7 @@ .PHONY: git-pull git-pull: cd emacs_mode; git pull - cd sql; git pull; cp sql.apl ../../wslib5/sql.apl + cd sql; git pull; cp sql.apl ../../wslib5/SQL.apl .PHONY: help help: Index: src/sql/SQL.apl =================================================================== --- src/sql/SQL.apl (revision 387) +++ src/sql/SQL.apl (working copy) @@ -1,123 +0,0 @@ -#!apl -f - -⍝ This file contains helper definititions to make the SQL API more easy -⍝ to use. Example use: -⍝ -⍝ db ← 'sqlite' SQL∆Connect '/path/to/db/file' -⍝ -⍝ Connects to the database of type X with connect arguments Y. -⍝ This call returns the ID of the connection. -⍝ -⍝ results ← 'select * from foo where a > ?' SQL∆Select[db] 100 -⍝ -⍝ Executes the query given in X with the bind parameters in Y. -⍝ -⍝ SQL∆Disconnect db -⍝ -⍝ Disconnects from the database connection given as X. - -∇Z←L SQL∆Connect R -⍝ Connect to database of type L using connection arguments R. -⍝ -⍝ L must be a string indicating the database type. Current supported -⍝ values are 'postgresql' and 'sqlite'. -⍝ -⍝ R is the connection parameters which depends on the type of -⍝ database. -⍝ -⍝ This function returns a database handle that should be used when -⍝ using other SQL functions. This value should be seen as an opaque -⍝ handle. It is, however, guaranteed that the handle is a scalar -⍝ value. - Z←L SQL[1] R -∇ - -∇Z←SQL∆Disconnect R -⍝ Disconnect from database R. -⍝ -⍝ R is the database handle that should be disconnected. After this -⍝ function has been called, no further operations are to be performed -⍝ on this handle. Future calls to SQL∆Connect may reuse previously -⍝ disconnected handles. - Z←SQL[2] R -∇ - -∇Z←L SQL∆Select[db] R -⍝ Execute a select statement and return the result table. -⍝ -⍝ The axis parameter indicates the database handle. -⍝ -⍝ L is a select statement to be executed. Positional parameters can be -⍝ supplied by specifying a question mark "?" in the statemement. -⍝ -⍝ R is an array containing the values for the positional parameters. -⍝ If the array is of rank 2, the statement will be executed multiple -⍝ times with each row being the values for each call. -⍝ -⍝ The return value is a rank-2 array representing the result of the -⍝ select statement. Null values are returned as ⍬ and empty strings -⍝ are returned as ''. - Z←L SQL[3,db] R -∇ - -∇Z←L SQL∆Exec[db] R -⍝ Execute an SQL statement that does not return a result. -⍝ -⍝ This function is identical to SQL∆Select with the exception that it -⍝ is used on statements which do not return a result table. - Z←L SQL[4,db] R -∇ - -∇Z←SQL∆Begin R -⍝ Begin a transaction. - Z←SQL[5] R -∇ - -∇Z←SQL∆Commit R -⍝ Commit a transaction. - Z←SQL[6] R -∇ - -∇Z←SQL∆Rollback R -⍝ Rolls back the current transaction. - Z←SQL[7] R -∇ - -∇Z←SQL∆Tables R -⍝ Return an array containing the name of all tables. - Z←SQL[8] R -∇ - -∇Z←X (F SQL∆WithTransaction FINDDB) Y;result - SQL∆Begin FINDDB - - →(0≠⎕NC 'X')/dyadic - result ← '→rollback' ⎕EA 'F Y' - →commit - -dyadic: - result ← '→rollback' ⎕EA 'X F Y' - -commit: - SQL∆Commit FINDDB - Z ← result - →end - -rollback: - SQL∆Rollback FINDDB - ⎕ES "Transaction rolled back" -end: -∇ - -∇sql⍙load_library;result - →(0≠⎕NC 'SQL')/skip - result ← 'lib_sql.so' ⎕FX 'SQL' - →('SQL'≡result)/skip - ⎕ES 'Error loading native library' -skip: -∇ - -sql⍙load_library -)erase sql⍙load_library - -⎕←'SQL lib loaded' Index: src/sql/sql.apl =================================================================== --- src/sql/sql.apl (revision 0) +++ src/sql/sql.apl (working copy) @@ -0,0 +1,123 @@ +#!apl -f + +⍝ This file contains helper definititions to make the SQL API more easy +⍝ to use. Example use: +⍝ +⍝ db ← 'sqlite' SQL∆Connect '/path/to/db/file' +⍝ +⍝ Connects to the database of type X with connect arguments Y. +⍝ This call returns the ID of the connection. +⍝ +⍝ results ← 'select * from foo where a > ?' SQL∆Select[db] 100 +⍝ +⍝ Executes the query given in X with the bind parameters in Y. +⍝ +⍝ SQL∆Disconnect db +⍝ +⍝ Disconnects from the database connection given as X. + +∇Z←L SQL∆Connect R +⍝ Connect to database of type L using connection arguments R. +⍝ +⍝ L must be a string indicating the database type. Current supported +⍝ values are 'postgresql' and 'sqlite'. +⍝ +⍝ R is the connection parameters which depends on the type of +⍝ database. +⍝ +⍝ This function returns a database handle that should be used when +⍝ using other SQL functions. This value should be seen as an opaque +⍝ handle. It is, however, guaranteed that the handle is a scalar +⍝ value. + Z←L SQL[1] R +∇ + +∇Z←SQL∆Disconnect R +⍝ Disconnect from database R. +⍝ +⍝ R is the database handle that should be disconnected. After this +⍝ function has been called, no further operations are to be performed +⍝ on this handle. Future calls to SQL∆Connect may reuse previously +⍝ disconnected handles. + Z←SQL[2] R +∇ + +∇Z←L SQL∆Select[db] R +⍝ Execute a select statement and return the result table. +⍝ +⍝ The axis parameter indicates the database handle. +⍝ +⍝ L is a select statement to be executed. Positional parameters can be +⍝ supplied by specifying a question mark "?" in the statemement. +⍝ +⍝ R is an array containing the values for the positional parameters. +⍝ If the array is of rank 2, the statement will be executed multiple +⍝ times with each row being the values for each call. +⍝ +⍝ The return value is a rank-2 array representing the result of the +⍝ select statement. Null values are returned as ⍬ and empty strings +⍝ are returned as ''. + Z←L SQL[3,db] R +∇ + +∇Z←L SQL∆Exec[db] R +⍝ Execute an SQL statement that does not return a result. +⍝ +⍝ This function is identical to SQL∆Select with the exception that it +⍝ is used on statements which do not return a result table. + Z←L SQL[4,db] R +∇ + +∇Z←SQL∆Begin R +⍝ Begin a transaction. + Z←SQL[5] R +∇ + +∇Z←SQL∆Commit R +⍝ Commit a transaction. + Z←SQL[6] R +∇ + +∇Z←SQL∆Rollback R +⍝ Rolls back the current transaction. + Z←SQL[7] R +∇ + +∇Z←SQL∆Tables R +⍝ Return an array containing the name of all tables. + Z←SQL[8] R +∇ + +∇Z←X (F SQL∆WithTransaction FINDDB) Y;result + SQL∆Begin FINDDB + + →(0≠⎕NC 'X')/dyadic + result ← '→rollback' ⎕EA 'F Y' + →commit + +dyadic: + result ← '→rollback' ⎕EA 'X F Y' + +commit: + SQL∆Commit FINDDB + Z ← result + →end + +rollback: + SQL∆Rollback FINDDB + ⎕ES "Transaction rolled back" +end: +∇ + +∇sql⍙load_library;result + →(0≠⎕NC 'SQL')/skip + result ← 'lib_sql.so' ⎕FX 'SQL' + →('SQL'≡result)/skip + ⎕ES 'Error loading native library' +skip: +∇ + +sql⍙load_library +)erase sql⍙load_library + +⎕←'SQL lib loaded' Index: wslib5/Makefile.am =================================================================== --- wslib5/Makefile.am (revision 387) +++ wslib5/Makefile.am (working copy) @@ -1,6 +1,6 @@ dist_apl5_DATA = HTML.apl \ - sql.apl + SQL.apl apl5dir = $(pkglibdir)/wslib5 Index: wslib5/SQL.apl =================================================================== --- wslib5/SQL.apl (revision 0) +++ wslib5/SQL.apl (working copy) @@ -0,0 +1,123 @@ +#!apl -f + +⍝ This file contains helper definititions to make the SQL API more easy +⍝ to use. Example use: +⍝ +⍝ db ← 'sqlite' SQL∆Connect '/path/to/db/file' +⍝ +⍝ Connects to the database of type X with connect arguments Y. +⍝ This call returns the ID of the connection. +⍝ +⍝ results ← 'select * from foo where a > ?' SQL∆Select[db] 100 +⍝ +⍝ Executes the query given in X with the bind parameters in Y. +⍝ +⍝ SQL∆Disconnect db +⍝ +⍝ Disconnects from the database connection given as X. + +∇Z←L SQL∆Connect R +⍝ Connect to database of type L using connection arguments R. +⍝ +⍝ L must be a string indicating the database type. Current supported +⍝ values are 'postgresql' and 'sqlite'. +⍝ +⍝ R is the connection parameters which depends on the type of +⍝ database. +⍝ +⍝ This function returns a database handle that should be used when +⍝ using other SQL functions. This value should be seen as an opaque +⍝ handle. It is, however, guaranteed that the handle is a scalar +⍝ value. + Z←L SQL[1] R +∇ + +∇Z←SQL∆Disconnect R +⍝ Disconnect from database R. +⍝ +⍝ R is the database handle that should be disconnected. After this +⍝ function has been called, no further operations are to be performed +⍝ on this handle. Future calls to SQL∆Connect may reuse previously +⍝ disconnected handles. + Z←SQL[2] R +∇ + +∇Z←L SQL∆Select[db] R +⍝ Execute a select statement and return the result table. +⍝ +⍝ The axis parameter indicates the database handle. +⍝ +⍝ L is a select statement to be executed. Positional parameters can be +⍝ supplied by specifying a question mark "?" in the statemement. +⍝ +⍝ R is an array containing the values for the positional parameters. +⍝ If the array is of rank 2, the statement will be executed multiple +⍝ times with each row being the values for each call. +⍝ +⍝ The return value is a rank-2 array representing the result of the +⍝ select statement. Null values are returned as ⍬ and empty strings +⍝ are returned as ''. + Z←L SQL[3,db] R +∇ + +∇Z←L SQL∆Exec[db] R +⍝ Execute an SQL statement that does not return a result. +⍝ +⍝ This function is identical to SQL∆Select with the exception that it +⍝ is used on statements which do not return a result table. + Z←L SQL[4,db] R +∇ + +∇Z←SQL∆Begin R +⍝ Begin a transaction. + Z←SQL[5] R +∇ + +∇Z←SQL∆Commit R +⍝ Commit a transaction. + Z←SQL[6] R +∇ + +∇Z←SQL∆Rollback R +⍝ Rolls back the current transaction. + Z←SQL[7] R +∇ + +∇Z←SQL∆Tables R +⍝ Return an array containing the name of all tables. + Z←SQL[8] R +∇ + +∇Z←X (F SQL∆WithTransaction FINDDB) Y;result + SQL∆Begin FINDDB + + →(0≠⎕NC 'X')/dyadic + result ← '→rollback' ⎕EA 'F Y' + →commit + +dyadic: + result ← '→rollback' ⎕EA 'X F Y' + +commit: + SQL∆Commit FINDDB + Z ← result + →end + +rollback: + SQL∆Rollback FINDDB + ⎕ES "Transaction rolled back" +end: +∇ + +∇sql⍙load_library;result + →(0≠⎕NC 'SQL')/skip + result ← 'lib_sql.so' ⎕FX 'SQL' + →('SQL'≡result)/skip + ⎕ES 'Error loading native library' +skip: +∇ + +sql⍙load_library +)erase sql⍙load_library + +⎕←'SQL lib loaded'