]> git.nothing2do.fr Git - diary-shell.git/commitdiff
mem don't need to exist anymore ! replaced by "memo <name>"
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Sun, 14 Jul 2013 14:22:59 +0000 (16:22 +0200)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Sun, 14 Jul 2013 14:22:59 +0000 (16:22 +0200)
alias.sql
sqldb.cpp

index e79e4c30e326e5f610a46f578dc6a045a4bbd714..6702bab5244f06100ced7da3c62e825ce340821b 100644 (file)
--- a/alias.sql
+++ b/alias.sql
@@ -6,8 +6,9 @@ INSERT INTO alias (nom, command, argc, help) VALUES ('rm', 'DELETE FROM raw WHER
 INSERT INTO alias (nom, command, argc, help) VALUES ('alias', 'select nom from alias;', 0, 'print every alias''s name');
 insert into alias (nom, command, argc, help) values ('var', 'select nom from var', 0, 'print avery var/named var content');
 insert into alias (nom, command, argc) values ('var', 'select nom,value from var where nom=$1 order by id', 1);
-insert into alias (nom, command, argc, inf, help) values ('memo', 'insert into memo (word, rem) values ($1, $2);', 1, '1', 'list memo''s name/record new one/');
+insert into alias (nom, command, argc, inf, help) values ('memo', 'insert into memo (word, rem) values ($1, $2);', 1, '1', 'list memo''s name');
 insert into alias (nom, command, argc) values ('memo', 'select distinct word from memo', 0);
-insert into alias (nom, command, argc, help) values ('mem', 'select id,rem from memo where word=$1 order by id', 1, 'print memo content');
+insert into alias (nom, command, argc, help) values ('memo', 'select id,rem from memo where word=$1 order by id', 1, 'print memo content');
 insert into alias (nom, command, argc, help) values ('help', 'select distinct nom from alias', 0, 'help itself (add "command to get specific help")');
 insert into alias (nom, command, argc) values ('help', 'select distinct id,nom,command from alias where nom=$1', 1);
+insert into alias (nom, command, argc) values ('help', 'select id,nom,command from alias where nom=$1 and argc=$2', 1);
index 4b5aed5a9917d52fa03d0d31312e295308c996e8..dd142b100b4ce5b52fd315f97077ce304686d29b 100644 (file)
--- a/sqldb.cpp
+++ b/sqldb.cpp
@@ -241,7 +241,7 @@ inline int sqlpg::testSQL(PGresult* a){
 }
 bool sqlpg::alias(vector<string> a){
     clog<<"alias start here\n";
-    string nom=a[0], as=toString(a.size()-1).c_str(), i;
+    string nom=a[0], as=toString(a.size()-1), i;
     int argca=2, inf=0;
     const char *valuea[2]={nom.c_str(), as.c_str()};
     int lengtha[2]={nom.size(), as.size()};
@@ -275,9 +275,9 @@ bool sqlpg::alias(vector<string> a){
     clog<<"for finish, \n";
     if(inf==1){
         clog<<"inf==1\n";
-        t=a[argc+1];
-        clog<<"for infinite (j="<<argc+2<<"; j<="<<asize-1<<") t="<<t<<endl;
-        for(int j=argc+2; j<=asize-1; j++){
+        t=a[argc];
+        clog<<"for infinite (j="<<argc+1<<"; j<="<<asize-1<<") t="<<t<<endl;
+        for(int j=argc+1; j<=asize-1; j++){
             t=t+" "+a[j];
             clog<<"bcl t="<<t<<endl;
         }
@@ -299,8 +299,8 @@ bool sqlpg::alias(vector<string> a){
     res=PQprepare(conn, "execalias",cmd2.c_str(), argc+inf, NULL);
     clog<<"PQprepart done(cmd2="<<cmd2<<" argc+inf="<<argc+inf<<"\n";
     testSQL(res);
-    res=PQexecPrepared(conn, "execalias", argc+inf, value, length, binary, 0);
-    clog<<"PQexecPrepared done argc+inf="<<argc+inf<<endl;
+    res=PQexecPrepared(conn, "execalias", argc, value, length, binary, 0);
+    clog<<"PQexecPrepared done argc="<<argc<<endl;
     testSQL(res);
     print();
     exec("DEALLOCATE execalias");