logo       

rev 209 - trunk/src: msg#00077

Subject: rev 209 - trunk/src
Author: bcollins
Date: 2004-03-30 10:33:18 -0500 (Tue, 30 Mar 2004)
New Revision: 209

Modified:
   trunk/src/builtins.c
   trunk/src/prothon.y
Log:
Fix bug #3. Also cleanup str_tuple_list to act more like python.


Modified: trunk/src/builtins.c
===================================================================
--- trunk/src/builtins.c        2004-03-30 13:50:37 UTC (rev 208)
+++ trunk/src/builtins.c        2004-03-30 15:33:18 UTC (rev 209)
@@ -324,26 +324,41 @@
 }
 
 
-static obj_p str_tuple_list(isp ist, obj_p self, char* ldelim, char* rdelim) {
+static obj_p str_tuple_list(isp ist, obj_p self, char* ldelim, char* rdelim)
+{
        int i, len=list_len(ist, self);
-       char msg[1024], *res = pr_malloc(2); 
+       char msg[64], *res;
+
+       /* Need enough room for just empty list */
+       res = pr_malloc(strlen(ldelim) + strlen(rdelim) + 1);
+
        strcpy(res, ldelim);
-       for (i=0; i < len; i++) {
+
+       for (i = 0; i < len; i++) {
                char* item_str;
                obj_p item = list_item(ist, self,i);
-               if ((uintptr_t)item > 10) item_str = as_str(ist, item);
-               else {
+               int is_str = 0;
+
+               if ((uintptr_t)item > 10) {
+                       item_str = as_str(ist, item);
+                       is_str = 1;
+               } else {
                        apr_snprintf(msg, sizeof(msg), "<objptr:%lx>", 
(unsigned long)(uintptr_t)item);
                        item_str = msg;
                }
-               res = pr_realloc(res, strlen(res)+strlen(item_str)+4);
+
+               res = pr_realloc(res, strlen(res) + strlen(item_str) + 
strlen(rdelim) + 6);
+               if (is_str)
+                       strcat(res, "'");
                strcat(res, item_str);
-               if (i != len-1) strcat(res, ", ");
+               if (is_str)
+                       strcat(res,"'");
+
+               if (i != len-1)
+                       strcat(res, ", ");
        }
        strcat(res, rdelim);
-       if (res[0]=='(' && res[1]==')') {
-               res[1]=','; res[2]=')'; res[3]=0;
-       }
+
        return new_string_obj(res);
 }
 

Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y 2004-03-30 13:50:37 UTC (rev 208)
+++ trunk/src/prothon.y 2004-03-30 15:33:18 UTC (rev 209)
@@ -596,7 +596,8 @@
                expr ':' expr                                                   
                                        { $$ = new_list2(yylex_param, $1, $3); }
        ;
 tuple_params:
-               expr ','                                                        
                                                { $$ = new_list(yylex_param, 
$1); }
+               { $$ = new_clist(0); }
+       |       expr ','                                                        
                                                { $$ = new_list(yylex_param, 
$1); }
        |       tuple_params2
        |       tuple_params2 ','
        ;




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
web.pylons.gene...    hurd.l4/2002-10...    kernel.commits....    user-groups.lin...    yellowdog.gener...    java.drools.use...    security.openva...    package-managem...    linux.debian.us...    qnx.openqnx.dev...    genealogy.gramp...    file-systems.if...    voip.wengophone...    tex.context/200...    ietf.smime/2003...    audio.csound.de...    culture.region....    xfree86.devel/2...    mobile.kannel.u...    distributed.con...    education.engli...    org.user-groups...    bug-tracking.gn...    recreation.bicy...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe