Update of /cvsroot/monetdb/clients/src/mapiclient
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20789

Modified Files:
        MapiClient.mx 
Log Message:
Rename ILLEGALMODE to NOLANGUAGE.  It's not so much an illegal value
(it is the initial value) but it is the value that indicates that no
language choice has (yet) been made.

Fix MAL debugging interaction: we now always go through the new
function fetch_line() which checks for debugger prompts and sets the
mode accordingly.


Index: MapiClient.mx
===================================================================
RCS file: /cvsroot/monetdb/clients/src/mapiclient/MapiClient.mx,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- MapiClient.mx       27 Aug 2007 21:00:18 -0000      1.72
+++ MapiClient.mx       28 Aug 2007 07:43:07 -0000      1.73
@@ -116,7 +116,7 @@
 #endif
 
 enum modes {
-       ILLEGALMODE,
+       NOLANGUAGE,
        MAL,
        SQL,
        XQUERY,
@@ -132,7 +132,7 @@
 static char promptbuf[16];
 static int echoquery = 0;
 
-#define setPrompt() sprintf(promptbuf, "%.*s>", (int) sizeof(promptbuf) - 2, 
language);
+#define setPrompt() sprintf(promptbuf, "%.*s>", (int) sizeof(promptbuf) - 2, 
language)
 #define debugMode() (strncmp(promptbuf, "mdb", 3) == 0)
 
 /* the internal formatters */
@@ -349,16 +349,28 @@
 we need to detect end of debugging. We overload
 the routine to our liking.
 @c
+static char *
+fetch_line(MapiHdl hdl)
+{
+       char *reply;
+
+       if ((reply = mapi_fetch_line(hdl)) == NULL)
+               return NULL;
+       if (strstr(reply, "mdb>#EOD"))
+               setPrompt();
+       else if (strncmp(reply, "mdb>#", 5) == 0)
+               sprintf(promptbuf, "mdb>");
+       return reply;
+}
+
 static int
 fetch_row(MapiHdl hdl)
 {
        char *reply;
 
        do {
-               if ((reply = mapi_fetch_line(hdl)) == NULL)
+               if ((reply = fetch_line(hdl)) == NULL)
                        return 0;
-               if (strstr(reply, "mdb>#EOD"))
-                       setPrompt();
        } while (*reply != '[' && *reply != '=');
        return mapi_split_line(hdl);
 }
@@ -400,9 +412,7 @@
 {
        char *line;
 
-       while ((line = mapi_fetch_line(hdl)) != 0) {
-               if (strstr(line, "mdb>#EOD"))
-                       setPrompt();
+       while ((line = fetch_line(hdl)) != 0) {
                if (*line == '=')
                        line++;
                fprintf(toConsole, "%s\n", line);
@@ -517,7 +527,7 @@
        int cnt = 0;
 
        sprintf(promptbuf, "mdb>");
-       while ((reply = mapi_fetch_line(hdl))) {
+       while ((reply = fetch_line(hdl))) {
                cnt++;
                fprintf(toConsole, "%s\n", reply);
                if (strncmp(reply, "mdb>#EOD", 7) == 0) {
@@ -558,13 +568,11 @@
        len[0] = pagewidth - 4; /* remove borders */
        numeric[0] = 0;
        SQLseparator(len, 1, '-');
-       while ((fields[0] = mapi_fetch_line(hdl)) != NULL) {
+       while ((fields[0] = fetch_line(hdl)) != NULL) {
                if (silent)
                        continue;
                if (*fields[0] == '%')
                        continue;
-               if (strstr(fields[0], "mdb>#EOD"))
-                       setPrompt();
                fields[0] = fields[0] + 1;      /* ignore marker */
                SQLrow(len, numeric, fields, 1, 0);
                if (ps && rows % ps == ps - 1 && rows != 
mapi_get_row_count(hdl) && fromConsole)
@@ -590,13 +598,11 @@
        numeric[0] = 0;
        numeric[1] = 0;
 
-       while ((fields[0] = mapi_fetch_line(hdl)) != NULL) {
+       while ((fields[0] = fetch_line(hdl)) != NULL) {
                if (silent)
                        continue;
                if (*fields[0] == '%')
                        continue;
-               if (fields[0] && strstr(fields[0], "mdb>#EOD"))
-                       setPrompt();
 
                /* simple render */
                fields[0] = fields[0] + 1;
@@ -1675,7 +1681,7 @@
                }
        }
        /* language value is mandatory */
-       if (mode == 0) {
+       if (mode == NOLANGUAGE) {
                fprintf(stderr, "Please specify a language option\n\n");
                usage(argv[0]);
        }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to